List of usage examples for net.minecraftforge.event.entity.player PlayerInteractEvent.EntityInteractSpecific getWorld
public World getWorld()
From source file:com.lothrazar.cyclicmagic.playerupgrade.PlayerAbilitiesModule.java
License:Open Source License
@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; }/* www . jav a2s.com*/ 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); } } }