Search in sources :

Example 36 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Engine by VoltzEngine-Project.

the class ChunkMap method onChunkLoaded.

@SubscribeEvent
public void onChunkLoaded(ChunkEvent.Load event) {
    Chunk chunk = event.getChunk();
    ChunkCoordIntPair coords = chunk.getChunkCoordIntPair();
    if (chunks.containsKey(coords)) {
    //TODO load data into existing object
    } else {
    //TODO load object
    }
}
Also used : ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) Chunk(net.minecraft.world.chunk.Chunk) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 37 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Engine by VoltzEngine-Project.

the class PlayerKeyHandler method mouseHandler.

@SubscribeEvent
public void mouseHandler(MouseEvent e) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    ItemStack stack = player.getCurrentEquippedItem();
    if (stack != null) {
        final Item item = stack.getItem();
        if (item instanceof IModeItem.IModeScrollItem) {
            if (player.isSneaking() && e.dwheel != 0) {
                int newMode = ((IModeItem.IModeScrollItem) stack.getItem()).cycleMode(stack, player, e.dwheel / 120);
                if (newMode != ((IModeItem.IModeScrollItem) stack.getItem()).getMode(stack)) {
                    Engine.instance.packetHandler.sendToServer(new PacketPlayerItemMode(player.inventory.currentItem, newMode));
                }
                e.setCanceled(true);
            }
        } else if (item instanceof IMouseButtonHandler && e.button != -1) {
            Engine.instance.packetHandler.sendToServer(new PacketMouseClick(player.inventory.currentItem, e.button, e.buttonstate));
            ((IMouseButtonHandler) item).mouseClick(stack, player, e.button, e.buttonstate);
            if (((IMouseButtonHandler) item).shouldCancelMouseEvent(stack, player, e.button, e.buttonstate)) {
                e.setCanceled(true);
            }
        }
    }
}
Also used : IModeItem(com.builtbroken.mc.api.items.tools.IModeItem) Item(net.minecraft.item.Item) PacketPlayerItemMode(com.builtbroken.mc.core.network.packet.user.PacketPlayerItemMode) PacketMouseClick(com.builtbroken.mc.core.network.packet.user.PacketMouseClick) IModeItem(com.builtbroken.mc.api.items.tools.IModeItem) IMouseButtonHandler(com.builtbroken.mc.api.items.IMouseButtonHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 38 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMClientEventHandler method onPlayerRender.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerRender(RenderPlayerEvent.Post event) {
    ModelBiped mainModel = ReflectionHelper.getPrivateValue(RenderPlayer.class, event.renderer, "field_77109_a", "modelBipedMain");
    if (mainModel != null) {
        mainModel.bipedLeftArm.isHidden = false;
        mainModel.bipedRightArm.isHidden = false;
    }
    if (ExtendedProperties.For(event.entityPlayer).getFlipRotation() > 0) {
        GL11.glPopMatrix();
    }
    if (ExtendedProperties.For(event.entityPlayer).getShrinkPct() > 0) {
        GL11.glPopMatrix();
    }
    CloakUtils.renderCloakModel(event.entityPlayer, mainModel, event.partialRenderTick);
    if (event.entityPlayer == AMCore.proxy.getLocalPlayer()) {
        if (AMCore.proxy.getLocalPlayer().isPotionActive(BuffList.trueSight.id)) {
            if (AMGuiHelper.instance.playerRunesAlpha < 1)
                AMGuiHelper.instance.playerRunesAlpha += 0.01f;
        } else {
            if (AMGuiHelper.instance.playerRunesAlpha > 0)
                AMGuiHelper.instance.playerRunesAlpha -= 0.01f;
        }
        if (AMGuiHelper.instance.playerRunesAlpha > 0) {
            int runeCombo = EntityUtilities.getRuneCombo(event.entityPlayer);
            int numRunes = 0;
            for (int i = 0; i <= 16; ++i) {
                int bit = 1 << i;
                if ((runeCombo & bit) == bit) {
                    numRunes++;
                }
            }
            double step = 0.25f;
            double xOffset = -(numRunes / 2.0f) * step + ((numRunes % 2 == 0) ? step / 2f : 0);
            for (int i = 0; i <= 16; ++i) {
                int bit = 1 << i;
                if ((runeCombo & bit) == bit) {
                    RenderUtilities.DrawIconInWorldAtOffset(ItemsCommonProxy.rune.getIconFromDamage(i), xOffset, 0.5f, 0, 0.25f, 0.25f);
                    xOffset += step;
                }
            }
        }
    }
}
Also used : ModelBiped(net.minecraft.client.model.ModelBiped) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 39 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMClientEventHandler method onItemTooltip.

@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
    ItemStack stack = event.itemStack;
    if (stack != null && stack.getItem() instanceof ItemArmor) {
        double xp = 0;
        int armorLevel = 0;
        String[] effects = new String[0];
        if (stack.hasTagCompound()) {
            NBTTagCompound armorCompound = (NBTTagCompound) stack.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
            if (armorCompound != null) {
                xp = armorCompound.getDouble(AMArmor.NBT_KEY_TOTALXP);
                armorLevel = armorCompound.getInteger(AMArmor.NBT_KEY_ARMORLEVEL);
                String effectsList = armorCompound.getString(AMArmor.NBT_KEY_EFFECTS);
                if (effectsList != null && effectsList != "") {
                    effects = effectsList.split(AMArmor.INFUSION_DELIMITER);
                }
            }
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
            event.toolTip.add(StatCollector.translateToLocalFormatted("am2.tooltip.armorxp", String.format("%.2f", xp)));
            event.toolTip.add(String.format(StatCollector.translateToLocal("am2.tooltip.armorlevel"), armorLevel));
            for (String s : effects) {
                event.toolTip.add(StatCollector.translateToLocal("am2.tooltip." + s));
            }
        } else {
            event.toolTip.add(StatCollector.translateToLocal("am2.tooltip.shiftForDetails"));
        }
    } else if (stack.getItem() instanceof ItemBlock) {
        if (((ItemBlock) stack.getItem()).field_150939_a == BlocksCommonProxy.manaBattery) {
            if (stack.hasTagCompound()) {
                NBTTagList list = stack.stackTagCompound.getTagList("Lore", Constants.NBT.TAG_COMPOUND);
                if (list != null) {
                    for (int i = 0; i < list.tagCount(); ++i) {
                        NBTBase tag = list.getCompoundTagAt(i);
                        if (tag instanceof NBTTagString) {
                            event.toolTip.add((((NBTTagString) tag).func_150285_a_()));
                        }
                    }
                }
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTBase(net.minecraft.nbt.NBTBase) ItemArmor(net.minecraft.item.ItemArmor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 40 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMClientEventHandler method onPlayerRender.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerRender(RenderPlayerEvent.Pre event) {
    ItemStack chestPlate = event.entityPlayer.inventory.armorInventory[2];
    ModelBiped mainModel = ReflectionHelper.getPrivateValue(RenderPlayer.class, event.renderer, "field_77109_a", "modelBipedMain");
    boolean holdingItem = false;
    if (event.entityPlayer.getCurrentEquippedItem() != null)
        holdingItem = true;
    if (!AMCore.proxy.playerTracker.hasCLS(event.entityPlayer.getUniqueID().toString())) {
        if (chestPlate != null && chestPlate.getItem() == ItemsCommonProxy.earthGuardianArmor) {
            if (mainModel != null) {
                mainModel.bipedLeftArm.isHidden = true;
                mainModel.bipedRightArm.isHidden = !holdingItem;
            }
        } else {
            if (mainModel != null) {
                mainModel.bipedLeftArm.isHidden = false;
                mainModel.bipedRightArm.isHidden = false;
            }
        }
    }
    double dX = AMCore.proxy.getLocalPlayer().posX - event.entityPlayer.posX;
    double dY = AMCore.proxy.getLocalPlayer().posY - event.entityPlayer.posY;
    double dZ = AMCore.proxy.getLocalPlayer().posZ - event.entityPlayer.posZ;
    double dpX = AMCore.proxy.getLocalPlayer().prevPosX - event.entityPlayer.prevPosX;
    double dpY = AMCore.proxy.getLocalPlayer().prevPosY - event.entityPlayer.prevPosY;
    double dpZ = AMCore.proxy.getLocalPlayer().prevPosZ - event.entityPlayer.prevPosZ;
    double transX = dpX + (dX - dpX) * event.partialRenderTick;
    double transY = dpY + (dY - dpY) * event.partialRenderTick;
    double transZ = dpZ + (dZ - dpZ) * event.partialRenderTick;
    if (ExtendedProperties.For(event.entityPlayer).getFlipRotation() > 0) {
        GL11.glPushMatrix();
        GL11.glTranslated(-transX, -transY, -transZ);
        GL11.glRotatef(ExtendedProperties.For(event.entityPlayer).getFlipRotation(), 0, 0, 1.0f);
        GL11.glTranslated(transX, transY, transZ);
        float offset = event.entityPlayer.height * (ExtendedProperties.For(event.entityPlayer).getFlipRotation() / 180.0f);
        GL11.glTranslatef(0, -offset, 0);
    }
    float shrink = ExtendedProperties.For(event.entityPlayer).getShrinkPct();
    if (shrink > 0) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0 - 0.5f * shrink, 0);
        GL11.glScalef(1 - 0.5f * shrink, 1 - 0.5f * shrink, 1 - 0.5f * shrink);
    }
}
Also used : ModelBiped(net.minecraft.client.model.ModelBiped) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

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