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
}
}
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);
}
}
}
}
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;
}
}
}
}
}
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_()));
}
}
}
}
}
}
}
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);
}
}
Aggregations