Search in sources :

Example 1 with LargePlaneEntity

use of xyz.przemyk.simpleplanes.entities.LargePlaneEntity in project simple-planes by przemykomo.

the class CommonEventHandler method interact.

@SubscribeEvent
public static void interact(PlayerInteractEvent.RightClickItem event) {
    Player player = event.getPlayer();
    Entity entity = player.getRootVehicle();
    if (entity instanceof PlaneEntity) {
        ItemStack itemStack = player.getItemInHand(event.getHand());
        if (!itemStack.isEmpty()) {
            if (itemStack.getItem() == Items.TNT && entity instanceof LargePlaneEntity && ((LargePlaneEntity) entity).tryToAddTNT(player, itemStack)) {
                return;
            }
            PlaneEntity planeEntity = (PlaneEntity) entity;
            for (Upgrade upgrade : planeEntity.upgrades.values()) {
                upgrade.onItemRightClick(event);
            }
        }
    }
}
Also used : Entity(net.minecraft.world.entity.Entity) LargePlaneEntity(xyz.przemyk.simpleplanes.entities.LargePlaneEntity) PlaneEntity(xyz.przemyk.simpleplanes.entities.PlaneEntity) Player(net.minecraft.world.entity.player.Player) LargePlaneEntity(xyz.przemyk.simpleplanes.entities.LargePlaneEntity) PlaneEntity(xyz.przemyk.simpleplanes.entities.PlaneEntity) LargePlaneEntity(xyz.przemyk.simpleplanes.entities.LargePlaneEntity) ItemStack(net.minecraft.world.item.ItemStack) Upgrade(xyz.przemyk.simpleplanes.upgrades.Upgrade) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Entity (net.minecraft.world.entity.Entity)1 Player (net.minecraft.world.entity.player.Player)1 ItemStack (net.minecraft.world.item.ItemStack)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 LargePlaneEntity (xyz.przemyk.simpleplanes.entities.LargePlaneEntity)1 PlaneEntity (xyz.przemyk.simpleplanes.entities.PlaneEntity)1 Upgrade (xyz.przemyk.simpleplanes.upgrades.Upgrade)1