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

        world.getMinecraftServer().isServerRunning()

 

Idk, but that might resolve it?

Minecraft#isGamePaused

will tell you if the game is paused. This can only be called on the client side.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

The

IntegratedServer#isGamePaused

field will also tell you this, but you'll need to access it via reflection.

 

This can only be accessed from the logical server on the physical client. You can read more about sides here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

How do I get the integrated server from a player?

 

Get the player's

World

from the

Entity#world

field, check that

World#isRemote

is

false

(i.e. you're on the logical server), then get the server with

World#getMinecraftServer

.

 

You can check if a server is dedicated or integrated using

MinecraftServer#isDedicatedServer

.

 

Since

IntegratedServer

is a client-only class, you'll need to create a method in your proxy to get the value of

IntegratedServer#isGamePaused

. Return

false

from the server proxy and only reference

IntegratedServer

from the client proxy.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Since

IntegratedServer

is a client-only class, you'll need to create a method in your proxy to get the value of

IntegratedServer#isGamePaused

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

I now have this:

	@SubscribeEvent
public void onPlayerTick(PlayerTickEvent event) {
	EntityPlayer player = event.player;
	ICheese cheese = player.getCapability(CheeseProvider.CHEESE_CAP, null);
	Random random = new Random();
	World world = player.world;
	if (!world.isRemote) {
		MinecraftServer server = player.getServer();
		if (!server.isDedicatedServer()) {
			boolean isGamePaused = DeGeweldigeMod.proxy.isGamePaused();
			if (random.nextInt(100) == 0 && !player.isCreative()
					&& world.getWorldInfo().getDifficulty() != EnumDifficulty.PEACEFUL
					&& world.getBiome(player.getPosition()) != CheeseBiomes.CHEESE_BIOME && !isGamePaused) {
				cheese.remove(1);
			}
			if (cheese.get() <= 0 && random.nextInt(25) == 0 && !player.isCreative()
					&& world.getWorldInfo().getDifficulty() != EnumDifficulty.PEACEFUL
					&& world.getBiome(player.getPosition()) != CheeseBiomes.CHEESE_BIOME && !isGamePaused) {
				player.attackEntityFrom(DamageSource.STARVE, 1.5F);
				cheese.set(0);
			}
			if (world.getWorldInfo().getDifficulty() == EnumDifficulty.PEACEFUL && random.nextInt(5) == 0
					&& !isGamePaused) {
				cheese.add(random.nextInt(2));
			}
		}
	}
}

But now it doesn't remove anything... my proxys: Client

	public boolean isGamePaused() {
	IntegratedServer server = Minecraft.getMinecraft().getIntegratedServer();
	return (Boolean) CheeseUtils.getField(IntegratedServer.class, server, "isGamePaused");
}

Common

	public boolean isGamePaused() {
	return false;
}

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

  • Author

So, it didn't work because of the isDedicatedServer boolean, I'll just not check for if the world is paused... Now it doesn't update when paused?!?!? Well.. ok

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Guest
This topic is now closed to further replies.

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.