Started by
tret
on
Topic category: Help with Minecraft modding (Java Edition)
I face a problem that i can't seem to resolve.
For more manageable mod I should change a global variable's type to int array. I have added my variable as player lifetime double and after this I have managed to open the variables section in mcreator (as the source code) and i have made the following changes:
private static class PlayerVariablesStorage implements Capability.IStorage<PlayerVariables> {
@Override
public INBT writeNBT(Capability<PlayerVariables> capability, PlayerVariables instance, Direction side) {
CompoundNBT nbt = new CompoundNBT();
nbt.putIntArray("Proficiencies", instance.Proficiencies);
return nbt;
}
@Override
public void readNBT(Capability<PlayerVariables> capability, PlayerVariables instance, Direction side, INBT inbt) {
CompoundNBT nbt = (CompoundNBT) inbt;
instance.Proficiencies = nbt.getIntArray("Proficiencies");
}
}
public static class PlayerVariables {
public int[] Proficiencies = new int[50];
public void syncPlayerVariables(Entity entity) {
if (entity instanceof ServerPlayerEntity)
MinecraftMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) entity),
new PlayerVariablesSyncMessage(this));
}
But my procedures and everything else throws an error at me about "Proficiencies can not be converted to int[]".
What did i do wrong or how can i fix this?
I found out what the problem is and i do not like it. After each build and start the MCreactor's variable handler turns back every public variable as it is defined in the variables menu. Is there a way to stop this?