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

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!

  • Author

Lol, okey.

So than how can i notice other players to render the item if its in my hotbar slot?

Send a packet to all players or what?

Thanks!

  • Author

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!

  • Author

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.

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.