Jump to content

Recommended Posts

Posted (edited)

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
Posted

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

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