From bffa5a117176f7c02b6678daa24a732dc77a4359 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Mon, 22 Aug 2016 15:10:41 -0500 Subject: [PATCH] Remove redundant code and fix pixies being slow --- .../common/entity/EntityFlyingCreature.java | 87 ------------------- .../botania/common/entity/EntityPixie.java | 8 +- 2 files changed, 7 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java diff --git a/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java b/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java deleted file mode 100644 index 7da3b679d..000000000 --- a/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [? (GMT)] - */ -package vazkii.botania.common.entity; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.passive.EntityAmbientCreature; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; - -import javax.annotation.Nonnull; - -public class EntityFlyingCreature extends EntityAmbientCreature { - - public EntityFlyingCreature(World world) { - super(world); - } - - @Override - public void fall(float dist, float damageMult) {} - - @Override - protected void updateFallState(double y, boolean onGround, @Nonnull IBlockState state, @Nonnull BlockPos pos) {} - - @Override - public void moveEntityWithHeading(float par1, float par2) { - if(isInWater()) { - moveRelative(par1, par2, 0.02F); - moveEntity(motionX, motionY, motionZ); - motionX *= 0.800000011920929D; - motionY *= 0.800000011920929D; - motionZ *= 0.800000011920929D; - } else if(isNotColliding()) { - moveRelative(par1, par2, 0.02F); - moveEntity(motionX, motionY, motionZ); - motionX *= 0.5D; - motionY *= 0.5D; - motionZ *= 0.5D; - } else { - float f2 = 0.91F; - - if (onGround) { - Block block = worldObj.getBlockState(new BlockPos(MathHelper.floor_double(posX), MathHelper.floor_double(getEntityBoundingBox().minY) - 1, MathHelper.floor_double(posZ))).getBlock(); - f2 = block.slipperiness * 0.91F; - } - - float f3 = 0.16277136F / (f2 * f2 * f2); - moveRelative(par1, par2, onGround ? 0.1F * f3 : 0.02F); - f2 = 0.91F; - - if (onGround) { - Block block = worldObj.getBlockState(new BlockPos(MathHelper.floor_double(posX), MathHelper.floor_double(getEntityBoundingBox().minY) - 1, MathHelper.floor_double(posZ))).getBlock(); - f2 = block.slipperiness * 0.91F; - } - - moveEntity(motionX, motionY, motionZ); - motionX *= f2; - motionY *= f2; - motionZ *= f2; - } - - prevLimbSwingAmount = limbSwingAmount; - double d0 = posX - prevPosX; - double d1 = posZ - prevPosZ; - float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; - - if(f4 > 1.0F) - f4 = 1.0F; - - limbSwingAmount += (f4 - limbSwingAmount) * 0.4F; - limbSwing += limbSwingAmount; - } - - @Override - public boolean isOnLadder() { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/entity/EntityPixie.java b/src/main/java/vazkii/botania/common/entity/EntityPixie.java index 710187c1e..7d6dabf12 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPixie.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPixie.java @@ -10,6 +10,7 @@ */ package vazkii.botania.common.entity; +import net.minecraft.entity.EntityFlying; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; @@ -23,7 +24,7 @@ import vazkii.botania.common.Botania; import javax.annotation.Nonnull; -public class EntityPixie extends EntityFlyingCreature { +public class EntityPixie extends EntityFlying { private static final DataParameter TYPE = EntityDataManager.createKey(EntityPixie.class, DataSerializers.VARINT); @@ -135,4 +136,9 @@ public class EntityPixie extends EntityFlyingCreature { return false; } + @Override + public boolean canBeLeashedTo(EntityPlayer player) { + return false; + } + } \ No newline at end of file