Jump to content

[1.14.4][solved] Changing worldInfo settings not working properly


Recommended Posts

Posted (edited)

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?

Edited by Terpo
Posted

My mod has an item that currently stops changes the weather, actually theres 1 that makes it clear one that makes it rain and one that makes thunder.

its called xp plus. Its open source maybe that can help you figure out what you can do.

Posted (edited)

Well I did take a look and it seems, when changing the weather info in onItemRightClick everything is working fine. In onItemUse the same method block does not work.

When creating a an entity in both methods and then trying to change the weather info in the entity class it will not work either.

 

Edit:

Holy ...... I solved my problem. And as always .... such a simple trick.

I have a WeatherEntity, that is extended by AntiRain and Rain Entity. Turns out my WeahterEntity still had some code to turn on the rain and my AntiRain Entity was calling the super method. So it disabled the rain and then turned it on again. Heck... time for weekend xD

Edited by Terpo
  • Haha 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.