Jump to content

Recommended Posts

Posted (edited)

So I have a capability of an int array that assigns 5 values to each chunk. I also have an Item that is supposed to read the array in the chunk that the player is currently in. 

How do I use these packets? I already made them and I get the general idea of how they work, but I just don't know how to send them.

 

My major problem is that i need an EntityPlayerMP, which is the same player as the one who activated the item "playerIn" but I don't know how to pass that on from EntityPlayer to EntityPlayerMP, since casting is out of the question

Spoiler

@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
    {
        //TODO sense the stuff
			Chunk chunk = worldIn.getChunkFromBlockCoords(playerIn.getPosition());
			IArcana a = chunk.getCapability(ArcanaProvider.ARCANA_CAP, null);
			int[] s = a.getArcana();
			//TODO find a way to convert single player to multiplayer
			GrandSorcery.handler.INSTANCE.sendTo(new ElementMessage(s), entityPlayerMP);
			
	
		if(worldIn.isRemote) {
			int f = element[0];
			int ai = element[1];
			int ea = element[2];
			int w = element[3];
			int ar = element[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);
		}
		return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
    }
	
	public static void setElement(int[] val) {
		element = val;
	}

 

 

 

Edited by GooberGunter
Posted (edited)

Is there some sort of way to link the EntityPlayer from the method to EntityPlayerMP?

Edited by GooberGunter
Accidentally thought I found a bigger problem but it was just because I was loading from an older save

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.