@SubscribeEvent public void onEntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific event) { if (armorStandSwap) { //added for https://www.twitch.tv/darkphan if (event.getWorld().isRemote) { return; } //server side only if (event.getTarget() == null || event.getTarget() instanceof EntityArmorStand == false) { return; } EntityArmorStand entityStand = (EntityArmorStand) event.getTarget(); EntityPlayer player = event.getEntityPlayer(); if (player.isSneaking() == false) { return; } //bc when not sneaking, we do the normal single item version event.setCanceled(true);//which means we need to now cancel that normal version and do our own for (EntityEquipmentSlot slot : armorStandEquipment) { ItemStack itemPlayer = player.getItemStackFromSlot(slot); ItemStack itemArmorstand = entityStand.getItemStackFromSlot(slot); player.setItemStackToSlot(slot, itemArmorstand); entityStand.setItemStackToSlot(slot, itemPlayer); } } }
@SubscribeEvent public void onEntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific event) { EntityPlayer player = event.getEntityPlayer(); if(event.getTarget().world.isRemote || player.isSpectator() || player.isCreative() || !(event.getTarget() instanceof EntityArmorStand)) return; if(player.isSneaking()) { event.setCanceled(true); EntityArmorStand armorStand = (EntityArmorStand) event.getTarget(); swapSlot(player, armorStand, EntityEquipmentSlot.HEAD); swapSlot(player, armorStand, EntityEquipmentSlot.CHEST); swapSlot(player, armorStand, EntityEquipmentSlot.LEGS); swapSlot(player, armorStand, EntityEquipmentSlot.FEET); if(offhandSwapping) swapSlot(player, armorStand, EntityEquipmentSlot.OFFHAND); } }
@SubscribeEvent public void onEntityInteract(PlayerInteractEvent.EntityInteractSpecific event) { if (event.getEntityLiving() instanceof EntityLiving) { StoneEntityProperties properties = EntityPropertiesHandler.INSTANCE.getProperties(event.getEntityLiving(), StoneEntityProperties.class); if (properties != null && properties.isStone) { event.setCanceled(true); } } }