Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.