Jump to content

Recommended Posts

Posted (edited)

Hi,

 

I'm using the following code to prevent the player breaking carrots which aren't fully-grown. It works fine on singleplayer, but not at all on multiplayer. Why could this be?

@SubscribeEvent
    public void onBlockBreak(BreakEvent event)
    {
        IBlockState state = event.getState();
        net.minecraft.block.Block block = state.getBlock();
        
        for (Object o : state.getProperties().entrySet())
        {
            Map.Entry e = (Map.Entry)o;
            
            if (e.getKey() instanceof PropertyInteger)
            {
                PropertyInteger prop = (PropertyInteger)e.getKey();

                if (prop.getName().equals("age"))
                {
                    int age = state.getValue(prop);
                    if (age < 7) event.setCanceled(true);
                }
            }
        }
}

 

Edited by AntiRix
  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.