use of net.minecraft.block.BlockSilverfish in project minecolonies by Minecolonies.
the class EventHandler method onPlayerInteract.
/**
* Event when a player right clicks a block, or right clicks with an item.
* Event gets cancelled when player has no permission. Event gets cancelled
* when the player has no permission to place a hut, and tried it.
*
* @param event {@link PlayerInteractEvent.RightClickBlock}
*/
@SubscribeEvent
public void onPlayerInteract(@NotNull final PlayerInteractEvent.RightClickBlock event) {
final EntityPlayer player = event.getEntityPlayer();
final World world = event.getWorld();
//Only execute for the main hand our colony events.
if (event.getHand() == EnumHand.MAIN_HAND && !(event.getWorld().isRemote)) {
// and uses that return value, but I didn't want to call it twice
if (playerRightClickInteract(player, world, event.getPos()) && world.getBlockState(event.getPos()).getBlock() instanceof AbstractBlockHut) {
final IColony colony = ColonyManager.getIColony(world, event.getPos());
if (colony != null && !colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
event.setCanceled(true);
}
return;
} else if (event.getEntityPlayer() != null && "pmardle".equalsIgnoreCase(event.getEntityPlayer().getName()) && event.getItemStack() != null && Block.getBlockFromItem(event.getItemStack().getItem()) instanceof BlockSilverfish) {
LanguageHandler.sendPlayerMessage(event.getEntityPlayer(), "Stop that you twat!!!");
event.setCanceled(true);
}
if (player.getHeldItemMainhand() == null || player.getHeldItemMainhand().getItem() == null) {
return;
}
handleEventCancellation(event, player);
}
}
Aggregations