use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityJump.
@SubscribeEvent
public void onEntityJump(LivingJumpEvent event) {
if (event.entityLiving.isPotionActive(BuffList.agility.id)) {
event.entityLiving.motionY *= 1.5f;
}
if (event.entityLiving.isPotionActive(BuffList.leap.id)) {
Entity velocityTarget = event.entityLiving;
if (event.entityLiving.ridingEntity != null) {
if (event.entityLiving.ridingEntity instanceof EntityMinecart) {
event.entityLiving.ridingEntity.setPosition(event.entityLiving.ridingEntity.posX, event.entityLiving.ridingEntity.posY + 1.5, event.entityLiving.ridingEntity.posZ);
}
velocityTarget = event.entityLiving.ridingEntity;
}
double yVelocity = 0;
double xVelocity = 0;
double zVelocity = 0;
Vec3 vec = event.entityLiving.getLookVec().normalize();
switch(event.entityLiving.getActivePotionEffect(BuffList.leap).getAmplifier()) {
case BuffPowerLevel.Low:
yVelocity = 0.4;
xVelocity = velocityTarget.motionX * 1.08 * Math.abs(vec.xCoord);
zVelocity = velocityTarget.motionZ * 1.08 * Math.abs(vec.zCoord);
break;
case BuffPowerLevel.Medium:
yVelocity = 0.7;
xVelocity = velocityTarget.motionX * 1.25 * Math.abs(vec.xCoord);
zVelocity = velocityTarget.motionZ * 1.25 * Math.abs(vec.zCoord);
break;
case BuffPowerLevel.High:
yVelocity = 1;
xVelocity = velocityTarget.motionX * 1.75 * Math.abs(vec.xCoord);
zVelocity = velocityTarget.motionZ * 1.75 * Math.abs(vec.zCoord);
break;
default:
break;
}
float maxHorizontalVelocity = 1.45f;
if (event.entityLiving.ridingEntity != null && (event.entityLiving.ridingEntity instanceof EntityMinecart || event.entityLiving.ridingEntity instanceof EntityBoat) || event.entityLiving.isPotionActive(BuffList.haste.id)) {
maxHorizontalVelocity += 25;
xVelocity *= 2.5;
zVelocity *= 2.5;
}
if (xVelocity > maxHorizontalVelocity) {
xVelocity = maxHorizontalVelocity;
} else if (xVelocity < -maxHorizontalVelocity) {
xVelocity = -maxHorizontalVelocity;
}
if (zVelocity > maxHorizontalVelocity) {
zVelocity = maxHorizontalVelocity;
} else if (zVelocity < -maxHorizontalVelocity) {
zVelocity = -maxHorizontalVelocity;
}
if (ExtendedProperties.For(event.entityLiving).getIsFlipped()) {
yVelocity *= -1;
}
velocityTarget.addVelocity(xVelocity, yVelocity, zVelocity);
}
if (event.entityLiving.isPotionActive(BuffList.entangled.id)) {
event.entityLiving.motionY = 0;
}
if (event.entityLiving instanceof EntityPlayer) {
ItemStack boots = ((EntityPlayer) event.entityLiving).inventory.armorInventory[0];
if (boots != null && boots.getItem() == ItemsCommonProxy.enderBoots && event.entityLiving.isSneaking()) {
ExtendedProperties.For(event.entityLiving).toggleFlipped();
}
if (ExtendedProperties.For(event.entityLiving).getFlipRotation() > 0)
((EntityPlayer) event.entityLiving).addVelocity(0, -2 * event.entityLiving.motionY, 0);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onEndermanTeleport.
@SubscribeEvent
public void onEndermanTeleport(EnderTeleportEvent event) {
EntityLivingBase ent = event.entityLiving;
ArrayList<Long> keystoneKeys = KeystoneUtilities.instance.GetKeysInInvenory(ent);
TileEntityAstralBarrier blockingBarrier = DimensionUtilities.GetBlockingAstralBarrier(event.entityLiving.worldObj, (int) event.targetX, (int) event.targetY, (int) event.targetZ, keystoneKeys);
if (ent.isPotionActive(BuffList.astralDistortion.id) || blockingBarrier != null) {
event.setCanceled(true);
if (blockingBarrier != null) {
blockingBarrier.onEntityBlocked(ent);
}
return;
}
if (!ent.worldObj.isRemote && ent instanceof EntityEnderman && ent.worldObj.rand.nextDouble() < 0.01f) {
EntityFlicker flicker = new EntityFlicker(ent.worldObj);
flicker.setPosition(ent.posX, ent.posY, ent.posZ);
flicker.setFlickerType(Affinity.ENDER);
ent.worldObj.spawnEntityInWorld(flicker);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onPlayerPickupItem.
@SubscribeEvent
public void onPlayerPickupItem(EntityItemPickupEvent event) {
if (event.entityPlayer == null)
return;
if (!event.entityPlayer.worldObj.isRemote && ExtendedProperties.For(event.entityPlayer).getMagicLevel() <= 0 && event.item.getEntityItem().getItem() == ItemsCommonProxy.arcaneCompendium) {
event.entityPlayer.addChatMessage(new ChatComponentText("You have unlocked the secrets of the arcane!"));
AMNetHandler.INSTANCE.sendCompendiumUnlockPacket((EntityPlayerMP) event.entityPlayer, "shapes", true);
AMNetHandler.INSTANCE.sendCompendiumUnlockPacket((EntityPlayerMP) event.entityPlayer, "components", true);
AMNetHandler.INSTANCE.sendCompendiumUnlockPacket((EntityPlayerMP) event.entityPlayer, "modifiers", true);
ExtendedProperties.For(event.entityPlayer).setMagicLevelWithMana(1);
ExtendedProperties.For(event.entityPlayer).forceSync();
return;
}
if (event.item.getEntityItem().getItem() == ItemsCommonProxy.spell) {
if (event.entityPlayer.worldObj.isRemote) {
AMNetHandler.INSTANCE.sendCompendiumUnlockPacket((EntityPlayerMP) event.entityPlayer, "spell_book", false);
}
} else {
Item item = event.item.getEntityItem().getItem();
int meta = event.item.getEntityItem().getItemDamage();
if (event.entityPlayer.worldObj.isRemote && item.getUnlocalizedName() != null && (AMCore.proxy.items.getArsMagicaItems().contains(item)) || (item instanceof ItemBlock && AMCore.proxy.blocks.getArsMagicaBlocks().contains(((ItemBlock) item).field_150939_a))) {
AMNetHandler.INSTANCE.sendCompendiumUnlockPacket((EntityPlayerMP) event.entityPlayer, item.getUnlocalizedName().replace("item.", "").replace("arsmagica2:", "").replace("tile.", "") + ((meta > -1) ? "@" + meta : ""), false);
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMWorldEventHandler method onChunkLoaded.
@SubscribeEvent
public void onChunkLoaded(ChunkDataEvent.Load event) {
int dimensionID = event.world.provider.dimensionId;
ChunkCoordIntPair chunkLocation = event.getChunk().getChunkCoordIntPair();
NBTTagCompound compound = (NBTTagCompound) event.getData().getTag("ArsMagica2");
if (AMCore.config.retroactiveWorldgen() && (compound == null || !compound.hasKey(genKey))) {
LogHelper.info("Detected a chunk that requires retrogen. Adding to retrogen list.");
AMCore.proxy.addQueuedRetrogen(dimensionID, chunkLocation);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMWorldEventHandler method onChunkSaved.
@SubscribeEvent
public void onChunkSaved(ChunkDataEvent.Save event) {
NBTTagCompound compound = new NBTTagCompound();
if (event.getData().hasKey("ArsMagica2")) {
compound = event.getData().getCompoundTag("ArsMagica2");
}
compound.setBoolean(genKey, true);
event.getData().setTag("ArsMagica2", compound);
}
Aggregations