diff options
Diffstat (limited to 'src')
16 files changed, 939 insertions, 61 deletions
diff --git a/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java b/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java new file mode 100644 index 0000000000..24348988d6 --- /dev/null +++ b/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java @@ -0,0 +1,22 @@ +package gtPlusPlus.api.damage; + +import net.minecraft.entity.Entity; +import net.minecraft.util.EntityDamageSourceIndirect; + +public class BaseCustomDamageSource extends EntityDamageSourceIndirect { + + public BaseCustomDamageSource(String name, Entity transmitter, Entity indirectSource) { + super(name, transmitter, indirectSource); + this.setDifficultyScaled(); + } + + /** + * Return whether this damage source will have its damage amount scaled based on the current difficulty. + */ + public boolean isDifficultyScaled() + { + return true; + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java b/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java new file mode 100644 index 0000000000..ada2ba5c3d --- /dev/null +++ b/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java @@ -0,0 +1,22 @@ +package gtPlusPlus.api.damage; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; + +public class DamageTeslaTower extends BaseCustomDamageSource{ + + public DamageTeslaTower(Entity transmitter) { + super("plasmabolt", transmitter, null); + this.setDamageBypassesArmor(); + this.setDamageIsAbsolute(); + } + + @Override + public IChatComponent func_151519_b(EntityLivingBase target) { + String s = "death.attack." + this.damageType; + return new ChatComponentTranslation(s, target.getCommandSenderName(), "Plasma"); + } + +} diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java b/src/Java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java index 42071428a7..359229adaa 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java @@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; @@ -28,7 +29,7 @@ public class RenderMiningExplosivesPrimed extends Render { * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ - public void doRender(final EntityTNTPrimed entity, final double p_76986_2_, final double p_76986_4_, final double p_76986_6_, final float p_76986_8_, final float p_76986_9_){ + public void doRender(final EntityPrimedMiningExplosive entity, final double p_76986_2_, final double p_76986_4_, final double p_76986_6_, final float p_76986_8_, final float p_76986_9_){ Logger.INFO("Rendering Mining Explosion. 2"); GL11.glPushMatrix(); GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); @@ -78,7 +79,7 @@ public class RenderMiningExplosivesPrimed extends Render { /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(final EntityTNTPrimed p_110775_1_){ + protected ResourceLocation getEntityTexture(final EntityPrimedMiningExplosive p_110775_1_){ return TextureMap.locationBlocksTexture; } @@ -87,7 +88,8 @@ public class RenderMiningExplosivesPrimed extends Render { */ @Override protected ResourceLocation getEntityTexture(final Entity p_110775_1_){ - return this.getEntityTexture((EntityTNTPrimed)p_110775_1_); + Logger.INFO("Rendering Mining Explosion. 4"); + return this.getEntityTexture((EntityPrimedMiningExplosive)p_110775_1_); } /** @@ -98,6 +100,7 @@ public class RenderMiningExplosivesPrimed extends Render { */ @Override public void doRender(final Entity p_76986_1_, final double p_76986_2_, final double p_76986_4_, final double p_76986_6_, final float p_76986_8_, final float p_76986_9_){ - this.doRender((EntityTNTPrimed)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + Logger.INFO("Rendering Mining Explosion. 3"); + this.doRender((EntityPrimedMiningExplosive)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java b/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java new file mode 100644 index 0000000000..673fdff733 --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java @@ -0,0 +1,165 @@ +package gtPlusPlus.core.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.CSPRNG; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.entity.EntityTeslaTowerLightning; + +import java.util.Random; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderPlasmaBolt extends Render { + + public RenderPlasmaBolt(){ + Logger.INFO("[Render] Create custom lightning renderer."); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker + * function which does the actual work. In all probabilty, the class Render + * is generic (Render<T extends Entity) and this method has signature public + * void func_76986_a(T entity, double d, double d1, double d2, float f, + * float f1). But JAD is pre 1.5 so doesn't do that. + */ + public void doRender(EntityTeslaTowerLightning p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, + float p_76986_8_, float p_76986_9_) { + Logger.INFO("Render 1"); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + double[] adouble = new double[8]; + double[] adouble1 = new double[8]; + double d3 = 0.0D; + double d4 = 0.0D; + Random random = CSPRNG.generate(new Random(p_76986_1_.boltVertex)); + + for (int i = 7; i >= 0; --i) { + adouble[i] = d3; + adouble1[i] = d4; + d3 += (double) (random.nextInt(11) - 5); + d4 += (double) (random.nextInt(11) - 5); + } + + for (int k1 = 0; k1 < 4; ++k1) { + Random random1 = CSPRNG.generate(new Random(p_76986_1_.boltVertex)); + + for (int j = 0; j < 3; ++j) { + int k = 7; + int l = 0; + + if (j > 0) { + k = 7 - j; + } + + if (j > 0) { + l = k - 2; + } + + double d5 = adouble[k] - d3; + double d6 = adouble1[k] - d4; + + for (int i1 = k; i1 >= l; --i1) { + double d7 = d5; + double d8 = d6; + + if (j == 0) { + d5 += (double) (random1.nextInt(11) - 5); + d6 += (double) (random1.nextInt(11) - 5); + } + else { + d5 += (double) (random1.nextInt(31) - 15); + d6 += (double) (random1.nextInt(31) - 15); + } + + tessellator.startDrawing(5); + float f2 = 0.5F; + tessellator.setColorRGBA_F(0.9F * f2, 0.9F * f2, 1.0F * f2, 0.3F); + double d9 = 0.1D + (double) k1 * 0.2D; + + if (j == 0) { + d9 *= (double) i1 * 0.1D + 1.0D; + } + + double d10 = 0.1D + (double) k1 * 0.2D; + + if (j == 0) { + d10 *= (double) (i1 - 1) * 0.1D + 1.0D; + } + + for (int j1 = 0; j1 < 5; ++j1) { + double d11 = p_76986_2_ + 0.5D - d9; + double d12 = p_76986_6_ + 0.5D - d9; + + if (j1 == 1 || j1 == 2) { + d11 += d9 * 2.0D; + } + + if (j1 == 2 || j1 == 3) { + d12 += d9 * 2.0D; + } + + double d13 = p_76986_2_ + 0.5D - d10; + double d14 = p_76986_6_ + 0.5D - d10; + + if (j1 == 1 || j1 == 2) { + d13 += d10 * 2.0D; + } + + if (j1 == 2 || j1 == 3) { + d14 += d10 * 2.0D; + } + + tessellator.addVertex(d13 + d5, p_76986_4_ + (double) (i1 * 16), d14 + d6); + tessellator.addVertex(d11 + d7, p_76986_4_ + (double) ((i1 + 1) * 16), d12 + d8); + } + + tessellator.draw(); + } + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called + * unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityTeslaTowerLightning p_110775_1_) { + return null; + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called + * unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityTeslaTowerLightning) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker + * function which does the actual work. In all probabilty, the class Render + * is generic (Render<T extends Entity) and this method has signature public + * void func_76986_a(T entity, double d, double d1, double d2, float f, + * float f1). But JAD is pre 1.5 so doesn't do that. + */ + public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, + float p_76986_9_) { + Logger.INFO("Render 2"); + this.doRender((EntityTeslaTowerLightning) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, + p_76986_9_); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 11be6f5f2d..532da59515 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -71,6 +71,8 @@ public class CommonProxy { registerEntities(); Logger.INFO("[Proxy] Calling Tile Entity registrator."); registerTileEntities(); + Logger.INFO("[Proxy] Calling Render registrator."); + registerRenderThings(); } @@ -104,9 +106,6 @@ public class CommonProxy { * End of Subscribe Event registration. */ - Logger.INFO("[Proxy] Calling Render registrator."); - registerRenderThings(); - //Compat Handling COMPAT_HANDLER.registerMyModsOreDictEntries(); COMPAT_HANDLER.intermodOreDictionarySupport(); diff --git a/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java b/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java new file mode 100644 index 0000000000..2a7effbe8a --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java @@ -0,0 +1,133 @@ +package gtPlusPlus.core.entity; +import java.util.List; + +import gtPlusPlus.api.damage.DamageTeslaTower; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.entity.EntityUtils; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.effect.EntityWeatherEffect; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityTeslaTowerLightning extends EntityWeatherEffect +{ + /** Declares which state the lightning bolt is in. Whether it's in the air, hit the ground, etc. */ + private int lightningState; + /** A random long that is used to change the vertex of the lightning rendered in RenderLightningBolt */ + public long boltVertex; + /** Determines the time before the EntityLightningBolt is destroyed. It is a random integer decremented over time. */ + private int boltLivingTime; + + public EntityTeslaTowerLightning(World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_) + { + super(p_i1703_1_); + this.setLocationAndAngles(p_i1703_2_, p_i1703_4_, p_i1703_6_, 0.0F, 0.0F); + this.lightningState = 2; + this.boltVertex = this.rand.nextLong(); + this.boltLivingTime = this.rand.nextInt(3) + 1; + + //Puts fires out + if (!p_i1703_1_.isRemote && p_i1703_1_.getGameRules().getGameRuleBooleanValue("doFireTick") && (p_i1703_1_.difficultySetting == EnumDifficulty.NORMAL || p_i1703_1_.difficultySetting == EnumDifficulty.HARD) && p_i1703_1_.doChunksNearChunkExist(MathHelper.floor_double(p_i1703_2_), MathHelper.floor_double(p_i1703_4_), MathHelper.floor_double(p_i1703_6_), 10)) + { + int i = MathHelper.floor_double(p_i1703_2_); + int j = MathHelper.floor_double(p_i1703_4_); + int k = MathHelper.floor_double(p_i1703_6_); + + if (p_i1703_1_.getBlock(i, j, k).getMaterial() == Material.fire) + { + p_i1703_1_.setBlock(i, j, k, Blocks.air); + } + + for (i = 0; i < 4; ++i) + { + j = MathHelper.floor_double(p_i1703_2_) + this.rand.nextInt(3) - 1; + k = MathHelper.floor_double(p_i1703_4_) + this.rand.nextInt(3) - 1; + int l = MathHelper.floor_double(p_i1703_6_) + this.rand.nextInt(3) - 1; + + if (p_i1703_1_.getBlock(j, k, l).getMaterial() == Material.fire) + { + p_i1703_1_.setBlock(j, k, l, Blocks.air); + } + } + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + //Logger.INFO("Zap"); + super.onUpdate(); + + if (this.lightningState == 2) + { + this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F); + } + --this.lightningState; + if (this.lightningState < 0) + { + if (this.boltLivingTime == 0) + { + this.setDead(); + } + else if (this.lightningState < -this.rand.nextInt(10)) + { + --this.boltLivingTime; + this.lightningState = 1; + this.boltVertex = this.rand.nextLong(); + //Puts fires out. + if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && this.worldObj.doChunksNearChunkExist(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 10)) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.fire) + { + this.worldObj.setBlock(i, j, k, Blocks.air); + } + } + + } + } + + if (this.lightningState >= 0) + { + if (this.worldObj.isRemote) + { + this.worldObj.lastLightningBolt = 2; + } + else + { + double d0 = 3.0D; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0)); + + for (int l = 0; l < list.size(); ++l) + { + Entity entity = (Entity)list.get(l); + //if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) + EntityUtils.doFireDamage(entity, 5); + EntityUtils.doDamage(entity, new DamageTeslaTower(entity), 20); + } + } + } + } + + protected void entityInit() {} + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {} + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {} +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java index 5233c876e9..a33596b76a 100644 --- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -15,14 +15,34 @@ public class InternalEntityRegistry { public static void registerEntities(){ Logger.INFO("Registering GT++ Entities."); - //EntityRegistry.registerModEntity(EntityMiningChargePrimed.class, "MiningCharge", 3, Main.modInstance, 64, 20, true); + + EntityRegistry.registerGlobalEntityID(EntityPrimedMiningExplosive.class, "MiningCharge", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityPrimedMiningExplosive.class, "MiningCharge", mEntityID++, GTplusplus.instance, 64, 20, true); + + + EntityRegistry.registerGlobalEntityID(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", mEntityID++, GTplusplus.instance, 64, 20, true); + + + EntityRegistry.registerGlobalEntityID(EntityHydrofluoricAcidPotion.class, "throwablePotionHydrofluoric", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityHydrofluoricAcidPotion.class, "throwablePotionHydrofluoric", mEntityID++, GTplusplus.instance, 64, 20, true); + + + EntityRegistry.registerGlobalEntityID(EntityToxinballSmall.class, "toxinBall", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityToxinballSmall.class, "toxinBall", mEntityID++, GTplusplus.instance, 64, 20, true); + + + EntityRegistry.registerGlobalEntityID(EntityStaballoyConstruct.class, "constructStaballoy", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityStaballoyConstruct.class, "constructStaballoy", mEntityID++, GTplusplus.instance, 64, 20, true); + + + EntityRegistry.registerGlobalEntityID(EntitySickBlaze.class, "sickBlaze", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntitySickBlaze.class, "sickBlaze", mEntityID++, GTplusplus.instance, 64, 20, true); - + + + EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); + } } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 14f281b2e9..c6aff47c5b 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -101,6 +101,7 @@ public class COMPAT_HANDLER { GregtechIndustrialCuttingFactory.run(); GregtechMiniRaFusion.run(); GregtechComponentAssembler.run(); + GregtechTeslaTower.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index b04ce3baac..c8637f5aeb 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -761,66 +761,86 @@ public class Material { final public int calculateMeltingPoint(){ - int meltingPoint = 0; - for (MaterialStack part : this.vMaterialInput){ - if (part != null){ - int incrementor = part.getStackMaterial().getMeltingPointC(); - meltingPoint += incrementor; - Logger.WARNING("Melting Point for "+this.getLocalizedName()+" increased to "+ incrementor); - } - else { - Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + try { + int meltingPoint = 0; + for (MaterialStack part : this.vMaterialInput){ + if (part != null){ + int incrementor = part.getStackMaterial().getMeltingPointC(); + meltingPoint += incrementor; + Logger.WARNING("Melting Point for "+this.getLocalizedName()+" increased to "+ incrementor); + } + else { + Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + } } + int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); + Logger.WARNING("Dividing "+meltingPoint+" / "+divisor+" to get average melting point."); + meltingPoint = (meltingPoint/divisor); + return meltingPoint; + } + catch (Throwable r){ + return 500; } - int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); - Logger.WARNING("Dividing "+meltingPoint+" / "+divisor+" to get average melting point."); - meltingPoint = (meltingPoint/divisor); - return meltingPoint; } final public int calculateBoilingPoint(){ - int boilingPoint = 0; - for (MaterialStack part : this.vMaterialInput){ - if (part != null){ - boilingPoint += part.getStackMaterial().getBoilingPointC(); - } - else { - Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + try { + int boilingPoint = 0; + for (MaterialStack part : this.vMaterialInput){ + if (part != null){ + boilingPoint += part.getStackMaterial().getBoilingPointC(); + } + else { + Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + } } + int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); + boilingPoint = (boilingPoint/divisor); + return boilingPoint; + } + catch (Throwable r){ + return 2500; } - int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); - boilingPoint = (boilingPoint/divisor); - return boilingPoint; } final public long calculateProtons(){ - long protonCount = 0; - for (MaterialStack part : this.vMaterialInput){ - if (part != null){ - protonCount += (part.getStackMaterial().getProtons()); - } - else { - Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + try { + long protonCount = 0; + for (MaterialStack part : this.vMaterialInput){ + if (part != null){ + protonCount += (part.getStackMaterial().getProtons()); + } + else { + Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + } } + int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); + protonCount = (protonCount/divisor); + return protonCount; + } + catch (Throwable r){ + return 50; } - int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); - protonCount = (protonCount/divisor); - return protonCount; } final public long calculateNeutrons(){ - long neutronCount = 0; - for (MaterialStack part : this.vMaterialInput){ - if (part != null){ - neutronCount += (part.getStackMaterial().getNeutrons()); - } - else { - Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + try { + long neutronCount = 0; + for (MaterialStack part : this.vMaterialInput){ + if (part != null){ + neutronCount += (part.getStackMaterial().getNeutrons()); + } + else { + Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); + } } + int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); + neutronCount = (neutronCount/divisor); + return neutronCount; + } + catch (Throwable r){ + return 75; } - int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); - neutronCount = (neutronCount/divisor); - return neutronCount; } diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 712df63e67..f20c3ef91a 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -17,8 +17,10 @@ import gtPlusPlus.core.client.renderer.*; import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.common.compat.COMPAT_PlayerAPI; import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; +import gtPlusPlus.core.entity.EntityTeslaTowerLightning; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; +import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; import gtPlusPlus.core.handler.render.FirepitRender; @@ -30,6 +32,7 @@ import gtPlusPlus.core.util.particles.EntityParticleFXMysterious; import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.entity.RenderLightningBolt; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.entity.Entity; @@ -96,7 +99,8 @@ public class ClientProxy extends CommonProxy implements Runnable{ RenderingRegistry.registerEntityRenderingHandler(EntityToxinballSmall.class, new RenderToxinball(1F)); Logger.INFO("Registering Custom Renderer for Sulfuric potion."); RenderingRegistry.registerEntityRenderingHandler(EntitySulfuricAcidPotion.class, new RenderSnowball(ModItems.itemSulfuricPotion)); - + RenderingRegistry.registerEntityRenderingHandler(EntityHydrofluoricAcidPotion.class, new RenderSnowball(ModItems.itemHydrofluoricPotion)); + RenderingRegistry.registerEntityRenderingHandler(EntityTeslaTowerLightning.class, new RenderLightningBolt()); //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBloodSteelChest.class, new BloodSteelChestRenderer()); //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.tutChest), new ItemRenderBloodSteelChest()); diff --git a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java index 60b05a308f..90b4b2b22c 100644 --- a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java @@ -1,12 +1,17 @@ package gtPlusPlus.core.util.entity; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import cpw.mods.fml.common.registry.EntityRegistry; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; import net.minecraft.block.Block; import net.minecraft.entity.*; +import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -36,7 +41,7 @@ public class EntityUtils { final int blockZ = MathHelper.floor_double(parEntity.posZ); return parEntity.worldObj.getBlock(blockX, blockY, blockZ); } - + public static BlockPos findBlockPosUnderEntity(final Entity parEntity){ final int blockX = MathHelper.floor_double(parEntity.posX); final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; @@ -72,4 +77,34 @@ public class EntityUtils { return false; } + + /** + * Static Version of the method used in {@code doFireDamage(entity, int)} to save memory. + */ + private static volatile Method dealFireDamage; + + /** + * Reflective Call to do Fire Damage to an entity (Does not set entity on fire though) + */ + public static boolean doFireDamage(Entity entity, int amount){ + if (dealFireDamage == null){ + try { + dealFireDamage = Entity.class.getDeclaredMethod("dealFireDamage", int.class); + dealFireDamage.setAccessible(true); + } + catch (NoSuchMethodException | SecurityException e) {} + } + else { + try { + dealFireDamage.invoke(entity, amount); + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} + } + return false; + } + + public static void doDamage(Entity entity, DamageSource dmg, int i) { + entity.attackEntityFrom(dmg, i); + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index fd548a208b..233b175ba7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -174,8 +174,8 @@ public enum GregtechItemList implements GregtechItemContainer { Casing_Autocrafter, Casing_CuttingFactoryFrame, - Casing_PlaceHolder14, - Casing_PlaceHolder15, + Casing_TeslaTower, + Casing_PLACEHOLDER_TreeFarmer, //LFTR ThoriumReactor, @@ -273,7 +273,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Component Makers Machine_LV_Component_Maker, Machine_MV_Component_Maker, Machine_HV_Component_Maker, - Machine_EV_Component_Maker, Machine_IV_Component_Maker, + Machine_EV_Component_Maker, Machine_IV_Component_Maker, + + //Tesla Tower + TelsaTower, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index 21f7742b60..f6857c3ca9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -33,7 +33,7 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Placeholder Casing "); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Tesla Containment Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Casing "); //Tree Farmer Textures GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); @@ -49,8 +49,8 @@ extends GregtechMetaCasingBlocksAbstract { GregtechItemList.Casing_ThermalContainment.set(new ItemStack(this, 1, 11)); GregtechItemList.Casing_Autocrafter.set(new ItemStack(this, 1, 12)); GregtechItemList.Casing_CuttingFactoryFrame.set(new ItemStack(this, 1, 13)); - GregtechItemList.Casing_PlaceHolder14.set(new ItemStack(this, 1, 14)); - GregtechItemList.Casing_PlaceHolder15.set(new ItemStack(this, 1, 15)); //Tree Farmer Textures + GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 14)); + GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.set(new ItemStack(this, 1, 15)); //Tree Farmer Textures } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java index d588e38dbe..17fa039c4e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -52,7 +52,7 @@ public class CasingTextureHandler2 { case 13: return TexturesGtBlock.Casing_Machine_Ultra.getIcon(); case 14: - return TexturesGtBlock._PlaceHolder.getIcon(); + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); case 15: return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon(); //Tree Farmer Textures diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java new file mode 100644 index 0000000000..471d30d4d5 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java @@ -0,0 +1,436 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.GT_Values.W; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.entity.EntityTeslaTowerLightning; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMTE_TeslaTower extends GregtechMeta_MultiBlockBase { + + private Block casingBlock; + private int casingMeta; + private int frameMeta; + private int casingTextureIndex; + + private ForgeDirection back; + + private int xLoc, yLoc, zLoc; + + protected int mRange; + /** + * Machine Mode, + * {@value false} Attacks all entities, + * {@value true} Only attacks players. + */ + protected volatile boolean mMode = false; + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_TeslaTower(mName); + } + + public GregtechMTE_TeslaTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + initFields(); + } + + public GregtechMTE_TeslaTower(String aName) { + super(aName); + initFields(); + } + + @Override + public String[] getDescription() { + String casings = getCasingBlockItem().get(0).getDisplayName(); + return new String[]{ + "Controller Block for the Tesla Defence Tower Mk3200", + "Enemies within "+this.mRange+"m are blasted with a high energy plasma.", + "This uses 5,000,000EU per blast.", + "Can screwdriver to toggle mode between Players and all Entities.", + "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", + "3x1x3 Base of " + casings, + "1x3x1 " + casings + " pillar (Center of base)", + "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", + "1x Maintenance Hatch (One of base casings)", + "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; + } + + private void initFields() { + casingBlock = ModBlocks.blockCasings2Misc; + casingMeta = getCasingBlockItem().get(0).getItemDamage(); + int frameId = 4096 + getFrameMaterial().mMetaItemSubID; + frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W; + casingTextureIndex = getCasingTextureIndex(); + mRange = 50; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[getCasingTextureIndex()], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[getCasingTextureIndex()]}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mMode", this.mMode); + aNBT.setInteger("mRange", this.mRange); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mMode = aNBT.getBoolean("mMode"); + this.mRange = aNBT.getInteger("mRange"); + super.loadNBTData(aNBT); + } + + private boolean isEnergyEnough() { + if (this.getEUVar() >= 5000000){ + return true; + } + return false; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + /*if (!isEnergyEnough()) { + this.mProgresstime = 0; + this.mMaxProgresstime = 20; + this.getBaseMetaTileEntity().setActive(false); + stopMachine(); + } + else {*//* + this.mProgresstime = 1; + this.mMaxProgresstime = 100; + this.getBaseMetaTileEntity().setActive(true);*/ + //} + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + updateCoordinates(); + //check base layer + for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { + for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { + if (xOff == 0 && zOff == 0) continue; + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); + if (!checkCasingBlock(xOff, 0, zOff) + && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) + && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)){ + Logger.INFO("bad block"); + return false; + } + } + } + if(!checkHatches()){ + Logger.INFO("bad Hatches"); + return false; + } + if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()){ + Logger.INFO("bad Voltage"); + return false; + } + //check tower + for (int yOff = 1; yOff < 4; yOff++) { + if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) + || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) + || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)){ + Logger.INFO("bad frame?"); + return false; + } + } + Logger.INFO("good"); + return true; + } + + private void updateCoordinates() { + casingTextureIndex = getCasingTextureIndex(); + mRange = 50; + xLoc = getBaseMetaTileEntity().getXCoord(); + yLoc = getBaseMetaTileEntity().getYCoord(); + zLoc = getBaseMetaTileEntity().getZCoord(); + back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()); + } + + protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { + Logger.INFO("Looking For Casing."); + return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); + } + //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation) + protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { + Logger.INFO("Looking For Frame."); + return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); + } + + protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { + return checkBlockAndMeta(xLoc + xOff, yLoc + yOff, zLoc + zOff, block, meta); + } + + private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { + Logger.INFO("Found: "+getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName()+" | Meta: "+getBaseMetaTileEntity().getMetaID(x, y, z)); + Logger.INFO("Expected: "+block.getLocalizedName()+" | Meta: "+meta); + return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) + && getBaseMetaTileEntity().getBlock(x, y, z) == block; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + protected int getMinTier() { + return 7; + } + + protected boolean checkHatches() { + return !mMaintenanceHatches.isEmpty() && !mEnergyHatches.isEmpty(); + } + + private Map<Pair<Long, Long>, Entity> mInRange = new HashMap<Pair<Long, Long>, Entity>(); + + @SuppressWarnings("unchecked") + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + try { + if (this.getBaseMetaTileEntity().isServerSide()){ + if (this.mEnergyHatches.size() > 0) { + for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches){ + if (isValidMetaTileEntity(tHatch)) { + long mHT = tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (tHatch.getEUVar() >= mHT) { + for (int o=0;o<(tHatch.getEUVar()/mHT);o++){ + //1A + if (this.getEUVar()<(this.maxEUStore()-mHT)){ + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); + this.setEUVar(this.getEUVar()+mHT); + } + //2A + if (this.getEUVar()<(this.maxEUStore()-mHT)){ + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); + this.setEUVar(this.getEUVar()+mHT); + } + } + } + } + } + } + + if (aTick % 10 == 0){ + if (this.getEUVar() >= 5000000){ + //Logger.INFO("Can Zap."); + this.getBaseMetaTileEntity().enableWorking(); + this.getBaseMetaTileEntity().setActive(true); + if (this.mProgresstime <= 0){ + this.mProgresstime++; + } + else if (this.mProgresstime >= 100){ + this.mProgresstime = 0; + } + this.mMaxProgresstime = 10000; + } + //Logger.INFO("Allowed to be Working? "+this.getBaseMetaTileEntity().isAllowedToWork()); + //Logger.INFO("Working? "+this.getBaseMetaTileEntity().isActive()); + //Logger.INFO("Has Working just been enabled? "+this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()); + } + + + if (aTick % 20 == 0){ + List<Object> o = aBaseMetaTileEntity.getWorld().loadedEntityList; + //Clean up old entities first + if (this.mInRange.size() > 0){ + for (Entity j : this.mInRange.values()){ + if (((Entity) j).getDistance(this.xLoc, this.yLoc, this.zLoc) > this.mRange){ + mInRange.remove(new Pair<Long, Long>(((Entity) j).getUniqueID().getMostSignificantBits(), ((Entity) j).getUniqueID().getLeastSignificantBits()), (Entity) j); + } + } + } + //Add new entities + if (o.size() > 0){ + for (Object r : o){ + if (r instanceof Entity){ + if (!((Entity) r).getUniqueID().equals(getOwner())){ + if (((Entity) r).isEntityAlive() || r instanceof EntityLiving){ + if (((Entity) r).getDistance(this.xLoc, this.yLoc, this.zLoc) <= this.mRange){ + if (!this.mMode){ + mInRange.put(new Pair<Long, Long>(((Entity) r).getUniqueID().getMostSignificantBits(), ((Entity) r).getUniqueID().getLeastSignificantBits()), (Entity) r); + } + else { + if (r instanceof EntityPlayer){ + mInRange.put(new Pair<Long, Long>(((Entity) r).getUniqueID().getMostSignificantBits(), ((Entity) r).getUniqueID().getLeastSignificantBits()), (Entity) r); + } + } + } + } + } + } + } + } + } + } + } + catch (Throwable r){ + + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + try { + if (this.getBaseMetaTileEntity().isServerSide()){ + //Handle Progress Time + if (this.getEUVar() >= 0 && !this.getBaseMetaTileEntity().isAllowedToWork()){ + this.mProgresstime = 20; + this.mMaxProgresstime = 40; + } + else if (this.getEUVar() >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()){ + this.mProgresstime = 20; + this.mMaxProgresstime = 40; + } + + if (aTick % 10 == 0){ + if (this.mInRange.size() > 0){ + if (this.getEUVar() >= 5000000){ + + for (Entity f : mInRange.values()){ + if (f instanceof EntityLiving){ + int j1 = (int) f.posX; + int l1 = (int) f.posY; + int k1 = (int) f.posZ; + World world = aBaseMetaTileEntity.getWorld(); + + if (f.isEntityAlive() && !f.getUniqueID().equals(getOwner())){ + //if (world.canLightningStrikeAt(j1, l1+1, k1)){ + if (isEnergyEnough() && world.addWeatherEffect(new EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1))){ + this.mInRange.remove(new Pair<Long, Long>(f.getUniqueID().getMostSignificantBits(), f.getUniqueID().getLeastSignificantBits())); + this.setEUVar(this.getEUVar()-5000000); + } + //} + } + + } + } + } + } + } + } + } + catch (Throwable r){ + + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + + protected GregtechItemList getCasingBlockItem() { + return GregtechItemList.Casing_TeslaTower; + } + + protected Materials getFrameMaterial() { + /*casingBlock = getCasingBlockItem().getBlock(); + casingMeta = getCasingBlockItem().get(0).getItemDamage(); + int frameId = 4096 + getFrameMaterial().mMetaItemSubID; + frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W; + */return Materials.TungstenCarbide; + } + + protected int getCasingTextureIndex() { + return TAE.GTPP_INDEX(30); + } + + public UUID getOwner(){ + return PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxEUInput() { + return 131072; + } + + @Override + public long maxEUStore() { + return Integer.MAX_VALUE; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mMode = Utils.invertBoolean(mMode); + this.mInRange.clear(); + if (mMode){ + PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Now only targetting players."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Targetting all types of entities."); + } + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java new file mode 100644 index 0000000000..5e49c73634 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java @@ -0,0 +1,15 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMTE_TeslaTower; + +public class GregtechTeslaTower { + + public static void run() { + Logger.INFO("Gregtech5u Content | Registering Tesla Tower."); + GregtechItemList.TelsaTower.set(new GregtechMTE_TeslaTower(984, "multimachine.telsatower", "Tesla's Last Testament").getStackForm(1)); + + } + +} |