Search in sources :

Example 86 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project NyaSamaRailway by NSDN.

the class EntityInteractHandler method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    if (event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        if (player.worldObj.isRemote)
            return;
        Entity entity = event.target;
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null) {
            if (stack.getItem() instanceof ItemNTP8Bit) {
                if (player.isSneaking()) {
                    ((ItemNTP8Bit) stack.getItem()).clearCart(stack, player);
                    return;
                }
                if (entity instanceof EntityMinecart) {
                    ((ItemNTP8Bit) stack.getItem()).addCart(stack, player, entity);
                }
            } else if (stack.getItem() instanceof ItemNTP32Bit) {
                if (player.isSneaking()) {
                    ((ItemNTP32Bit) stack.getItem()).clearCart(stack, player);
                    return;
                }
                if (entity instanceof EntityMinecart) {
                    ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                } else {
                    if (ExRollerCoaster.getInstance() != null) {
                        if (ExRollerCoaster.getInstance().verifyEntity(entity)) {
                            ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                        }
                    }
                    if (RailsOfWar.getInstance() != null) {
                        if (RailsOfWar.getInstance().verifyEntity(entity)) {
                            ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                        }
                    }
                }
            } else if (stack.getItem() instanceof Item1N4148) {
                if (entity instanceof NSPCT8J) {
                    NSPCT8J loco = (NSPCT8J) entity;
                    loco.modifyHighSpeedMode(player);
                }
            } else if (stack.getItem() instanceof ItemNSPCT5) {
                if (entity instanceof NSPCT5) {
                    ((NSPCT5) entity).modifyLength();
                }
            } else if (stack.getItem() instanceof ItemNSPCT5L) {
                if (entity instanceof NSPCT5L) {
                    ((NSPCT5L) entity).modifyLength();
                }
            }
        }
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) Entity(net.minecraft.entity.Entity) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) NSPCT8J(club.nsdn.nyasamarailway.entity.loco.NSPCT8J) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) NSPCT5(club.nsdn.nyasamarailway.entity.cart.NSPCT5) ItemNSPCT5(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) NSPCT5L(club.nsdn.nyasamarailway.entity.cart.NSPCT5L) ItemNSPCT5L(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L) EntityMinecart(net.minecraft.entity.item.EntityMinecart) ItemNSPCT5L(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L) ItemNSPCT5(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 87 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ClaySoldiersMod by SanAndreasP.

the class RenderStatDisplayOverlay method renderText.

@SubscribeEvent
public void renderText(RenderGameOverlayEvent.Text event) {
    Minecraft mc = Minecraft.getMinecraft();
    if (this.p_titleRenderer == null) {
        this.p_titleRenderer = mc.fontRenderer;
    }
    if (this.p_statRenderer == null) {
        this.p_statRenderer = new FontRenderer(mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), mc.renderEngine, true);
        if (mc.gameSettings.language != null) {
            this.p_statRenderer.setBidiFlag(mc.getLanguageManager().isCurrentLanguageBidirectional());
        }
    }
    ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem();
    if (!mc.gameSettings.showDebugInfo && equippedStack != null && equippedStack.getItem() == RegistryItems.statDisplay) {
        this.renderSoldiers(mc);
        this.renderMounts(mc);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 88 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ClaySoldiersMod by SanAndreasP.

the class RenderClayCamHandler method onRenderTick.

@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    if (event.phase == Phase.START) {
        if (mc.thePlayer != null && ClientProxy.s_clayCamEntity != null) {
            if (this.viewMode == -1) {
                this.viewMode = mc.gameSettings.thirdPersonView;
            }
            mc.gameSettings.thirdPersonView = 1;
            if (this.p_clayCamRenderer == null) {
                this.p_clayCamRenderer = new EntityRendererClayCam(mc, mc.getResourceManager());
            }
            if (mc.entityRenderer != this.p_clayCamRenderer) {
                // be sure to store the previous renderer
                this.p_prevEntityRenderer = mc.entityRenderer;
                mc.entityRenderer = this.p_clayCamRenderer;
            }
            if (mc.thePlayer.isSneaking() || ClientProxy.s_clayCamEntity.isDead) {
                mc.gameSettings.thirdPersonView = this.viewMode;
                this.viewMode = -1;
                ClaySoldiersMod.proxy.switchClayCam(false, null);
            }
        } else if (this.p_prevEntityRenderer != null && mc.entityRenderer != this.p_prevEntityRenderer) {
            // reset the renderer
            mc.entityRenderer = this.p_prevEntityRenderer;
        }
    } else if (ClientProxy.s_clayCamEntity != null) {
        mc.gameSettings.thirdPersonView = this.viewMode;
    }
}
Also used : EntityRendererClayCam(de.sanandrew.mods.claysoldiers.client.render.EntityRendererClayCam) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 89 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project pvp-mode by VulcanForge.

the class PvPEventHandler method interceptPvP.

/**
 * Cancels combat events associated with PvP-disabled players.
 */
@SubscribeEvent
public void interceptPvP(LivingAttackEvent event) {
    EntityPlayerMP attacker = getMaster(event.source.getEntity());
    EntityPlayerMP victim = getMaster(event.entity);
    if (attacker == null || victim == null)
        return;
    if (attacker.capabilities.allowFlying) {
        if (attacker == event.source.getEntity())
            fly(attacker);
        event.setCanceled(true);
        return;
    }
    if (victim.capabilities.allowFlying) {
        event.setCanceled(true);
        return;
    }
    if (attacker.capabilities.isCreativeMode) {
        if (attacker == event.source.getEntity())
            gm1(attacker);
        event.setCanceled(true);
        return;
    }
    if (!victim.getEntityData().getBoolean("PvPEnabled")) {
        if (attacker == event.source.getEntity())
            disabled(attacker);
        event.setCanceled(true);
        return;
    }
    if (!attacker.getEntityData().getBoolean("PvPEnabled")) {
        event.setCanceled(true);
        return;
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 90 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project pvp-mode by VulcanForge.

the class PvPEventHandler method onNewPlayer.

/**
 * Adds a PvPEnabled tag to a new player.
 */
@SubscribeEvent
public void onNewPlayer(PlayerLoggedInEvent event) {
    EntityPlayerMP player = (EntityPlayerMP) event.player;
    if (!player.getEntityData().hasKey("PvPEnabled")) {
        player.getEntityData().setBoolean("PvPEnabled", false);
        player.getEntityData().setLong("PvPWarmup", 0);
        player.getEntityData().setLong("PvPCooldown", 0);
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)138 EntityPlayer (net.minecraft.entity.player.EntityPlayer)57 ItemStack (net.minecraft.item.ItemStack)48 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)18 Minecraft (net.minecraft.client.Minecraft)14 EntityLivingBase (net.minecraft.entity.EntityLivingBase)14 World (net.minecraft.world.World)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)12 ArrayList (java.util.ArrayList)10 EntityItem (net.minecraft.entity.item.EntityItem)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)9 ChunkPosition (net.minecraft.world.ChunkPosition)9 ChatComponentText (net.minecraft.util.ChatComponentText)8 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)8 Block (net.minecraft.block.Block)7 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)6 AffinityData (am2.playerextensions.AffinityData)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)5