Search in sources :

Example 6 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 7 with SubscribeEvent

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

the class ClientSemiBlockManager method renderWorldLastEvent.

@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    EntityPlayer player = mc.thePlayer;
    double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.partialTicks;
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.partialTicks;
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.partialTicks;
    GL11.glPushMatrix();
    GL11.glTranslated(-playerX, -playerY, -playerZ);
    //  GL11.glEnable(GL11.GL_BLEND);
    //  GL11.glEnable(GL11.GL_LIGHTING);
    RenderHelper.enableStandardItemLighting();
    for (Map<ChunkPosition, ISemiBlock> map : SemiBlockManager.getInstance(player.worldObj).getSemiBlocks().values()) {
        for (ISemiBlock semiBlock : map.values()) {
            ISemiBlockRenderer renderer = getRenderer(semiBlock);
            if (renderer != null) {
                GL11.glPushMatrix();
                GL11.glTranslated(semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
                renderer.render(semiBlock, event.partialTicks);
                GL11.glPopMatrix();
            }
        }
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}
Also used : ISemiBlock(pneumaticCraft.common.semiblock.ISemiBlock) ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 8 with SubscribeEvent

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

the class CommonHUDHandler method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.PlayerTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        EntityPlayer player = event.player;
        if (this == PneumaticCraft.proxy.getCommonHudHandler()) {
            getHandlerForPlayer(player).tickEnd(event);
        } else {
            ItemStack helmetStack = player.getCurrentArmor(3);
            if (helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet) {
                helmetPressure = ((IPressurizable) helmetStack.getItem()).getPressure(helmetStack);
                if (ticksExisted == 0) {
                    checkHelmetInventory(helmetStack);
                }
                ticksExisted++;
                if (!player.worldObj.isRemote) {
                    if (ticksExisted > getStartupTime() && !player.capabilities.isCreativeMode) {
                        ((IPressurizable) helmetStack.getItem()).addAir(helmetStack, (int) -UpgradeRenderHandlerList.instance().getAirUsage(player, false));
                    }
                }
            } else {
                ticksExisted = 0;
            }
            if (!player.worldObj.isRemote)
                handleHacking(player);
        }
    }
}
Also used : IPressurizable(pneumaticCraft.api.item.IPressurizable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 9 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)

Example 10 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)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)109 EntityPlayer (net.minecraft.entity.player.EntityPlayer)45 ItemStack (net.minecraft.item.ItemStack)45 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)14 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 World (net.minecraft.world.World)11 Minecraft (net.minecraft.client.Minecraft)10 ChunkPosition (net.minecraft.world.ChunkPosition)9 EntityItem (net.minecraft.entity.item.EntityItem)8 ChatComponentText (net.minecraft.util.ChatComponentText)8 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 AffinityData (am2.playerextensions.AffinityData)5 SideOnly (cpw.mods.fml.relauncher.SideOnly)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Block (net.minecraft.block.Block)5 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)5 ExtendedProperties (am2.playerextensions.ExtendedProperties)4