diff --git a/changelog b/changelog index 1e3e818a7..bb000ef7e 100644 --- a/changelog +++ b/changelog @@ -14,6 +14,9 @@ * This means that a chemical factory can make hydrogen peroxide, sulfuric acid and nitric acid, and the only fluid input needed is water * Paintable exhaust pipe * Full block exhaust pipe that behaves like paintable cables and ducts +* Rangefinder + * A simple tool for checking the distance to a block + * Is now used as the base ingredient for long range target designatory, artillery remotes and airstrike designators ## Changed * Updated chinese and ukrainian localizations @@ -44,6 +47,8 @@ * Open doors can now be interacted through * Area abilities on tools now drop all mined blocks in the center * Tools with AoE now come with the new "flat AoE" ability, which is the same but the area is only 1 block tall +* Atomic airstrike now requires a control unit +* Parallelized explosions have been temporarily disabled, regardless of config option, explosions will use the previous system ## Fixed * Chemical plant ports. For real this time. @@ -62,3 +67,4 @@ * Replaced paintabble cables in the lighthouse with regular ones, fixing an issue where the paint would ID shift * Fixed light blocks being considered solid for NPC pathfinding * Fixed issue regarding locked slots when using crates +* Fixed MK3 explosions crashing when spawned with invalid size or when not being deserialized correctly diff --git a/gradle.properties b/gradle.properties index 17c61bd4b..da72d22ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_version=1.0.27 # Empty build number makes a release type -mod_build_number=5357 +mod_build_number=5377 credits=HbMinecraft,\ \ rodolphito (explosion algorithms),\ diff --git a/src/main/java/com/hbm/blocks/BlockDummyable.java b/src/main/java/com/hbm/blocks/BlockDummyable.java index 9508350b5..19c33db65 100644 --- a/src/main/java/com/hbm/blocks/BlockDummyable.java +++ b/src/main/java/com/hbm/blocks/BlockDummyable.java @@ -77,27 +77,20 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl super.onNeighborBlockChange(world, x, y, z, block); - if(world.isRemote || safeRem) + if(safeRem) return; - int metadata = world.getBlockMetadata(x, y, z); - - // if it's an extra, remove the extra-ness - if(metadata >= extra) - metadata -= extra; - - ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite(); - Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - - if(b != this) { - world.setBlockToAir(x, y, z); - } + destroyIfOrphan(world, x, y, z); } public void updateTick(World world, int x, int y, int z, Random rand) { super.updateTick(world, x, y, z, rand); + destroyIfOrphan(world, x, y, z); + } + + private void destroyIfOrphan(World world, int x, int y, int z) { if(world.isRemote) return; @@ -110,10 +103,32 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite(); Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - if(b != this) { - world.setBlockToAir(x, y, z); + // An extra precaution against multiblocks on chunk borders being erroneously deleted. + // Technically, this might be used to persist ghost dummy blocks by manipulating + // loaded chunks and block destruction, but this gives no benefit to the player, + // cannot be done accidentally, and is definitely preferable to multiblocks + // just vanishing when their chunks are unloaded in an unlucky way. + if(b != this && world.checkChunksExist(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)) { + if (isLegacyMonoblock(world, x, y, z)) { + fixLegacyMonoblock(world, x, y, z); + } else { + world.setBlockToAir(x, y, z); + } } + } + // Override this when turning a single block into a pseudo-multiblock. + // If this returns true, instead of being deleted as an orphan, the block + // will be promoted to a core of a dummyable, however without any dummies. + // This is only called if the block is presumed an orphan, so you don't + // need to check that here. + protected boolean isLegacyMonoblock(World world, int x, int y, int z) { + return false; + } + + protected void fixLegacyMonoblock(World world, int x, int y, int z) { + // Promote to a lone core block with the same effective rotation as before the change + world.setBlockMetadataWithNotify(x, y, z, offset + world.getBlockMetadata(x, y, z), 3); } public int[] findCore(World world, int x, int y, int z) { diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index 465ea6c69..82eb6d89f 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -1,129 +1,80 @@ package com.hbm.blocks.machine; -import java.util.Random; - -import com.hbm.main.MainRegistry; +import com.hbm.blocks.BlockDummyable; +import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachineEPress; -import com.hbm.world.gen.INBTTransformable; -import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; +import api.hbm.block.IToolable; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; -public class MachineEPress extends BlockContainer implements INBTTransformable { +public class MachineEPress extends BlockDummyable implements IToolable { - private final Random field_149933_a = new Random(); - private static boolean keepInventory; - - public MachineEPress(Material p_i45386_1_) { - super(p_i45386_1_); + public MachineEPress(Material mat) { + super(mat); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileEntityMachineEPress(); + public TileEntity createNewTileEntity(World world, int meta) { + if(meta >= 12) return new TileEntityMachineEPress(); + if(meta >= 6) return new TileEntityProxyCombo(true, false, false); + return null; } @Override - public int getRenderType() { - return -1; + public int[] getDimensions() { + return new int[] {2, 0, 0, 0, 0, 0}; } @Override - public boolean isOpaqueCube() { - return false; + public int getOffset() { + return 0; } @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { - if(!keepInventory) { - ISidedInventory tileentityfurnace = (ISidedInventory) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - - if(tileentityfurnace != null) { - for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) { - ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); - - if(itemstack != null) { - float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - - while(itemstack.stackSize > 0) { - int j1 = this.field_149933_a.nextInt(21) + 10; - - if(j1 > itemstack.stackSize) { - j1 = itemstack.stackSize; - } - - itemstack.stackSize -= j1; - EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - - if(itemstack.hasTagCompound()) { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3; - entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3; - p_149749_1_.spawnEntityInWorld(entityitem); - } - } - } - - p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); - } - } - - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + protected boolean isLegacyMonoblock(World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + return te != null && te instanceof TileEntityMachineEPress; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { - int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - - if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2); - if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2); - if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2); - if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2); + super.onBlockPlacedBy(world, x, y, z, player, itemStack); if(itemStack.hasDisplayName()) { - ((TileEntityMachineEPress) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); + int[] pos = this.findCore(world, x, y, z); + if(pos != null) { + TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(pos[0], pos[1], pos[2]); + if(entity != null) { + entity.setCustomName(itemStack.getDisplayName()); + } + } } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if(world.isRemote) { - return true; - } else if(!player.isSneaking()) { - TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(x, y, z); - if(entity != null) { - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); - } - return true; - } else { - return false; - } + return this.standardOpenBehavior(world, x, y, z, player, 0); } + // Un-multiblickable with a hand drill for schenanigans @Override - public int transformMeta(int meta, int coordBaseMode) { - return INBTTransformable.transformMetaDeco(meta, coordBaseMode); + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + + if (tool != ToolType.HAND_DRILL) + return false; + + int meta = world.getBlockMetadata(x, y, z); + if (meta >= 12) + return false; + + safeRem = true; + world.setBlockToAir(x, y, z); + safeRem = false; + return true; } } \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index a28d22172..b02f3dab8 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -1,105 +1,64 @@ package com.hbm.blocks.machine; -import java.util.Random; - -import com.hbm.main.MainRegistry; +import com.hbm.blocks.BlockDummyable; +import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachinePress; -import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; + +import api.hbm.block.IToolable; import net.minecraft.block.material.Material; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class MachinePress extends BlockContainer { - - private final Random field_149933_a = new Random(); - private static boolean keepInventory; +public class MachinePress extends BlockDummyable implements IToolable { - public MachinePress(Material p_i45386_1_) { - super(p_i45386_1_); + public MachinePress(Material mat) { + super(mat); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileEntityMachinePress(); + public TileEntity createNewTileEntity(World world, int meta) { + if(meta >= 12) return new TileEntityMachinePress(); + if(meta >= 6) return new TileEntityProxyCombo(true, false, false); + return null; } @Override - public int getRenderType() { - return -1; + public int[] getDimensions() { + return new int[] {2, 0, 0, 0, 0, 0}; } @Override - public boolean isOpaqueCube() { - return false; + public int getOffset() { + return 0; } @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { - if(!keepInventory) { - TileEntityMachinePress tileentityfurnace = (TileEntityMachinePress) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - - if(tileentityfurnace != null) { - for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) { - ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); - - if(itemstack != null) { - float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - - while(itemstack.stackSize > 0) { - int j1 = this.field_149933_a.nextInt(21) + 10; - - if(j1 > itemstack.stackSize) { - j1 = itemstack.stackSize; - } - - itemstack.stackSize -= j1; - EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - - if(itemstack.hasTagCompound()) { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3; - entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3; - p_149749_1_.spawnEntityInWorld(entityitem); - } - } - } - - p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); - } - } - - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + protected boolean isLegacyMonoblock(World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + return te != null && te instanceof TileEntityMachinePress; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if(world.isRemote) { - return true; - } else if(!player.isSneaking()) { - TileEntityMachinePress entity = (TileEntityMachinePress) world.getTileEntity(x, y, z); - if(entity != null) { - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); - } - return true; - } else { - return false; - } + return this.standardOpenBehavior(world, x, y, z, player, 0); } + + // Un-multiblickable with a hand drill for schenanigans + @Override + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + + if (tool != ToolType.HAND_DRILL) + return false; + + int meta = world.getBlockMetadata(x, y, z); + if (meta >= 12) + return false; + + safeRem = true; + world.setBlockToAir(x, y, z); + safeRem = false; + return true; + } + } diff --git a/src/main/java/com/hbm/crafting/ConsumableRecipes.java b/src/main/java/com/hbm/crafting/ConsumableRecipes.java index a64f9759c..8d867f56e 100644 --- a/src/main/java/com/hbm/crafting/ConsumableRecipes.java +++ b/src/main/java/com/hbm/crafting/ConsumableRecipes.java @@ -27,11 +27,11 @@ public class ConsumableRecipes { public static void register() { //Airstikes - CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 0), new Object[] { "TTT", "TRT", "TTT", 'T', Blocks.tnt, 'R', ModItems.detonator_laser }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 1), new Object[] { "TTT", "TRT", "TTT", 'T', ModItems.grenade_gascan, 'R', ModItems.detonator_laser }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 2), new Object[] { "TTT", "TRT", "TTT", 'T', ModItems.pellet_gas, 'R', ModItems.detonator_laser }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 3), new Object[] { "TRT", 'T', ModItems.grenade_cloud, 'R', ModItems.detonator_laser }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 4), new Object[] { "TR", 'T', DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.NUKE_HIGH), 'R', ModItems.detonator_laser }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 0), new Object[] { "TTT", "TRT", "TTT", 'T', Blocks.tnt, 'R', ModItems.rangefinder }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 1), new Object[] { "TTT", "TRT", "TTT", 'T', ModItems.grenade_gascan, 'R', ModItems.rangefinder }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 2), new Object[] { "TTT", "TRT", "TTT", 'T', ModItems.pellet_gas, 'R', ModItems.rangefinder }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 3), new Object[] { "TRT", 'T', ModItems.grenade_cloud, 'R', ModItems.rangefinder }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_caller, 1, 4), new Object[] { "TRC", 'T', DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.NUKE_HIGH), 'R', ModItems.rangefinder, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CONTROLLER) }); //Food CraftingManager.addRecipeAuto(new ItemStack(ModItems.bomb_waffle, 1), new Object[] { "WEW", "MPM", "WEW", 'W', Items.wheat, 'E', Items.egg, 'M', Items.milk_bucket, 'P', ModItems.man_core }); diff --git a/src/main/java/com/hbm/crafting/ToolRecipes.java b/src/main/java/com/hbm/crafting/ToolRecipes.java index 26a04b5fe..39c00cde5 100644 --- a/src/main/java/com/hbm/crafting/ToolRecipes.java +++ b/src/main/java/com/hbm/crafting/ToolRecipes.java @@ -112,10 +112,11 @@ public class ToolRecipes { CraftingManager.addRecipeAuto(new ItemStack(ModItems.ullapool_caber, 1), new Object[] { "ITI", " S ", " S ", 'I', IRON.plate(), 'T', Blocks.tnt, 'S', KEY_STICK }); //Utility + CraftingManager.addRecipeAuto(new ItemStack(ModItems.rangefinder, 1), new Object[] { "GRC", " S", 'G', KEY_ANYPANE, 'R', REDSTONE.dust(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'S' ,STEEL.plate() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.designator, 1), new Object[] { " A", "#B#", "#B#", '#', IRON.plate(), 'A', STEEL.plate(), 'B', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC) }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.designator_range, 1), new Object[] { "RRD", "PIC", " P", 'P', STEEL.plate(), 'R', Items.redstone, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'D', ModItems.designator, 'I', STEEL.ingot() }); + CraftingManager.addShapelessAuto(new ItemStack(ModItems.designator_range, 1), new Object[] { ModItems.rangefinder, ModItems.designator, ANY_PLASTIC.ingot() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.designator_manual, 1), new Object[] { " A", "#C#", "#B#", '#', ANY_PLASTIC.ingot(), 'A', PB.plate(), 'B', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'C', ModItems.designator }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.designator_arty_range, 1), new Object[] { "M", "C", "P", 'M', ModItems.magnetron, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'P', ANY_PLASTIC.ingot() }); + CraftingManager.addShapelessAuto(new ItemStack(ModItems.designator_arty_range, 1), new Object[] { ModItems.rangefinder, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), ANY_PLASTIC.ingot() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.linker, 1), new Object[] { "I I", "ICI", "GGG", 'I', IRON.plate(), 'G', GOLD.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED) }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.oil_detector, 1), new Object[] { "W I", "WCI", "PPP", 'W', GOLD.wireFine(), 'I', CU.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG), 'P', STEEL.plate528() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.turret_chip, 1), new Object[] { "WWW", "CPC", "WWW", 'W', GOLD.wireFine(), 'P', ANY_PLASTIC.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), }); diff --git a/src/main/java/com/hbm/entity/logic/EntityNukeExplosionMK5.java b/src/main/java/com/hbm/entity/logic/EntityNukeExplosionMK5.java index dac30b1db..06480aa21 100644 --- a/src/main/java/com/hbm/entity/logic/EntityNukeExplosionMK5.java +++ b/src/main/java/com/hbm/entity/logic/EntityNukeExplosionMK5.java @@ -10,7 +10,6 @@ import com.hbm.config.GeneralConfig; import com.hbm.entity.effect.EntityFalloutRain; import com.hbm.explosion.ExplosionNukeGeneric; import com.hbm.explosion.ExplosionNukeRayBatched; -import com.hbm.explosion.ExplosionNukeRayParallelized; import com.hbm.main.MainRegistry; import com.hbm.util.ContaminationUtil; import com.hbm.util.ContaminationUtil.ContaminationType; @@ -70,13 +69,11 @@ public class EntityNukeExplosionMK5 extends EntityExplosionChunkloading { if(explosion == null) { explosionStart = System.currentTimeMillis(); - if (BombConfig.explosionAlgorithm == 1 || BombConfig.explosionAlgorithm == 2) { - explosion = new ExplosionNukeRayParallelized(worldObj, posX, posY, posZ, - strength, speed, length); - } else { - explosion = new ExplosionNukeRayBatched(worldObj, (int) posX, (int) posY, (int) posZ, - strength, speed, length); - } + //if(BombConfig.explosionAlgorithm == 1 || BombConfig.explosionAlgorithm == 2) { + // explosion = new ExplosionNukeRayParallelized(worldObj, posX, posY, posZ, strength, speed, length); + //} else { + explosion = new ExplosionNukeRayBatched(worldObj, (int) posX, (int) posY, (int) posZ, strength, speed, length); + //} } if(!explosion.isComplete()) { diff --git a/src/main/java/com/hbm/explosion/ExplosionFleija.java b/src/main/java/com/hbm/explosion/ExplosionFleija.java index 5a478fe14..8c06d708a 100644 --- a/src/main/java/com/hbm/explosion/ExplosionFleija.java +++ b/src/main/java/com/hbm/explosion/ExplosionFleija.java @@ -6,8 +6,8 @@ import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class ExplosionFleija -{ +public class ExplosionFleija { + public int posX; public int posY; public int posZ; @@ -23,7 +23,7 @@ public class ExplosionFleija private int element; public float explosionCoefficient = 1.0F; public float explosionCoefficient2 = 1.0F; - + public void saveToNbt(NBTTagCompound nbt, String name) { nbt.setInteger(name + "posX", posX); nbt.setInteger(name + "posY", posY); @@ -40,7 +40,7 @@ public class ExplosionFleija nbt.setFloat(name + "explosionCoefficient", explosionCoefficient); nbt.setFloat(name + "explosionCoefficient2", explosionCoefficient2); } - + public void readFromNbt(NBTTagCompound nbt, String name) { posX = nbt.getInteger(name + "posX"); posY = nbt.getInteger(name + "posY"); @@ -57,29 +57,28 @@ public class ExplosionFleija explosionCoefficient = nbt.getFloat(name + "explosionCoefficient"); explosionCoefficient2 = nbt.getFloat(name + "explosionCoefficient2"); } - - public ExplosionFleija(int x, int y, int z, World world, int rad, float coefficient, float coefficient2) - { + + public ExplosionFleija(int x, int y, int z, World world, int rad, float coefficient, float coefficient2) { this.posX = x; this.posY = y; this.posZ = z; - + this.worldObj = world; - + this.radius = rad; this.radius2 = this.radius * this.radius; this.explosionCoefficient = coefficient; this.explosionCoefficient2 = coefficient2; - + this.nlimit = this.radius2 * 4; } - - public boolean update() - { + + public boolean update() { breakColumn(this.lastposX, this.lastposZ); this.shell = (int) Math.floor((Math.sqrt(n) + 1) / 2); int shell2 = this.shell * 2; + if(shell2 == 0) return true; // end explosion if the shell size is 0 to prevent division by zero crash this.leg = (int) Math.floor((this.n - (shell2 - 1) * (shell2 - 1)) / shell2); this.element = (this.n - (shell2 - 1) * (shell2 - 1)) - shell2 * this.leg - this.shell + 1; this.lastposX = this.leg == 0 ? this.shell : this.leg == 1 ? -this.element : this.leg == 2 ? -this.shell : this.element; @@ -88,15 +87,13 @@ public class ExplosionFleija return this.n > this.nlimit; } - private void breakColumn(int x, int z) - { + private void breakColumn(int x, int z) { int dist = this.radius2 - (x * x + z * z); - if (dist > 0) - { + if(dist > 0) { dist = (int) Math.sqrt(dist); - for (int y = (int)(dist / this.explosionCoefficient2); y > -dist / this.explosionCoefficient; y--) - { - if(this.posY + y > 0 && !(this.worldObj.getBlock(this.posX+x, this.posY+y, this.posZ+z) instanceof DecoBlockAlt))this.worldObj.setBlock(this.posX+x, this.posY+y, this.posZ+z, Blocks.air); + for(int y = (int) (dist / this.explosionCoefficient2); y > -dist / this.explosionCoefficient; y--) { + if(this.posY + y > 0 && !(this.worldObj.getBlock(this.posX + x, this.posY + y, this.posZ + z) instanceof DecoBlockAlt)) + this.worldObj.setBlock(this.posX + x, this.posY + y, this.posZ + z, Blocks.air); } } } diff --git a/src/main/java/com/hbm/handler/HTTPHandler.java b/src/main/java/com/hbm/handler/HTTPHandler.java index 4efc054f4..3af10a74b 100644 --- a/src/main/java/com/hbm/handler/HTTPHandler.java +++ b/src/main/java/com/hbm/handler/HTTPHandler.java @@ -13,6 +13,7 @@ import com.hbm.main.MainRegistry; public class HTTPHandler { public static List capsule = new ArrayList(); + public static List tipOfTheDay = new ArrayList(); public static boolean newVersion = false; public static String versionNumber = ""; @@ -25,6 +26,7 @@ public class HTTPHandler { try { loadVersion(); loadSoyuz(); + loadTips(); } catch(IOException e) { MainRegistry.logger.warn("Version checker failed!"); } @@ -69,12 +71,17 @@ public class HTTPHandler { BufferedReader in = new BufferedReader(new InputStreamReader(github.openStream())); String line; - - while((line = in.readLine()) != null) { - capsule.add(line); - } - + while((line = in.readLine()) != null) capsule.add(line); in.close(); } + private static void loadTips() throws IOException { + + URL github = new URL("https://gist.githubusercontent.com/HbmMods/a03c66ba160184e12f43de826b30c096/raw/tip_of_the_day"); + BufferedReader in = new BufferedReader(new InputStreamReader(github.openStream())); + + String line; + while((line = in.readLine()) != null) tipOfTheDay.add(line); + in.close(); + } } diff --git a/src/main/java/com/hbm/inventory/gui/LoadingScreenRendererNT.java b/src/main/java/com/hbm/inventory/gui/LoadingScreenRendererNT.java new file mode 100644 index 000000000..d9dc5e676 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/LoadingScreenRendererNT.java @@ -0,0 +1,189 @@ +package com.hbm.inventory.gui; + +import java.util.Random; + +import org.lwjgl.opengl.GL11; + +import com.hbm.handler.HTTPHandler; + +import cpw.mods.fml.client.FMLClientHandler; +import net.minecraft.client.LoadingScreenRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MinecraftError; + +public class LoadingScreenRendererNT extends LoadingScreenRenderer { + + private String message = ""; + private Minecraft mc; + private String currentlyDisplayedText = ""; + private long time = Minecraft.getSystemTime(); + private boolean doesProgress; + private ScaledResolution resolution; + private Framebuffer frameBuffer; + public String tipOfTheDay = "Tip of the day: " + chooseTip(); + + public LoadingScreenRendererNT(Minecraft mc) { + super(mc); + this.mc = mc; + this.resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + this.frameBuffer = new Framebuffer(mc.displayWidth, mc.displayHeight, false); + this.frameBuffer.setFramebufferFilter(9728); + } + + private String chooseTip() { + if(HTTPHandler.tipOfTheDay.isEmpty()) return "null"; + return HTTPHandler.tipOfTheDay.get(new Random().nextInt(HTTPHandler.tipOfTheDay.size())); + } + + @Override + public void resetProgressAndMessage(String message) { + this.doesProgress = false; + this.func_73722_d(message); + } + + @Override + public void displayProgressMessage(String message) { + this.doesProgress = true; + this.func_73722_d(message); + } + + @Override + public void func_73722_d(String message) { + this.currentlyDisplayedText = message; + + if(!this.mc.running) { + if(!this.doesProgress) { + throw new MinecraftError(); + } + } else { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + + if(OpenGlHelper.isFramebufferEnabled()) { + int scale = this.resolution.getScaleFactor(); + GL11.glOrtho(0.0D, (this.resolution.getScaledWidth() * scale), (this.resolution.getScaledHeight() * scale), 0.0D, 100.0D, 300.0D); + } else { + ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); + GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -200.0F); + } + } + + @Override + public void resetProgresAndWorkingMessage(String message) { + if(!this.mc.running) { + if(!this.doesProgress) { + throw new MinecraftError(); + } + } else { + this.time = 0L; + this.message = message; + this.setLoadingProgress(-1); + this.time = 0L; + } + } + + @Override + public void setLoadingProgress(int p_73718_1_) { + if(!this.mc.running) { + if(!this.doesProgress) { + throw new MinecraftError(); + } + } else { + long time = Minecraft.getSystemTime(); + + if(time - this.time >= 100L) { + this.time = time; + ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); + int scaleFactor = scaledresolution.getScaleFactor(); + int width = scaledresolution.getScaledWidth(); + int height = scaledresolution.getScaledHeight(); + + if(OpenGlHelper.isFramebufferEnabled()) { + this.frameBuffer.framebufferClear(); + } else { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + } + + this.frameBuffer.bindFramebuffer(false); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -200.0F); + + if(!OpenGlHelper.isFramebufferEnabled()) { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + } + + if(!FMLClientHandler.instance().handleLoadingScreen(scaledresolution)) { + Tessellator tessellator = Tessellator.instance; + this.mc.getTextureManager().bindTexture(Gui.optionsBackground); + float f = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(4210752); + tessellator.addVertexWithUV(0.0D, height, 0.0D, 0.0D, height / f); + tessellator.addVertexWithUV(width, height, 0.0D, width / f, height / f); + tessellator.addVertexWithUV(width, 0.0D, 0.0D, width / f, 0.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + + if(p_73718_1_ >= 0) { + byte b0 = 100; + byte b1 = 2; + int j1 = width / 2 - b0 / 2; + int k1 = height / 2 + 16; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(8421504); + tessellator.addVertex(j1, k1, 0.0D); + tessellator.addVertex(j1, k1 + b1, 0.0D); + tessellator.addVertex(j1 + b0, k1 + b1, 0.0D); + tessellator.addVertex(j1 + b0, k1, 0.0D); + tessellator.setColorOpaque_I(8454016); + tessellator.addVertex(j1, k1, 0.0D); + tessellator.addVertex(j1, (k1 + b1), 0.0D); + tessellator.addVertex(j1 + p_73718_1_, k1 + b1, 0.0D); + tessellator.addVertex(j1 + p_73718_1_, k1, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + this.mc.fontRenderer.drawStringWithShadow(this.currentlyDisplayedText, (width - this.mc.fontRenderer.getStringWidth(this.currentlyDisplayedText)) / 2, height / 2 - 4 - 16, 16777215); + this.mc.fontRenderer.drawStringWithShadow(this.message, (width - this.mc.fontRenderer.getStringWidth(this.message)) / 2, height / 2 - 4 + 8, 16777215); + + String[] frags = this.tipOfTheDay.split("$"); + for(int i = 0; i < frags.length; i++) { + String frag = frags[i]; + this.mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW + frag, (width - this.mc.fontRenderer.getStringWidth(frag)) / 2, height / 2 - 4 - 60 + i * 10, 16777215); + } + } + this.frameBuffer.unbindFramebuffer(); + + if(OpenGlHelper.isFramebufferEnabled()) { + this.frameBuffer.framebufferRender(width * scaleFactor, height * scaleFactor); + } + + this.mc.func_147120_f(); + + try { Thread.yield(); } catch(Exception exception) { } + } + } + } + + @Override public void func_146586_a() { } +} diff --git a/src/main/java/com/hbm/inventory/recipes/PedestalRecipes.java b/src/main/java/com/hbm/inventory/recipes/PedestalRecipes.java index 8554afafc..76d22d7c8 100644 --- a/src/main/java/com/hbm/inventory/recipes/PedestalRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/PedestalRecipes.java @@ -62,9 +62,9 @@ public class PedestalRecipes extends SerializableRecipe { .extra(PedestalExtraCondition.SUN)); register(new PedestalRecipe(new ItemStack(ModItems.gun_autoshotgun_sexy), - new ComparableStack(ModItems.bolt_spike, 16), new OreDictStack(STAR.ingot(), 4), new ComparableStack(ModItems.bolt_spike, 16), + new ComparableStack(ModItems.bolt_spike, 16), new ComparableStack(ModItems.wild_p), new ComparableStack(ModItems.bolt_spike, 16), new ComparableStack(ModItems.card_qos), new ComparableStack(ModItems.gun_autoshotgun), new ComparableStack(ModItems.card_aos), - new ComparableStack(ModItems.bolt_spike, 16), new OreDictStack(STAR.ingot(), 4), new ComparableStack(ModItems.bolt_spike, 16))); + new ComparableStack(ModItems.bolt_spike, 16), new OreDictStack(STAR.ingot(), 16), new ComparableStack(ModItems.bolt_spike, 16))); register(new PedestalRecipe(new ItemStack(ModItems.gun_minigun_lacunae), null, new ComparableStack(ModItems.powder_magic, 4), null, diff --git a/src/main/java/com/hbm/items/ItemEnums.java b/src/main/java/com/hbm/items/ItemEnums.java index 18878469c..d92c7840b 100644 --- a/src/main/java/com/hbm/items/ItemEnums.java +++ b/src/main/java/com/hbm/items/ItemEnums.java @@ -87,6 +87,6 @@ public class ItemEnums { } public static enum EnumIngotMetal { - INGOT, COUNTER, KEY, BEACON, CASING, CLOCKWORK, BAR, DETECTOR + SCRAP, INGOT, COUNTER, KEY, BEACON, CASING, CLOCKWORK, BAR, DETECTOR } } diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index d7b7fb410..7387de265 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -1169,6 +1169,7 @@ public class ModItems { public static Item pellet_buckshot; public static Item pellet_charged; + public static Item rangefinder; public static Item designator; public static Item designator_range; public static Item designator_manual; @@ -3553,6 +3554,7 @@ public class ModItems { pellet_buckshot = new Item().setUnlocalizedName("pellet_buckshot").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":pellets_lead"); pellet_charged = new Item().setUnlocalizedName("pellet_charged").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":pellets_charged"); + rangefinder = new ItemRangefinder().setUnlocalizedName("rangefinder").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":rangefinder"); designator = new ItemDesingator().setUnlocalizedName("designator").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator"); designator_range = new ItemDesingatorRange().setUnlocalizedName("designator_range").setFull3D().setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator_range_alt"); designator_manual = new ItemDesingatorManual().setUnlocalizedName("designator_manual").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator_manual"); @@ -6136,6 +6138,7 @@ public class ModItems { GameRegistry.registerItem(spawn_duck, spawn_duck.getUnlocalizedName()); //Computer Tools + GameRegistry.registerItem(rangefinder, rangefinder.getUnlocalizedName()); GameRegistry.registerItem(designator, designator.getUnlocalizedName()); GameRegistry.registerItem(designator_range, designator_range.getUnlocalizedName()); GameRegistry.registerItem(designator_manual, designator_manual.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/tool/ItemRangefinder.java b/src/main/java/com/hbm/items/tool/ItemRangefinder.java new file mode 100644 index 000000000..9c1d5179f --- /dev/null +++ b/src/main/java/com/hbm/items/tool/ItemRangefinder.java @@ -0,0 +1,47 @@ +package com.hbm.items.tool; + +import com.hbm.main.MainRegistry; +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.toclient.PlayerInformPacket; +import com.hbm.util.ChatBuilder; +import com.hbm.util.Vec3NT; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ItemRangefinder extends Item { + + public static final int META_POLARIZED = 1; + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(world.isRemote) return stack; + + Vec3NT start = new Vec3NT(player.posX, player.posY + player.eyeHeight, player.posZ); + Vec3NT startOriginal = new Vec3NT(start); // why the fuck + Vec3NT end = new Vec3NT(start).add(new Vec3NT(player.getLookVec()).multiply(300)); + + MovingObjectPosition mop = world.func_147447_a(start, end, false, true, false); + + if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK) { + double dist = startOriginal.distanceTo(mop.hitVec); + String msg = ((int)(dist * 10D)) / 10D + "m"; + if(stack.getItemDamage() == META_POLARIZED) msg = EnumChatFormatting.LIGHT_PURPLE + msg + EnumChatFormatting.RESET; + PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(ChatBuilder.start(msg).flush(), MainRegistry.proxy.ID_DETONATOR, 5000), (EntityPlayerMP) player); + } + + return stack; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + String name = super.getItemStackDisplayName(stack); + if(stack.getItemDamage() == META_POLARIZED) name = EnumChatFormatting.LIGHT_PURPLE + name + EnumChatFormatting.RESET; + return name; + } +} diff --git a/src/main/java/com/hbm/lib/RefStrings.java b/src/main/java/com/hbm/lib/RefStrings.java index 27fe4f45d..f56883283 100644 --- a/src/main/java/com/hbm/lib/RefStrings.java +++ b/src/main/java/com/hbm/lib/RefStrings.java @@ -3,7 +3,7 @@ package com.hbm.lib; public class RefStrings { public static final String MODID = "hbm"; public static final String NAME = "Hbm's Nuclear Tech Mod"; - public static final String VERSION = "1.0.27 BETA (5357)"; + public static final String VERSION = "1.0.27 BETA (5377)"; //HBM's Beta Naming Convention: //V T (X) //V -> next release version diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index 86a280f16..846699693 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -313,8 +313,7 @@ public class CraftingManager { addRecipeAuto(new ItemStack(ModItems.detonator, 1), new Object[] { "C", "S", 'S', STEEL.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), }); addShapelessAuto(new ItemStack(ModItems.detonator_multi, 1), new Object[] { ModItems.detonator, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED) }); - addRecipeAuto(new ItemStack(ModItems.detonator_laser, 1), new Object[] { "RRD", "PIC", " P", 'P', STEEL.plate(), 'R', REDSTONE.dust(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'D', DIAMOND.gem(), 'I', STEEL.ingot() }); - addRecipeAuto(new ItemStack(ModItems.detonator_laser, 1), new Object[] { "RRD", "PIC", " P", 'P', STEEL.plate(), 'R', REDSTONE.dust(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'D', EMERALD.gem(), 'I', STEEL.ingot() }); + addShapelessAuto(new ItemStack(ModItems.detonator_laser, 1), new Object[] { ModItems.rangefinder, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), RUBBER.ingot(), GOLD.wireDense() }); addShapelessAuto(new ItemStack(ModItems.detonator_deadman, 1), new Object[] { ModItems.detonator, ModItems.defuser, ModItems.ducttape }); addRecipeAuto(new ItemStack(ModItems.detonator_de, 1), new Object[] { "T", "D", "T", 'T', Blocks.tnt, 'D', ModItems.detonator_deadman }); diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index e9e40dfe0..aea94c19b 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -22,6 +22,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.gui.GUIArmorTable; import com.hbm.inventory.gui.GUIScreenPreview; import com.hbm.inventory.gui.GUIScreenWikiRender; +import com.hbm.inventory.gui.LoadingScreenRendererNT; import com.hbm.items.ItemCustomLore; import com.hbm.items.ModItems; import com.hbm.items.armor.*; @@ -1032,10 +1033,15 @@ public class ModEventHandlerClient { @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.LOWEST) public void onClientTickLast(ClientTickEvent event) { + + Minecraft mc = Minecraft.getMinecraft(); + if(!(mc.loadingScreen instanceof LoadingScreenRendererNT)) { + mc.loadingScreen = new LoadingScreenRendererNT(mc); + } if(event.phase == Phase.START && GeneralConfig.enableSkyboxes) { - World world = Minecraft.getMinecraft().theWorld; + World world = mc.theWorld; if(world == null) return; IRenderHandler sky = world.provider.getSkyRenderer(); @@ -1059,7 +1065,7 @@ public class ModEventHandlerClient { } } - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + EntityPlayer player = mc.thePlayer; long millis = Clock.get_ms(); if(lastStarCheck + 200 < millis) { diff --git a/src/main/java/com/hbm/main/ServerProxy.java b/src/main/java/com/hbm/main/ServerProxy.java index 7ec6eaa23..271a21759 100644 --- a/src/main/java/com/hbm/main/ServerProxy.java +++ b/src/main/java/com/hbm/main/ServerProxy.java @@ -32,8 +32,7 @@ public class ServerProxy { public static final int ID_FLUID_ID = 9; public static final int ID_FAN_MODE = 10; public static final int ID_TOOLABILITY = 11; - public static final int ID_GUN_MODE = 12; - public static final int ID_GAS_HAZARD = 13; + public static final int ID_GAS_HAZARD = 12; public ITranslate getI18n() { return I18N; } diff --git a/src/main/java/com/hbm/render/tileentity/RenderEPress.java b/src/main/java/com/hbm/render/tileentity/RenderEPress.java index 987ab9a0a..cf8915ef8 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderEPress.java +++ b/src/main/java/com/hbm/render/tileentity/RenderEPress.java @@ -2,6 +2,7 @@ package com.hbm.render.tileentity; import org.lwjgl.opengl.GL11; +import com.hbm.blocks.BlockDummyable; import com.hbm.main.ResourceManager; import com.hbm.render.util.RenderDecoItem; import com.hbm.tileentity.machine.TileEntityMachineEPress; @@ -28,7 +29,7 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - switch(tileentity.getBlockMetadata()) { + switch(tileentity.getBlockMetadata() - BlockDummyable.offset) { case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: GL11.glRotatef(0, 0F, 1F, 0F); break; case 3: GL11.glRotatef(90, 0F, 1F, 0F); break; @@ -50,7 +51,7 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - switch(tileentity.getBlockMetadata()) { + switch(tileentity.getBlockMetadata() - BlockDummyable.offset) { case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: GL11.glRotatef(0, 0F, 1F, 0F); break; case 3: GL11.glRotatef(90, 0F, 1F, 0F); break; @@ -78,7 +79,7 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - switch(tileentity.getBlockMetadata()) { + switch(tileentity.getBlockMetadata() - BlockDummyable.offset) { case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java index b2afe4309..4dc4df595 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java @@ -64,6 +64,11 @@ public class TileEntityMachineEPress extends TileEntityMachineBase implements IE if(!worldObj.isRemote) { + // Triggers the legacy monoblock fix + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < 12) { + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1); + } + this.updateConnections(); power = Library.chargeTEFromItems(slots, 0, power, maxPower); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java index c927edc0a..a0d1e5b8a 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java @@ -53,6 +53,11 @@ public class TileEntityMachinePress extends TileEntityMachineBase implements IGU if(!worldObj.isRemote) { + // Triggers the legacy monoblock fix + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < 12) { + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1); + } + boolean preheated = false; for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneExtractor.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneExtractor.java index 105ceb3fd..804c42321 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneExtractor.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneExtractor.java @@ -10,6 +10,8 @@ import com.hbm.items.ModItems; import com.hbm.module.ModulePatternMatcher; import com.hbm.tileentity.IControlReceiverFilter; import com.hbm.tileentity.IGUIProvider; +import com.hbm.util.InventoryUtil; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; @@ -94,54 +96,62 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU } boolean hasSent = false; + + IConveyorBelt belt = null; if(b instanceof IConveyorBelt) { + belt = (IConveyorBelt) b; + } - IConveyorBelt belt = (IConveyorBelt) b; + /* try to send items from a connected inv, if present */ + if(te instanceof IInventory) { - /* try to send items from a connected inv, if present */ - if(te instanceof IInventory) { + IInventory inv = (IInventory) te; + int size = access == null ? inv.getSizeInventory() : access.length; + + for(int i = 0; i < size; i++) { + int index = access == null ? i : access[i]; + ItemStack stack = inv.getStackInSlot(index); - IInventory inv = (IInventory) te; - int size = access == null ? inv.getSizeInventory() : access.length; - - for(int i = 0; i < size; i++) { - int index = access == null ? i : access[i]; - ItemStack stack = inv.getStackInSlot(index); + if(stack != null && (sided == null || sided.canExtractItem(index, stack, inputSide.getOpposite().ordinal()))){ - if(stack != null && (sided == null || sided.canExtractItem(index, stack, inputSide.getOpposite().ordinal()))){ + boolean match = this.matchesFilter(stack); + + if((isWhitelist && match) || (!isWhitelist && !match)) { + stack = stack.copy(); + int toSend = Math.min(amount, stack.stackSize); - boolean match = this.matchesFilter(stack); - - if((isWhitelist && match) || (!isWhitelist && !match)) { - stack = stack.copy(); - int toSend = Math.min(amount, stack.stackSize); + if (belt != null) { inv.decrStackSize(index, toSend); stack.stackSize = toSend; - sendItem(stack, belt, outputSide); - hasSent = true; - break; + } else { + stack.stackSize = toSend; + ItemStack remaining = InventoryUtil.tryAddItemToInventory(this.slots, 9, 17, stack); + inv.decrStackSize(index, toSend - (remaining == null ? 0 : remaining.stackSize)); } + hasSent = true; + break; } } } + } + + /* if no item has been sent, send buffered items while ignoring the filter */ + if(!hasSent && belt != null) { - /* if no item has been sent, send buffered items while ignoring the filter */ - if(!hasSent) { + for(int i = 9; i < 18; i++) { + ItemStack stack = slots[i]; - for(int i = 9; i < 18; i++) { - ItemStack stack = slots[i]; - - if(stack != null){ - stack = stack.copy(); - int toSend = Math.min(amount, stack.stackSize); - decrStackSize(i, toSend); - stack.stackSize = toSend; - - sendItem(stack, belt, outputSide); - break; - } + if(stack != null){ + stack = stack.copy(); + int toSend = Math.min(amount, stack.stackSize); + + decrStackSize(i, toSend); + stack.stackSize = toSend; + sendItem(stack, belt, outputSide); + + break; } } } diff --git a/src/main/java/com/hbm/util/Vec3NT.java b/src/main/java/com/hbm/util/Vec3NT.java index 0cb8121a7..1e6cb1294 100644 --- a/src/main/java/com/hbm/util/Vec3NT.java +++ b/src/main/java/com/hbm/util/Vec3NT.java @@ -29,6 +29,13 @@ public class Vec3NT extends Vec3 { return this; } + public Vec3NT add(Vec3 vec) { + this.xCoord += vec.xCoord; + this.yCoord += vec.yCoord; + this.zCoord += vec.zCoord; + return this; + } + public Vec3NT multiply(double m) { this.xCoord *= m; this.yCoord *= m; @@ -43,6 +50,13 @@ public class Vec3NT extends Vec3 { return this; } + public double distanceTo(double x, double y, double z) { + double dX = x - this.xCoord; + double dY = y - this.yCoord; + double dZ = z - this.zCoord; + return Math.sqrt(dX * dX + dY * dY + dZ * dZ); + } + @Override public Vec3NT setComponents(double x, double y, double z) { this.xCoord = x; diff --git a/src/main/resources/META-INF/HBM_at.cfg b/src/main/resources/META-INF/HBM_at.cfg index 81514dff3..859de4618 100644 --- a/src/main/resources/META-INF/HBM_at.cfg +++ b/src/main/resources/META-INF/HBM_at.cfg @@ -55,3 +55,5 @@ public net.minecraft.client.gui.GuiIngame field_92016_l # hi # Block public net.minecraft.block.Block func_149642_a(Lnet/minecraft/world/World;IIILnet/minecraft/item/ItemStack;)V # dropBlockAsItem +# Minecraft +public net.minecraft.client.Minecraft field_71425_J # running diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 33050befc..c76f24002 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -3039,6 +3039,7 @@ item.radx.name=Rad-X item.rag.name=Stoff item.rag_damp.name=Nasser Stoff item.rag_piss.name=Pisslappen +item.rangefinder.name=Entfernungsmessgerät item.rbmk_fuel_balefire.name=Balefire-RBMK-Kernbrennstoff item.rbmk_fuel_balefire_gold.name=Flammgold-RBMK-Kernbrennstoff item.rbmk_fuel_drx.name=§cDigamma-RBMK-Kernbrennstoff diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 924ab3652..d60a76787 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -3992,6 +3992,7 @@ item.radx.desc=Increases radiation resistance by 0.2 (37%%) for 3 minutes item.rag.name=Cloth item.rag_damp.name=Damp Cloth item.rag_piss.name=Piss-Soaked Rag +item.rangefinder.name=Rangefinder item.rbmk_fuel_balefire.name=Balefire RBMK Fuel Rod item.rbmk_fuel_balefire_gold.name=Flashgold RBMK Fuel Rod item.rbmk_fuel_drx.name=§cDigamma RBMK Fuel Rod§r diff --git a/src/main/resources/assets/hbm/textures/items/ingot_metal.scrap.png b/src/main/resources/assets/hbm/textures/items/ingot_metal.scrap.png new file mode 100644 index 000000000..a0074ffc8 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/ingot_metal.scrap.png differ diff --git a/src/main/resources/assets/hbm/textures/items/ingot_metal_sheet.png b/src/main/resources/assets/hbm/textures/items/ingot_metal_sheet.png index 3697db98c..d45fd4404 100644 Binary files a/src/main/resources/assets/hbm/textures/items/ingot_metal_sheet.png and b/src/main/resources/assets/hbm/textures/items/ingot_metal_sheet.png differ diff --git a/src/main/resources/assets/hbm/textures/items/rangefinder.png b/src/main/resources/assets/hbm/textures/items/rangefinder.png new file mode 100644 index 000000000..d7539ee67 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/rangefinder.png differ