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

So, I have an Item, when it is right clicked it fetches the capability data stored in the player's current chunk:

Spoiler

public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
    {
        //TODO sense arcana
		if(!worldIn.isRemote) {
			Chunk chunk = worldIn.getChunkFromBlockCoords(playerIn.getPosition());
			Chunk chunk2 = Minecraft.getMinecraft().world.getChunkFromBlockCoords(playerIn.getPosition());
			IArcana a = chunk.getCapability(ArcanaProvider.ARCANA_CAP, null);
			IArcana a1 = chunk2.getCapability(ArcanaProvider.ARCANA_CAP, null);
			int[] s = a.getArcana();
			int[] s1 = a1.getArcana();
			int f = s[0];
			int ai = s[1];
			int ea = s[2];
			int w = s[3];
			int ar = s[4];
			
			int f1 = s1[0];
			int ai1 = s1[1];
			int ea1 = s1[2];
			int w1 = s1[3];
			int ar1 = s1[4];
			playerIn.sendMessage(new TextComponentTranslation("Fire: "+f+" Air: "+ai+" Earth: "+ea+" Water: "+w+" Arcana: "+ar));
			//Util.logger.info("Fire: "+f+" Air: "+ai+" Earth: "+ea+" Water: "+w+" Arcana: "+ar);
			playerIn.sendMessage(new TextComponentTranslation("TEST Fire: "+f1+" Air: "+ai1+" Earth: "+ea1+" Water: "+w1+" Arcana: "+ar1));
		}
		return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
    }

 

However, while I was testing some gui code that also fetched the same data, I noticed a difference in the result leading to the above test.

 

In the first test, I get an instance of the Chunk from the worldIn object

In the second test, I get an instance of the Chunk from Minecraft's (I think it's called a singleton) main world instance

I then print both and get two different outcomes. 

 

Question: Why are they different? Can I just run my code (i.e. subtracting and adding to the chunk capability) based off of Minecraft::world without any consequences?

Edited by GooberGunter

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.