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

Hey all.
Question in the title. I have a special armor item, that has defense properties, which depend on the current biome. I overrode the onArmorTick method like this:
 

	@Override
	public void onArmorTick(ItemStack stack, World world, PlayerEntity player) {
		if(world.getDayTime() % 20 == 0) {
			Biome biome = world.getBiome(player.getPosition());
			DefenseLayer layer = BasePropertiesAPI.getDefenseLayer(biome);
			DefenseDataAPI.putLayer(stack, layer, ElementalCombatWeaponry.ARMOR_RESOURCE_LOCATION);
			
			if(world.isRemote) {
				ElementalCombatWeaponry.LOGGER.info("Biome: " + biome.getRegistryName());
			}
		}
	}

This code produces the indented behavior, if run in single player. But when I am running the same code in a multiplayer setting I run into trouble on the client side. On server everything runs as expected, but on the client side the biome has the registryName = null (I know this because of the logging). The BasePropertiesAPI#getDefenseLayer checks a Map<ResourceLocation, DefenseLayer> with the registryName of the biome. Since the registryName is null, only a default value is returned. This means, I also have desyncronzied data... (at the end the method from DefenseDataAPI will update my itemstack capability.)

Gameplaywise everything is fine (the defense properties are used for calculation on the server side anyway). But the properties should be the same on client for display purpose.

I tried to look at the DebugOverlayGUI class, because this obviously works and can show the registryName of the current biome. The important line of this class is the following:

list.add("Biome: " + this.mc.world.func_241828_r().getRegistry(Registry.BIOME_KEY).getKey(this.mc.world.getBiome(blockpos)));


Could anyone please explain, what 'this.mc.world.func_241828_r().getRegistry(Registry.BIOME_KEY).getKey()' does and why the simple  world.getBiome(blockpos) doesn't suffice?

Thank you and with best regards

Tavi

Edited by Tavi007

  • Author

Is the quoted line able to run both on server and client? And can I simply copy it or are there better methods available? I am able to change BasePropertiesAPI#getDefenseLayer(biome) and it would be great, if I can adjust this api method without it breaking on either side.

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.