diff --git a/changelog b/changelog index 86021d890..4b0a875c9 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +## Added +* Laser pistol + ## Changed * Trenchmaster armor now has the fast reload and more ammo traits again * Fast reload now also plays the animation twice as fast @@ -19,6 +22,9 @@ * Mines can no longer be triggered if a non-air block is above them * Moved the cooling tower particle toggle from `hbm.cfg` to the client config, named `COOLING_TOWER_PARTICLES` * Updated HSS textures +* The diesel generator and turbofan will both now halt operation when powered by redstone +* Infinite batteries will now also drain energy when put into a charging slot +* TOREX effects now cause the sky to go fullbright again for 10 seconds after they spawn ## Fixed * Fixed fatal gamebreaking hard drive corrupting issue where taurun leggings were misspelled diff --git a/src/main/java/com/hbm/blocks/machine/MachineDiesel.java b/src/main/java/com/hbm/blocks/machine/MachineDiesel.java index 4bce53d0b..1f7b923a2 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineDiesel.java +++ b/src/main/java/com/hbm/blocks/machine/MachineDiesel.java @@ -29,20 +29,9 @@ public class MachineDiesel extends BlockMachineBase implements ITooltipProvider return new TileEntityMachineDiesel(); } - @Override - public int getRenderType(){ - return -1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override public int getRenderType(){ return -1; } + @Override public boolean isOpaqueCube() { return false; } + @Override public boolean renderAsNormalBlock() { return false; } @Override @SideOnly(Side.CLIENT) diff --git a/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java b/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java index bc6eafaec..0c8f7b843 100644 --- a/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java +++ b/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java @@ -71,6 +71,8 @@ public class EntityNukeTorex extends Entity { lastSpawnY = posY - 3; } + if(ticksExisted < 100) this.worldObj.lastLightningBolt = 2; + int spawnTarget = Math.max(worldObj.getHeightValue((int) Math.floor(posX), (int) Math.floor(posZ)) - 3, 1); double moveSpeed = 0.5D; diff --git a/src/main/java/com/hbm/entity/missile/EntityMissileBase.java b/src/main/java/com/hbm/entity/missile/EntityMissileBase.java deleted file mode 100644 index 66d076d6c..000000000 --- a/src/main/java/com/hbm/entity/missile/EntityMissileBase.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.hbm.entity.missile; - -import com.hbm.calc.EasyLocation; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.entity.projectile.EntityThrowable; -import net.minecraft.init.Blocks; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.world.World; - -public class EntityMissileBase extends EntityThrowable { - - EasyLocation origin; - EasyLocation loc0; - EasyLocation loc1; - EasyLocation loc2; - EasyLocation loc3; - EasyLocation loc4; - EasyLocation loc5; - EasyLocation loc6; - EasyLocation loc7; - EasyLocation target; - - public int phase = 0; - - public int targetPoint = 0; - public int lengthX; - public int lengthZ; - public double lengthFlight; - public int baseHeight = 50; - public double missileSpeed = 1.5; - - public EntityMissileBase(World p_i1776_1_) { - super(p_i1776_1_); - this.ignoreFrustumCheck = true; - } - - public EntityMissileBase(World p_i1582_1_, int x, int z, double a, double b, double c) { - super(p_i1582_1_); - this.ignoreFrustumCheck = true; - this.posX = a; - this.posY = b; - this.posZ = c; - - this.motionY = 0.1; - - lengthX = (int) (x - this.posX); - lengthZ = (int) (z - this.posZ); - lengthFlight = Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthZ, 2)); - - - origin = new EasyLocation(this.posX, this.posY, this.posZ); - - loc0 = new EasyLocation(this.posX, this.posY + baseHeight, this.posZ); - loc1 = new EasyLocation(this.posX + lengthX/lengthFlight * 10, this.posY + baseHeight + 20, this.posZ + lengthZ/lengthFlight * 10); - loc2 = new EasyLocation(this.posX + lengthX/lengthFlight * 30, this.posY + baseHeight + 40, this.posZ + lengthZ/lengthFlight * 30); - loc3 = new EasyLocation(this.posX + lengthX/lengthFlight * 50, this.posY + baseHeight + 50, this.posZ + lengthZ/lengthFlight * 50); - - loc4 = new EasyLocation(x - (lengthX/lengthFlight * 50), this.posY + baseHeight + 50, z - (lengthZ/lengthFlight * 50)); - loc5 = new EasyLocation(x - (lengthX/lengthFlight * 30), this.posY + baseHeight + 40, z - (lengthZ/lengthFlight * 30)); - loc6 = new EasyLocation(x - (lengthX/lengthFlight * 10), this.posY + baseHeight + 20, z - (lengthZ/lengthFlight * 10)); - loc7 = new EasyLocation(x, this.posY + baseHeight, z); - - - target = new EasyLocation(x, 0, z); - } - - protected void freePizzaGoddammit(EasyLocation loc) { - double x = loc.posX - this.posX; - double y = loc.posY - this.posY; - double z = loc.posZ - this.posZ; - lengthFlight = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)); - - this.motionX = x / this.lengthFlight * missileSpeed; - this.motionY = y / this.lengthFlight * missileSpeed; - this.motionZ = z / this.lengthFlight * missileSpeed; - } - - protected void rotation() { - float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - - for (this.rotationPitch = (float)(Math.atan2(this.motionY, f2) * 180.0D / Math.PI) - 90; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) - { - ; - } - - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) - { - this.prevRotationPitch += 360.0F; - } - - while (this.rotationYaw - this.prevRotationYaw < -180.0F) - { - this.prevRotationYaw -= 360.0F; - } - - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) - { - this.prevRotationYaw += 360.0F; - } - } - - @Override - public void onUpdate() - { - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - - this.rotation(); - - switch(phase) - { - case 0: - if(loc0 != null) - { - freePizzaGoddammit(loc0); - if(loc0.posX + 2 > this.posX && loc0.posX - 2 < this.posX && - loc0.posY + 2 > this.posY && loc0.posY - 2 < this.posY && - loc0.posZ + 2 > this.posZ && loc0.posZ - 2 < this.posZ) - { - this.phase = 1; - } - } - break; - case 1: - if(loc1 != null) - { - freePizzaGoddammit(loc1); - if(loc1.posX + 2 > this.posX && loc1.posX - 2 < this.posX && - loc1.posY + 2 > this.posY && loc1.posY - 2 < this.posY && - loc1.posZ + 2 > this.posZ && loc1.posZ - 2 < this.posZ) - { - this.phase = 2; - } - } - break; - case 2: - if(loc2 != null) - { - freePizzaGoddammit(loc2); - if(loc2.posX + 2 > this.posX && loc2.posX - 2 < this.posX && - loc2.posY + 2 > this.posY && loc2.posY - 2 < this.posY && - loc2.posZ + 2 > this.posZ && loc2.posZ - 2 < this.posZ) - { - this.phase = 3; - } - } - break; - case 3: - if(loc3 != null) - { - freePizzaGoddammit(loc3); - if(loc3.posX + 2 > this.posX && loc3.posX - 2 < this.posX && - loc3.posY + 2 > this.posY && loc3.posY - 2 < this.posY && - loc3.posZ + 2 > this.posZ && loc3.posZ - 2 < this.posZ) - { - this.phase = 4; - } - } - break; - case 4: - if(loc4 != null) - { - freePizzaGoddammit(loc4); - if(loc4.posX + 2 > this.posX && loc4.posX - 2 < this.posX && - loc4.posY + 2 > this.posY && loc4.posY - 2 < this.posY && - loc4.posZ + 2 > this.posZ && loc4.posZ - 2 < this.posZ) - { - this.phase = 5; - } - } - break; - case 5: - if(loc5 != null) - { - freePizzaGoddammit(loc5); - if(loc5.posX + 2 > this.posX && loc5.posX - 2 < this.posX && - loc5.posY + 2 > this.posY && loc5.posY - 2 < this.posY && - loc5.posZ + 2 > this.posZ && loc5.posZ - 2 < this.posZ) - { - this.phase = 6; - } - } - break; - case 6: - if(loc6 != null) - { - freePizzaGoddammit(loc6); - if(loc6.posX + 2 > this.posX && loc6.posX - 2 < this.posX && - loc6.posY + 2 > this.posY && loc6.posY - 2 < this.posY && - loc6.posZ + 2 > this.posZ && loc6.posZ - 2 < this.posZ) - { - this.phase = 7; - } - } - break; - case 7: - if(loc7 != null) - { - freePizzaGoddammit(loc7); - if(loc7.posX + 2 > this.posX && loc7.posX - 2 < this.posX && - loc7.posY + 2 > this.posY && loc7.posY - 2 < this.posY && - loc7.posZ + 2 > this.posZ && loc7.posZ - 2 < this.posZ) - { - this.phase = 8; - } - } - break; - case 8: - if(target != null) - { - freePizzaGoddammit(target); - if(target.posX + 2 > this.posX && target.posX - 2 < this.posX && - target.posY + 2 > this.posY && target.posY - 2 < this.posY && - target.posZ + 2 > this.posZ && target.posZ - 2 < this.posZ) - { - this.phase = -1; - } - } - break; - } - - if(this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.air && this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.water && this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.flowing_water) - { - if(!this.worldObj.isRemote) - { - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 5.0F, true); - } - this.setDead(); - } - } - - @Override - protected void onImpact(MovingObjectPosition p_70184_1_) { - - } - - @Override - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(double distance) - { - return distance < 25000; - } - -} diff --git a/src/main/java/com/hbm/explosion/ExplosionChaos.java b/src/main/java/com/hbm/explosion/ExplosionChaos.java index 19b7caabb..dd15674cf 100644 --- a/src/main/java/com/hbm/explosion/ExplosionChaos.java +++ b/src/main/java/com/hbm/explosion/ExplosionChaos.java @@ -7,8 +7,6 @@ import com.hbm.blocks.ModBlocks; import com.hbm.entity.grenade.EntityGrenadeTau; import com.hbm.entity.grenade.EntityGrenadeZOMG; import com.hbm.entity.item.EntityFallingBlockNT; -import com.hbm.entity.missile.EntityMissileAntiBallistic; -import com.hbm.entity.missile.EntityMissileBase; import com.hbm.entity.particle.EntityChlorineFX; import com.hbm.entity.particle.EntityCloudFX; import com.hbm.entity.particle.EntityModFX; @@ -652,91 +650,6 @@ public class ExplosionChaos { radius = (int) f; } - public static Entity getHomingTarget(World world, int x, int y, int z, int radius, Entity e) { - float f = radius; - int i; - int j; - int k; - double d5; - double d6; - double d7; - double wat = radius * 2; - - radius *= 2.0F; - i = MathHelper.floor_double(x - wat - 1.0D); - j = MathHelper.floor_double(x + wat + 1.0D); - k = MathHelper.floor_double(y - wat - 1.0D); - int i2 = MathHelper.floor_double(y + wat + 1.0D); - int l = MathHelper.floor_double(z - wat - 1.0D); - int j2 = MathHelper.floor_double(z + wat + 1.0D); - List list = world.getEntitiesWithinAABBExcludingEntity(e, AxisAlignedBB.getBoundingBox(i, k, l, j, i2, j2)); - - for (int i1 = 0; i1 < list.size(); ++i1) { - Entity entity = (Entity) list.get(i1); - double d4 = entity.getDistance(x, y, z) / radius; - - if (d4 <= 1.0D) { - d5 = entity.posX - x; - d6 = entity.posY + entity.getEyeHeight() - y; - d7 = entity.posZ - z; - double d9 = MathHelper.sqrt_double(d5 * d5 + d6 * d6 + d7 * d7); - if (true) { - d5 /= d9; - d6 /= d9; - d7 /= d9; - if (entity instanceof EntityMissileBase && !(entity instanceof EntityMissileAntiBallistic)) { - return entity; - } - } - } - } - - radius = (int) f; - return null; - } - - public static void delMissiles(World world, int x, int y, int z, int radius, Entity e) { - float f = radius; - int i; - int j; - int k; - double d5; - double d6; - double d7; - double wat = radius * 2; - - radius *= 2.0F; - i = MathHelper.floor_double(x - wat - 1.0D); - j = MathHelper.floor_double(x + wat + 1.0D); - k = MathHelper.floor_double(y - wat - 1.0D); - int i2 = MathHelper.floor_double(y + wat + 1.0D); - int l = MathHelper.floor_double(z - wat - 1.0D); - int j2 = MathHelper.floor_double(z + wat + 1.0D); - List list = world.getEntitiesWithinAABBExcludingEntity(e, AxisAlignedBB.getBoundingBox(i, k, l, j, i2, j2)); - - for (int i1 = 0; i1 < list.size(); ++i1) { - Entity entity = (Entity) list.get(i1); - double d4 = entity.getDistance(x, y, z) / radius; - - if (d4 <= 1.0D) { - d5 = entity.posX - x; - d6 = entity.posY + entity.getEyeHeight() - y; - d7 = entity.posZ - z; - double d9 = MathHelper.sqrt_double(d5 * d5 + d6 * d6 + d7 * d7); - if (true) { - d5 /= d9; - d6 /= d9; - d7 /= d9; - if (entity instanceof EntityMissileBase) { - entity = null; - } - } - } - } - - radius = (int) f; - } - public static void plasma(World world, int x, int y, int z, int radius) { int r = radius; int r2 = r * r; diff --git a/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java b/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java index 41b6ba3be..356f99bcd 100644 --- a/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java @@ -142,7 +142,7 @@ public class AssemblerRecipes extends SerializableRecipe { makeRecipe(new ComparableStack(ModBlocks.machine_bat9000, 1), new AStack[] {new OreDictStack(STEEL.plate528(), 16), new OreDictStack(ANY_RESISTANTALLOY.plateWelded(), 2), new ComparableStack(ModBlocks.steel_scaffold, 16), new OreDictStack(ANY_TAR.any(), 16), },150); makeRecipe(new ComparableStack(ModBlocks.machine_orbus, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 12), new OreDictStack(ANY_RESISTANTALLOY.plateWelded(), 8), new OreDictStack(BIGMT.plate(), 12), new ComparableStack(ModItems.coil_advanced_alloy, 12), new ComparableStack(ModItems.battery_sc_polonium, 1) }, 200); makeRecipe(new ComparableStack(ModBlocks.machine_mining_laser, 1), new AStack[] {new ComparableStack(ModItems.tank_steel, 3), !exp ? new OreDictStack(STEEL.plate528(), 16) : new OreDictStack(STEEL.heavyComp(), 3), new ComparableStack(ModItems.crystal_redstone, 3), new ComparableStack(Items.diamond, 3), new OreDictStack(ANY_PLASTIC.ingot(), 4), new ComparableStack(ModItems.motor, 3), !exp ? new OreDictStack(DURA.ingot(), 4) : new OreDictStack(DESH.heavyComp(), 1), new OreDictStack(DURA.bolt(), 8), new ComparableStack(ModBlocks.machine_battery, 3), },400); - makeRecipe(new ComparableStack(ModBlocks.machine_turbofan, 1), new AStack[] {!exp ? new OreDictStack(TI.shell(), 6) : new OreDictStack(TI.heavyComp(), 1), new OreDictStack(DURA.pipe(), 4), new OreDictStack(ANY_PLASTIC.ingot(), 8), new ComparableStack(ModItems.turbine_tungsten, 1), new ComparableStack(ModItems.turbine_titanium, 3) }, 300); + makeRecipe(new ComparableStack(ModBlocks.machine_turbofan, 1), new AStack[] {!exp ? new OreDictStack(TI.shell(), 8) : new OreDictStack(TI.heavyComp(), 1), new OreDictStack(DURA.pipe(), 4), new OreDictStack(ANY_PLASTIC.ingot(), 12), new ComparableStack(ModItems.turbine_tungsten, 1), new OreDictStack(GOLD.wireDense(), 12) }, 300); makeRecipe(new ComparableStack(ModBlocks.machine_turbinegas, 1), new AStack[] {!exp ? new OreDictStack(STEEL.shell(), 10) : new OreDictStack(STEEL.heavyComp(), 2), new OreDictStack(GOLD.wireDense(), 12), new OreDictStack(DURA.pipe(), 4), new ComparableStack(ModBlocks.steel_scaffold, 8), new OreDictStack(STEEL.pipe(), 4), new ComparableStack(ModItems.turbine_tungsten, 3), new ComparableStack(ModItems.motor, 2), new ComparableStack(ModItems.ingot_rubber, 4), new ComparableStack(ModItems.circuit, 3, EnumCircuitType.BASIC.ordinal())}, 600); makeRecipe(new ComparableStack(ModBlocks.machine_teleporter, 1), new AStack[] {new OreDictStack(TI.ingot(), 8), new OreDictStack(ALLOY.plate528(), 12), new OreDictStack(GOLD.wireFine(), 32), new ComparableStack(ModItems.entanglement_kit, 1), new ComparableStack(ModBlocks.machine_battery, 1) },300); makeRecipe(new ComparableStack(ModBlocks.machine_schrabidium_transmutator, 1), new AStack[] {new OreDictStack(MAGTUNG.ingot(), 1), !exp ? new OreDictStack(TI.ingot(), 24) : new OreDictStack(TI.heavyComp(), 2), !exp ? new OreDictStack(ALLOY.plate(), 18) : new OreDictStack(ALLOY.heavyComp(), 1), new OreDictStack(STEEL.plateWelded(), 12), new ComparableStack(ModItems.plate_desh, 6), new OreDictStack(RUBBER.ingot(), 8), new ComparableStack(ModBlocks.machine_battery, 5), new ComparableStack(ModItems.circuit, 2, EnumCircuitType.ADVANCED.ordinal()), },500); diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index edeed491a..be231222b 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -41,7 +41,6 @@ import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; import com.hbm.potion.HbmPotion; import com.hbm.tileentity.machine.rbmk.IRBMKFluxReceiver.NType; -import com.hbm.util.EnchantmentUtil; import com.hbm.util.RTGUtil; import api.hbm.block.IToolable.ToolType; @@ -57,7 +56,6 @@ import net.minecraft.item.ItemSoup; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; @@ -66,8 +64,7 @@ import net.minecraftforge.fluids.FluidStack; public class ModItems { - public static void mainRegistry() - { + public static void mainRegistry() { initializeItem(); registerItem(); } @@ -1701,9 +1698,6 @@ public class ModItems { public static Item arc_electrode; public static Item arc_electrode_burnt; - /*public static Item factory_core_titanium; - public static Item factory_core_advanced;*/ - public static Item upgrade_muffler; public static Item upgrade_template; @@ -2251,8 +2245,8 @@ public class ModItems { public static Item conveyor_wand; - public static void initializeItem() - { + public static void initializeItem() { + redstone_sword = new RedstoneSword(ToolMaterial.STONE).setUnlocalizedName("redstone_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":redstone_sword"); big_sword = new BigSword(ToolMaterial.EMERALD).setUnlocalizedName("big_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":big_sword"); @@ -3001,10 +2995,10 @@ public class ModItems { gas_empty = new Item().setUnlocalizedName("gas_empty").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":gas_empty"); gas_full = new ItemGasTank().setUnlocalizedName("gas_full").setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.gas_empty).setTextureName(RefStrings.MODID + ":gas_empty"); + ItemSimpleConsumable.init(); + + //TODO: move all this crap to ItemSimpleConsumable syringe_empty = new Item().setUnlocalizedName("syringe_empty").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_empty"); - syringe_antidote = new ItemSyringe().setUnlocalizedName("syringe_antidote").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_antidote"); - syringe_poison = new ItemSyringe().setUnlocalizedName("syringe_poison").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_poison"); - syringe_awesome = new ItemSyringe().setUnlocalizedName("syringe_awesome").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_awesome"); syringe_metal_empty = new Item().setUnlocalizedName("syringe_metal_empty").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_empty"); syringe_metal_stimpak = new ItemSyringe().setUnlocalizedName("syringe_metal_stimpak").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_stimpak"); syringe_metal_medx = new ItemSyringe().setUnlocalizedName("syringe_metal_medx").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_medx"); @@ -3012,47 +3006,7 @@ public class ModItems { syringe_metal_super = new ItemSyringe().setUnlocalizedName("syringe_metal_super").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_super"); syringe_taint = new ItemSyringe().setUnlocalizedName("syringe_taint").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_taint"); syringe_mkunicorn = new ItemSyringe().setUnlocalizedName("syringe_mkunicorn").setFull3D().setCreativeTab(null).setTextureName(RefStrings.MODID + ":syringe_mkunicorn"); - - iv_empty = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - if(user.hurtResistantTime <= 0) { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.syringe", new ItemStack(ModItems.iv_blood)); - user.setHealth(Math.max(user.getHealth() - 5F, 0F)); - if(user.getHealth() <= 0) user.onDeath(DamageSource.magic); - } - }).setUnlocalizedName("iv_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_empty"); - - iv_blood = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty)); - user.heal(5F); - }).setUnlocalizedName("iv_blood").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_blood"); - - iv_xp_empty = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - if(EnchantmentUtil.getTotalExperience(user) >= 100) { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.syringe", new ItemStack(ModItems.iv_xp)); - EnchantmentUtil.setExperience(user, EnchantmentUtil.getTotalExperience(user) - 100); - } - }).setUnlocalizedName("iv_xp_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_xp_empty"); - - iv_xp = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "random.orb", new ItemStack(ModItems.iv_xp_empty)); - EnchantmentUtil.addExperience(user, 100, false); - }).setUnlocalizedName("iv_xp").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_xp"); - - radaway = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty)); - ItemSimpleConsumable.addPotionEffect(user, HbmPotion.radaway, 140, 0); - }).setUnlocalizedName("radaway").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radaway"); - - radaway_strong = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty)); - ItemSimpleConsumable.addPotionEffect(user, HbmPotion.radaway, 350, 0); - }).setUnlocalizedName("radaway_strong").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radaway_strong"); - - radaway_flush = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { - ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty)); - ItemSimpleConsumable.addPotionEffect(user, HbmPotion.radaway, 500, 2); - }).setUnlocalizedName("radaway_flush").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radaway_flush"); - + med_bag = new ItemSyringe().setUnlocalizedName("med_bag").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":med_bag"); radx = new ItemPill(0).setUnlocalizedName("radx").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radx"); siox = new ItemPill(0).setUnlocalizedName("siox").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":siox"); diff --git a/src/main/java/com/hbm/items/special/ItemSimpleConsumable.java b/src/main/java/com/hbm/items/special/ItemSimpleConsumable.java index d31a376a8..f092824f6 100644 --- a/src/main/java/com/hbm/items/special/ItemSimpleConsumable.java +++ b/src/main/java/com/hbm/items/special/ItemSimpleConsumable.java @@ -2,14 +2,23 @@ package com.hbm.items.special; import java.util.function.BiConsumer; +import com.hbm.config.VersatileConfig; import com.hbm.items.ItemCustomLore; +import com.hbm.items.ModItems; +import com.hbm.lib.ModDamageSource; +import com.hbm.lib.RefStrings; +import com.hbm.main.MainRegistry; +import com.hbm.potion.HbmPotion; +import com.hbm.util.EnchantmentUtil; import com.hbm.util.Tuple.Pair; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class ItemSimpleConsumable extends ItemCustomLore { @@ -19,6 +28,10 @@ public class ItemSimpleConsumable extends ItemCustomLore { private BiConsumer useActionServer; private BiConsumer> hitAction; private BiConsumer> hitActionServer; + + public ItemSimpleConsumable() { + this.setCreativeTab(MainRegistry.consumableTab); + } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { @@ -69,9 +82,97 @@ public class ItemSimpleConsumable extends ItemCustomLore { } } + public static void doRadaway(ItemStack stack, EntityPlayer user, int duration) { + giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty)); + addPotionEffect(user, HbmPotion.radaway, duration, 0); + } + //this formatting style probably already has a name but i will call it "the greg" public ItemSimpleConsumable setUseAction( BiConsumer delegate) { this.useAction = delegate; return this; } public ItemSimpleConsumable setUseActionServer( BiConsumer delegate) { this.useActionServer = delegate; return this; } public ItemSimpleConsumable setHitAction( BiConsumer> delegate) { this.hitAction = delegate; return this; } public ItemSimpleConsumable setHitActionServer( BiConsumer> delegate) { this.hitActionServer = delegate; return this; } + + public static void init() { + + /// SYRINGES /// + ModItems.syringe_antidote = new ItemSimpleConsumable() + .setUseActionServer((stack, user) -> { effectAntidote(stack, user, user); }).setHitActionServer((stack, pair) -> { effectAntidote(stack, pair.key, pair.value); }) + .setUnlocalizedName("syringe_antidote").setFull3D().setTextureName(RefStrings.MODID + ":syringe_antidote"); + + ModItems.syringe_poison = new ItemSimpleConsumable() + .setUseActionServer((stack, user) -> { effectPoison(stack, user, user); }).setHitActionServer((stack, pair) -> { effectPoison(stack, pair.key, pair.value); }) + .setUnlocalizedName("syringe_poison").setFull3D().setTextureName(RefStrings.MODID + ":syringe_poison"); + + ModItems.syringe_awesome = new ItemSimpleConsumable() + .setUseActionServer((stack, user) -> { effectAwesome(stack, user, user); }).setHitActionServer((stack, pair) -> { effectAwesome(stack, pair.key, pair.value); }) + .setRarity(EnumRarity.uncommon).setEffect().setUnlocalizedName("syringe_awesome").setFull3D().setTextureName(RefStrings.MODID + ":syringe_awesome"); + + /// BLOOD BAGS /// + ModItems.iv_empty = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + giveSoundAndDecrement(stack, user, "hbm:item.syringe", new ItemStack(ModItems.iv_blood)); + user.setHealth(Math.max(user.getHealth() - 5F, 0F)); + if(user.getHealth() <= 0) user.onDeath(DamageSource.magic); + }).setUnlocalizedName("iv_empty").setTextureName(RefStrings.MODID + ":iv_empty"); + + ModItems.iv_blood = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty)); + user.heal(5F); + }).setUnlocalizedName("iv_blood").setTextureName(RefStrings.MODID + ":iv_blood"); + + ModItems.iv_xp_empty = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + if(EnchantmentUtil.getTotalExperience(user) >= 100) { + giveSoundAndDecrement(stack, user, "hbm:item.syringe", new ItemStack(ModItems.iv_xp)); + EnchantmentUtil.setExperience(user, EnchantmentUtil.getTotalExperience(user) - 100); + } + }).setUnlocalizedName("iv_xp_empty").setTextureName(RefStrings.MODID + ":iv_xp_empty"); + + ModItems.iv_xp = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + giveSoundAndDecrement(stack, user, "random.orb", new ItemStack(ModItems.iv_xp_empty)); + EnchantmentUtil.addExperience(user, 100, false); + }).setUnlocalizedName("iv_xp").setTextureName(RefStrings.MODID + ":iv_xp"); + + /// RADAWAY /// + ModItems.radaway = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + doRadaway(stack, user, 140); + }).setUnlocalizedName("radaway").setTextureName(RefStrings.MODID + ":radaway"); + + ModItems.radaway_strong = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + doRadaway(stack, user, 350); + }).setUnlocalizedName("radaway_strong").setTextureName(RefStrings.MODID + ":radaway_strong"); + + ModItems.radaway_flush = new ItemSimpleConsumable().setUseActionServer((stack, user) -> { + doRadaway(stack, user, 500); + }).setUnlocalizedName("radaway_flush").setTextureName(RefStrings.MODID + ":radaway_flush"); + } + + public static void effectAntidote(ItemStack stack, EntityLivingBase affected, EntityLivingBase source) { + if(VersatileConfig.hasPotionSickness(affected)) return; + affected.clearActivePotions(); + giveSoundAndDecrement(stack, source, "hbm:item.syringe", new ItemStack(ModItems.syringe_empty)); + VersatileConfig.applyPotionSickness(affected, 5); + } + + public static void effectPoison(ItemStack stack, EntityLivingBase affected, EntityLivingBase source) { + if(affected == source) affected.attackEntityFrom(affected.getRNG().nextBoolean() ? ModDamageSource.euthanizedSelf : ModDamageSource.euthanizedSelf2, 30); + else affected.attackEntityFrom(ModDamageSource.euthanized(source, source), 30); + giveSoundAndDecrement(stack, source, "hbm:item.syringe", new ItemStack(ModItems.syringe_empty)); + } + + public static void effectAwesome(ItemStack stack, EntityLivingBase affected, EntityLivingBase source) { + if(VersatileConfig.hasPotionSickness(affected)) return; + giveSoundAndDecrement(stack, source, "hbm:item.syringe", new ItemStack(ModItems.syringe_empty)); + affected.addPotionEffect(new PotionEffect(Potion.regeneration.id, 50 * 20, 9)); + affected.addPotionEffect(new PotionEffect(Potion.resistance.id, 50 * 20, 9)); + affected.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 50 * 20, 0)); + affected.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 50 * 20, 24)); + affected.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 50 * 20, 9)); + affected.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50 * 20, 6)); + affected.addPotionEffect(new PotionEffect(Potion.jump.id, 50 * 20, 9)); + affected.addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 50 * 20, 9)); + affected.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 50 * 20, 4)); + affected.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 4)); + affected.addPotionEffect(new PotionEffect(HbmPotion.radx.id, 50 * 20, 9)); + VersatileConfig.applyPotionSickness(affected, 5); + } } diff --git a/src/main/java/com/hbm/items/special/ItemSyringe.java b/src/main/java/com/hbm/items/special/ItemSyringe.java index 2c6fd1c3f..b2c6be5b5 100644 --- a/src/main/java/com/hbm/items/special/ItemSyringe.java +++ b/src/main/java/com/hbm/items/special/ItemSyringe.java @@ -6,19 +6,15 @@ import java.util.Random; import com.hbm.config.VersatileConfig; import com.hbm.extprop.HbmLivingProps; import com.hbm.handler.ArmorModHandler; +import com.hbm.interfaces.Spaghetti; import com.hbm.inventory.fluid.Fluids; import com.hbm.items.ModItems; import com.hbm.items.weapon.ItemGunBase; -import com.hbm.lib.ModDamageSource; import com.hbm.potion.HbmPotion; import api.hbm.fluidmk2.IFillableItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; @@ -27,6 +23,7 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +@Spaghetti("fuck") public class ItemSyringe extends Item { Random rand = new Random(); @@ -34,74 +31,6 @@ public class ItemSyringe extends Item { @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(this == ModItems.syringe_antidote && !VersatileConfig.hasPotionSickness(player)) { - if(!world.isRemote) { - player.clearActivePotions(); - - stack.stackSize--; - world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); - - if(stack.stackSize <= 0) { - return new ItemStack(ModItems.syringe_empty); - } - - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); - } - - VersatileConfig.applyPotionSickness(player, 5); - } - } - - if(this == ModItems.syringe_awesome && !VersatileConfig.hasPotionSickness(player)) { - if(!world.isRemote) { - player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 50 * 20, 9)); - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 50 * 20, 9)); - player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 50 * 20, 0)); - player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 50 * 20, 24)); - player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 50 * 20, 9)); - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50 * 20, 6)); - player.addPotionEffect(new PotionEffect(Potion.jump.id, 50 * 20, 9)); - player.addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 50 * 20, 9)); - player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 50 * 20, 4)); - player.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 4)); - player.addPotionEffect(new PotionEffect(HbmPotion.radx.id, 50 * 20, 9)); - - stack.stackSize--; - world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); - - if(stack.stackSize <= 0) { - return new ItemStack(ModItems.syringe_empty); - } - - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); - } - - VersatileConfig.applyPotionSickness(player, 50); - } - } - - if(this == ModItems.syringe_poison) { - if(!world.isRemote) { - if(rand.nextInt(2) == 0) - player.attackEntityFrom(ModDamageSource.euthanizedSelf, 30); - else - player.attackEntityFrom(ModDamageSource.euthanizedSelf2, 30); - - stack.stackSize--; - world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); - - if(stack.stackSize <= 0) { - return new ItemStack(ModItems.syringe_empty); - } - - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); - } - } - } - if(this == ModItems.syringe_metal_stimpak && !VersatileConfig.hasPotionSickness(player)) { if(!world.isRemote) { player.heal(5); @@ -344,94 +273,10 @@ public class ItemSyringe extends Item { return stack; } - @Override - @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack p_77636_1_) { - if(this == ModItems.syringe_awesome) { - return true; - } - - return false; - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - if(this == ModItems.syringe_awesome) { - return EnumRarity.uncommon; - } - return EnumRarity.common; - } - @Override public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase entityPlayer) { World world = entity.worldObj; - if(this == ModItems.syringe_antidote && !VersatileConfig.hasPotionSickness(entity)) { - if(!world.isRemote) { - entity.clearActivePotions(); - VersatileConfig.applyPotionSickness(entity, 5); - - stack.stackSize--; - world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); - - if(entityPlayer instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityPlayer; - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); - } - } - } - } - - if(this == ModItems.syringe_awesome && !VersatileConfig.hasPotionSickness(entity)) { - if(!world.isRemote) { - - if(entity instanceof EntityCow) { - - entity.addPotionEffect(new PotionEffect(HbmPotion.bang.id, 40, 0)); - - } else { - entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 50 * 20, 9)); - entity.addPotionEffect(new PotionEffect(Potion.resistance.id, 50 * 20, 9)); - entity.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 50 * 20, 0)); - entity.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 50 * 20, 24)); - entity.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 50 * 20, 9)); - entity.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50 * 20, 6)); - entity.addPotionEffect(new PotionEffect(Potion.jump.id, 50 * 20, 9)); - entity.addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 50 * 20, 9)); - entity.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 50 * 20, 4)); - entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 4)); - VersatileConfig.applyPotionSickness(entity, 50); - } - - stack.stackSize--; - world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); - - if(entityPlayer instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityPlayer; - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); - } - } - } - } - - if(this == ModItems.syringe_poison) { - if(!world.isRemote) { - entity.attackEntityFrom(ModDamageSource.euthanized(entityPlayer, entityPlayer), 30); - - stack.stackSize--; - world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); - - if(entityPlayer instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityPlayer; - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); - } - } - } - } - if(this == ModItems.syringe_metal_stimpak && !VersatileConfig.hasPotionSickness(entity)) { if(!world.isRemote) { entity.heal(5); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java index 6fa22c67c..b81318b02 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java @@ -143,7 +143,7 @@ public class XFactoryEnergy { ).setUnlocalizedName("gun_tesla_cannon"); ModItems.gun_laser_pistol = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig() - .dura(2_000).draw(10).inspect(26).crosshair(Crosshair.CIRCLE).scopeTexture(scope_luna) + .dura(2_000).draw(10).inspect(26).crosshair(Crosshair.CIRCLE) .rec(new Receiver(0) .dmg(50F).delay(8).spread(1F).spreadHipfire(2.5F).reload(44).jam(36).sound("hbm:weapon.fire.laser", 1.0F, 1.0F) .mag(new MagazineFullReload(0, 30).addConfigs(energy_las, energy_las_overcharge, energy_las_ir)) diff --git a/src/main/java/com/hbm/lib/Library.java b/src/main/java/com/hbm/lib/Library.java index e64f3cc36..e0d5217cb 100644 --- a/src/main/java/com/hbm/lib/Library.java +++ b/src/main/java/com/hbm/lib/Library.java @@ -233,11 +233,11 @@ public class Library { //not great either but certainly better public static long chargeItemsFromTE(ItemStack[] slots, int index, long power, long maxPower) { - if(power < 0) - return 0; - - if(power > maxPower) - return maxPower; + if(power < 0) return 0; + if(power > maxPower) return maxPower; + + if(slots[index] != null && slots[index].getItem() == ModItems.battery_creative) return 0; + if(slots[index] != null && slots[index].getItem() == ModItems.fusion_core_infinite) return 0; if(slots[index] != null && slots[index].getItem() instanceof IBatteryItem) { @@ -258,13 +258,8 @@ public class Library { public static long chargeTEFromItems(ItemStack[] slots, int index, long power, long maxPower) { - if(slots[index] != null && slots[index].getItem() == ModItems.battery_creative) { - return maxPower; - } - - if(slots[index] != null && slots[index].getItem() == ModItems.fusion_core_infinite) { - return maxPower; - } + if(slots[index] != null && slots[index].getItem() == ModItems.battery_creative) return maxPower; + if(slots[index] != null && slots[index].getItem() == ModItems.fusion_core_infinite) return maxPower; if(slots[index] != null && slots[index].getItem() instanceof IBatteryItem) { diff --git a/src/main/java/com/hbm/module/ModuleRichTooltip.java b/src/main/java/com/hbm/module/ModuleRichTooltip.java deleted file mode 100644 index 62eb1dd40..000000000 --- a/src/main/java/com/hbm/module/ModuleRichTooltip.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.hbm.module; - -import java.util.Iterator; -import java.util.List; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import com.hbm.inventory.gui.GuiInfoContainer; - -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -public class ModuleRichTooltip { - - private GuiInfoContainer gui; - - protected int colorBg = 0xF0100010; - protected int color0 = 0x505000FF; - protected int color1 = (color0 & 0xFEFEFE) >> 1 | color0 & 0xFF000000; - - public ModuleRichTooltip(GuiInfoContainer gui) { - this.gui = gui; - } - - public ModuleRichTooltip setBG(int colorBg) { - this.colorBg = colorBg; - return this; - } - - public ModuleRichTooltip setColors(int color0, int color1) { - this.color0 = color0; - this.color1 = color1; - return this; - } - - protected void drawStackText(List lines, int x, int y, FontRenderer font) { - - if(!lines.isEmpty()) { - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - int height = 0; - int longestline = 0; - Iterator iterator = lines.iterator(); - - while(iterator.hasNext()) { - Object[] line = (Object[]) iterator.next(); - int lineWidth = 0; - - boolean hasStack = false; - - for(Object o : line) { - - if(o instanceof String) { - lineWidth += font.getStringWidth((String) o); - } else { - lineWidth += 18; - hasStack = true; - } - } - - if(hasStack) { - height += 18; - } else { - height += 10; - } - - if(lineWidth > longestline) { - longestline = lineWidth; - } - } - - int minX = x + 12; - int minY = y - 12; - - if(minX + longestline > gui.width) { - minX -= 28 + longestline; - } - - if(minY + height + 6 > gui.height) { - minY = gui.height - height - 6; - } - - gui.setZLevel(300F); - gui.getItemRenderer().zLevel = 300.0F; - - this.drawGradientRect(minX - 3, minY - 4, minX + longestline + 3, minY - 3, colorBg, colorBg); - this.drawGradientRect(minX - 3, minY + height + 3, minX + longestline + 3, minY + height + 4, colorBg, colorBg); - this.drawGradientRect(minX - 3, minY - 3, minX + longestline + 3, minY + height + 3, colorBg, colorBg); - this.drawGradientRect(minX - 4, minY - 3, minX - 3, minY + height + 3, colorBg, colorBg); - this.drawGradientRect(minX + longestline + 3, minY - 3, minX + longestline + 4, minY + height + 3, colorBg, colorBg); - - this.drawGradientRect(minX - 3, minY - 3 + 1, minX - 3 + 1, minY + height + 3 - 1, color0, color1); - this.drawGradientRect(minX + longestline + 2, minY - 3 + 1, minX + longestline + 3, minY + height + 3 - 1, color0, color1); - this.drawGradientRect(minX - 3, minY - 3, minX + longestline + 3, minY - 3 + 1, color0, color0); - this.drawGradientRect(minX - 3, minY + height + 2, minX + longestline + 3, minY + height + 3, color1, color1); - - for(int index = 0; index < lines.size(); ++index) { - - Object[] line = (Object[]) lines.get(index); - int indent = 0; - boolean hasStack = false; - - for(Object o : line) { - if(!(o instanceof String)) { - hasStack = true; - } - } - - for(Object o : line) { - - if(o instanceof String) { - font.drawStringWithShadow((String) o, minX + indent, minY + (hasStack ? 4 : 0), -1); - indent += font.getStringWidth((String) o) + 2; - } else { - ItemStack stack = (ItemStack) o; - GL11.glColor3f(1F, 1F, 1F); - gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), gui.mc.getTextureManager(), stack, minX + indent, minY); - gui.getItemRenderer().renderItemOverlayIntoGUI(gui.getFontRenderer(), gui.mc.getTextureManager(), stack, minX + indent, minY, stack.stackSize == 0 ? (EnumChatFormatting.RED + "_ _") : null); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_DEPTH_TEST); - indent += 18; - } - } - - if(index == 0) { - minY += 2; - } - - minY += hasStack ? 18 : 10; - } - - gui.setZLevel(0F); - gui.getItemRenderer().zLevel = 0.0F; - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - RenderHelper.enableStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - } - } - - protected void drawGradientRect(int minX, int minY, int maxX, int maxY, int colorTop, int colorBottom) { - float zLevel = gui.getZLevel(); - float topA = (float) (colorTop >> 24 & 255) / 255.0F; - float topR = (float) (colorTop >> 16 & 255) / 255.0F; - float topG = (float) (colorTop >> 8 & 255) / 255.0F; - float topB = (float) (colorTop & 255) / 255.0F; - float bottomA = (float) (colorBottom >> 24 & 255) / 255.0F; - float bottomR = (float) (colorBottom >> 16 & 255) / 255.0F; - float bottomG = (float) (colorBottom >> 8 & 255) / 255.0F; - float bottomB = (float) (colorBottom & 255) / 255.0F; - - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glShadeModel(GL11.GL_SMOOTH); - - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(topR, topG, topB, topA); - tessellator.addVertex((double) maxX, (double) minY, (double) zLevel); - tessellator.addVertex((double) minX, (double) minY, (double) zLevel); - tessellator.setColorRGBA_F(bottomR, bottomG, bottomB, bottomA); - tessellator.addVertex((double) minX, (double) maxY, (double) zLevel); - tessellator.addVertex((double) maxX, (double) maxY, (double) zLevel); - tessellator.draw(); - - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - public static class TooltipLine { - - protected int contentHeight = 0; - } -} diff --git a/src/main/java/com/hbm/test/ExplosionTests.java b/src/main/java/com/hbm/test/ExplosionTests.java deleted file mode 100644 index bbc3dcd78..000000000 --- a/src/main/java/com/hbm/test/ExplosionTests.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.hbm.test; - -import com.hbm.test.MK5Frame.BufferArray; -import com.hbm.test.MK5Frame.BufferMap; -import com.hbm.test.MK5Frame.BufferNone; -import com.hbm.util.TimeAnalyzer; -import cpw.mods.fml.common.FMLCommonHandler; - -public class ExplosionTests { - - private static ExplosionWorld world = new ExplosionWorld(); - public static double BUFFER_THRESHOLD = 0.25D; - - public static void runTest() { - - int standardSpeed = (int)Math.ceil(100000 / 300); - - double[] thresholds = new double[] {0.25, 0.5}; - int[] radii = new int[] {100, 250}; - - int x = 200; - int y = 70; - int z = 200; - long mem = 0; - - for(int radius : radii) { - - int strength = radius * 2; - int length = radius; - - System.gc(); - mem = getMem(); - System.out.println("#### STARTING TEST WITH NO PROXIMITY BUFFER " + radius + " ####"); - MK5Frame noBuf = new MK5Frame(world, x, y, z, strength, length).setBuffer(new BufferNone()); - while(!noBuf.isCollectionComplete) noBuf.collectTip(standardSpeed * 10); - while(noBuf.perChunk.size() > 0) noBuf.processChunk(); - TimeAnalyzer.endCount(); - TimeAnalyzer.dump(); - System.out.println("Mem diff: " + ((getMem() - mem) / 1_048_576) + "MB"); - - for(double threshold : thresholds) { - BUFFER_THRESHOLD = threshold; - - System.gc(); - mem = getMem(); - System.out.println("#### STARTING TEST WITH MAP-BASED PROXIMITY BUFFER " + radius + " / " + threshold + " ####"); - MK5Frame mapBuf = new MK5Frame(world, x, y, z, strength, length).setBuffer(new BufferMap()); - while(!mapBuf.isCollectionComplete) mapBuf.collectTip(standardSpeed * 10); - while(mapBuf.perChunk.size() > 0) mapBuf.processChunk(); - TimeAnalyzer.endCount(); - TimeAnalyzer.dump(); - System.out.println("Mem diff: " + ((getMem() - mem) / 1_048_576) + "MB"); - - System.gc(); - mem = getMem(); - System.out.println("#### STARTING TEST WITH ARRAY PROXIMITY BUFFER " + radius + " / " + threshold + " ####"); - MK5Frame arrayBuf = new MK5Frame(world, x, y, z, strength, length).setBuffer(new BufferArray(x, y, z, (int) (length))); - while(!arrayBuf.isCollectionComplete) arrayBuf.collectTip(standardSpeed * 10); - while(arrayBuf.perChunk.size() > 0) arrayBuf.processChunk(); - TimeAnalyzer.endCount(); - TimeAnalyzer.dump(); - System.out.println("Mem diff: " + ((getMem() - mem) / 1_048_576) + "MB"); - } - } - - FMLCommonHandler.instance().exitJava(0, true); - } - - public static long getMem() { - return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - } -} diff --git a/src/main/java/com/hbm/test/ExplosionWorld.java b/src/main/java/com/hbm/test/ExplosionWorld.java deleted file mode 100644 index 469090d9b..000000000 --- a/src/main/java/com/hbm/test/ExplosionWorld.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hbm.test; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; - -public class ExplosionWorld { - - //public Block[][][] blocks = new Block[500][256][500]; - - public void setBlock(int x, int y, int z, Block block) { - long nanos = System.nanoTime(); - while(System.nanoTime() < nanos + 30_000); - } //NOP - - public Block getBlock(int x, int y, int z) { - long nanos = System.nanoTime(); - while(System.nanoTime() < nanos + 1_000); - if(y == 0) return Blocks.bedrock; - if(y < 50) return Blocks.stone; - if(y < 64) return Blocks.dirt; - - return Blocks.air; - } - - public boolean isAirBlock(int x, int y, int z) { - return getBlock(x, y, z) == Blocks.air; - } -} diff --git a/src/main/java/com/hbm/test/MK5Frame.java b/src/main/java/com/hbm/test/MK5Frame.java deleted file mode 100644 index 383ecc043..000000000 --- a/src/main/java/com/hbm/test/MK5Frame.java +++ /dev/null @@ -1,290 +0,0 @@ -package com.hbm.test; - -import com.hbm.util.TimeAnalyzer; -import com.hbm.util.fauxpointtwelve.BlockPos; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.Vec3; -import net.minecraft.world.ChunkCoordIntPair; - -import java.util.*; - -public class MK5Frame { - - public HashMap> perChunk = new HashMap(); //for future: optimize blockmap further by using sub-chunks instead of chunks - public List orderedChunks = new ArrayList(); - private CoordComparator comparator = new CoordComparator(); - int posX; - int posY; - int posZ; - ExplosionWorld world; - - int strength; - int length; - - int gspNumMax; - int gspNum; - double gspX; - double gspY; - - public boolean isCollectionComplete = false; - - public MK5Frame(ExplosionWorld world, int x, int y, int z, int strength, int length) { - this.world = world; - this.posX = x; - this.posY = y; - this.posZ = z; - this.strength = strength; - this.length = length; - - // Total number of points - this.gspNumMax = (int)(2.5 * Math.PI * Math.pow(this.strength,2)); - this.gspNum = 1; - - // The beginning of the generalized spiral points - this.gspX = Math.PI; - this.gspY = 0.0; - } - - private void generateGspUp(){ - - if (this.gspNum < this.gspNumMax) { - int k = this.gspNum + 1; - double hk = -1.0 + 2.0 * (k - 1.0) / (this.gspNumMax - 1.0); - this.gspX = Math.acos(hk); - - double prev_lon = this.gspY; - double lon = prev_lon + 3.6 / Math.sqrt(this.gspNumMax) / Math.sqrt(1.0 - hk * hk); - this.gspY = lon % (Math.PI * 2); - } else { - this.gspX = 0.0; - this.gspY = 0.0; - } - this.gspNum++; - } - - // Get Cartesian coordinates for spherical coordinates - private Vec3 getSpherical2cartesian(){ - double dx = Math.sin(this.gspX) * Math.cos(this.gspY); - double dz = Math.sin(this.gspX) * Math.sin(this.gspY); - double dy = Math.cos(this.gspX); - return Vec3.createVectorHelper(dx, dy, dz); - } - - public void collectTip(int count) { - - TimeAnalyzer.startCount("collect"); - - int amountProcessed = 0; - - while (this.gspNumMax >= this.gspNum){ - // Get Cartesian coordinates for spherical coordinates - Vec3 vec = this.getSpherical2cartesian(); - - int length = (int)Math.ceil(strength); - float res = strength; - - FloatTriplet lastPos = null; - HashSet chunkCoords = new HashSet(); - - for(int i = 0; i < length; i ++) { - - if(i > this.length) - break; - - float x0 = (float) (posX + (vec.xCoord * i)); - float y0 = (float) (posY + (vec.yCoord * i)); - float z0 = (float) (posZ + (vec.zCoord * i)); - - int iX = (int) Math.floor(x0); - int iY = (int) Math.floor(y0); - int iZ = (int) Math.floor(z0); - - double fac = 100 - ((double) i) / ((double) length) * 100; - fac *= 0.07D; - - Block block = null; - boolean withinThreshold = (double) i / (double) length <= ExplosionTests.BUFFER_THRESHOLD; - - Float buffered = withinThreshold ? buffer.getBufferedResult(iX, iY, iZ) : null; - - float f = 0; - - if(buffered == null) { - - block = world.getBlock(iX, iY, iZ); - - if(!block.getMaterial().isLiquid()) { - f = (float) Math.pow(block.getExplosionResistance(null), 7.5D - fac); - } - - if(withinThreshold) buffer.setBufferedResult(iX, iY, iZ, f); - - } else { - f = buffered; - } - - res -= f; - - if(res > 0 && block != Blocks.air && buffered == null) { // if we already have a buffered result we don't need to move the tip forward since that block is already affected - lastPos = new FloatTriplet(x0, y0, z0); - //all-air chunks don't need to be buffered at all - ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(iX >> 4, iZ >> 4); - chunkCoords.add(chunkPos); - } - - if(res <= 0 || i + 1 >= this.length) { - break; - } - } - - for(ChunkCoordIntPair pos : chunkCoords) { - List triplets = perChunk.get(pos); - - if(triplets == null) { - triplets = new ArrayList(); - perChunk.put(pos, triplets); //we re-use the same pos instead of using individualized per-chunk ones to save on RAM - } - - triplets.add(lastPos); - } - - // Raise one generalized spiral points - this.generateGspUp(); - - amountProcessed++; - if(amountProcessed >= count) { - TimeAnalyzer.endCount(); - return; - } - } - - orderedChunks.addAll(perChunk.keySet()); - orderedChunks.sort(comparator); - - isCollectionComplete = true; - TimeAnalyzer.endCount(); - } - - /* TEST INSERT START */ - private ResultBuffer buffer; - public MK5Frame setBuffer(ResultBuffer buffer) { - this.buffer = buffer; - return this; - } - public static interface ResultBuffer { - Float getBufferedResult(int x, int y, int z); - void setBufferedResult(int x, int y, int z, float f); - } - public static class BufferNone implements ResultBuffer { - @Override public Float getBufferedResult(int x, int y, int z) { return null; } - @Override public void setBufferedResult(int x, int y, int z, float f) { } - } - public static class BufferMap implements ResultBuffer { - HashMap map = new HashMap(); - @Override public Float getBufferedResult(int x, int y, int z) { if(y < 0 || y > 255) return null; return map.get(new BlockPos(x, y, z)); } - @Override public void setBufferedResult(int x, int y, int z, float f) { if(y < 0 || y > 255) return; map.put(new BlockPos(x, y, z), f); } - } - public static class BufferArray implements ResultBuffer { - BlockPos center; Float[][][] buffer; int size; public BufferArray(int x, int y, int z, int size) { this.size = (int) (size * 2.1); center = new BlockPos(x, y, z); buffer = new Float[this.size][256][this.size];} - HashMap map = new HashMap(); - @Override public Float getBufferedResult(int x, int y, int z) { - if(y < 0 || y > 255) return null; - int iX = x - center.getX() + size * 100; int iZ = z - center.getZ() + size * 100; - return buffer[iX % size][y][iZ % size]; - } - @Override public void setBufferedResult(int x, int y, int z, float f) { - if(y < 0 || y > 255) return; - int iX = x - center.getX() + size * 100; int iZ = z - center.getZ() + size * 100; - buffer[iX % size][y][iZ % size] = f; - } - } - /* TEST INSERT END */ - - /** little comparator for roughly sorting chunks by distance to the center */ - public class CoordComparator implements Comparator { - - @Override - public int compare(ChunkCoordIntPair o1, ChunkCoordIntPair o2) { - - int chunkX = MK5Frame.this.posX >> 4; - int chunkZ = MK5Frame.this.posZ >> 4; - - int diff1 = Math.abs((chunkX - o1.chunkXPos)) + Math.abs((chunkZ - o1.chunkZPos)); - int diff2 = Math.abs((chunkX - o2.chunkXPos)) + Math.abs((chunkZ - o2.chunkZPos)); - - return diff1 > diff2 ? 1 : diff1 < diff2 ? -1 : 0; - } - } - - public void processChunk() { - - TimeAnalyzer.startCount("processChunk"); - if(this.perChunk.isEmpty()) { - TimeAnalyzer.endCount(); - return; - } - - ChunkCoordIntPair coord = orderedChunks.get(0); - List list = perChunk.get(coord); - HashSet toRem = new HashSet(); - int chunkX = coord.chunkXPos; - int chunkZ = coord.chunkZPos; - - int enter = (int) (Math.min( - Math.abs(posX - (chunkX << 4)), - Math.abs(posZ - (chunkZ << 4)))) - 16; //jump ahead to cut back on NOPs - - for(FloatTriplet triplet : list) { - float x = triplet.xCoord; - float y = triplet.yCoord; - float z = triplet.zCoord; - Vec3 vec = Vec3.createVectorHelper(x - this.posX, y - this.posY, z - this.posZ); - double pX = vec.xCoord / vec.lengthVector(); - double pY = vec.yCoord / vec.lengthVector(); - double pZ = vec.zCoord / vec.lengthVector(); - - boolean inChunk = false; - for(int i = enter; i < vec.lengthVector(); i++) { - int x0 = (int) Math.floor(posX + pX * i); - int y0 = (int) Math.floor(posY + pY * i); - int z0 = (int) Math.floor(posZ + pZ * i); - - if(x0 >> 4 != chunkX || z0 >> 4 != chunkZ) { - if(inChunk) { - break; - } else { - continue; - } - } - - inChunk = true; - - if(!world.isAirBlock(x0, y0, z0)) { - toRem.add(new BlockPos(x0, y0, z0)); - } - } - } - - for(BlockPos pos : toRem) { - world.setBlock(pos.getX(), pos.getY(), pos.getZ(), Blocks.air); - } - - perChunk.remove(coord); - orderedChunks.remove(0); - - TimeAnalyzer.endCount(); - } - - public class FloatTriplet { - public float xCoord; - public float yCoord; - public float zCoord; - - public FloatTriplet(float x, float y, float z) { - xCoord = x; - yCoord = y; - zCoord = z; - } - } -} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineDiesel.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineDiesel.java index d8907f333..1734850fb 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineDiesel.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineDiesel.java @@ -233,6 +233,8 @@ public class TileEntityMachineDiesel extends TileEntityMachinePolluting implemen public void generate() { + if(this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) return; + if(hasAcceptableFuel()) { if (tank.getFill() > 0) { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java index bab03ab96..250875829 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java @@ -162,21 +162,32 @@ public class TileEntityMachineTurbofan extends TileEntityMachinePolluting implem long burnValue = 0; int amount = 1 + this.afterburner; - - if(tank.getTankType().hasTrait(FT_Combustible.class) && tank.getTankType().getTrait(FT_Combustible.class).getGrade() == FuelGrade.AERO) { - burnValue = tank.getTankType().getTrait(FT_Combustible.class).getCombustionEnergy() / 1_000; - } - int amountToBurn = Math.min(amount, this.tank.getFill()); - - if(amountToBurn > 0) { - this.wasOn = true; - this.tank.setFill(this.tank.getFill() - amountToBurn); - this.output = (int) (burnValue * amountToBurn * (1 + Math.min(this.afterburner / 3D, 4))); - this.power += this.output; - this.consumption = amountToBurn; - - if(worldObj.getTotalWorldTime() % 20 == 0) super.pollute(tank.getTankType(), FluidTrait.FluidReleaseType.BURN, amountToBurn * 5);; + + boolean redstone = false; + + for(DirPos pos : getConPos()) { + if(this.worldObj.isBlockIndirectlyGettingPowered(pos.getX(), pos.getY(), pos.getZ())) { + redstone = true; + break; + } + } + + if(!redstone) { + + if(tank.getTankType().hasTrait(FT_Combustible.class) && tank.getTankType().getTrait(FT_Combustible.class).getGrade() == FuelGrade.AERO) { + burnValue = tank.getTankType().getTrait(FT_Combustible.class).getCombustionEnergy() / 1_000; + } + + if(amountToBurn > 0) { + this.wasOn = true; + this.tank.setFill(this.tank.getFill() - amountToBurn); + this.output = (int) (burnValue * amountToBurn * (1 + Math.min(this.afterburner / 3D, 4))); + this.power += this.output; + this.consumption = amountToBurn; + + if(worldObj.getTotalWorldTime() % 20 == 0) super.pollute(tank.getTankType(), FluidTrait.FluidReleaseType.BURN, amountToBurn * 5);; + } } power = Library.chargeItemsFromTE(slots, 3, power, power);