use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onLivingDrops.
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
if (EntityUtilities.isSummon(event.entityLiving) && !(event.entityLiving instanceof EntityHorse)) {
event.setCanceled(true);
}
if (event.source == DamageSources.darkNexus) {
event.setCanceled(true);
}
if (!event.entityLiving.worldObj.isRemote && event.entityLiving instanceof EntityPig && event.entityLiving.getRNG().nextDouble() < 0.3f) {
EntityItem animalFat = new EntityItem(event.entityLiving.worldObj);
ItemStack stack = new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_ANIMALFAT);
animalFat.setPosition(event.entity.posX, event.entity.posY, event.entity.posZ);
animalFat.setEntityItemStack(stack);
event.drops.add(animalFat);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMPacketProcessorClient method onPacketData.
@SubscribeEvent
public void onPacketData(ClientCustomPacketEvent event) {
ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
byte packetID = -1;
try {
if (event.packet.getTarget() != Side.CLIENT) {
return;
}
// constant details all packets share: ID, player, and remaining data
packetID = bbis.readByte();
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
byte[] remaining = new byte[bbis.available()];
bbis.readFully(remaining);
switch(packetID) {
case AMPacketIDs.SPELL_CAST:
handleSpellCast(remaining);
break;
case AMPacketIDs.MAGIC_LEVEL_UP:
handleMagicLevelUpResponse(remaining);
break;
case AMPacketIDs.PARTICLE_SPAWN_SPECIAL:
AMCore.instance.proxy.particleManager.handleClientPacketData(Minecraft.getMinecraft().theWorld, remaining);
break;
case AMPacketIDs.PLAYER_VELOCITY_ADD:
handleVelocityAdd(remaining);
break;
case AMPacketIDs.FLASH_ARMOR_PIECE:
handleFlashArmor(remaining);
break;
case AMPacketIDs.REMOVE_BUFF_EFFECT:
handleRemoveBuffEffect(remaining);
break;
case AMPacketIDs.SYNC_EXTENDED_PROPS:
handleSyncProps(remaining);
break;
case AMPacketIDs.SYNC_BETA_PARTICLES:
handleSyncBetaParticles(remaining);
break;
case AMPacketIDs.REQUEST_BETA_PARTICLES:
handleRequestBetaParticles(remaining);
break;
case AMPacketIDs.SYNC_AIR_CHANGE:
handleSyncAir(remaining);
break;
case AMPacketIDs.SYNC_AFFINITY_DATA:
handleSyncAffinity(remaining);
break;
case AMPacketIDs.SYNC_SPELL_KNOWLEDGE:
handleSyncSpellKnowledge(remaining);
break;
case AMPacketIDs.ENTITY_ACTION_UPDATE:
handleEntityActionUpdate(remaining, player);
break;
case AMPacketIDs.PLAYER_LOGIN_DATA:
handlePlayerLoginData(remaining, player);
break;
case AMPacketIDs.NBT_DUMP:
handleNBTDump(player);
break;
case AMPacketIDs.SET_MAG_WORK_REC:
handleSetMagicicansWorkbenchRecipe(player);
break;
case AMPacketIDs.COMPENDIUM_UNLOCK:
handleCompendiumUnlock(remaining);
break;
case AMPacketIDs.SYNC_WORLD_NAME:
handleSyncWorldName(remaining);
break;
case AMPacketIDs.STAR_FALL:
handleStarFall(remaining);
break;
case AMPacketIDs.HIDDEN_COMPONENT_UNLOCK:
Minecraft.getMinecraft().guiAchievement.func_146256_a(ArcaneCompendium.componentUnlock);
break;
case AMPacketIDs.SPELL_APPLY_EFFECT:
handleSpellApplyEffect(remaining);
break;
case AMPacketIDs.HECATE_DEATH:
handleHecateDeath(remaining);
break;
case AMPacketIDs.REQUEST_PWR_PATHS:
handleRcvPowerPaths(remaining);
break;
case AMPacketIDs.CAPABILITY_CHANGE:
handleCapabilityChange(remaining);
break;
case AMPacketIDs.CRAFTING_ALTAR_DATA:
handleCraftingAltarData(remaining);
break;
case AMPacketIDs.LECTERN_DATA:
handleLecternData(remaining);
break;
case AMPacketIDs.CALEFACTOR_DATA:
handleCalefactorData(remaining);
break;
case AMPacketIDs.OBELISK_DATA:
handleObeliskData(remaining);
break;
}
} catch (Throwable t) {
LogHelper.error("Client Packet Failed to Handle!");
LogHelper.error("Packet Type: " + packetID);
t.printStackTrace();
} finally {
try {
if (bbis != null)
bbis.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class PowerNodeCache method onWorldSave.
@SubscribeEvent
public void onWorldSave(WorldEvent.Save event) {
World world = event.world;
if (world.isRemote)
return;
HashMap<ChunkCoordIntPair, NBTTagCompound> saveData = PowerNodeRegistry.For(world).saveAll();
for (ChunkCoordIntPair pair : saveData.keySet()) {
SaveNBTToFile(world, pair, saveData.get(pair), AMCore.config.savePowerDataOnWorldSave());
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Engine by VoltzEngine-Project.
the class PlayerKeyHandler method mouseHandler.
@SubscribeEvent
@SideOnly(Side.CLIENT)
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 BetterStorage by copygirl.
the class ClientProxy method onRenderPlayerSpecialsPre.
@SubscribeEvent
public void onRenderPlayerSpecialsPre(RenderPlayerEvent.Specials.Pre event) {
ItemStack backpack = ItemBackpack.getBackpackData(event.entityPlayer).backpack;
if (backpack != null) {
EntityPlayer player = event.entityPlayer;
float partial = event.partialRenderTick;
ItemBackpack backpackType = (ItemBackpack) backpack.getItem();
int color = backpackType.getColor(backpack);
ModelBackpackArmor model = (ModelBackpackArmor) backpackType.getArmorModel(player, backpack, 0);
model.onGround = ReflectionUtils.invoke(RendererLivingEntity.class, event.renderer, "func_77040_d", "renderSwingProgress", EntityLivingBase.class, float.class, player, partial);
model.setLivingAnimations(player, 0, 0, partial);
RenderUtils.bindTexture(new ResourceLocation(backpackType.getArmorTexture(backpack, player, 0, null)));
RenderUtils.setColorFromInt((color >= 0) ? color : 0xFFFFFF);
model.render(player, 0, 0, 0, 0, 0, 0);
if (color >= 0) {
RenderUtils.bindTexture(new ResourceLocation(backpackType.getArmorTexture(backpack, player, 0, "overlay")));
GL11.glColor3f(1.0F, 1.0F, 1.0F);
model.render(player, 0, 0, 0, 0, 0, 0);
}
if (backpack.isItemEnchanted()) {
float f9 = player.ticksExisted + partial;
RenderUtils.bindTexture(Resources.enchantedEffect);
GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4f(0.5F, 0.5F, 0.5F, 1.0F);
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDepthMask(false);
for (int k = 0; k < 2; ++k) {
GL11.glDisable(GL11.GL_LIGHTING);
float f11 = 0.76F;
GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
float f12 = f9 * (0.001F + k * 0.003F) * 20.0F;
float f13 = 0.33333334F;
GL11.glScalef(f13, f13, f13);
GL11.glRotatef(30.0F - k * 60.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.0F, f12, 0.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
model.render(player, 0, 0, 0, 0, 0, 0);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glDepthMask(true);
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
} else
backpack = ItemBackpack.getBackpack(event.entityPlayer);
if (backpack != null)
event.renderCape = false;
}
Aggregations