Search in sources :

Example 46 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.

the class DroneSpecialVariableHandler method onSpecialVariableRetrieving.

@SubscribeEvent
public void onSpecialVariableRetrieving(SpecialVariableRetrievalEvent.CoordinateVariable.Drone event) {
    if (event.specialVarName.equalsIgnoreCase("owner")) {
        EntityDrone drone = (EntityDrone) event.drone;
        EntityPlayer player = drone.getOwner();
        if (player != null)
            event.coordinate = getPosForEntity(player);
    } else if (event.specialVarName.equalsIgnoreCase("drone")) {
        event.coordinate = getPosForEntity(event.drone);
    } else if (event.specialVarName.toLowerCase().startsWith("player=")) {
        EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.specialVarName.substring("player=".length()));
        if (player != null)
            event.coordinate = getPosForEntity(player);
    }
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 47 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.

the class GuiKeybindCheckBox method onKeyInput.

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    if (mc.inGameHasFocus && keyBinding != null && keyBinding.isPressed()) {
        onMouseClicked(0, 0, 0);
        HUDHandler.instance().addMessage(I18n.format("pneumaticHelmet.message." + (checked ? "enable" : "disable") + "Setting", I18n.format(text)), new ArrayList<String>(), 60, 0x7000AA00);
    }
}
Also used : Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 48 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Minechem by iopleke.

the class ScheduledTickHandler method checkForPoison.

@SubscribeEvent
public void checkForPoison(PlayerUseItemEvent.Finish event) {
    if (event.item != null && event.item.getTagCompound() != null && Settings.FoodSpiking) {
        NBTTagCompound stackTag = event.item.getTagCompound();
        boolean isPoisoned = stackTag.getBoolean("minechem.isPoisoned");
        int[] effectTypes = stackTag.getIntArray("minechem.effectTypes");
        if (isPoisoned) {
            for (int effectType : effectTypes) {
                MoleculeEnum molecule = MoleculeEnum.getById(effectType);
                PharmacologyEffectRegistry.applyEffect(molecule, event.entityPlayer);
            }
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) MoleculeEnum(minechem.item.molecule.MoleculeEnum) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 49 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.

the class EventHandlerPneumaticCraft method onPlayerClick.

@SubscribeEvent
public void onPlayerClick(PlayerInteractEvent event) {
    Block interactedBlock = event.world.getBlock(event.x, event.y, event.z);
    if (!event.entityPlayer.capabilities.isCreativeMode || !event.entityPlayer.canCommandSenderUseCommand(2, "securityStation")) {
        if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR && event.world != null && !event.world.isRemote) {
            if (interactedBlock != Blockss.securityStation || event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
                ItemStack heldItem = event.entityPlayer.getCurrentEquippedItem();
                boolean tryingToPlaceSecurityStation = heldItem != null && heldItem.getItem() instanceof ItemBlock && ((ItemBlock) heldItem.getItem()).field_150939_a == Blockss.securityStation;
                int blockingStations = PneumaticCraftUtils.getProtectingSecurityStations(event.entity.worldObj, event.x, event.y, event.z, event.entityPlayer, true, tryingToPlaceSecurityStation);
                if (blockingStations > 0) {
                    event.setCanceled(true);
                    event.entityPlayer.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(tryingToPlaceSecurityStation ? "message.securityStation.stationPlacementPrevented" : "message.securityStation.accessPrevented", blockingStations)));
                }
            }
        }
    }
    /**
     * Due to some weird quirk that causes Block#onBlockActivated not getting called on the server when the player is sneaking, this is a workaround.
     */
    if (!event.isCanceled() && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && !event.world.isRemote) {
        if (event.entityPlayer.isSneaking() && (interactedBlock == Blockss.elevatorCaller || interactedBlock == Blockss.chargingStation)) {
            event.setCanceled(interactedBlock.onBlockActivated(event.world, event.x, event.y, event.z, event.entityPlayer, event.face, 0, 0, 0));
        } else if (event.entityPlayer.getCurrentEquippedItem() != null && ModInteractionUtilImplementation.getInstance().isModdedWrench(event.entityPlayer.getCurrentEquippedItem().getItem())) {
            if (interactedBlock instanceof IPneumaticWrenchable) {
                ((IPneumaticWrenchable) interactedBlock).rotateBlock(event.world, event.entityPlayer, event.x, event.y, event.z, ForgeDirection.getOrientation(event.face));
            }
        }
    }
    if (!event.isCanceled() && interactedBlock == Blocks.cobblestone) {
        AchievementHandler.checkFor9x9(event.entityPlayer, event.x, event.y, event.z);
    }
}
Also used : Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IPneumaticWrenchable(pneumaticCraft.api.block.IPneumaticWrenchable) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) ChatComponentText(net.minecraft.util.ChatComponentText) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 50 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project PneumaticCraft by MineMaarten.

the class EventHandlerPneumaticCraft method FillBucket.

@SubscribeEvent
public void FillBucket(FillBucketEvent event) {
    MovingObjectPosition p = event.target;
    if (event.current == null || event.current.getItem() != Items.bucket || event.world.getBlockMetadata(p.blockX, p.blockY, p.blockZ) != 0)
        return;
    ItemStack result = attemptFill(event.world, event.target);
    if (result != null) {
        event.result = result;
        AchievementHandler.giveAchievement(event.entityPlayer, result);
        event.setResult(Result.ALLOW);
    }
}
Also used : MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ItemStack(net.minecraft.item.ItemStack) 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