diff --git a/src/main/java/furgl/babyMobs/client/model/ModelBabyBlaze.java b/src/main/java/furgl/babyMobs/client/model/ModelBabyBlaze.java index 4999140..7403794 100644 --- a/src/main/java/furgl/babyMobs/client/model/ModelBabyBlaze.java +++ b/src/main/java/furgl/babyMobs/client/model/ModelBabyBlaze.java @@ -1,10 +1,10 @@ package furgl.babyMobs.client.model; -import furgl.babyMobs.common.BabyMobs; import net.minecraft.client.model.ModelBlaze; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -18,8 +18,8 @@ public class ModelBabyBlaze extends ModelBlaze public ModelBabyBlaze() { super(); - this.blazeSticks = (ModelRenderer[]) BabyMobs.reflect(ModelBlaze.class, "blazeSticks", this); - this.blazeHead = (ModelRenderer) BabyMobs.reflect(ModelBlaze.class, "blazeHead", this); + this.blazeSticks = (ModelRenderer[]) ReflectionHelper.getPrivateValue(ModelBlaze.class, this, 0); + this.blazeHead = (ModelRenderer) ReflectionHelper.getPrivateValue(ModelBlaze.class, this, 1); } /** diff --git a/src/main/java/furgl/babyMobs/client/model/ModelBabyGhast.java b/src/main/java/furgl/babyMobs/client/model/ModelBabyGhast.java index 9af8ec5..50728a5 100644 --- a/src/main/java/furgl/babyMobs/client/model/ModelBabyGhast.java +++ b/src/main/java/furgl/babyMobs/client/model/ModelBabyGhast.java @@ -1,10 +1,10 @@ package furgl.babyMobs.client.model; -import furgl.babyMobs.common.BabyMobs; import net.minecraft.client.model.ModelGhast; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -16,9 +16,9 @@ public class ModelBabyGhast extends ModelGhast public ModelBabyGhast() { - super(); - this.body = (ModelRenderer) BabyMobs.reflect(ModelGhast.class, "body", this); - this.tentacles = (ModelRenderer[]) BabyMobs.reflect(ModelGhast.class, "tentacles", this); + super(); + this.body = (ModelRenderer) ReflectionHelper.getPrivateValue(ModelGhast.class, this, 0); + this.tentacles = (ModelRenderer[]) ReflectionHelper.getPrivateValue(ModelGhast.class, this, 1); } @Override diff --git a/src/main/java/furgl/babyMobs/client/model/ModelBabyGuardian.java b/src/main/java/furgl/babyMobs/client/model/ModelBabyGuardian.java index 548d1d2..611edb9 100644 --- a/src/main/java/furgl/babyMobs/client/model/ModelBabyGuardian.java +++ b/src/main/java/furgl/babyMobs/client/model/ModelBabyGuardian.java @@ -1,6 +1,5 @@ package furgl.babyMobs.client.model; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.entity.monster.EntityBabyGuardian; import net.minecraft.client.model.ModelGuardian; import net.minecraft.client.model.ModelRenderer; @@ -8,19 +7,20 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityGuardian; import net.minecraft.util.math.MathHelper; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelBabyGuardian extends ModelGuardian { - private ModelRenderer guardianBody; + private ModelRenderer guardianBody; private ModelRenderer[] guardianSpines; public ModelBabyGuardian() { super(); - this.guardianBody = (ModelRenderer) BabyMobs.reflect(ModelGuardian.class, "guardianBody", this); + this.guardianBody = (ModelRenderer) ReflectionHelper.getPrivateValue(ModelGuardian.class, this, 0); this.guardianSpines = new ModelRenderer[12]; for (int i = 0; i < this.guardianSpines.length; ++i) { diff --git a/src/main/java/furgl/babyMobs/client/model/ModelBabyShulker.java b/src/main/java/furgl/babyMobs/client/model/ModelBabyShulker.java index e8b6818..025bc03 100644 --- a/src/main/java/furgl/babyMobs/client/model/ModelBabyShulker.java +++ b/src/main/java/furgl/babyMobs/client/model/ModelBabyShulker.java @@ -1,104 +1,44 @@ package furgl.babyMobs.client.model; -import furgl.babyMobs.common.entity.monster.EntityBabyShulker; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelShulker; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelBabyShulker extends ModelShulker { - private ModelRenderer field_187067_b; //bottom - private ModelRenderer field_187068_c; //top - public ModelRenderer field_187066_a; //head - - public ModelBabyShulker() - { - this.textureHeight = 64; - this.textureWidth = 64; - this.field_187068_c = new ModelRenderer(this); - this.field_187067_b = new ModelRenderer(this); - this.field_187066_a = new ModelRenderer(this); - this.field_187068_c.setTextureOffset(0, 0).addBox(-8.0F, -16.0F, -8.0F, 16, 12, 16); - this.field_187068_c.setRotationPoint(0.0F, 24.0F, 0.0F); - this.field_187067_b.setTextureOffset(0, 28).addBox(-8.0F, -8.0F, -8.0F, 16, 8, 16); - this.field_187067_b.setRotationPoint(0.0F, 24.0F, 0.0F); - this.field_187066_a.setTextureOffset(0, 52).addBox(-3.0F, 0.0F, -3.0F, 6, 6, 6); - this.field_187066_a.setRotationPoint(0.0F, 12.0F, 0.0F); - } - - public int func_187065_a() - { - return 28; - } - - /** - * Used for easily adding entity-dependent animations. The second and third float params here are the same second - * and third as in the setRotationAngles method. - */ - public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) - { - } - - /** - * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms - * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how - * "far" arms and legs can swing at most. - */ - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) - { - EntityBabyShulker entityshulker = (EntityBabyShulker)entityIn; - float f = ageInTicks - (float)entityshulker.ticksExisted; - float f1 = (0.5F + entityshulker.func_184688_a(f)) * (float)Math.PI; - float f2 = -1.0F + MathHelper.sin(f1); - float f3 = 0.0F; - - if (f1 > (float)Math.PI) - { - f3 = MathHelper.sin(ageInTicks * 0.1F) * 0.7F; - } - - this.field_187068_c.setRotationPoint(0.0F, 16.0F + MathHelper.sin(f1) * 8.0F + f3, 0.0F); - - if (entityshulker.func_184688_a(f) > 0.3F) - { - this.field_187068_c.rotateAngleY = f2 * f2 * f2 * f2 * (float)Math.PI * 0.125F; - } - else - { - this.field_187068_c.rotateAngleY = 0.0F; - } - - this.field_187066_a.rotateAngleX = headPitch * 0.017453292F; - this.field_187066_a.rotateAngleY = netHeadYaw * 0.017453292F; - } - - /** - * Sets the models various rotation angles then renders the model. - */ - public void render(Entity entityIn, float par2, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { - isChild = true; + private ModelRenderer field_187067_b; //bottom + private ModelRenderer field_187068_c; //top + + public ModelBabyShulker() + { + super(); + field_187067_b = ReflectionHelper.getPrivateValue(ModelShulker.class, this, 0); + field_187068_c = ReflectionHelper.getPrivateValue(ModelShulker.class, this, 1); + } + + public void render(Entity entityIn, float par2, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale) + { + isChild = true; this.setRotationAngles(par2, limbSwing, ageInTicks, netHeadYaw, headPitch, scale, entityIn); GlStateManager.pushMatrix(); float f6 = 2F; GlStateManager.scale(1.5F / f6, 1.5F / f6, 1.5F / f6); GlStateManager.translate(0.0F, 16.0F * scale + 0.3F, 0.0F); - - GlStateManager.popMatrix(); + + GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.scale(1.0F / f6, 1.0F / f6, 1.0F / f6); GlStateManager.translate(0.0F, 24.0F * scale, 0.0F); - this.field_187066_a.render(scale); //head + //this.field_187066_a.render(scale); //head - in RenderBabyShulker this.field_187067_b.render(scale); //bottom this.field_187068_c.render(scale); //top GlStateManager.popMatrix(); - } + } } \ No newline at end of file diff --git a/src/main/java/furgl/babyMobs/client/model/ModelBabySquid.java b/src/main/java/furgl/babyMobs/client/model/ModelBabySquid.java index 27bad87..12afd09 100644 --- a/src/main/java/furgl/babyMobs/client/model/ModelBabySquid.java +++ b/src/main/java/furgl/babyMobs/client/model/ModelBabySquid.java @@ -1,46 +1,46 @@ package furgl.babyMobs.client.model; -import furgl.babyMobs.common.BabyMobs; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelSquid; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelBabySquid extends ModelSquid { - /** The squid's body */ - ModelRenderer squidBody; - /** The squid's tentacles */ - ModelRenderer[] squidTentacles = new ModelRenderer[8]; - - public ModelBabySquid() - { - super(); - this.squidBody = (ModelRenderer) BabyMobs.reflect(ModelSquid.class, "squidBody", this); - this.squidTentacles = (ModelRenderer[]) BabyMobs.reflect(ModelSquid.class, "squidTentacles", this); - } - - @Override + /** The squid's body */ + ModelRenderer squidBody; + /** The squid's tentacles */ + ModelRenderer[] squidTentacles = new ModelRenderer[8]; + + public ModelBabySquid() + { + super(); + this.squidBody = (ModelRenderer) ReflectionHelper.getPrivateValue(ModelSquid.class, this, 0); + this.squidTentacles = (ModelRenderer[]) ReflectionHelper.getPrivateValue(ModelSquid.class, this, 1); + } + + @Override public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) - { - isChild = true; - + { + isChild = true; + float scaleFactor = 0.5F; GlStateManager.pushMatrix(); - GlStateManager.translate(0F, 0F, 0F); - GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor); - - this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); - this.squidBody.render(p_78088_7_); - - for (int i = 0; i < this.squidTentacles.length; ++i) - { - this.squidTentacles[i].render(p_78088_7_); - } - - GlStateManager.popMatrix(); - } + GlStateManager.translate(0F, 0F, 0F); + GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor); + + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + this.squidBody.render(p_78088_7_); + + for (int i = 0; i < this.squidTentacles.length; ++i) + { + this.squidTentacles[i].render(p_78088_7_); + } + + GlStateManager.popMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/furgl/babyMobs/client/model/ModelBabyWither.java b/src/main/java/furgl/babyMobs/client/model/ModelBabyWither.java index f3c204d..21e7173 100644 --- a/src/main/java/furgl/babyMobs/client/model/ModelBabyWither.java +++ b/src/main/java/furgl/babyMobs/client/model/ModelBabyWither.java @@ -1,28 +1,28 @@ package furgl.babyMobs.client.model; -import furgl.babyMobs.common.BabyMobs; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelWither; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelBabyWither extends ModelWither { - private ModelRenderer[] pieces; - private ModelRenderer[] heads; + private ModelRenderer[] field_82905_a; //pieces + private ModelRenderer[] field_82904_b; //heads public ModelBabyWither(float p_i46302_1_) { super(p_i46302_1_); - this.pieces = (ModelRenderer[]) BabyMobs.reflect(ModelWither.class, "field_82905_a", this); - this.pieces[0] = new ModelRenderer(this, 0, 16); - this.heads = new ModelRenderer[1]; - this.heads[0] = new ModelRenderer(this, 0, 0); - this.heads[0].addBox(-4.0F, -1.0F, -4.0F, 8, 8, 8, p_i46302_1_); + this.field_82905_a = (ModelRenderer[]) ReflectionHelper.getPrivateValue(ModelWither.class, this, 0); + this.field_82905_a[0] = new ModelRenderer(this, 0, 16); + this.field_82904_b = new ModelRenderer[1]; + this.field_82904_b[0] = new ModelRenderer(this, 0, 0); + this.field_82904_b[0].addBox(-4.0F, -1.0F, -4.0F, 8, 8, 8, p_i46302_1_); } @Override @@ -36,7 +36,7 @@ public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor); this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); - ModelRenderer[] amodelrenderer = this.heads; + ModelRenderer[] amodelrenderer = this.field_82904_b; int i = amodelrenderer.length; int j; ModelRenderer modelrenderer; @@ -45,7 +45,7 @@ public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float modelrenderer = amodelrenderer[j]; modelrenderer.render(p_78088_7_); } - amodelrenderer = this.pieces; + amodelrenderer = this.field_82905_a; i = amodelrenderer.length; for (j = 0; j < i; ++j) { @@ -59,6 +59,6 @@ public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float @Override public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) { - + } } \ No newline at end of file diff --git a/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyEnderman.java b/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyEnderman.java index 3ca2cdb..54d676e 100644 --- a/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyEnderman.java +++ b/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyEnderman.java @@ -3,7 +3,6 @@ import org.lwjgl.opengl.GL11; import furgl.babyMobs.client.model.ModelBabyEnderman; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.entity.monster.EntityBabyEnderman; import net.minecraft.client.model.ModelEnderman; import net.minecraft.client.renderer.GlStateManager; @@ -17,6 +16,7 @@ import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -29,7 +29,7 @@ public RenderBabyEnderman(RenderManager renderManager) { super(renderManager); this.mainModel = new ModelBabyEnderman(0.0F); - BabyMobs.reflect(RenderEnderman.class, "endermanModel", this, (ModelEnderman) this.mainModel); + ReflectionHelper.setPrivateValue(RenderEnderman.class, this, (ModelEnderman) this.mainModel, 1); } @Override diff --git a/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyShulker.java b/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyShulker.java index bf801d5..d5f8215 100644 --- a/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyShulker.java +++ b/src/main/java/furgl/babyMobs/client/renderer/entity/mob/RenderBabyShulker.java @@ -1,7 +1,6 @@ package furgl.babyMobs.client.renderer.entity.mob; import furgl.babyMobs.client.model.ModelBabyShulker; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.entity.monster.EntityBabyShulker; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; @@ -15,20 +14,19 @@ @SideOnly(Side.CLIENT) public class RenderBabyShulker extends RenderShulker { - private static ResourceLocation field_188342_a; - + private static final ResourceLocation field_188342_a = new ResourceLocation("textures/entity/shulker/endergolem.png"); + public RenderBabyShulker(RenderManager renderManager, ModelBabyShulker model) { super(renderManager, model); - RenderBabyShulker.field_188342_a = (ResourceLocation) BabyMobs.reflect(RenderShulker.class, "field_188342_a", this); for (LayerRenderer layer : this.layerRenderers) { - if (layer.getClass().getSimpleName().equals("HeadLayer")) - { - this.layerRenderers.remove(layer); - break; - } - } - this.addLayer(new RenderBabyShulker.HeadLayer()); + if (layer.getClass().getSimpleName().equals("HeadLayer")) + { + this.layerRenderers.remove(layer); + break; + } + } + this.addLayer(new RenderBabyShulker.HeadLayer()); } @SideOnly(Side.CLIENT) @@ -42,7 +40,7 @@ public void doRenderLayer(EntityBabyShulker entitylivingbaseIn, float limbSwing, { GlStateManager.pushMatrix(); - switch (entitylivingbaseIn.func_184696_cZ()) + /*switch (entitylivingbaseIn.func_184696_cZ()) { case DOWN: default: @@ -71,12 +69,54 @@ public void doRenderLayer(EntityBabyShulker entitylivingbaseIn, float limbSwing, case UP: GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); GlStateManager.translate(0.0F, -2.0F, 0.0F); - } + }*/ ModelRenderer modelrenderer = ((ModelBabyShulker)RenderBabyShulker.this.getMainModel()).field_187066_a; modelrenderer.rotateAngleY = netHeadYaw * 0.017453292F; modelrenderer.rotateAngleX = headPitch * 0.017453292F; RenderBabyShulker.this.bindTexture(RenderBabyShulker.field_188342_a); + + float f6 = 2F; + GlStateManager.scale(1.5F / f6, 1.5F / f6, 1.5F / f6); + GlStateManager.translate(0.0F, 16.0F * scale + 0.3F, 0.0F); + + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + GlStateManager.scale(1.0F / f6, 1.0F / f6, 1.0F / f6); + GlStateManager.translate(0.0F, 24.0F * scale, 0.0F); + + switch (entitylivingbaseIn.func_184696_cZ()) + { + case DOWN: + default: + break; + case EAST: + GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.translate(1.0F, -1.0F, 0.0F); + GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); + break; + case WEST: + GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F); + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.translate(-1.0F, -1.0F, 0.0F); + GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); + break; + case NORTH: + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.translate(0.0F, -1.0F, -1.0F); + break; + case SOUTH: + GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.translate(0.0F, -1.0F, 1.0F); + break; + case UP: + GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.translate(0.0F, -2.0F, 0.0F); + } + + modelrenderer.render(scale); GlStateManager.popMatrix(); } diff --git a/src/main/java/furgl/babyMobs/common/BabyMobs.java b/src/main/java/furgl/babyMobs/common/BabyMobs.java index e09c5a9..c8364a1 100644 --- a/src/main/java/furgl/babyMobs/common/BabyMobs.java +++ b/src/main/java/furgl/babyMobs/common/BabyMobs.java @@ -154,42 +154,4 @@ public ItemStack dispenseStack(IBlockSource source, ItemStack stack) } } } - - /*** - * Returns field of reflected variable - * - * @param clazz Class that variable is in - * @param name Name of variable - * @param instance Instance to get variable from - */ - public static Object reflect(Class clazz, String name, Object instance) { - try { - Field field = clazz.getDeclaredField(name); - field.setAccessible(true); - return field.get(instance); - } - catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - /*** - * Sets value of reflected variable - * - * @param clazz Class that variable is in - * @param name Name of variable - * @param instance Instance to get variable from - * @param value Value to set variable to - */ - public static void reflect(Class clazz, String name, Object instance, Object value) { - try { - Field field = clazz.getDeclaredField(name); - field.setAccessible(true); - field.set(instance, value); - } - catch(Exception e) { - e.printStackTrace(); - } - } } diff --git a/src/main/java/furgl/babyMobs/common/entity/ai/EntityAIZombieRiders.java b/src/main/java/furgl/babyMobs/common/entity/ai/EntityAIZombieRiders.java index 2dcfb4d..ff0a2e4 100644 --- a/src/main/java/furgl/babyMobs/common/entity/ai/EntityAIZombieRiders.java +++ b/src/main/java/furgl/babyMobs/common/entity/ai/EntityAIZombieRiders.java @@ -31,7 +31,7 @@ public void updateTask() this.horse.tasks.removeTask(this); this.horse.setType(HorseArmorType.ZOMBIE); this.horse.setHorseTamed(true); - this.horse.setGrowingAge(0); + //this.horse.setGrowingAge(0); this.horse.worldObj.addWeatherEffect(new EntityLightningBolt(this.horse.worldObj, this.horse.posX, this.horse.posY, this.horse.posZ, true)); EntityZombie entityzombie = this.setupZombie(difficultyinstance, this.horse); entityzombie.startRiding(this.horse); diff --git a/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyCreeper.java b/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyCreeper.java index 76cfe9f..b4f94ce 100644 --- a/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyCreeper.java +++ b/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyCreeper.java @@ -1,7 +1,6 @@ package furgl.babyMobs.common.entity.monster; import furgl.babyMobs.client.gui.achievements.Achievements; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.config.Config; import furgl.babyMobs.common.entity.ai.EntityAIBabyFollowParent; import furgl.babyMobs.common.entity.ai.EntityAIBabyHurtByTarget; @@ -16,6 +15,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.relauncher.ReflectionHelper; public class EntityBabyCreeper extends EntityCreeper { @@ -74,8 +74,8 @@ public void onUpdate() { if (Config.useSpecialAbilities) { - int ignitedTime = (int) BabyMobs.reflect(EntityCreeper.class, "timeSinceIgnited", this); - int fuse = (int) BabyMobs.reflect(EntityCreeper.class, "fuseTime", this); + int ignitedTime = (int) ReflectionHelper.getPrivateValue(EntityCreeper.class, this, 4); + int fuse = (int) ReflectionHelper.getPrivateValue(EntityCreeper.class, this, 5); if (rand.nextInt(20)==0 && this.worldObj.isRemote) { @@ -103,7 +103,7 @@ private void explode() { if (!this.worldObj.isRemote) { - int ignitedTime = (int) BabyMobs.reflect(EntityCreeper.class, "timeSinceIgnited", this); + int ignitedTime = (int) ReflectionHelper.getPrivateValue(EntityCreeper.class, this, 4); boolean flag = this.worldObj.getGameRules().getBoolean("mobGriefing"); float f = this.getPowered() ? 2.0F : 1.0F; this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag); diff --git a/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyGuardian.java b/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyGuardian.java index 7d225e8..29d041d 100644 --- a/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyGuardian.java +++ b/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabyGuardian.java @@ -1,7 +1,6 @@ package furgl.babyMobs.common.entity.monster; import furgl.babyMobs.client.gui.achievements.Achievements; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.config.Config; import furgl.babyMobs.common.entity.ai.EntityAIBabyFollowParent; import furgl.babyMobs.common.entity.ai.EntityAIBabyHurtByTarget; @@ -19,6 +18,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.relauncher.ReflectionHelper; public class EntityBabyGuardian extends EntityGuardian { @@ -45,7 +45,7 @@ public void onDeath(DamageSource cause) //first achievement public boolean hasTargetedEntity() { - DataParameter dataParam = (DataParameter) BabyMobs.reflect(EntityGuardian.class, "TARGET_ENTITY", this); + DataParameter dataParam = (DataParameter) ReflectionHelper.getPrivateValue(EntityGuardian.class, this, 1); return this.dataWatcher.get(dataParam) != 0; } diff --git a/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabySquid.java b/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabySquid.java index 26fb792..38598c3 100644 --- a/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabySquid.java +++ b/src/main/java/furgl/babyMobs/common/entity/monster/EntityBabySquid.java @@ -1,7 +1,6 @@ package furgl.babyMobs.common.entity.monster; import furgl.babyMobs.client.gui.achievements.Achievements; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.config.Config; import furgl.babyMobs.common.entity.projectile.EntitySquidInk; import furgl.babyMobs.common.item.ModItems; @@ -17,6 +16,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.relauncher.ReflectionHelper; public class EntityBabySquid extends EntitySquid { @@ -71,8 +71,9 @@ public boolean attackEntityFrom(DamageSource source, float amount) entitySpawner.setMovementInOut(-1D); entitySpawner.setRandVar(0.5D); entitySpawner.run(); + + ReflectionHelper.setPrivateValue(EntitySquid.class, this, 2.0F, 8); - BabyMobs.reflect(EntitySquid.class, "randomMotionSpeed", this, 2.0F); this.squidRotation = (float) (Math.PI-1); this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, SoundEvents.entity_slime_attack, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 8F, false); } diff --git a/src/main/java/furgl/babyMobs/common/event/AttackEvent.java b/src/main/java/furgl/babyMobs/common/event/AttackEvent.java index be6b948..a1737c1 100644 --- a/src/main/java/furgl/babyMobs/common/event/AttackEvent.java +++ b/src/main/java/furgl/babyMobs/common/event/AttackEvent.java @@ -70,5 +70,11 @@ else if (!event.getEntity().worldObj.isRemote && event.getSource().getEntity() i event.setCanceled(true); } } + else if (!event.getEntity().worldObj.isRemote && event.getSource().getEntity() instanceof EntityZombie && ((EntityZombie)event.getSource().getEntity()).isConverting()) + event.setCanceled(true); + else if (!event.getEntity().worldObj.isRemote && event.getSource().getEntity() instanceof EntityZombieChicken && ((EntityZombieChicken)event.getSource().getEntity()).isConverting()) + event.setCanceled(true); + else if (!event.getEntity().worldObj.isRemote && event.getSource().getEntity() instanceof EntityZombiePig && ((EntityZombiePig)event.getSource().getEntity()).isConverting()) + event.setCanceled(true); } } diff --git a/src/main/java/furgl/babyMobs/common/event/BabyReplaceEvent.java b/src/main/java/furgl/babyMobs/common/event/BabyReplaceEvent.java index d38d738..79e4a46 100644 --- a/src/main/java/furgl/babyMobs/common/event/BabyReplaceEvent.java +++ b/src/main/java/furgl/babyMobs/common/event/BabyReplaceEvent.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Random; +import java.util.UUID; -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.config.Config; import furgl.babyMobs.common.entity.ai.EntityAIUndeadHorseMate; import furgl.babyMobs.common.entity.ai.EntityAIZombieRiders; @@ -55,6 +55,7 @@ import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.ReflectionHelper; public class BabyReplaceEvent { @@ -105,7 +106,7 @@ else if (task.action.getClass().getSimpleName().equals("EntityAIZombieRiders")) { if (((EntityZombie) event.getEntity()).isChild()) ((EntityZombie) event.getEntity()).setChild(false); //prevent baby zombies spawning naturally - if (rand.nextInt(101) <= Config.babyZombieRate || event.getEntity().getRidingEntity() instanceof EntityHorse && ((EntityHorse)event.getEntity().getRidingEntity()).isChild()) + if (rand.nextInt(100) < Config.babyZombieRate || event.getEntity().getRidingEntity() instanceof EntityHorse && ((EntityHorse)event.getEntity().getRidingEntity()).isChild()) { Entity entity = this.spawnEntity(EntityBabyZombie.class, event.getEntity()); event.getEntity().setDead(); @@ -136,7 +137,7 @@ else if (event.getEntity().getClass() == EntityPigZombie.class) { if (((EntityPigZombie) event.getEntity()).isChild()) ((EntityPigZombie) event.getEntity()).setChild(false); //prevent baby zombie pigmen spawning naturally - if (rand.nextInt(101) <= Config.babyPigZombieRate) + if (rand.nextInt(100) < Config.babyPigZombieRate) { Entity entity = this.spawnEntity(EntityBabyPigZombie.class, event.getEntity()); event.getEntity().setDead(); @@ -160,7 +161,7 @@ else if (event.getEntity().getClass() == EntityHorse.class && ((EntityHorse)even ((EntityHorse)event.getEntity()).setHorseTamed(true); Iterator it = event.getEntity().getRecursivePassengers().iterator(); Entity entity = it.hasNext() ? (Entity) it.next() : null; - if (rand.nextInt(101) <= Config.babySkeletonHorseRate || entity instanceof EntitySkeleton && ((EntitySkeleton) entity).isChild()) + if (rand.nextInt(100) < Config.babySkeletonHorseRate || entity instanceof EntitySkeleton && ((EntitySkeleton) entity).isChild()) { EntityHorse horse = (EntityHorse) this.spawnEntity(EntityHorse.class, event.getEntity()); horse.setType(HorseArmorType.SKELETON); @@ -174,7 +175,7 @@ else if (event.getEntity().getClass() == EntityHorse.class && ((EntityHorse)even ((EntityHorse)event.getEntity()).setHorseTamed(true); Iterator it = event.getEntity().getRecursivePassengers().iterator(); Entity entity = it.hasNext() ? (Entity) it.next() : null; - if (rand.nextInt(101) <= Config.babyZombieHorseRate || entity instanceof EntityZombie && ((EntityZombie) entity).isChild()) + if (rand.nextInt(100) < Config.babyZombieHorseRate || entity instanceof EntityZombie && ((EntityZombie) entity).isChild()) { EntityHorse horse = (EntityHorse) this.spawnEntity(EntityHorse.class, event.getEntity()); horse.setType(HorseArmorType.ZOMBIE); @@ -182,7 +183,7 @@ else if (event.getEntity().getClass() == EntityHorse.class && ((EntityHorse)even horse.setSkeletonTrap(((EntityHorse)event.getEntity()).isSkeletonTrap()); if (horse.isSkeletonTrap()) { - EntityAISkeletonRiders skeletonTrapAI = (EntityAISkeletonRiders) BabyMobs.reflect(EntityHorse.class, "skeletonTrapAI", horse); + EntityAISkeletonRiders skeletonTrapAI = (EntityAISkeletonRiders) ReflectionHelper.getPrivateValue(EntityHorse.class, horse, 12); horse.tasks.removeTask(skeletonTrapAI); horse.tasks.addTask(1, new EntityAIZombieRiders(horse)); } @@ -191,7 +192,7 @@ else if (event.getEntity().getClass() == EntityHorse.class && ((EntityHorse)even } else if (event.getEntity().getClass() == EntitySpider.class) { - if (rand.nextInt(101) <= Config.babySpiderRate) + if (rand.nextInt(100) < Config.babySpiderRate) { this.spawnEntity(EntityBabySpider.class, event.getEntity()); event.getEntity().setDead(); @@ -199,7 +200,7 @@ else if (event.getEntity().getClass() == EntitySpider.class) } else if (event.getEntity().getClass() == EntityShulker.class) { - if (rand.nextInt(101) <= Config.babyShulkerRate) + if (rand.nextInt(100) < Config.babyShulkerRate) { this.spawnEntity(EntityBabyShulker.class, event.getEntity()); event.getEntity().setDead(); @@ -207,7 +208,7 @@ else if (event.getEntity().getClass() == EntityShulker.class) } else if (event.getEntity().getClass() == EntitySkeleton.class && ((EntitySkeleton) event.getEntity()).getSkeletonType() == 0) { - if (rand.nextInt(101) <= Config.babySkeletonRate || event.getEntity().getRidingEntity() instanceof EntityHorse && ((EntityHorse)event.getEntity().getRidingEntity()).isChild()) + if (rand.nextInt(100) < Config.babySkeletonRate || event.getEntity().getRidingEntity() instanceof EntityHorse && ((EntityHorse)event.getEntity().getRidingEntity()).isChild()) { this.spawnEntity(EntityBabySkeleton.class, event.getEntity()); event.getEntity().setDead(); @@ -217,7 +218,7 @@ else if (event.getEntity().getClass() == EntitySkeleton.class && ((EntitySkeleto } else if (event.getEntity().getClass() == EntityCreeper.class) { - if (rand.nextInt(101) <= Config.babyCreeperRate) + if (rand.nextInt(100) < Config.babyCreeperRate) { this.spawnEntity(EntityBabyCreeper.class, event.getEntity()); event.getEntity().setDead(); @@ -225,7 +226,7 @@ else if (event.getEntity().getClass() == EntityCreeper.class) } else if (event.getEntity().getClass() == EntitySkeleton.class && ((EntitySkeleton) event.getEntity()).getSkeletonType() == 1) { - if (rand.nextInt(101) <= Config.babyWitherSkeletonRate) + if (rand.nextInt(100) < Config.babyWitherSkeletonRate) { this.spawnEntity(EntityBabyWitherSkeleton.class, event.getEntity()); event.getEntity().setDead(); @@ -233,12 +234,12 @@ else if (event.getEntity().getClass() == EntitySkeleton.class && ((EntitySkeleto } else if (event.getEntity().getClass() == EntityEnderman.class) { - if (event.getEntity().worldObj.getBiomeGenForCoords(event.getEntity().getPosition()) instanceof BiomeGenEnd && rand.nextInt(101) <= Config.babyEndermanEndRate) + if (event.getEntity().worldObj.getBiomeGenForCoords(event.getEntity().getPosition()) instanceof BiomeGenEnd && rand.nextInt(100) < Config.babyEndermanEndRate) { this.spawnEntity(EntityBabyEnderman.class, event.getEntity()); event.getEntity().setDead(); } - else if (!(event.getEntity().worldObj.getBiomeGenForCoords(event.getEntity().getPosition()) instanceof BiomeGenEnd) && rand.nextInt(101) <= Config.babyEndermanRate) + else if (!(event.getEntity().worldObj.getBiomeGenForCoords(event.getEntity().getPosition()) instanceof BiomeGenEnd) && rand.nextInt(100) < Config.babyEndermanRate) { this.spawnEntity(EntityBabyEnderman.class, event.getEntity()); event.getEntity().setDead(); @@ -246,7 +247,7 @@ else if (!(event.getEntity().worldObj.getBiomeGenForCoords(event.getEntity().get } else if (event.getEntity().getClass() == EntityBlaze.class) { - if (rand.nextInt(101) <= Config.babyBlazeRate) + if (rand.nextInt(100) < Config.babyBlazeRate) { this.spawnEntity(EntityBabyBlaze.class, event.getEntity()); event.getEntity().setDead(); @@ -254,7 +255,7 @@ else if (event.getEntity().getClass() == EntityBlaze.class) } else if (event.getEntity().getClass() == EntityWitch.class) { - if (rand.nextInt(101) <= Config.babyWitchRate) + if (rand.nextInt(100) < Config.babyWitchRate) { this.spawnEntity(EntityBabyWitch.class, event.getEntity()); EntityLiving entityToSpawn = (EntityLiving) EntityList.createEntityByName("babymobs.babyOcelot", event.getEntity().worldObj); @@ -273,7 +274,7 @@ else if (event.getEntity().getClass() == EntityBabyWitch.class) } else if (event.getEntity().getClass() == EntityGuardian.class) { - if (rand.nextInt(101) <= Config.babyGuardianRate) + if (rand.nextInt(100) < Config.babyGuardianRate) { this.spawnEntity(EntityBabyGuardian.class, event.getEntity()); event.getEntity().setDead(); @@ -281,7 +282,7 @@ else if (event.getEntity().getClass() == EntityGuardian.class) } else if (event.getEntity().getClass() == EntitySquid.class) { - if (rand.nextInt(101) <= Config.babySquidRate) + if (rand.nextInt(100) < Config.babySquidRate) { this.spawnEntity(EntityBabySquid.class, event.getEntity()); event.getEntity().setDead(); @@ -289,7 +290,7 @@ else if (event.getEntity().getClass() == EntitySquid.class) } else if (event.getEntity().getClass() == EntityCaveSpider.class) { - if (rand.nextInt(101) <= Config.babyCaveSpiderRate) + if (rand.nextInt(100) < Config.babyCaveSpiderRate) { this.spawnEntity(EntityBabyCaveSpider.class, event.getEntity()); event.getEntity().setDead(); @@ -297,7 +298,7 @@ else if (event.getEntity().getClass() == EntityCaveSpider.class) } else if (event.getEntity().getClass() == EntityGhast.class) { - if (rand.nextInt(101) <= Config.babyGhastRate) + if (rand.nextInt(100) < Config.babyGhastRate) { this.spawnEntity(EntityBabyGhast.class, event.getEntity()); event.getEntity().setDead(); @@ -305,7 +306,7 @@ else if (event.getEntity().getClass() == EntityGhast.class) } else if (event.getEntity().getClass() == EntityIronGolem.class && (!((EntityIronGolem) event.getEntity()).isPlayerCreated())) { - if (rand.nextInt(101) <= Config.babyIronGolemRate) + if (rand.nextInt(100) < Config.babyIronGolemRate) { this.spawnEntity(EntityBabyIronGolem.class, event.getEntity()); event.getEntity().setDead(); @@ -333,9 +334,9 @@ private Entity spawnEntity(Class entityToSpawnClass, Entity originalEntity, Enti entityToSpawn = (Entity) entityToSpawnClass.getConstructor(World.class).newInstance(world); NBTTagCompound nbt = new NBTTagCompound(); originalEntity.writeToNBT(nbt); - nbt.setLong("UUIDLeast", nbt.getLong("UUIDLeast")+1L); entityToSpawn.readFromNBT(nbt); entityToSpawn.setCustomNameTag(originalEntity.getCustomNameTag()); + entityToSpawn.setUniqueId(UUID.randomUUID()); world.spawnEntityInWorld(entityToSpawn); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException| NoSuchMethodException | SecurityException e) diff --git a/src/main/java/furgl/babyMobs/common/event/ZombieTrapEvent.java b/src/main/java/furgl/babyMobs/common/event/ZombieTrapEvent.java index 12dcd8d..5e0bb4b 100644 --- a/src/main/java/furgl/babyMobs/common/event/ZombieTrapEvent.java +++ b/src/main/java/furgl/babyMobs/common/event/ZombieTrapEvent.java @@ -1,93 +1,53 @@ package furgl.babyMobs.common.event; -import java.util.Iterator; -import java.util.List; - -import com.google.common.base.Predicate; - -import furgl.babyMobs.common.BabyMobs; import furgl.babyMobs.common.entity.ai.EntityAIZombieRiders; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.block.material.Material; import net.minecraft.entity.ai.EntityAISkeletonRiders; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.HorseArmorType; -import net.minecraft.server.management.PlayerManager; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.DifficultyInstance; -import net.minecraft.world.WorldServer; -import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; +import net.minecraftforge.fml.relauncher.ReflectionHelper; public class ZombieTrapEvent { + EntityLightningBolt bolt; + + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(EntityEvent.EntityConstructing event) { + if (event.getEntity() instanceof EntityLightningBolt && !event.getEntity().worldObj.isRemote && bolt == null) { + bolt = (EntityLightningBolt) event.getEntity(); + } + } + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(TickEvent.WorldTickEvent event) { - if (event.phase == Phase.END && !event.world.isRemote && event.world.isRaining() && event.world.isThundering()) { - WorldServer worldServer = event.world.getMinecraftServer().worldServerForDimension(event.world.provider.getDimension()); - PlayerManager thePlayerManager = (PlayerManager) BabyMobs.reflect(WorldServer.class, "thePlayerManager", worldServer); - for (Iterator iterator = worldServer.getPersistentChunkIterable(thePlayerManager.getChunkIterator()) ; iterator.hasNext() ; ) + if (bolt != null && !event.world.isRemote && bolt.getPosition() != new BlockPos(0, 0, 0)) { + DifficultyInstance difficultyinstance = event.world.getDifficultyForLocation(bolt.getPosition()); + if (!(boolean)(ReflectionHelper.getPrivateValue(EntityLightningBolt.class, bolt, 3)) && event.world.rand.nextDouble() < (double)difficultyinstance.getAdditionalDifficulty() * 0.05D) { - Chunk chunk = (Chunk)iterator.next(); - int j = chunk.xPosition * 16; - int k = chunk.zPosition * 16; - if (event.world.provider.canDoLightning(chunk) && event.world.rand.nextInt(100000) == 0) - { - int l = event.world.rand.nextInt() >> 2; - BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)), worldServer); - - if (worldServer.isRainingAt(blockpos)) - { - DifficultyInstance difficultyinstance = worldServer.getDifficultyForLocation(blockpos); - - if (event.world.rand.nextDouble() < (double)difficultyinstance.getAdditionalDifficulty() * 0.05D) - { - EntityHorse entityhorse = new EntityHorse(event.world); - entityhorse.setType(HorseArmorType.ZOMBIE); - entityhorse.setSkeletonTrap(true); - EntityAISkeletonRiders skeletonTrapAI = (EntityAISkeletonRiders) BabyMobs.reflect(EntityHorse.class, "skeletonTrapAI", entityhorse); - entityhorse.tasks.removeTask(skeletonTrapAI); - entityhorse.tasks.addTask(1, new EntityAIZombieRiders(entityhorse)); - entityhorse.setGrowingAge(0); - entityhorse.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ()); - event.world.spawnEntityInWorld(entityhorse); - //System.out.println(blockpos); - worldServer.addWeatherEffect(new EntityLightningBolt(worldServer, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), true)); - } - } - } + BlockPos blockpos = bolt.getPosition(); + EntityHorse entityhorse = new EntityHorse(event.world); + entityhorse.setType(HorseArmorType.ZOMBIE); + entityhorse.setSkeletonTrap(true); + EntityAISkeletonRiders skeletonTrapAI = (EntityAISkeletonRiders) ReflectionHelper.getPrivateValue(EntityHorse.class, entityhorse, 12); + entityhorse.tasks.removeTask(skeletonTrapAI); + entityhorse.tasks.addTask(1, new EntityAIZombieRiders(entityhorse)); + entityhorse.setGrowingAge(0); + entityhorse.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ()); + event.world.spawnEntityInWorld(entityhorse); + //System.out.println(blockpos); + //extinguish fire because can't turn on effectonly (done in constructor) + if (event.world.getBlockState(blockpos).getMaterial() == Material.fire) + event.world.setBlockState(blockpos, Blocks.air.getDefaultState()); } + bolt = null; } } - - private BlockPos adjustPosToNearbyEntity(BlockPos pos, final WorldServer worldServer) - { - BlockPos blockpos = worldServer.getPrecipitationHeight(pos); - AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.getX(), worldServer.getHeight(), blockpos.getZ()))).expandXyz(3.0D); - List list = worldServer.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new Predicate() - { - public boolean apply(EntityLivingBase p_apply_1_) - { - return p_apply_1_ != null && p_apply_1_.isEntityAlive() && worldServer.canSeeSky(p_apply_1_.getPosition()); - } - }); - - if (!list.isEmpty()) - { - return ((EntityLivingBase)list.get(worldServer.rand.nextInt(list.size()))).getPosition(); - } - else - { - if (blockpos.getY() == -1) - { - blockpos = blockpos.up(2); - } - - return blockpos; - } - } }