diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 764527e5d..0f405629f 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -722,7 +722,7 @@ public class ModBlocks { public static Block machine_battery_socket; public static Block machine_battery_redd; - + @Deprecated public static Block machine_battery_potato; @Deprecated public static Block machine_battery; @Deprecated public static Block machine_lithium_battery; @@ -1217,6 +1217,7 @@ public class ModBlocks { public static Block wand_structure; public static Block logic_block; + public static Block logic_block_invis; public static Material materialGas = new MaterialGas(); @@ -1821,7 +1822,7 @@ public class ModBlocks { machine_battery_socket = new MachineBatterySocket().setBlockName("machine_battery_socket").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_battery_redd = new MachineBatteryREDD().setBlockName("machine_battery_redd").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); - + machine_battery_potato = new MachineBattery(Material.iron, 10_000).setBlockName("machine_battery_potato").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null); machine_battery = new MachineBattery(Material.iron, 1_000_000).setBlockName("machine_battery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null); machine_lithium_battery = new MachineBattery(Material.iron, 50_000_000).setBlockName("machine_lithium_battery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null); @@ -2358,6 +2359,7 @@ public class ModBlocks { wand_structure = new BlockWandStructure().setBlockName("wand_structure"); logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block"); + logic_block_invis = new LogicBlock().setBlockName("logic_block_invis").setBlockTextureName(RefStrings.MODID + ":logic_block"); } @@ -3500,6 +3502,7 @@ public class ModBlocks { register(wand_structure); register(logic_block); + register(logic_block_invis); } private static void register(Block b) { diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandLogic.java b/src/main/java/com/hbm/blocks/generic/BlockWandLogic.java index 70fe879a1..05e8737af 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandLogic.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandLogic.java @@ -117,6 +117,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo return true; } } + } return super.onBlockActivated(world, x, y, z, player, side, fX, fY, fZ); } @@ -221,6 +222,8 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo Block disguise; int disguiseMeta = -1; + boolean invisible = false; + public String actionID = "FODDER_WAVE"; public String conditionID = "PLAYER_CUBE_5"; public String interactionID; @@ -242,7 +245,8 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a logic block but we're doing a TE update as if it is, cancelling!"); return; } - worldObj.setBlock(xCoord,yCoord,zCoord, ModBlocks.logic_block); + + worldObj.setBlock(xCoord,yCoord,zCoord, disguise == null ? ModBlocks.logic_block_invis : ModBlocks.logic_block); TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord); @@ -324,6 +328,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo nbt.setString("conditionID", conditionID); if(interactionID != null) nbt.setString("interactionID", interactionID); + nbt.setInteger("rotation", placedRotation); if(disguise != null){ nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); nbt.setInteger("disguiseMeta", disguiseMeta); @@ -337,6 +342,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo actionID = nbt.getString("actionID"); conditionID = nbt.getString("conditionID"); interactionID = nbt.getString("interactionID"); + placedRotation = nbt.getInteger("disguiseMeta"); if(nbt.hasKey("disguise")){ disguise = Block.getBlockFromName(nbt.getString("disguise")); disguiseMeta = nbt.getInteger("disguiseMeta"); diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandLoot.java b/src/main/java/com/hbm/blocks/generic/BlockWandLoot.java index 4242f32ba..14d40578b 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandLoot.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandLoot.java @@ -11,6 +11,8 @@ import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ModBlocks; import com.hbm.config.ServerConfig; import com.hbm.config.StructureConfig; +import com.hbm.interfaces.IBomb; +import com.hbm.interfaces.ICopiable; import com.hbm.itempool.ItemPool; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; @@ -48,7 +50,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; -public class BlockWandLoot extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation { +public class BlockWandLoot extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb { @SideOnly(Side.CLIENT) protected IIcon iconTop; @@ -212,12 +214,23 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool } } + @Override + public BombReturnCode explode(World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + + if(!(te instanceof BlockWandLoot.TileEntityWandLoot)) return null; + + ((BlockWandLoot.TileEntityWandLoot) te).triggerReplace = true; + + return BombReturnCode.TRIGGERED; + } + @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityWandLoot(); } - public static class TileEntityWandLoot extends TileEntityLoadedBase implements INBTTileEntityTransformable { + public static class TileEntityWandLoot extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable { private boolean triggerReplace; @@ -355,6 +368,29 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool poolName = BufferUtil.readString(buf); } + @Override + public NBTTagCompound getSettings(World world, int x, int y, int z) { + NBTTagCompound nbt = new NBTTagCompound(); + Block block = replaceBlock != null ? replaceBlock : ModBlocks.deco_loot; + + nbt.setInteger("replaceBlock", Block.getIdFromBlock(block)); + nbt.setInteger("replaceMeta", replaceMeta); + nbt.setInteger("minItems", minItems); + nbt.setInteger("maxItems", maxItems); + nbt.setString("poolName", poolName); + + return nbt; + } + + @Override + public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { + replaceBlock = Block.getBlockById(nbt.getInteger("replaceBlock")); + replaceMeta = nbt.getInteger("replaceMeta"); + minItems = nbt.getInteger("minItems"); + maxItems = nbt.getInteger("maxItems"); + poolName = nbt.getString("poolName"); + + } } } diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandStructure.java b/src/main/java/com/hbm/blocks/generic/BlockWandStructure.java index 0684989cf..426c8bf3d 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandStructure.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandStructure.java @@ -229,8 +229,9 @@ public class BlockWandStructure extends BlockContainer implements IBlockMulti, I File structureFile = new File(structureDirectory, name + ".nbt"); + boolean debug = !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); boolean previousDebug = ServerConfig.STRUCTURE_DEBUG.get(); - ServerConfig.STRUCTURE_DEBUG.set(true); + ServerConfig.STRUCTURE_DEBUG.set(debug); try { NBTStructure structure = new NBTStructure(structureFile); diff --git a/src/main/java/com/hbm/blocks/generic/LogicBlock.java b/src/main/java/com/hbm/blocks/generic/LogicBlock.java index 462755811..5487f4263 100644 --- a/src/main/java/com/hbm/blocks/generic/LogicBlock.java +++ b/src/main/java/com/hbm/blocks/generic/LogicBlock.java @@ -1,5 +1,6 @@ package com.hbm.blocks.generic; +import com.hbm.blocks.ModBlocks; import com.hbm.world.gen.util.LogicBlockActions; import com.hbm.world.gen.util.LogicBlockConditions; import com.hbm.world.gen.util.LogicBlockInteractions; @@ -50,6 +51,11 @@ public class LogicBlock extends BlockContainer { return super.getIcon(world, x, y, z, side); } + @Override + public boolean isOpaqueCube() { + return this != ModBlocks.logic_block_invis; + } + @Override public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) { TileEntity te = worldIn.getTileEntity(x, y, z); diff --git a/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java b/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java index 1ba8c4eb6..2e67882f6 100644 --- a/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java +++ b/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java @@ -15,13 +15,13 @@ public class EntityAIFireGun extends EntityAIBase { private final EntityLiving host; - private double attackMoveSpeed = 1.0D; // how fast we move while in this state - private double maxRange = 20; // how far our target can be before we stop shooting - private int burstTime = 10; // maximum number of ticks in a burst (for automatic weapons) - private int minWait = 10; // minimum number of ticks to wait between bursts/shots - private int maxWait = 40; // maximum number of ticks to wait between bursts/shots - private float inaccuracy = 30; // how many degrees of inaccuracy does the AI have - + public double attackMoveSpeed = 1.0D; // how fast we move while in this state + public double maxRange = 20; // how far our target can be before we stop shooting + public int burstTime = 10; // maximum number of ticks in a burst (for automatic weapons) + public int minWait = 10; // minimum number of ticks to wait between bursts/shots + public int maxWait = 40; // maximum number of ticks to wait between bursts/shots + public float inaccuracy = 30; // how many degrees of inaccuracy does the AI have + public boolean randomBurst = true; //whether the burst time should be fixed or random // state timers private int attackTimer = 0; private FireState state = FireState.IDLE; @@ -33,7 +33,7 @@ public class EntityAIFireGun extends EntityAIBase { FIRING, RELOADING, } - + public EntityAIFireGun(EntityLiving host) { this.host = host; } @@ -89,7 +89,8 @@ public class EntityAIFireGun extends EntityAIBase { if(rec.getMagazine(stack).getAmount(stack, null) <= 0) { updateState(FireState.RELOADING, 20, gun, stack); } else if(ItemGunBaseNT.getState(stack, 0) == GunState.IDLE) { - updateState(FireState.FIRING, host.worldObj.rand.nextInt(burstTime), gun, stack); + int time = randomBurst ? host.worldObj.rand.nextInt(burstTime) : burstTime; + updateState(FireState.FIRING, time, gun, stack); } } } @@ -114,8 +115,9 @@ public class EntityAIFireGun extends EntityAIBase { // Turn body to face firing direction, since the gun is attached to that, not the head // Also apply accuracy debuff just before firing if(bind != null && bind != EnumKeybind.RELOAD) { - host.rotationYawHead += (host.worldObj.rand.nextFloat() - 0.5F) * inaccuracy; - host.rotationPitch += (host.worldObj.rand.nextFloat() - 0.5F) * inaccuracy; + float inacc = inaccuracy * (getYerGun().getConfig(stack, 0).getReceivers(stack)[0].getHipfireSpread(stack) * 20); + host.rotationYawHead += (host.worldObj.rand.nextFloat() - 0.5F) * inacc; + host.rotationPitch += (host.worldObj.rand.nextFloat() - 0.5F) * inacc; host.rotationYaw = host.rotationYawHead; } @@ -132,5 +134,5 @@ public class EntityAIFireGun extends EntityAIBase { return (ItemGunBaseNT) stack.getItem(); } - + } diff --git a/src/main/java/com/hbm/itempool/ItemPoolsPile.java b/src/main/java/com/hbm/itempool/ItemPoolsPile.java index f3c7bfde5..8c303556c 100644 --- a/src/main/java/com/hbm/itempool/ItemPoolsPile.java +++ b/src/main/java/com/hbm/itempool/ItemPoolsPile.java @@ -3,6 +3,7 @@ package com.hbm.itempool; import static com.hbm.lib.HbmChestContents.weighted; import com.hbm.inventory.material.Mats; +import com.hbm.items.ItemEnums; import com.hbm.items.ModItems; import com.hbm.items.weapon.grenade.ItemGrenadeExtra.EnumGrenadeExtra; import com.hbm.items.weapon.grenade.ItemGrenadeFilling.EnumGrenadeFilling; @@ -28,6 +29,7 @@ public class ItemPoolsPile { public static final String POOL_PILE_NUKE_STORAGE = "POOL_PILE_NUKE_STORAGE"; public static final String POOL_PILE_OF_GARBAGE = "POOL_PILE_OF_GARBAGE"; public static final String POOL_PILE_MECHANICAL = "POOL_PILE_MECHANICAL"; + public static final String POOL_PILE_GEAR = "POOL_PILE_GEAR"; public static void init() { @@ -146,15 +148,29 @@ public class ItemPoolsPile { new ItemPool(POOL_PILE_MECHANICAL) {{ this.pool = new WeightedRandomChestContent[] { - weighted(ModItems.defuser, 0, 1, 1, 5), + weighted(ModItems.defuser, 0, 1, 1, 30), weighted(ModItems.screwdriver, 0, 1, 1, 30), weighted(ModItems.wire_fine, Mats.MAT_COPPER.id, 8, 12, 120), weighted(ModItems.plate_steel, 0, 3, 8, 40), weighted(ModItems.plate_copper, 0, 2, 5, 40), weighted(ModItems.coil_copper, 0, 2, 5, 40), - weighted(ModItems.coil_tungsten, 0, 2, 5, 40), - weighted(ModItems.ammo_standard, EnumAmmo.NUKE_TOTS.ordinal(), 1, 1, 10), + weighted(ModItems.coil_tungsten, 0, 2, 5, 40) + }; + }}; + new ItemPool(POOL_PILE_GEAR) {{ + this.pool = new WeightedRandomChestContent[] { + weighted(ModItems.defuser, 0, 1, 1, 40), + weighted(ModItems.screwdriver, 0, 1, 1, 30), + weighted(ModItems.canteen_vodka,0, 1, 1, 40), + weighted(ModItems.casing, ItemEnums.EnumCasingType.SMALL_STEEL.ordinal(), 1, 4, 30), + weighted(ModItems.casing, ItemEnums.EnumCasingType.SMALL.ordinal(), 3, 8, 40), + weighted(ModItems.casing, ItemEnums.EnumCasingType.BUCKSHOT.ordinal(), 3, 8, 40), + weighted(ModItems.canned_conserve, 0, 2, 5, 40), + weighted(ModItems.taurun_helmet, 0, 1, 1, 20), + weighted(ModItems.taurun_plate, 0, 1, 1, 20), + weighted(ModItems.taurun_legs, 0, 1, 1, 20), + weighted(ModItems.taurun_boots, 0, 1, 1, 20) }; }}; } diff --git a/src/main/java/com/hbm/itempool/ItemPoolsSingle.java b/src/main/java/com/hbm/itempool/ItemPoolsSingle.java index 73623ef83..37338373e 100644 --- a/src/main/java/com/hbm/itempool/ItemPoolsSingle.java +++ b/src/main/java/com/hbm/itempool/ItemPoolsSingle.java @@ -23,7 +23,8 @@ public class ItemPoolsSingle { public static final String POOL_VAULT_UNBREAKABLE = "POOL_VAULT_UNBREAKABLE"; public static final String POOL_METEORITE_TREASURE = "POOL_METEORITE_TREASURE"; public static final String POOL_BLUEPRINTS = "POOL_BLUEPRINTS"; - + + public static void init() { new ItemPool(POOL_VAULT_RUSTY) {{ @@ -43,7 +44,7 @@ public class ItemPoolsSingle { weighted(Items.diamond, 0, 1, 2, 1) }; }}; - + new ItemPool(POOL_VAULT_STANDARD) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.ingot_desh, 0, 2, 6, 1), @@ -59,7 +60,7 @@ public class ItemPoolsSingle { weighted(ModItems.circuit, EnumCircuitType.CHIP.ordinal(), 2, 6, 1) }; }}; - + new ItemPool(POOL_VAULT_REINFORCED) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.ingot_desh, 0, 6, 16, 1), @@ -76,7 +77,7 @@ public class ItemPoolsSingle { weighted(ModItems.circuit, EnumCircuitType.BASIC.ordinal(), 6, 12, 1) }; }}; - + new ItemPool(POOL_VAULT_UNBREAKABLE) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.ammo_container, 0, 3, 6, 1), @@ -87,7 +88,7 @@ public class ItemPoolsSingle { weighted(ModItems.circuit, EnumCircuitType.ADVANCED.ordinal(), 6, 12, 1) }; }}; - + new ItemPool(POOL_METEORITE_TREASURE) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.cobalt_pickaxe, 0, 1, 1, 10), @@ -111,7 +112,7 @@ public class ItemPoolsSingle { weighted(ModItems.blueprint_folder, 1, 1, 1, 1) }; }}; - + new ItemPool(POOL_BLUEPRINTS) {{ this.pool = new WeightedRandomChestContent[] { weighted(ModItems.blueprint_folder, 0, 1, 1, 10), @@ -119,5 +120,13 @@ public class ItemPoolsSingle { weighted(ModItems.blueprint_folder, 0, 1, 1, 1), }; }}; + + new ItemPool(POOL_BLUEPRINTS) {{ + this.pool = new WeightedRandomChestContent[] { + weighted(ModItems.blueprint_folder, 0, 1, 1, 10), + weighted(ModItems.blueprint_folder, 1, 1, 1, 5), + weighted(ModItems.blueprint_folder, 0, 1, 1, 1), + }; + }}; } } diff --git a/src/main/java/com/hbm/util/LootGenerator.java b/src/main/java/com/hbm/util/LootGenerator.java index 7e4ab2eb8..77bc6d2a0 100644 --- a/src/main/java/com/hbm/util/LootGenerator.java +++ b/src/main/java/com/hbm/util/LootGenerator.java @@ -31,6 +31,7 @@ public class LootGenerator { public static final String LOOT_FLAREGUN = "LOOT_FLAREGUN"; public static final String LOOT_SHIT = "LOOT_SHIT"; public static final String LOOT_MECHANICAL = "LOOT_MECHANICAL"; + public static final String LOOT_GEAR = "LOOT_GEAR"; public static void applyLoot(World world, int x, int y, int z, String name) { switch(name) { @@ -46,6 +47,7 @@ public class LootGenerator { case LOOT_FLAREGUN: lootFlareGun(world, x, y, z); case LOOT_SHIT: lootShit(world, x, y, z); case LOOT_MECHANICAL: lootMechanical(world, x, y, z); + case LOOT_GEAR: lootMechanical(world, x, y, z); default: lootBones(world, x, y, z); break; } } @@ -63,6 +65,8 @@ public class LootGenerator { LOOT_METEOR, LOOT_FLAREGUN, LOOT_MECHANICAL, + LOOT_GEAR, + LOOT_SHIT, }; } @@ -257,10 +261,23 @@ public class LootGenerator { if(loot != null && loot.items.isEmpty()) { - int limit = world.rand.nextInt(3) + 1; + int limit = world.rand.nextInt(6) + 1; for(int i = 0; i < limit; i++) { addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPool.getPool(ItemPoolsPile.POOL_PILE_MECHANICAL), world.rand), world.rand.nextDouble() - 0.5, i * 0.03125, world.rand.nextDouble() - 0.5); } } } + + public static void lootGear(World world, int x, int y, int z) { + + TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z); + + if(loot != null && loot.items.isEmpty()) { + + int limit = world.rand.nextInt(6) + 1; + for(int i = 0; i < limit; i++) { + addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPool.getPool(ItemPoolsPile.POOL_PILE_GEAR), world.rand), world.rand.nextDouble() - 0.5, i * 0.03125, world.rand.nextDouble() - 0.5); + } + } + } } diff --git a/src/main/java/com/hbm/util/MobUtil.java b/src/main/java/com/hbm/util/MobUtil.java index 2fd154891..803619357 100644 --- a/src/main/java/com/hbm/util/MobUtil.java +++ b/src/main/java/com/hbm/util/MobUtil.java @@ -59,21 +59,21 @@ public class MobUtil { {ModItems.wrench, 20} })); - slotPoolRanged.put(4, createSlotPool(12000, new Object[][]{ + slotPoolRanged.put(4, createSlotPool(0, new Object[][]{ {ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8}, {ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16}, {ModItems.rag_piss, 1}, {ModItems.goggles, 1}, {ModItems.alloy_helmet, 2}, {ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8} })); - slotPoolRanged.put(3, createSlotPool(10000, new Object[][]{ + slotPoolRanged.put(3, createSlotPool(10, new Object[][]{ {ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.alloy_plate, 2}, //sadly they cant wear jackets bc it breaks it {ModItems.steel_plate, 8}, {ModItems.titanium_plate, 4} })); - slotPoolRanged.put(2, createSlotPool(10000, new Object[][]{ + slotPoolRanged.put(2, createSlotPool(10, new Object[][]{ {ModItems.zirconium_legs, 1}, {ModItems.cobalt_legs, 2}, {ModItems.steel_legs, 16}, {ModItems.titanium_legs, 8}, {ModItems.robes_legs, 32}, {ModItems.alloy_legs, 2}, })); - slotPoolRanged.put(1, createSlotPool(10000, new Object[][]{ + slotPoolRanged.put(1, createSlotPool(10, new Object[][]{ {ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}, {ModItems.titanium_boots, 6} })); @@ -121,68 +121,15 @@ public class MobUtil { //For action block slotPoolGunsTier1.put(0, createSlotPool(0, new Object[][]{ - {ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2} + {ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2}, {ModItems.gun_flaregun, 1} })); slotPoolGunsTier2.put(0, createSlotPool(0, new Object[][]{ - {ModItems.gun_uzi, 10}, {ModItems.gun_maresleg, 8}, {ModItems.gun_henry, 12}, {ModItems.gun_heavy_revolver, 4}, {ModItems.gun_flaregun, 4}, {ModItems.gun_carbine, 4} + {ModItems.gun_uzi, 12}, {ModItems.gun_maresleg, 8}, {ModItems.gun_henry, 12}, {ModItems.gun_heavy_revolver, 8}, {ModItems.gun_flaregun, 4}, {ModItems.gun_star_f, 8} })); slotPoolGunsTier3.put(0, createSlotPool(0, new Object[][]{ - {ModItems.gun_uzi, 25}, {ModItems.gun_spas12, 20}, {ModItems.gun_carbine, 20}, {ModItems.gun_g3, 10}, {ModItems.gun_am180, 5}, {ModItems.gun_stg77, 5} - })); - - slotPoolMasks.put(4, createSlotPool(0, new Object[][]{ - {ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16}, - {ModItems.rag_piss, 4}, {ModItems.goggles, 12} - })); - - slotPoolHelms.put(4, createSlotPool(0, new Object[][]{ - {ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8}, - {ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16}, - {ModItems.cobalt_helmet, 2}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2}, - {ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8} - })); - - slotPoolTierArmor.put(4, createSlotPool(new Object[][]{ - {ModItems.gas_mask_m65, 20}, - {ModItems.gas_mask_olde, 15}, - {ModItems.steel_helmet, 25}, - {ModItems.titanium_helmet, 15}, - {ModItems.alloy_helmet, 10}, - })); - - slotPoolTierArmor.put(3, createSlotPool(new Object[][]{ - {ModItems.steel_plate, 30}, - {ModItems.titanium_plate, 20}, - {ModItems.alloy_plate, 15}, - {ModItems.cobalt_plate, 5}, - {ModItems.starmetal_plate, 5} - })); - - slotPoolTierArmor.put(2, createSlotPool(new Object[][]{ - {ModItems.steel_legs, 30}, - {ModItems.titanium_legs, 20}, - {ModItems.alloy_legs, 15}, - {ModItems.cobalt_legs, 5}, - {ModItems.zirconium_legs, 5} - })); - - slotPoolTierArmor.put(1, createSlotPool(new Object[][]{ - {ModItems.steel_boots, 30}, - {ModItems.robes_boots, 25}, - {ModItems.titanium_boots, 20}, - {ModItems.alloy_boots, 15}, - {ModItems.hazmat_boots, 10}, - {ModItems.cobalt_boots, 5}, - })); - - slotPoolMelee.put(0, createSlotPool(2000, new Object[][]{ - {ModItems.pipe_lead, 40}, {ModItems.crowbar, 35}, {ModItems.wrench, 30}, - {ModItems.steel_sword, 25}, {ModItems.titanium_sword, 20}, - {ModItems.reer_graar, 20}, {ModItems.stopsign, 15}, - {ModItems.lead_gavel, 12}, {ModItems.wrench_flipped, 10}, - {ModItems.sopsign, 8}, {ModItems.chernobylsign, 8} + {ModItems.gun_g3, 25}, {ModItems.gun_spas12, 20}, {ModItems.gun_carbine, 15}, {ModItems.gun_star_f, 20}, {ModItems.gun_am180, 6}, {ModItems.gun_amat, 5} })); slotPoolAdvRanged = new HashMap<>(slotPoolAdv); @@ -268,4 +215,15 @@ public class MobUtil { entity.tasks.addTask(3, new EntityAIFireGun(entity)); } + + public static void addFireTask(EntityLiving entity, EntityAIFireGun gunTask) { + entity.setEquipmentDropChance(0, 0); // Prevent dropping guns + + for(Object entry : entity.tasks.taskEntries) { + EntityAITasks.EntityAITaskEntry task = (EntityAITasks.EntityAITaskEntry) entry; + if(task.action instanceof EntityAIFireGun) return; + } + + entity.tasks.addTask(3, gunTask); + } } diff --git a/src/main/java/com/hbm/world/gen/util/LogicBlockActions.java b/src/main/java/com/hbm/world/gen/util/LogicBlockActions.java index 2e24dbb58..2a9db50d0 100644 --- a/src/main/java/com/hbm/world/gen/util/LogicBlockActions.java +++ b/src/main/java/com/hbm/world/gen/util/LogicBlockActions.java @@ -2,11 +2,13 @@ package com.hbm.world.gen.util; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.bomb.BlockChargeBase; import com.hbm.blocks.generic.BlockSkeletonHolder; import com.hbm.blocks.generic.LogicBlock; import com.hbm.entity.item.EntityFallingBlockNT; import com.hbm.entity.missile.EntityMissileTier2; import com.hbm.entity.mob.EntityUndeadSoldier; +import com.hbm.entity.mob.ai.EntityAIFireGun; import com.hbm.items.ItemEnums; import com.hbm.items.ModItems; import com.hbm.tileentity.TileEntityDoorGeneric; @@ -200,8 +202,7 @@ public class LogicBlockActions { EntitySkeleton mob = new EntitySkeleton(world); mob.setPositionAndRotation(x, y, z, 0, 0); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier2, new Random()); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random()); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random()); + MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolRanged, new Random()); world.spawnEntityInWorld(mob); world.setBlock(x, y, z, Blocks.air); } @@ -217,8 +218,14 @@ public class LogicBlockActions { for (int i = 0; i < 3; i++) { EntitySkeleton mob = new EntitySkeleton(world); mob.setPositionAndRotation(x, y, z, 0, 0); + EntityAIFireGun gunTask = new EntityAIFireGun(mob); + gunTask.minWait = 4; + gunTask.maxWait = 5; + gunTask.burstTime = 6; + gunTask.inaccuracy = 5F; + gunTask.randomBurst = false; + MobUtil.addFireTask(mob, gunTask); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier3, new Random()); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdvRanged, new Random()); world.spawnEntityInWorld(mob); world.setBlock(x, y, z, Blocks.air); @@ -235,8 +242,7 @@ public class LogicBlockActions { for (int i = 0; i < 3; i++) { EntityZombie mob = new EntityZombie(world); mob.setPositionAndRotation(x, y, z, 0, 0); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random()); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random()); + MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolCommon, new Random()); world.spawnEntityInWorld(mob); world.setBlock(x, y, z, Blocks.air); } @@ -252,8 +258,7 @@ public class LogicBlockActions { for (int i = 0; i < 3; i++) { EntityZombie mob = new EntityZombie(world); mob.setPositionAndRotation(x, y, z, 0, 0); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random()); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random()); + MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdv, new Random()); world.spawnEntityInWorld(mob); world.setBlock(x, y, z, Blocks.air); } @@ -425,23 +430,47 @@ public class LogicBlockActions { int y = tile.yCoord; int z = tile.zCoord; - ForgeDirection direction = tile.direction.getOpposite(); + if(tile.phase == 0) { + world.setBlock(x, y + 1, z, ModBlocks.charge_c4, ForgeDirection.UP.ordinal(), 3); - if(tile.phase == 1){ - world.setBlock(x,y,z + direction.offsetZ, ModBlocks.charge_c4, 2, 3); - - TileEntity te = world.getTileEntity(x,y,z + direction.offsetZ); - if(te instanceof TileEntityCharge){ + TileEntity te = world.getTileEntity(x, y + 1, z); + if (te instanceof TileEntityCharge) { + TileEntityCharge bomb = (TileEntityCharge) te; + bomb.timer = 200; + } + } + + if(tile.phase >= 1) { + TileEntity te = world.getTileEntity(x, y + 1, z); + if (te instanceof TileEntityCharge) { TileEntityCharge bomb = (TileEntityCharge) te; - bomb.timer = 2400; bomb.started = true; } + } - world.setBlock(x,y,z, ModBlocks.crate_steel); - TileEntityCrateBase crate = (TileEntityCrateBase) world.getTileEntity(x,y,z); - crate.setPins(world.rand.nextInt(999)); - crate.lock(); - ((IInventory)crate).setInventorySlotContents(15, new ItemStack(ModItems.launch_key)); + + }; + + public static Consumer DEAD_GUY_CRANE = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + if(tile.phase == 1) { + world.setBlock(x, y, z, ModBlocks.skeleton_holder); + TileEntity te = world.getTileEntity(x, y, z); + EntityPlayer player = (EntityPlayer) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(25, 25, 25)).get(0); + + if (te instanceof BlockSkeletonHolder.TileEntitySkeletonHolder) { + BlockSkeletonHolder.TileEntitySkeletonHolder skeleton = (BlockSkeletonHolder.TileEntitySkeletonHolder) te; + if (player != null && player.inventory.hasItem(ModItems.gun_hangman)) { + skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 0); + } else { + skeleton.item = new ItemStack(ModItems.gun_hangman); + } + skeleton.markDirty(); + world.markBlockForUpdate(x, y, z); + } } }; @@ -463,6 +492,7 @@ public class LogicBlockActions { actions.put("COLLAPSE_ROOF_RAD_10", COLLAPSE_ROOF_RAD_10); actions.put("BOMB_TRAP", BOMB_TRAP); actions.put("BOMB_CRANE", BOMB_CRANE); + actions.put("DEAD_GUY_CRANE", DEAD_GUY_CRANE); //Mob Block Actions actions.put("SKELETON_GUN_TIER_1", SKELETONS_GUN_TIER_1); diff --git a/src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java b/src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java index 0e1de662f..75f7cbd5c 100644 --- a/src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java +++ b/src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java @@ -5,6 +5,7 @@ import com.hbm.blocks.generic.BlockPedestal; import com.hbm.blocks.generic.LogicBlock; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ModItems; +import com.hbm.tileentity.bomb.TileEntityCharge; import com.hbm.tileentity.machine.TileEntityLockableBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; @@ -12,6 +13,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -97,6 +99,27 @@ public class LogicBlockConditions { && ((BlockPedestal.TileEntityPedestal) pedestal).item.getItem() == ModItems.big_sword; }; + public static Function BOMB_CRANE = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + if(tile.phase == 0) { + world.setBlock(x, y + 1, z, ModBlocks.charge_c4, ForgeDirection.UP.ordinal(), 3); + + TileEntity te = world.getTileEntity(x, y + 1, z); + if (te instanceof TileEntityCharge) { + TileEntityCharge bomb = (TileEntityCharge) te; + bomb.timer = 200; + } + } + + return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(10, 10, 10)).isEmpty(); + }; + + + public static List getConditionNames(){ return new ArrayList<>(conditions.keySet()); @@ -115,6 +138,8 @@ public class LogicBlockConditions { conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5); conditions.put("PLAYER_CUBE_25", PLAYER_CUBE_25); + conditions.put("BOMB_CRANE", BOMB_CRANE); + //example conditions conditions.put("ABERRATOR", ABERRATOR); conditions.put("REDSTONE", REDSTONE); diff --git a/src/main/resources/assets/hbm/structures/crane_mod.nbt b/src/main/resources/assets/hbm/structures/crane_mod.nbt new file mode 100644 index 000000000..7a13e830d Binary files /dev/null and b/src/main/resources/assets/hbm/structures/crane_mod.nbt differ