Jump to content

[1.7.10]Hotbar slot on server side


FLUFFY2

Recommended Posts

Right now im using:

if(player.inventory.mainInventory[8] != null && player.inventory.mainInventory[8].getItem() == Amnesia.LanternOn)

But thats client only. So how can i make so that other players know that an item is in a hotbar slot?

I need a method that works both side and still can detect a specified inventory slot.

Thanks!

Link to comment
Share on other sites

Okey, than im probably doing something wrong.

I can see the render other cannot.

 

Slot detect:

if(!world.isRemote){
if(player.inventory.mainInventory[8] != null && player.inventory.mainInventory[8].getItem() == Amnesia.LanternOn){
	if(!props.isQuickEquipped()){
		Amnesia.snw.sendTo(new HotbarLanternMessageHandler(true), (EntityPlayerMP)player);
		props.setQuickEquipped(true);
	}
}else{
	if(props.isQuickEquipped()){
		Amnesia.snw.sendTo(new HotbarLanternMessageHandler(false), (EntityPlayerMP)player);
		props.setQuickEquipped(false);
	}
}
}

 

Packet handler(only onMessage):

@Override
public IMessage onMessage(HotbarLanternMessageHandler message, MessageContext ctx) { 

ExtendedPlayerPropertiesHandler.get(Minecraft.getMinecraft().thePlayer).setHotbarLantern(message.isWorn);

return null;
}

 

This is the render part:

@SubscribeEvent
public void render(RenderPlayerEvent.Specials.Pre event){
EntityPlayer player = event.entityPlayer;
ExtendedPlayerPropertiesHandler props = ExtendedPlayerPropertiesHandler.get(player);

if(props.hotbarLantern()){
	GL11.glPushMatrix();

	Minecraft.getMinecraft().renderEngine.bindTexture(lanternOnTexture);

	GL11.glRotatef(5F, 1.0F, 0.0F, 0.0F);
	GL11.glRotatef(-40F, 0.0F, 1.0F, 0.0F);
	GL11.glRotatef(165F, 0.0F, 0.0F, 1.0F);
	GL11.glTranslatef(0.0F, -1.4F, -0.12F);

	float scale = 0.1F;
	GL11.glScalef(scale, scale, scale);

	model.renderAll();
	GL11.glPopMatrix();
}
}

 

Thanks for helping!

Link to comment
Share on other sites

I know that the client is know whats in my hand.

I just don't uderstand how can i inform other players that i have it in there.

I know you said pakets, but you also said not to all player. That confuses me a bit.

 

Can you tell me what steps is bad because i doing the following:

Check hotbar on sevrer side -> Send a packet to the client -> Set a boolean to true -> Render.

 

But i will try this aswell:

Check hotbar client side -> Send packet to the server than send a return packet to others client and set the boolean -> Render

 

Thanks for helping and for your patience.

Link to comment
Share on other sites

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.