This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xuma202's profile picture

Client not calling onItemUse when using on Monitor in SMP.

Started by xuma202, 28 July 2012 - 09:52 AM
xuma202 #1
Posted 28 July 2012 - 11:52 AM
Hello,

When I use an item on a Monitor in SMP the onItemUse method get's only called on the server not on the client. But when I use the Item on a Block of Dirt the method get's called on both. This is the code:


public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer Player, World World, int x, int y, int z, int par7)
    {
  System.out.println("test");
			    return false;
    }

it's the same for client and Server.

Why get's the method not called on the client? I don't want to handle any logic I only want to add a message to the clients chat (only for the player using the item).
Cloudy #2
Posted 28 July 2012 - 01:03 PM
It's the way minecraft works in SMP. All logic is handled on the server. However you can still use the onItemUse server side and use the EntityPlayer object to add a chat message.
xuma202 #3
Posted 28 July 2012 - 01:42 PM
Yes but when I use the item on a Block of dirt the method gets called on the client too. That's a what is confusing me.
Xfel #4
Posted 28 July 2012 - 02:24 PM
That means that when on client, the monitor block grabs all activation events. The block is asked before the item is asked, so the method doesn't get called. If you really need it (which shouldn't be, you could do everything on the server as well), consider forge's beforeItemUse hook.