Hello,
I am hunting for a really weird behavior in my mod. There is an easy thing that needs to be achived: stop the rain.
But some short information first:
1.14.4 with Forge 28.1.0
https://github.com/Terpo/Waterworks
So basically, I created an item that should stop the rain.
The easiest way in my opinion, was to copy the way the commands are working: WeatherCommand.class
This shows how Minecraft is handling the command. time, per default is 6000 ticks. As you might expect the command is working.
source.getWorld().getWorldInfo().setClearWeatherTime(time);
source.getWorld().getWorldInfo().setRainTime(0);
source.getWorld().getWorldInfo().setThunderTime(0);
source.getWorld().getWorldInfo().setRaining(false);
source.getWorld().getWorldInfo().setThundering(false);
Now in my item class I do nearly the same: (even if I do not check for world.isRemote)
@Override
public ActionResultType onItemUse(ItemUseContext context) {
final World world = context.getWorld();
if (!world.isRemote) {
final WorldInfo worldInfo = world.getWorldInfo();
worldInfo.setClearWeatherTime(100000);
worldInfo.setRainTime(0);
worldInfo.setThunderTime(0);
worldInfo.setRaining(false);
worldInfo.setThundering(false);
}
return ActionResultType.SUCCESS;
}
The only difference is, that my item does not change the weather.
Even more interesting is, that if the weather is clear and the item is used, it starts raining.
If I am doing the same on a block like:
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand,
BlockRayTraceResult facing) {
final World world = worldIn;
final WorldInfo worldInfo = world.getWorldInfo();
worldInfo.setClearWeatherTime(100000);
worldInfo.setRainTime(0);
worldInfo.setThunderTime(0);
worldInfo.setRaining(false);
worldInfo.setThundering(false);
...
}
It is working again.
Currently I am simply out of ideas. Has anyone an idea how or why this is broken with an item?