From 453c47c6f0037374e4ef25a034326e40178153ea Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Sun, 29 Jun 2025 19:11:39 -0400 Subject: [PATCH 01/11] the gob block --- src/main/java/com/hbm/blocks/ModBlocks.java | 4 + .../hbm/blocks/generic/BlockWandSpawner.java | 249 ++++++++++++++++++ .../hbm/blocks/generic/DungeonSpawner.java | 106 ++------ src/main/java/com/hbm/main/MainRegistry.java | 2 + .../java/com/hbm/main/ModEventHandler.java | 140 ++-------- .../java/com/hbm/tileentity/TileMappings.java | 4 +- src/main/java/com/hbm/util/MobUtil.java | 197 ++++++++++++++ .../world/gen/util/DungeonSpawnerActions.java | 165 ++++++++++++ .../gen/util/DungeonSpawnerConditions.java | 91 +++++++ src/main/resources/assets/hbm/lang/en_US.lang | 1 + .../hbm/textures/blocks/wand_spawner.png | Bin 0 -> 730 bytes .../hbm/textures/blocks/wand_spawner_top.png | Bin 0 -> 740 bytes 12 files changed, 760 insertions(+), 199 deletions(-) create mode 100644 src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java create mode 100644 src/main/java/com/hbm/util/MobUtil.java create mode 100644 src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java create mode 100644 src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java create mode 100644 src/main/resources/assets/hbm/textures/blocks/wand_spawner.png create mode 100644 src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index f6dcd2065..f69f85497 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -1243,6 +1243,7 @@ public class ModBlocks { public static Block wand_air; public static Block wand_loot; public static Block wand_jigsaw; + public static Block wand_spawner; public static Material materialGas = new MaterialGas(); @@ -2396,6 +2397,8 @@ public class ModBlocks { wand_air = new BlockWand(Blocks.air).setBlockName("wand_air").setBlockTextureName(RefStrings.MODID + ":wand_air"); wand_loot = new BlockWandLoot().setBlockName("wand_loot").setBlockTextureName(RefStrings.MODID + ":wand_loot"); wand_jigsaw = new BlockWandJigsaw().setBlockName("wand_jigsaw").setBlockTextureName(RefStrings.MODID + ":wand_jigsaw"); + wand_spawner = new BlockWandSpawner().setBlockName("wand_spawner").setBlockTextureName(RefStrings.MODID + ":wand_spawner"); + } private static void registerBlock() { @@ -3542,6 +3545,7 @@ public class ModBlocks { register(wand_air); register(wand_loot); register(wand_jigsaw); + register(wand_spawner); } private static void register(Block b) { diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java new file mode 100644 index 000000000..fdfca7689 --- /dev/null +++ b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java @@ -0,0 +1,249 @@ +package com.hbm.blocks.generic; + +import api.hbm.block.IToolable; +import com.hbm.blocks.IBlockSideRotation; +import com.hbm.blocks.ILookOverlay; +import com.hbm.blocks.ITooltipProvider; +import com.hbm.blocks.ModBlocks; +import com.hbm.config.StructureConfig; +import com.hbm.interfaces.IBomb; +import com.hbm.interfaces.ICopiable; +import com.hbm.lib.RefStrings; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.TileEntityLoadedBase; +import com.hbm.util.BufferUtil; +import com.hbm.util.i18n.I18nUtil; +import com.hbm.world.gen.INBTTileEntityTransformable; +import com.hbm.world.gen.util.DungeonSpawnerActions; +import com.hbm.world.gen.util.DungeonSpawnerConditions; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderGameOverlayEvent; + +import java.util.ArrayList; +import java.util.List; + +public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb { + + @SideOnly(Side.CLIENT) protected IIcon iconTop; + + public BlockWandSpawner() { + super(Material.iron); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_spawner"); + this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_spawner_top"); + } + + @Override + public IIcon getIcon(int side, int meta) { + return (side <= 1) ? iconTop : blockIcon; + } + + @Override + public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) { + if(side == 0) return IBlockSideRotation.topToBottom(world.getBlockMetadata(x, y, z)); + if(side == 1) return world.getBlockMetadata(x, y, z); + return 0; + } + + @Override + public int getRenderType() { + return IBlockSideRotation.getRenderType(); + } + + @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, 3, 2); + if (i == 1) world.setBlockMetadataWithNotify(x, y, z, 2, 2); + if (i == 2) world.setBlockMetadataWithNotify(x, y, z, 0, 2); + if (i == 3) world.setBlockMetadataWithNotify(x, y, z, 1, 2); + + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TileEntityWandSpawner) + ((TileEntityWandSpawner)te).placedRotation = i; + } + + @Override + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + TileEntity te = world.getTileEntity(x, y, z); + + if(!(te instanceof TileEntityWandSpawner)) return false; + + TileEntityWandSpawner spawner = (TileEntityWandSpawner) te; + + switch(tool) { + case SCREWDRIVER: + List actionNames = DungeonSpawnerActions.getActionNames(); + int indexA = actionNames.indexOf(spawner.actionID); + + indexA += player.isSneaking() ? -1 : 1; + indexA = MathHelper.clamp_int(indexA, 0, actionNames.size() - 1); + + spawner.actionID = actionNames.get(indexA); + return true; + case DEFUSER: + List conditionNames = DungeonSpawnerConditions.getConditionNames(); + int indexC = conditionNames.indexOf(spawner.conditionID); + + indexC += player.isSneaking() ? -1 : 1; + indexC = MathHelper.clamp_int(indexC, 0, conditionNames.size() - 1); + + spawner.conditionID = conditionNames.get(indexC); + + return true; + + default: return false; + } + } + + @Override + public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + + if(!(te instanceof TileEntityWandSpawner)) return; + + TileEntityWandSpawner spawner = (TileEntityWandSpawner) te; + + List text = new ArrayList(); + text.add("Action: " + spawner.actionID); + text.add("Condition: " + spawner.conditionID); + + ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { + list.add(EnumChatFormatting.GOLD + "Use screwdriver to cycle forwards through the action list, shift click to go back"); + list.add(EnumChatFormatting.GOLD + "Use defuser to cycle forwards through the condition list, shift click to go back"); + list.add(EnumChatFormatting.BLUE + "Use a detonator to transform"); + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new TileEntityWandSpawner(); + } + + @Override + public BombReturnCode explode(World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + + if(!(te instanceof TileEntityWandSpawner)) return null; + + ((TileEntityWandSpawner) te).triggerReplace = true; + + return BombReturnCode.TRIGGERED; + } + + public static class TileEntityWandSpawner extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable { + private boolean triggerReplace; + + public int placedRotation; + + public String actionID = "PHASE_ABERRATOR"; + public String conditionID = "ABERRATOR"; + + @Override + public void updateEntity() { + if(!worldObj.isRemote) { + if(triggerReplace) { + // On the first tick of this TE, replace with intended block and fill with loot + replace(); + } else { + networkPackNT(15); + } + } + } + + private void replace() { + if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandSpawner)) { + MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a dungeon spawner block but we're doing a TE update as if it is, cancelling!"); + return; + } + worldObj.setBlock(xCoord,yCoord,zCoord, ModBlocks.dungeon_spawner); + + TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord); + + if(te == null || te instanceof BlockWandLoot.TileEntityWandLoot) { + MainRegistry.logger.warn("TE for dungeon spawner set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!"); + te = ModBlocks.wand_spawner.createTileEntity(worldObj, 0); + worldObj.setTileEntity(xCoord, yCoord, zCoord, te); + } + + if(te instanceof DungeonSpawner.TileEntityDungeonSpawner){ + DungeonSpawner.TileEntityDungeonSpawner spawner = (DungeonSpawner.TileEntityDungeonSpawner) te; + spawner.actionID = actionID; + spawner.conditionID = conditionID; + } + + } + + @Override + public void transformTE(World world, int coordBaseMode) { + triggerReplace = !StructureConfig.debugStructures; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setString("actionID", actionID); + nbt.setString("conditionID", conditionID); + nbt.setInteger("rotation", placedRotation); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + actionID = nbt.getString("actionID"); + conditionID = nbt.getString("conditionID"); + placedRotation = nbt.getInteger("rotation"); + } + + @Override + public void serialize(ByteBuf buf) { + buf.writeInt(placedRotation); + BufferUtil.writeString(buf, actionID); + BufferUtil.writeString(buf, conditionID); + } + + @Override + public void deserialize(ByteBuf buf) { + placedRotation = buf.readInt(); + actionID = BufferUtil.readString(buf); + conditionID = BufferUtil.readString(buf); + } + + @Override + public NBTTagCompound getSettings(World world, int x, int y, int z) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("actionID", actionID); + nbt.setString("conditionID", conditionID); + return nbt; + } + + @Override + public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { + actionID = nbt.getString("actionID"); + conditionID = nbt.getString("conditionID"); + } + } +} diff --git a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java index 4a6fc10d8..ffbb14239 100644 --- a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java @@ -7,7 +7,8 @@ import com.hbm.blocks.generic.BlockSkeletonHolder.TileEntitySkeletonHolder; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ItemEnums.EnumSecretType; import com.hbm.items.ModItems; -import com.hbm.util.EnumUtil; +import com.hbm.world.gen.util.DungeonSpawnerActions; +import com.hbm.world.gen.util.DungeonSpawnerConditions; import com.hbm.util.Vec3NT; import net.minecraft.block.BlockContainer; @@ -30,19 +31,35 @@ public class DungeonSpawner extends BlockContainer { public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityDungeonSpawner(); } - + public static class TileEntityDungeonSpawner extends TileEntity { - + public int phase = 0; public int timer = 0; - public EnumSpawnerType type = EnumSpawnerType.ABERRATOR; - + + public String conditionID = "ABERRATOR"; + //actions always get called before conditions, use the phase timer in order to control behavior via condition + public String actionID = "ABERRATOR"; + + public Function condition; + public Consumer action; + @Override public void updateEntity() { - + if(!worldObj.isRemote) { - type.phase.accept(this); - if(type.phaseCondition.apply(this)) { + if(action == null){ + action = DungeonSpawnerActions.actions.get(actionID); + } + if(condition == null){ + condition = DungeonSpawnerConditions.conditions.get(conditionID); + } + if(action == null || condition == null){ + worldObj.setBlock(xCoord,yCoord,zCoord, Blocks.air); + return; + } + action.accept(this); + if(condition.apply(this)) { phase++; timer = 0; } else { @@ -55,83 +72,16 @@ public class DungeonSpawner extends BlockContainer { public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("phase", phase); - nbt.setByte("type", (byte) type.ordinal()); + nbt.setString("conditionID", conditionID); + nbt.setString("actionID", actionID); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.phase = nbt.getInteger("phase"); - this.type = EnumUtil.grabEnumSafely(EnumSpawnerType.class, nbt.getByte("type")); + this.conditionID = nbt.getString("conditionID"); } } - - public static enum EnumSpawnerType { - - ABERRATOR(CON_ABERRATOR, PHASE_ABERRATOR); - public Function phaseCondition; - public Consumer phase; - - private EnumSpawnerType(Function con, Consumer ph) { - this.phaseCondition = con; - this.phase = ph; - } - } - - public static Function CON_ABERRATOR = (tile) -> { - World world = tile.getWorldObj(); - if(world.difficultySetting.ordinal() == 0) return false; - int x = tile.xCoord; - int y = tile.yCoord; - int z = tile.zCoord; - if(tile.phase == 0) { - if(world.getTotalWorldTime() % 20 != 0) return false; - return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(20, 10, 20)).isEmpty(); - } - if(tile.phase < 3) { - if(world.getTotalWorldTime() % 20 != 0 || tile.timer < 60) return false; - return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty(); - } - return false; - }; - - public static Consumer PHASE_ABERRATOR = (tile) -> { - World world = tile.getWorldObj(); - int x = tile.xCoord; - int y = tile.yCoord; - int z = tile.zCoord; - if(tile.phase == 1 || tile.phase == 2) { - if(tile.timer == 0) { - Vec3NT vec = new Vec3NT(10, 0, 0); - for(int i = 0; i < 10; i++) { - EntityUndeadSoldier mob = new EntityUndeadSoldier(world); - for(int j = 0; j < 7; j++) { - mob.setPositionAndRotation(x + 0.5 + vec.xCoord, y - 5, z + 0.5 + vec.zCoord, i * 36F, 0); - if(mob.getCanSpawnHere()) { - mob.onSpawnWithEgg(null); - world.spawnEntityInWorld(mob); - break; - } - } - - vec.rotateAroundYDeg(36D); - } - } - } - if(tile.phase > 2) { - TileEntity te = world.getTileEntity(x, y + 18, z); - if(te instanceof TileEntitySkeletonHolder) { - TileEntitySkeletonHolder skeleton = (TileEntitySkeletonHolder) te; - if(world.rand.nextInt(5) == 0) { - skeleton.item = new ItemStack(ModItems.item_secret, 1, EnumSecretType.ABERRATOR.ordinal()); - } else { - skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 1); - } - skeleton.markDirty(); - world.markBlockForUpdate(x, y + 18, z); - } - world.setBlock(x, y, z, Blocks.obsidian); - } - }; } diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index 4c8e7f954..0891e4012 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -877,6 +877,8 @@ public class MainRegistry { BlockToolConversion.registerRecipes(); AchievementHandler.register(); + MobUtil.intializeMobPools(); + proxy.registerMissileItems(); // Load compatibility for OC. diff --git a/src/main/java/com/hbm/main/ModEventHandler.java b/src/main/java/com/hbm/main/ModEventHandler.java index cd368b165..655656174 100644 --- a/src/main/java/com/hbm/main/ModEventHandler.java +++ b/src/main/java/com/hbm/main/ModEventHandler.java @@ -387,74 +387,18 @@ public class ModEventHandler { if(entity instanceof EntityZombie) { if(world.rand.nextFloat() < 0.005F && soot > 2) { // full hazmat zombine - equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots); + MobUtil.equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots); return; } - - if(world.rand.nextFloat() < 0.005F && soot > 20) { // full security zombine - equipFullSet(entity, ModItems.security_helmet, ModItems.security_plate, ModItems.security_legs, ModItems.security_boots); - return; - } - - slotPools.put(4, createSlotPool(8000, new Object[][]{ //new slots, smooth, brushed, no wrinkles // old slots, wrinkled, rusty, not smooth - {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.rag_piss, 1}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2}, - {ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8} - })); - slotPools.put(3, createSlotPool(7000, new Object[][]{ - {ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.robes_plate, 32}, - {ModItems.jackt, 32}, {ModItems.jackt2, 32}, {ModItems.alloy_plate, 2}, - {ModItems.steel_plate, 2} - })); - slotPools.put(2, createSlotPool(7000, 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} - })); - slotPools.put(1, createSlotPool(7000, new Object[][]{ - {ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2} - })); - slotPools.put(0, createSlotPool(10000, new Object[][]{ - {ModItems.pipe_lead, 30}, {ModItems.crowbar, 25}, {ModItems.geiger_counter, 20}, - {ModItems.reer_graar, 16}, {ModItems.steel_pickaxe, 12}, {ModItems.stopsign, 10}, - {ModItems.sopsign, 8}, {ModItems.chernobylsign, 6}, {ModItems.steel_sword, 15}, - {ModItems.alloy_axe, 5}, {ModItems.titanium_sword, 8}, {ModItems.lead_gavel, 4}, - {ModItems.wrench, 20}, {ModItems.cobalt_decorated_sword, 2}, {ModItems.detonator_de, 1} - })); + slotPools = MobUtil.slotPoolCommon; } else if(entity instanceof EntitySkeleton) { - - slotPools.put(4, createSlotPool(12000, 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.rag_piss, 1}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2}, - {ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8} - })); - slotPools.put(3, createSlotPool(10000, 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} - })); - slotPools.put(2, createSlotPool(10000, 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}, - })); - slotPools.put(1, createSlotPool(10000, new Object[][]{ - {ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}, - {ModItems.titanium_boots, 6} - })); - + slotPools = MobUtil.slotPoolRanged; ItemStack bowReplacement = getSkelegun(soot, world.rand); slotPools.put(0, createSlotPool(50, bowReplacement != null ? new Object[][]{{bowReplacement, 1}} : new Object[][]{})); } - assignItemsToEntity(entity, slotPools); - } - - private void equipFullSet(EntityLivingBase entity, Item helmet, Item chest, Item legs, Item boots) { //for brainlets (me) to add more armorsets later when i forget about how this works - entity.setCurrentItemOrArmor(4, new ItemStack(helmet)); //p_70062_1_ is the slot number - entity.setCurrentItemOrArmor(3, new ItemStack(chest)); - entity.setCurrentItemOrArmor(2, new ItemStack(legs)); - entity.setCurrentItemOrArmor(1, new ItemStack(boots)); + MobUtil.assignItemsToEntity(entity, slotPools, rand); } private List createSlotPool(int nullWeight, Object[][] items) { @@ -473,74 +417,30 @@ public class ModEventHandler { return pool; } - - public void assignItemsToEntity(EntityLivingBase entity, Map> slotPools) { - for (Map.Entry> entry : slotPools.entrySet()) { - int slot = entry.getKey(); - List pool = entry.getValue(); - - WeightedRandomObject choice = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool); //NullPointerException sludge fix - if (choice == null) { - continue; - } - - ItemStack stack = choice.asStack(); - if (stack == null || stack.getItem() == null) { - continue; - } - - if (stack.getItem() == ModItems.gas_mask_m65 //eyesore - || stack.getItem() == ModItems.gas_mask_olde - || stack.getItem() == ModItems.gas_mask_mono) { - ArmorUtil.installGasMaskFilter(stack, new ItemStack(ModItems.gas_mask_filter)); - } - - entity.setCurrentItemOrArmor(slot, stack); - - //Give skeleton AI if it has a gun - if (slot == 0 && entity instanceof EntitySkeleton && pool == slotPools.get(0)) { - addFireTask((EntityLiving) entity); - } - } - } - private static ItemStack getSkelegun(float soot, Random rand) { - if(!MobConfig.enableMobWeapons) return null; - if(rand.nextDouble() > Math.log(soot) * 0.25) return null; + if (!MobConfig.enableMobWeapons) return null; + if (rand.nextDouble() > Math.log(soot) * 0.25) return null; - ArrayList pool = new ArrayList(); - pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_light_revolver), 12)); - pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_heavy_revolver), 8)); + ArrayList pool = new ArrayList<>(); - if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_pepperbox), 10)); - if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_henry), 8)); - if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_greasegun), 6)); - - if(soot > 4) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_maresleg), 4)); - if(soot > 4) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_uzi), 6)); - - if(soot > 8) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_spas12), 3)); - if(soot > 8) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_am180), 4)); - - if(soot > 12) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_congolake), 1)); + if(soot < 0.3){ + pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_pepperbox), 5)); + pool.add(new WeightedRandomObject(null, 20)); + } else if(soot > 0.3 && soot < 1) { + pool.addAll(MobUtil.slotPoolGuns.get(0.3)); + } else if (soot < 3) { + pool.addAll(MobUtil.slotPoolGuns.get(1D)); + } else if (soot < 5) { + pool.addAll(MobUtil.slotPoolGuns.get(3D)); + } else { + pool.addAll(MobUtil.slotPoolGuns.get(5D)); + } WeightedRandomObject selected = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool); return selected.asStack(); } - // these fucking tasks keep stacking on top of themselves - private static void addFireTask(EntityLiving entity) { - 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, new EntityAIFireGun(entity)); - } - @SubscribeEvent public void addAITasks(EntityJoinWorldEvent event) { if(event.world.isRemote || !(event.entity instanceof EntityLiving)) return; @@ -549,7 +449,7 @@ public class ModEventHandler { ItemStack held = living.getHeldItem(); if(held != null && held.getItem() instanceof ItemGunBaseNT) { - addFireTask(living); + MobUtil.addFireTask(living); } } diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index ca3281bd1..f688059be 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -19,6 +19,7 @@ import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe; import com.hbm.blocks.generic.BlockSupplyCrate.TileEntitySupplyCrate; import com.hbm.blocks.generic.BlockWandJigsaw.TileEntityWandJigsaw; import com.hbm.blocks.generic.BlockWandLoot.TileEntityWandLoot; +import com.hbm.blocks.generic.BlockWandSpawner.TileEntityWandSpawner; import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner; import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter; import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF; @@ -236,6 +237,7 @@ public class TileMappings { put(TileEntityWandLoot.class, "tileentity_wand_loot"); put(TileEntityWandJigsaw.class, "tileentity_wand_jigsaw"); + put(TileEntityWandSpawner.class, "tileentity_wand_spawner"); putNetwork(); putBombs(); @@ -428,7 +430,7 @@ public class TileMappings { put(TileEntityCranePartitioner.class, "tileentity_partitioner"); put(TileEntityFan.class, "tileentity_fan"); put(TileEntityPistonInserter.class, "tileentity_piston_inserter"); - + put(TileEntityPneumoTube.class, "tileentity_pneumatic_tube"); put(TileEntityRadioTorchSender.class, "tileentity_rtty_sender"); diff --git a/src/main/java/com/hbm/util/MobUtil.java b/src/main/java/com/hbm/util/MobUtil.java new file mode 100644 index 000000000..8779c1ed2 --- /dev/null +++ b/src/main/java/com/hbm/util/MobUtil.java @@ -0,0 +1,197 @@ +package com.hbm.util; + +import com.hbm.entity.mob.ai.EntityAIFireGun; +import com.hbm.items.ModItems; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.EntityAITasks; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +import java.util.*; + +public class MobUtil { + + + public static Map> slotPoolCommon = new HashMap<>(); + public static Map> slotPoolRanged = new HashMap<>(); + + public static Map> slotPoolAdv = new HashMap<>(); + public static Map> slotPoolAdvRanged; + /**Unlike the above two, the Double is interpreted as minimum soot level, instead of armor slot **/ + public static HashMap> slotPoolGuns = new HashMap<>(); + + + public static void intializeMobPools(){ + slotPoolCommon.put(4, createSlotPool(8000, new Object[][]{ //new slots, smooth, brushed, no wrinkles // old slots, wrinkled, rusty, not smooth + {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.rag_piss, 1}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2}, + {ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8} + })); + slotPoolCommon.put(3, createSlotPool(7000, new Object[][]{ + {ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.robes_plate, 32}, + {ModItems.jackt, 32}, {ModItems.jackt2, 32}, {ModItems.alloy_plate, 2}, + {ModItems.steel_plate, 2} + })); + slotPoolCommon.put(2, createSlotPool(7000, 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} + })); + slotPoolCommon.put(1, createSlotPool(7000, new Object[][]{ + {ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2} + })); + slotPoolCommon.put(0, createSlotPool(10000, new Object[][]{ + {ModItems.pipe_lead, 30}, {ModItems.crowbar, 25}, {ModItems.geiger_counter, 20}, + {ModItems.reer_graar, 16}, {ModItems.steel_pickaxe, 12}, {ModItems.stopsign, 10}, + {ModItems.sopsign, 8}, {ModItems.chernobylsign, 6}, {ModItems.steel_sword, 15}, + {ModItems.titanium_sword, 8}, {ModItems.lead_gavel, 4}, {ModItems.wrench_flipped, 2}, + {ModItems.wrench, 20} + })); + + slotPoolRanged.put(4, createSlotPool(12000, 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[][]{ + {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[][]{ + {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[][]{ + {ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}, + {ModItems.titanium_boots, 6} + })); + + slotPoolGuns.put(0.3, createSlotPool(new Object[][]{ + {ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2} + })); + slotPoolGuns.put(1D, createSlotPool(new Object[][]{ + {ModItems.gun_light_revolver, 6}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 4}, {ModItems.gun_henry, 6} + })); + slotPoolGuns.put(3D, createSlotPool(new Object[][]{ + {ModItems.gun_uzi, 10}, {ModItems.gun_maresleg, 8}, {ModItems.gun_henry, 12}, {ModItems.gun_heavy_revolver, 4}, {ModItems.gun_flaregun, 2} + })); + slotPoolGuns.put(5D, createSlotPool(new Object[][]{ + {ModItems.gun_am180, 6}, {ModItems.gun_uzi, 10}, {ModItems.gun_spas12, 8}, {ModItems.gun_henry_lincoln, 2}, {ModItems.gun_heavy_revolver, 12}, {ModItems.gun_flaregun, 4}, {ModItems.gun_flamer, 2} + })); + + slotPoolAdv.put(4, createSlotPool(new Object[][]{ + {ModItems.security_helmet, 10}, {ModItems.t45_helmet, 4}, {ModItems.asbestos_helmet, 12}, + {ModItems.liquidator_helmet, 4}, {ModItems.no9, 12}, + {ModItems.hazmat_helmet, 6} + })); + slotPoolAdv.put(3, createSlotPool(new Object[][]{ + {ModItems.liquidator_plate, 4}, {ModItems.security_plate, 8}, {ModItems.asbestos_plate, 12}, + {ModItems.t45_plate, 4}, {ModItems.hazmat_plate, 6}, + {ModItems.steel_plate, 8} + })); + slotPoolAdv.put(2, createSlotPool(new Object[][]{ + {ModItems.liquidator_legs, 4}, {ModItems.security_legs, 8}, {ModItems.asbestos_legs, 12}, + {ModItems.t45_legs, 4}, {ModItems.hazmat_legs, 6}, + {ModItems.steel_legs, 8} + })); + slotPoolAdv.put(1, createSlotPool(new Object[][]{ + {ModItems.liquidator_boots, 4}, {ModItems.security_boots, 8}, {ModItems.asbestos_boots, 12}, + {ModItems.t45_boots, 4}, {ModItems.hazmat_boots, 6}, + {ModItems.robes_boots, 8} + })); + slotPoolAdv.put(0, createSlotPool(new Object[][]{ + {ModItems.pipe_lead, 20}, {ModItems.crowbar, 30}, {ModItems.geiger_counter, 20}, + {ModItems.reer_graar, 20}, {ModItems.wrench_flipped, 12}, {ModItems.stopsign, 16}, + {ModItems.sopsign, 4}, {ModItems.chernobylsign, 16}, + {ModItems.titanium_sword, 18}, {ModItems.lead_gavel, 8}, + {ModItems.wrench, 20} + })); + + slotPoolAdvRanged = new HashMap<>(slotPoolAdv); + slotPoolAdvRanged.remove(0); + + } + + public static List createSlotPool(int nullWeight, Object[][] items) { + List pool = new ArrayList<>(); + pool.add(new WeightedRandomObject(null, nullWeight)); + for (Object[] item : items) { + Object obj = item[0]; + int weight = (int) item[1]; + + if (obj instanceof Item) { + pool.add(new WeightedRandomObject(new ItemStack((Item) obj), weight)); + } else if (obj instanceof ItemStack) { //lol just make it pass ItemStack aswell + pool.add(new WeightedRandomObject(obj, weight)); + } + } + return pool; + } + public static List createSlotPool(Object[][] items) { + List pool = new ArrayList<>(); + for (Object[] item : items) { + Object obj = item[0]; + int weight = (int) item[1]; + + if (obj instanceof Item) { + pool.add(new WeightedRandomObject(new ItemStack((Item) obj), weight)); + } else if (obj instanceof ItemStack) { //lol just make it pass ItemStack aswell + pool.add(new WeightedRandomObject(obj, weight)); + } + } + return pool; + } + + public static void equipFullSet(EntityLivingBase entity, Item helmet, Item chest, Item legs, Item boots) { //for brainlets (me) to add more armorsets later when i forget about how this works + entity.setCurrentItemOrArmor(4, new ItemStack(helmet)); //p_70062_1_ is the slot number + entity.setCurrentItemOrArmor(3, new ItemStack(chest)); + entity.setCurrentItemOrArmor(2, new ItemStack(legs)); + entity.setCurrentItemOrArmor(1, new ItemStack(boots)); + } + + public static void assignItemsToEntity(EntityLivingBase entity, Map> slotPools, Random rand) { + for (Map.Entry> entry : slotPools.entrySet()) { + int slot = entry.getKey(); + List pool = entry.getValue(); + + WeightedRandomObject choice = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool); //NullPointerException sludge fix + if (choice == null) { + continue; + } + + ItemStack stack = choice.asStack(); + if (stack == null || stack.getItem() == null) { + continue; + } + + if (stack.getItem() == ModItems.gas_mask_m65 //eyesore + || stack.getItem() == ModItems.gas_mask_olde + || stack.getItem() == ModItems.gas_mask_mono) { + ArmorUtil.installGasMaskFilter(stack, new ItemStack(ModItems.gas_mask_filter)); + } + + entity.setCurrentItemOrArmor(slot, stack); + + //Give skeleton AI if it has a gun + if (slot == 0 && entity instanceof EntitySkeleton && pool == slotPools.get(0)) { + addFireTask((EntityLiving) entity); + } + } + } + + // these fucking tasks keep stacking on top of themselves + public static void addFireTask(EntityLiving entity) { + 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, new EntityAIFireGun(entity)); + } +} diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java new file mode 100644 index 000000000..120ea00e8 --- /dev/null +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java @@ -0,0 +1,165 @@ +package com.hbm.world.gen.util; + +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.generic.BlockPedestal; +import com.hbm.blocks.generic.BlockSkeletonHolder; +import com.hbm.blocks.generic.DungeonSpawner; +import com.hbm.entity.item.EntityFallingBlockNT; +import com.hbm.entity.mob.EntityUndeadSoldier; +import com.hbm.items.ItemEnums; +import com.hbm.items.ModItems; +import com.hbm.main.ModEventHandler; +import com.hbm.tileentity.machine.storage.TileEntityCrateBase; +import com.hbm.util.MobUtil; +import com.hbm.util.Vec3NT; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; +import java.util.function.Consumer; + +public class DungeonSpawnerActions { + + public static HashMap> actions = new HashMap<>(); + + public static Consumer PHASE_ABERRATOR = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + if (tile.phase == 1 || tile.phase == 2) { + if (tile.timer == 0) { + Vec3NT vec = new Vec3NT(10, 0, 0); + for (int i = 0; i < 10; i++) { + EntityUndeadSoldier mob = new EntityUndeadSoldier(world); + for (int j = 0; j < 7; j++) { + mob.setPositionAndRotation(x + 0.5 + vec.xCoord, y - 5, z + 0.5 + vec.zCoord, i * 36F, 0); + if (mob.getCanSpawnHere()) { + mob.onSpawnWithEgg(null); + world.spawnEntityInWorld(mob); + break; + } + } + + vec.rotateAroundYDeg(36D); + } + } + } + if (tile.phase > 2) { + TileEntity te = world.getTileEntity(x, y + 18, z); + if (te instanceof BlockSkeletonHolder.TileEntitySkeletonHolder) { + BlockSkeletonHolder.TileEntitySkeletonHolder skeleton = (BlockSkeletonHolder.TileEntitySkeletonHolder) te; + if (world.rand.nextInt(5) == 0) { + skeleton.item = new ItemStack(ModItems.item_secret, 1, ItemEnums.EnumSecretType.ABERRATOR.ordinal()); + } else { + skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 1); + } + skeleton.markDirty(); + world.markBlockForUpdate(x, y + 18, z); + } + world.setBlock(x, y, z, Blocks.obsidian); + } + }; + + public static Consumer COLLAPSE_ROOF_RAD_5 = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + if(tile.phase == 0) return; + + //from explosionChaos because i cannot be assed + int r = 4; + int r2 = r * r; + int r22 = r2 / 2; + + for (int xx = -r; xx < r; xx++) { + int X = xx + x; + int XX = xx * xx; + for (int yy = -r; yy < r; yy++) { + int Y = yy + y; + int YY = XX + yy * yy; + for (int zz = -r; zz < r; zz++) { + int Z = zz + z; + int ZZ = YY + zz * zz; + if (ZZ < r22) { + + if (world.getBlock(X, Y, Z).getExplosionResistance(null) <= 70) { + EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(world, X + 0.5, Y + 0.5, Z + 0.5, world.getBlock(X, Y, Z), world.getBlockMetadata(X, Y, Z)); + world.spawnEntityInWorld(entityfallingblock); + } + } + } + } + } + world.setBlock(x, y, z, ModBlocks.block_steel); + + }; + + public static Consumer FODDER_WAVE = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + if (tile.phase == 1) { + Vec3NT vec = new Vec3NT(5, 0, 0); + for (int i = 0; i < 10; i++) { + EntityZombie mob = new EntityZombie(world); + for (int j = 0; j < 7; j++) { + mob.setPositionAndRotation(x + 0.5 + vec.xCoord, world.getHeightValue(x,z), z + 0.5 + vec.zCoord, i * 36F, 0); + MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdv, new Random()); + if (mob.getCanSpawnHere()) { + world.spawnEntityInWorld(mob); + break; + } + } + vec.rotateAroundYDeg(36D); + } + world.setBlock(x, y, z, ModBlocks.block_steel); + } + }; + + public static Consumer PUZZLE_TEST = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + if(tile.phase == 2){ + world.setBlock(x,y,z, ModBlocks.crate_steel); + + EntityLightningBolt blitz = new EntityLightningBolt(world, x, world.getHeightValue(x, z) + 1, z); + world.spawnEntityInWorld(blitz); + + TileEntityCrateBase crate = (TileEntityCrateBase) world.getTileEntity(x,y,z); + ((IInventory)crate).setInventorySlotContents(15, new ItemStack(ModItems.gun_bolter)); + } + }; + + public static List getActionNames(){ + return new ArrayList<>(actions.keySet()); + } + + //register new actions here + static{ + actions.put("PHASE_ABERRATOR", PHASE_ABERRATOR); + actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5); + actions.put("FODDER_WAVE", FODDER_WAVE); + actions.put("PUZZLE_TEST", PUZZLE_TEST); + } + + + +} diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java new file mode 100644 index 000000000..0a634c271 --- /dev/null +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java @@ -0,0 +1,91 @@ +package com.hbm.world.gen.util; + +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.generic.BlockPedestal; +import com.hbm.blocks.generic.DungeonSpawner; +import com.hbm.entity.mob.EntityUndeadSoldier; +import com.hbm.items.ModItems; +import com.hbm.tileentity.machine.storage.TileEntityCrateBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.function.Function; + +public class DungeonSpawnerConditions { + + public static HashMap> conditions = new HashMap<>(); + + public static Function ABERRATOR = (tile) -> { + World world = tile.getWorldObj(); + if(world.difficultySetting.ordinal() == 0) return false; + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + if(tile.phase == 0) { + if(world.getTotalWorldTime() % 20 != 0) return false; + return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(20, 10, 20)).isEmpty(); + } + if(tile.phase < 3) { + if(world.getTotalWorldTime() % 20 != 0 || tile.timer < 60) return false; + return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty(); + } + return false; + }; + + public static Function PLAYER_CUBE_5 = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(5, 5, 5)).isEmpty(); + }; + + public static Function REDSTONE = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + return world.isBlockIndirectlyGettingPowered(x,y,z); + }; + + public static Function PUZZLE_TEST = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + if(tile.phase == 0 && world.isBlockIndirectlyGettingPowered(x,y,z)){ + world.getClosestPlayer(x,y,z, 25).addChatMessage(new ChatComponentText("Find a " + EnumChatFormatting.GOLD + "great" + EnumChatFormatting.RESET + " ancient weapon, of questionable use in the modern age")); + world.setBlock(x,y + 1,z, ModBlocks.pedestal); + return true; + } + + TileEntity pedestal = world.getTileEntity(x,y + 1,z); + + return tile.phase == 1 + && pedestal instanceof BlockPedestal.TileEntityPedestal + && ((BlockPedestal.TileEntityPedestal) pedestal).item != null + && ((BlockPedestal.TileEntityPedestal) pedestal).item.getItem() == ModItems.big_sword; + }; + + public static List getConditionNames(){ + return new ArrayList<>(conditions.keySet()); + } + + //register new conditions here + static { + conditions.put("ABERRATOR", ABERRATOR); + conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5); + conditions.put("REDSTONE", REDSTONE); + conditions.put("PUZZLE_TEST", PUZZLE_TEST); + } + +} diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 74c5a343b..0a90eddf7 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -6061,6 +6061,7 @@ tile.volcano_rad_core.name=Rad Volcano Core tile.wand_air.name=Structure Wand Block (Air) tile.wand_loot.name=Structure Wand Block (Lootable) tile.wand_jigsaw.name=Structure Wand Block (Jigsaw) +tile.wand_spawner.name=Structure Wand Block (Actions) tile.waste_earth.name=Dead Grass tile.waste_leaves.name=Dead Leaves tile.waste_log.name=Charred Log diff --git a/src/main/resources/assets/hbm/textures/blocks/wand_spawner.png b/src/main/resources/assets/hbm/textures/blocks/wand_spawner.png new file mode 100644 index 0000000000000000000000000000000000000000..4561c8e4ee9f3dd2e6c8eec19ef31a27d2648ff9 GIT binary patch literal 730 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPL>Y{_(X4)An#RtPA{Ps_|nWnj=a zKXsz5$6*JVqw&E@l|a-W%a>xlG`;@R5{R?fFL z;433wnwqFGpJ4YgVkT+9sL~*vB^mLr9?6&f^(@kSqSZVx znK3kDLahA{=|AtTX`S(@_H^WYQCm2tzffTVx5?|i&$VwX&I%v+&lB@9w|*<*nfgg_ z`PmPZ6AGkv?8wVLC0DSMxyMFwljiP8^Opr^FuYIy;$xZcLhMES=c??tkH0XU2nauI ze&C>@LEw@%U-iDfd;R9^`T9Hm6#gldvJwM)?eMhjJ*_rJuVDT&< z8w5Nh85v#x6Az3=vy=g-e*!xL3s9wjk+A{e0*I+#p8&j=q`{-;D&Q<|NI+#KBO8a{j>Z{fj&lwkU|{e$#-X$8k{QTt44$rj JF6*2UngE?A_U`}y literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png b/src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png new file mode 100644 index 0000000000000000000000000000000000000000..4788b84883581058c6fdf5525b3239d0e888f352 GIT binary patch literal 740 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPL>Y|3BPd`_OrtHz2RrJEzLct)l-`jtSimUq^_o?J^%8- zSW0o$i^bPA?74H~ipQKyj~`Ft+Ip{KrOrR|SHj-&SVebzSTMEt^P%oTe^>vU^GNn# z$JQK`7XMc3*qsYL?7eiBX}^Xa>zb8kI;8t~Io(^nhH%bS&C%VxtzdmY^r149_}Q8T zP9J9_S#M7Idnb7BhP;zA=LPLL6XqtF+~ir}6Xr2l(SQ1yJ`Fj;oBh*1ZfE)DSvd2N zS8`|a3>`DK2kw6lzR%m6;$N<~QjaUtf8YOWd=GVh-1_qOyz~A4R!tX_V=P?jzcH}g zbG@&VmHYd`2EO#^u4nJGedf)mJ0ZDF&_i)%lo988^-sQ=FI4cFer~;2_sw!&^NteJ zI@aCQ7bZ@6(`xj7o!;BG=ZzifUG_6Bo>sK$v&Z|*z)0Z?@CkAKFQfkd|9>D)x_ylg zNU*>ovY3H^TNs2H8D`Cq018T!xJHx&=ckpFCl;kL1SDqWmFW4ohA5co8R}U`XTDki zRMV3h;hE;?sl~tn=U5aI;JVVC4_S{flPBx7sn8Z z%gG4|0xV1lM>ROum?9(`oIC`Va7jCRdIWMFVqh|G_VDx+T*Ri*utcI?R3P2J0O%k? Wj>Vsvd|H4;FnGH9xvX Date: Sun, 29 Jun 2025 19:11:39 -0400 Subject: [PATCH 02/11] the gob block From 274995ebd6ec87b23b4e8939baf70013f954cd80 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:32:25 -0400 Subject: [PATCH 03/11] copy tool support and working directional offsets --- .../hbm/blocks/generic/BlockWandSpawner.java | 11 +++++- .../hbm/blocks/generic/DungeonSpawner.java | 4 +++ .../world/gen/util/DungeonSpawnerActions.java | 33 +++++++++++++++++- .../hbm/textures/blocks/wand_spawner_top.png | Bin 740 -> 743 bytes 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java index fdfca7689..0508002d7 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java @@ -33,6 +33,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import java.util.List; @@ -78,9 +79,16 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT if (i == 2) world.setBlockMetadataWithNotify(x, y, z, 0, 2); if (i == 3) world.setBlockMetadataWithNotify(x, y, z, 1, 2); + ForgeDirection dir = ForgeDirection.UNKNOWN; + switch(i){ + case 0: dir = ForgeDirection.SOUTH;break; + case 1: dir = ForgeDirection.WEST; break; + case 2: dir = ForgeDirection.NORTH;break; + case 3: dir = ForgeDirection.EAST; break; + } TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityWandSpawner) - ((TileEntityWandSpawner)te).placedRotation = i; + ((TileEntityWandSpawner)te).placedRotation = dir.ordinal(); } @Override @@ -193,6 +201,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT DungeonSpawner.TileEntityDungeonSpawner spawner = (DungeonSpawner.TileEntityDungeonSpawner) te; spawner.actionID = actionID; spawner.conditionID = conditionID; + spawner.direction = ForgeDirection.getOrientation(placedRotation); } } diff --git a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java index ffbb14239..41fa907b5 100644 --- a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java @@ -20,6 +20,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class DungeonSpawner extends BlockContainer { @@ -44,6 +45,7 @@ public class DungeonSpawner extends BlockContainer { public Function condition; public Consumer action; + public ForgeDirection direction = ForgeDirection.UNKNOWN; @Override public void updateEntity() { @@ -74,6 +76,7 @@ public class DungeonSpawner extends BlockContainer { nbt.setInteger("phase", phase); nbt.setString("conditionID", conditionID); nbt.setString("actionID", actionID); + nbt.setInteger("direction", direction.ordinal()); } @Override @@ -81,6 +84,7 @@ public class DungeonSpawner extends BlockContainer { super.readFromNBT(nbt); this.phase = nbt.getInteger("phase"); this.conditionID = nbt.getString("conditionID"); + this.direction = ForgeDirection.getOrientation(nbt.getInteger("direction")); } } diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java index 120ea00e8..1e32d9dc7 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java @@ -5,6 +5,7 @@ import com.hbm.blocks.generic.BlockPedestal; import com.hbm.blocks.generic.BlockSkeletonHolder; import com.hbm.blocks.generic.DungeonSpawner; import com.hbm.entity.item.EntityFallingBlockNT; +import com.hbm.entity.missile.EntityMissileTier2; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ItemEnums; import com.hbm.items.ModItems; @@ -12,6 +13,7 @@ import com.hbm.main.ModEventHandler; import com.hbm.tileentity.machine.storage.TileEntityCrateBase; import com.hbm.util.MobUtil; import com.hbm.util.Vec3NT; +import com.hbm.world.WorldUtil; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; @@ -21,7 +23,10 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; 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.HashMap; @@ -140,7 +145,7 @@ public class DungeonSpawnerActions { if(tile.phase == 2){ world.setBlock(x,y,z, ModBlocks.crate_steel); - EntityLightningBolt blitz = new EntityLightningBolt(world, x, world.getHeightValue(x, z) + 1, z); + EntityLightningBolt blitz = new EntityLightningBolt(world, x, world.getHeightValue(x, z) + 2, z); world.spawnEntityInWorld(blitz); TileEntityCrateBase crate = (TileEntityCrateBase) world.getTileEntity(x,y,z); @@ -148,6 +153,31 @@ public class DungeonSpawnerActions { } }; + public static Consumer MISSILE_STRIKE = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + if(tile.phase != 1) return; + + world.getClosestPlayer(x,y,z, 25).addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "[COMMAND UNIT]"+ EnumChatFormatting.RESET + " Missile Fired")); + + ForgeDirection parallel = tile.direction.getRotation(ForgeDirection.UP); + + EntityMissileTier2.EntityMissileStrong missile = + new EntityMissileTier2.EntityMissileStrong( + world, + x + tile.direction.offsetX * 300, + 200, + z + tile.direction.offsetZ * 300, + x + parallel.offsetX * 30 + tile.direction.offsetX * 30, + z + parallel.offsetZ * 30 + tile.direction.offsetZ * 30); + WorldUtil.loadAndSpawnEntityInWorld(missile); + + world.setBlock(x,y,z, ModBlocks.block_electrical_scrap); + }; + public static List getActionNames(){ return new ArrayList<>(actions.keySet()); } @@ -158,6 +188,7 @@ public class DungeonSpawnerActions { actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5); actions.put("FODDER_WAVE", FODDER_WAVE); actions.put("PUZZLE_TEST", PUZZLE_TEST); + actions.put("MISSILE_STRIKE", MISSILE_STRIKE); } diff --git a/src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png b/src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png index 4788b84883581058c6fdf5525b3239d0e888f352..65e3106a96f970891be895a960ccfb53a60b3915 100644 GIT binary patch delta 87 zcmaFD`kZyc3?_doPZ!4!iOb0e2?8uk3P&|K*q9Fw delta 84 zcmaFP`h<1E3??6QPZ!4!iOb0e2?8uk3P&|K*q9bP0l+XkK_SqL` From acb01b13e00b00f83477a118baaf2bbcb95fc0ea Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:32:25 -0400 Subject: [PATCH 04/11] copy tool support and working directional offsets From 714a5298a976fa26ef4708d950c966a6a16c2e04 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Tue, 1 Jul 2025 20:11:19 -0400 Subject: [PATCH 05/11] disguises for the logic block --- .../hbm/blocks/generic/BlockWandSpawner.java | 65 ++++++++++++++++++- .../hbm/blocks/generic/DungeonSpawner.java | 51 +++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java index 0508002d7..6d4a6f8a3 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java @@ -16,14 +16,18 @@ import com.hbm.util.i18n.I18nUtil; import com.hbm.world.gen.INBTTileEntityTransformable; import com.hbm.world.gen.util.DungeonSpawnerActions; import com.hbm.world.gen.util.DungeonSpawnerConditions; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -91,6 +95,30 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT ((TileEntityWandSpawner)te).placedRotation = dir.ordinal(); } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float fX, float fY, float fZ) { + + ItemStack stack = player.getHeldItem(); + + if (stack != null && stack.getItem() instanceof ItemBlock && !player.isSneaking()) { + ItemBlock ib = (ItemBlock) stack.getItem(); + Block block = ib.field_150939_a; + + if (block.renderAsNormalBlock() && block != this) { + + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof TileEntityWandSpawner){ + TileEntityWandSpawner spawner = (TileEntityWandSpawner) tile; + spawner.disguise = block; + spawner.disguiseMeta = stack.getItemDamage() & 15; + return true; + } + } + } + return super.onBlockActivated(world, x, y, z, player, side, fX, fY, fZ); + } + @Override public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { TileEntity te = world.getTileEntity(x, y, z); @@ -132,10 +160,17 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT TileEntityWandSpawner spawner = (TileEntityWandSpawner) te; - List text = new ArrayList(); + List text = new ArrayList<>(); text.add("Action: " + spawner.actionID); text.add("Condition: " + spawner.conditionID); + String block; + if(spawner.disguise != null && spawner.disguise != Blocks.air) + block = I18nUtil.resolveKey(spawner.disguise.getUnlocalizedName() + ".name"); + else + block = "None"; + + text.add("Disguise Block: " + block); ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); } @@ -167,9 +202,14 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT public int placedRotation; + Block disguise; + int disguiseMeta = -1; + public String actionID = "PHASE_ABERRATOR"; public String conditionID = "ABERRATOR"; + public boolean noDisguise; + @Override public void updateEntity() { if(!worldObj.isRemote) { @@ -202,6 +242,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT spawner.actionID = actionID; spawner.conditionID = conditionID; spawner.direction = ForgeDirection.getOrientation(placedRotation); + spawner.disguise = disguise; + spawner.disguiseMeta = disguiseMeta; } } @@ -217,6 +259,10 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT nbt.setString("actionID", actionID); nbt.setString("conditionID", conditionID); nbt.setInteger("rotation", placedRotation); + if(disguise != null){ + nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); + nbt.setInteger("disguiseMeta", disguiseMeta); + } } @Override @@ -225,6 +271,10 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT actionID = nbt.getString("actionID"); conditionID = nbt.getString("conditionID"); placedRotation = nbt.getInteger("rotation"); + if(nbt.hasKey("disguise")){ + disguise = Block.getBlockFromName(nbt.getString("disguise")); + disguiseMeta = nbt.getInteger("disguiseMeta"); + } } @Override @@ -232,6 +282,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT buf.writeInt(placedRotation); BufferUtil.writeString(buf, actionID); BufferUtil.writeString(buf, conditionID); + buf.writeInt(Block.getIdFromBlock(disguise)); + buf.writeInt(disguiseMeta); } @Override @@ -239,6 +291,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT placedRotation = buf.readInt(); actionID = BufferUtil.readString(buf); conditionID = BufferUtil.readString(buf); + disguise = Block.getBlockById(buf.readInt()); + disguiseMeta = buf.readInt(); } @Override @@ -246,6 +300,11 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT NBTTagCompound nbt = new NBTTagCompound(); nbt.setString("actionID", actionID); nbt.setString("conditionID", conditionID); + if(disguise != null){ + nbt.setString("disguise", disguise.getUnlocalizedName()); + nbt.setInteger("disguiseMeta", disguiseMeta); + } + return nbt; } @@ -253,6 +312,10 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { actionID = nbt.getString("actionID"); conditionID = nbt.getString("conditionID"); + if(nbt.hasKey("disguise")){ + disguise = Block.getBlockFromName(nbt.getString("disguise")); + disguiseMeta = nbt.getInteger("disguiseMeta"); + } } } } diff --git a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java index 41fa907b5..bba6ebfe7 100644 --- a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java @@ -7,18 +7,29 @@ import com.hbm.blocks.generic.BlockSkeletonHolder.TileEntitySkeletonHolder; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ItemEnums.EnumSecretType; import com.hbm.items.ModItems; +import com.hbm.util.BufferUtil; import com.hbm.world.gen.util.DungeonSpawnerActions; import com.hbm.world.gen.util.DungeonSpawnerConditions; import com.hbm.util.Vec3NT; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -33,11 +44,31 @@ public class DungeonSpawner extends BlockContainer { return new TileEntityDungeonSpawner(); } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof TileEntityDungeonSpawner){ + TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) tile; + if(spawner.disguise != null){ + return spawner.disguise.getIcon(side, spawner.disguiseMeta); + } + } + + return super.getIcon(world, x, y, z, side); + } + + + public static class TileEntityDungeonSpawner extends TileEntity { public int phase = 0; public int timer = 0; + public Block disguise; + public int disguiseMeta; + public String conditionID = "ABERRATOR"; //actions always get called before conditions, use the phase timer in order to control behavior via condition public String actionID = "ABERRATOR"; @@ -77,6 +108,10 @@ public class DungeonSpawner extends BlockContainer { nbt.setString("conditionID", conditionID); nbt.setString("actionID", actionID); nbt.setInteger("direction", direction.ordinal()); + if(disguise != null){ + nbt.setInteger("disguiseMeta", disguiseMeta); + nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); + } } @Override @@ -85,6 +120,22 @@ public class DungeonSpawner extends BlockContainer { this.phase = nbt.getInteger("phase"); this.conditionID = nbt.getString("conditionID"); this.direction = ForgeDirection.getOrientation(nbt.getInteger("direction")); + if(nbt.hasKey("disguise")){ + disguiseMeta = nbt.getInteger("disguiseMeta"); + disguise = Block.getBlockFromName(nbt.getString("disguise")); + } + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbt = new NBTTagCompound(); + this.writeToNBT(nbt); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + this.readFromNBT(pkt.func_148857_g()); } } From 3d77afab1f950d64dca34eff12650311a5defc21 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Tue, 1 Jul 2025 20:11:19 -0400 Subject: [PATCH 06/11] disguises for the logic block From 21efc6b61cc1c2f79765020a831bb39553094ff8 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Thu, 3 Jul 2025 15:09:09 -0400 Subject: [PATCH 07/11] Interactions for the logic block --- .../hbm/blocks/generic/BlockWandSpawner.java | 32 +++++- .../hbm/blocks/generic/DungeonSpawner.java | 34 +++++- .../world/gen/util/DungeonSpawnerActions.java | 105 ++++++++++++++---- .../gen/util/DungeonSpawnerConditions.java | 7 +- .../gen/util/DungeonSpawnerInteractions.java | 80 +++++++++++++ 5 files changed, 230 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java index 6d4a6f8a3..b6c042838 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java @@ -16,6 +16,7 @@ import com.hbm.util.i18n.I18nUtil; import com.hbm.world.gen.INBTTileEntityTransformable; import com.hbm.world.gen.util.DungeonSpawnerActions; import com.hbm.world.gen.util.DungeonSpawnerConditions; +import com.hbm.world.gen.util.DungeonSpawnerInteractions; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -146,6 +147,16 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT spawner.conditionID = conditionNames.get(indexC); + return true; + case HAND_DRILL: + List interactionNames = DungeonSpawnerInteractions.getInteractionNames(); + int indexI = interactionNames.indexOf(spawner.interactionID); + + indexI += player.isSneaking() ? -1 : 1; + indexI = MathHelper.clamp_int(indexI, 0, interactionNames.size() - 1); + + spawner.interactionID = interactionNames.get(indexI); + return true; default: return false; @@ -163,6 +174,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT List text = new ArrayList<>(); text.add("Action: " + spawner.actionID); text.add("Condition: " + spawner.conditionID); + text.add("Interaction: " + (spawner.interactionID != null ? spawner.interactionID : "None")); + String block; if(spawner.disguise != null && spawner.disguise != Blocks.air) @@ -171,6 +184,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT block = "None"; text.add("Disguise Block: " + block); + ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); } @@ -178,7 +192,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { list.add(EnumChatFormatting.GOLD + "Use screwdriver to cycle forwards through the action list, shift click to go back"); list.add(EnumChatFormatting.GOLD + "Use defuser to cycle forwards through the condition list, shift click to go back"); - list.add(EnumChatFormatting.BLUE + "Use a detonator to transform"); + list.add(EnumChatFormatting.GOLD + "Use hand drill to cycle forwards through the interaction list, shift click to go back"); + list.add(EnumChatFormatting.YELLOW + "Use a detonator to transform"); } @Override @@ -206,9 +221,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT int disguiseMeta = -1; public String actionID = "PHASE_ABERRATOR"; - public String conditionID = "ABERRATOR"; - - public boolean noDisguise; + public String conditionID = "EMPTY"; + public String interactionID; @Override public void updateEntity() { @@ -241,6 +255,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT DungeonSpawner.TileEntityDungeonSpawner spawner = (DungeonSpawner.TileEntityDungeonSpawner) te; spawner.actionID = actionID; spawner.conditionID = conditionID; + spawner.interactionID = interactionID; spawner.direction = ForgeDirection.getOrientation(placedRotation); spawner.disguise = disguise; spawner.disguiseMeta = disguiseMeta; @@ -258,6 +273,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT super.writeToNBT(nbt); nbt.setString("actionID", actionID); nbt.setString("conditionID", conditionID); + nbt.setString("interactionID", interactionID); nbt.setInteger("rotation", placedRotation); if(disguise != null){ nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); @@ -270,6 +286,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT super.readFromNBT(nbt); actionID = nbt.getString("actionID"); conditionID = nbt.getString("conditionID"); + interactionID = nbt.getString("interactionID"); placedRotation = nbt.getInteger("rotation"); if(nbt.hasKey("disguise")){ disguise = Block.getBlockFromName(nbt.getString("disguise")); @@ -282,6 +299,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT buf.writeInt(placedRotation); BufferUtil.writeString(buf, actionID); BufferUtil.writeString(buf, conditionID); + BufferUtil.writeString(buf, interactionID); buf.writeInt(Block.getIdFromBlock(disguise)); buf.writeInt(disguiseMeta); } @@ -291,6 +309,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT placedRotation = buf.readInt(); actionID = BufferUtil.readString(buf); conditionID = BufferUtil.readString(buf); + interactionID = BufferUtil.readString(buf); disguise = Block.getBlockById(buf.readInt()); disguiseMeta = buf.readInt(); } @@ -300,8 +319,10 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT NBTTagCompound nbt = new NBTTagCompound(); nbt.setString("actionID", actionID); nbt.setString("conditionID", conditionID); + if(interactionID != null) + nbt.setString("interactionID", interactionID); if(disguise != null){ - nbt.setString("disguise", disguise.getUnlocalizedName()); + nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); nbt.setInteger("disguiseMeta", disguiseMeta); } @@ -312,6 +333,7 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { actionID = nbt.getString("actionID"); conditionID = nbt.getString("conditionID"); + interactionID = nbt.getString("interactionID"); if(nbt.hasKey("disguise")){ disguise = Block.getBlockFromName(nbt.getString("disguise")); disguiseMeta = nbt.getInteger("disguiseMeta"); diff --git a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java index bba6ebfe7..52dbb6099 100644 --- a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java @@ -12,6 +12,7 @@ import com.hbm.world.gen.util.DungeonSpawnerActions; import com.hbm.world.gen.util.DungeonSpawnerConditions; import com.hbm.util.Vec3NT; +import com.hbm.world.gen.util.DungeonSpawnerInteractions; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -59,22 +60,38 @@ public class DungeonSpawner extends BlockContainer { return super.getIcon(world, x, y, z, side); } + @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); + if(te instanceof TileEntityDungeonSpawner && ((TileEntityDungeonSpawner) te).interaction != null) { + ((TileEntityDungeonSpawner) te).interaction.accept(new Object[]{worldIn, te, x, y, z, player, side, subX, subY, subZ}); + return true; + } + return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ); + } public static class TileEntityDungeonSpawner extends TileEntity { + //phase is incremented per condition check, timer counts since last condition check by default public int phase = 0; public int timer = 0; public Block disguise; public int disguiseMeta; + /**Actions always get called before conditions, use the phase and timer variables in order to control behavior via conditions*/ public String conditionID = "ABERRATOR"; - //actions always get called before conditions, use the phase timer in order to control behavior via condition public String actionID = "ABERRATOR"; + /**Interactions are called on right click, and passes on the parameters of the right click to consumer*/ + public String interactionID; public Function condition; public Consumer action; + /**Consists of world instance, TileEntity instance, three ints for coordinates, one int for block side, and player instance, in that order **/ + public Consumer interaction; + + public EntityPlayer player; public ForgeDirection direction = ForgeDirection.UNKNOWN; @Override @@ -87,6 +104,10 @@ public class DungeonSpawner extends BlockContainer { if(condition == null){ condition = DungeonSpawnerConditions.conditions.get(conditionID); } + if(interaction == null && interactionID != null){ + interaction = DungeonSpawnerInteractions.interactions.get(interactionID); + } + if(action == null || condition == null){ worldObj.setBlock(xCoord,yCoord,zCoord, Blocks.air); return; @@ -105,8 +126,12 @@ public class DungeonSpawner extends BlockContainer { public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("phase", phase); - nbt.setString("conditionID", conditionID); + nbt.setString("actionID", actionID); + nbt.setString("conditionID", conditionID); + if(interactionID != null) + nbt.setString("interactionID", interactionID); + nbt.setInteger("direction", direction.ordinal()); if(disguise != null){ nbt.setInteger("disguiseMeta", disguiseMeta); @@ -118,8 +143,13 @@ public class DungeonSpawner extends BlockContainer { public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.phase = nbt.getInteger("phase"); + + this.actionID = nbt.getString("actionID"); this.conditionID = nbt.getString("conditionID"); + if(nbt.hasKey("interactionID")) this.interactionID = nbt.getString("interactionID"); + this.direction = ForgeDirection.getOrientation(nbt.getInteger("direction")); + if(nbt.hasKey("disguise")){ disguiseMeta = nbt.getInteger("disguiseMeta"); disguise = Block.getBlockFromName(nbt.getString("disguise")); diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java index 1e32d9dc7..fee835c2e 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java @@ -1,7 +1,7 @@ package com.hbm.world.gen.util; +import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; -import com.hbm.blocks.generic.BlockPedestal; import com.hbm.blocks.generic.BlockSkeletonHolder; import com.hbm.blocks.generic.DungeonSpawner; import com.hbm.entity.item.EntityFallingBlockNT; @@ -9,34 +9,30 @@ import com.hbm.entity.missile.EntityMissileTier2; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ItemEnums; import com.hbm.items.ModItems; -import com.hbm.main.ModEventHandler; +import com.hbm.tileentity.TileEntityDoorGeneric; import com.hbm.tileentity.machine.storage.TileEntityCrateBase; +import com.hbm.util.ContaminationUtil; import com.hbm.util.MobUtil; import com.hbm.util.Vec3NT; import com.hbm.world.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Random; +import java.util.*; import java.util.function.Consumer; public class DungeonSpawnerActions { - public static HashMap> actions = new HashMap<>(); + public static LinkedHashMap> actions = new LinkedHashMap<>(); public static Consumer PHASE_ABERRATOR = (tile) -> { World world = tile.getWorldObj(); @@ -122,14 +118,10 @@ public class DungeonSpawnerActions { Vec3NT vec = new Vec3NT(5, 0, 0); for (int i = 0; i < 10; i++) { EntityZombie mob = new EntityZombie(world); - for (int j = 0; j < 7; j++) { - mob.setPositionAndRotation(x + 0.5 + vec.xCoord, world.getHeightValue(x,z), z + 0.5 + vec.zCoord, i * 36F, 0); - MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdv, new Random()); - if (mob.getCanSpawnHere()) { - world.spawnEntityInWorld(mob); - break; - } - } + mob.setPositionAndRotation(x + 0.5 + vec.xCoord, world.getHeightValue(x,z), z + 0.5 + vec.zCoord, i * 36F, 0); + MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdv, new Random()); + world.spawnEntityInWorld(mob); + vec.rotateAroundYDeg(36D); } world.setBlock(x, y, z, ModBlocks.block_steel); @@ -178,6 +170,78 @@ public class DungeonSpawnerActions { world.setBlock(x,y,z, ModBlocks.block_electrical_scrap); }; + public static Consumer RAD_CONTAINMENT_SYSTEM = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + + ForgeDirection direction = tile.direction.getOpposite(); + ForgeDirection rot = direction.getRotation(ForgeDirection.UP); + + AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x - rot.offsetX, y - 1, z - rot.offsetZ, x + rot.offsetX + direction.offsetX * 15, y + 1, z + rot.offsetZ + direction.offsetZ * 15).expand(2,2,2); + + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, bb); + + for(EntityLivingBase e : entities) { + + Vec3 vec = Vec3.createVectorHelper(e.posX - (x + 0.5), (e.posY + e.getEyeHeight()) - (y + 0.5), e.posZ - (z + 0.5)); + double len = vec.lengthVector(); + vec = vec.normalize(); + + len = Math.max(len,1D); + + float res = 0; + + for(int i = 1; i < len; i++) { + + int ix = (int)Math.floor(x + 0.5 + vec.xCoord * i); + int iy = (int)Math.floor(y + 0.5 + vec.yCoord * i); + int iz = (int)Math.floor(z + 0.5 + vec.zCoord * i); + + res += world.getBlock(ix, iy, iz).getExplosionResistance(null); + } + + if(res < 1) + res = 1; + + float eRads = 100F; + eRads /= (float)res; + eRads /= (float)(len * len); + + ContaminationUtil.contaminate(e, ContaminationUtil.HazardType.RADIATION, ContaminationUtil.ContaminationType.HAZMAT2, eRads); + } + + if (tile.phase == 2 && tile.timer > 40){ + world.getClosestPlayer(x,y,z, 25).addChatMessage(new ChatComponentText( + EnumChatFormatting.LIGHT_PURPLE + "[RAD CONTAINMENT SYSTEM]" + + EnumChatFormatting.RESET + " Diagnostics found containment failure, commencing lockdown")); + + for(int i = 1; i < 20; i++) { + int checkX, checkY, checkZ; + checkX = x + direction.offsetX * i; + checkY = y + 1; + checkZ = z + direction.offsetZ * i; + Block block = world.getBlock(checkX, checkY,checkZ); + TileEntity te = null; + if(block instanceof BlockDummyable){ + int[] coreCoords = ((BlockDummyable) block).findCore(world,checkX,checkY,checkZ); + te = world.getTileEntity(coreCoords[0], coreCoords[1], coreCoords[2]); + } + + if (te instanceof TileEntityDoorGeneric) { + TileEntityDoorGeneric door = (TileEntityDoorGeneric) te; + door.setPins(456); + door.close(); + door.lock(); + break; + } + } + + tile.phase = 3; + } + }; + public static List getActionNames(){ return new ArrayList<>(actions.keySet()); } @@ -189,6 +253,7 @@ public class DungeonSpawnerActions { actions.put("FODDER_WAVE", FODDER_WAVE); actions.put("PUZZLE_TEST", PUZZLE_TEST); actions.put("MISSILE_STRIKE", MISSILE_STRIKE); + actions.put("IRRADIATE_ENTITIES_AOE", RAD_CONTAINMENT_SYSTEM); } diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java index 0a634c271..83dd773e8 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java @@ -15,12 +15,16 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.function.Function; public class DungeonSpawnerConditions { - public static HashMap> conditions = new HashMap<>(); + public static LinkedHashMap> conditions = new LinkedHashMap<>(); + + /**For use with interactions, for having them handle all conditional tasks*/ + public static Function EMPTY = (tile) -> false; public static Function ABERRATOR = (tile) -> { World world = tile.getWorldObj(); @@ -82,6 +86,7 @@ public class DungeonSpawnerConditions { //register new conditions here static { + conditions.put("EMPTY", EMPTY); conditions.put("ABERRATOR", ABERRATOR); conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5); conditions.put("REDSTONE", REDSTONE); diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java new file mode 100644 index 000000000..32c19b81d --- /dev/null +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java @@ -0,0 +1,80 @@ +package com.hbm.world.gen.util; + +import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner; +import com.hbm.entity.missile.EntityMissileTier2; +import com.hbm.items.ModItems; +import com.hbm.potion.HbmPotion; +import com.hbm.tileentity.TileEntityDoorGeneric; +import com.hbm.util.Vec3NT; +import com.hbm.world.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.function.Consumer; + +/**Interactions are called when the player right-clicks the block**/ +public class DungeonSpawnerInteractions { + + /**Consumer consists of world instance, tile entity instance, three ints for coordinates, one int for block side, and player instance, + * in that order **/ + public static LinkedHashMap> interactions = new LinkedHashMap<>(); + + public static Consumer TEST = (array) -> { + World world = (World) array[0]; + TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) array[1]; + int x = (int) array[2]; + int y = (int) array[3]; + int z = (int) array[4]; + EntityPlayer player = (EntityPlayer) array[5]; + int side = (int) array[6]; + + if(spawner.phase > 1) return; + + if(player.getHeldItem() != null) + player.getHeldItem().stackSize--; + + spawner.phase++; + }; + + public static Consumer RAD_CONTAINMENT_SYSTEM = (array) -> { + TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) array[1]; + EntityPlayer player = (EntityPlayer) array[5]; + + if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.key){ + player.getHeldItem().stackSize--; + player.addChatMessage(new ChatComponentText( + EnumChatFormatting.LIGHT_PURPLE + "[RAD CONTAINMENT SYSTEM]" + + EnumChatFormatting.RESET + " Radiation treatment administered")); + player.addPotionEffect(new PotionEffect(HbmPotion.radaway.getId(), 3 * 60 * 20, 4)); + player.addPotionEffect(new PotionEffect(HbmPotion.radx.getId(), 3 * 60 * 20, 4)); + spawner.phase = 2; + spawner.timer = 0; + } + }; + + + + public static List getInteractionNames(){ + return new ArrayList<>(interactions.keySet()); + } + + //register new interactions here + static{ + interactions.put("TEST", TEST); + interactions.put("RADAWAY_INJECTOR", RAD_CONTAINMENT_SYSTEM); + } + + + +} From 541c6a1c997d51a9cd5f9f4c94f8b207c1283ce3 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Thu, 3 Jul 2025 15:09:09 -0400 Subject: [PATCH 08/11] Interactions for the logic block --- src/main/resources/assets/hbm/lang/en_US.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 0a90eddf7..dcb6d68b3 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -5279,6 +5279,7 @@ tile.ducrete_smooth_stairs.name=Ducrete Stairs tile.dummy_block.name=Dummy Block tile.dummy_port.name=Dummy Block (Electricity Port) tile.dungeon_chain.name=Metal Chain +tile.dungeon_spawner.name=Dungeon Action Block tile.dynamite.name=Dynamite tile.emp_bomb.name=EMP Device tile.factory_advanced_conductor.name=Advanced Factory Electricity Port From 603cc10696deb39faf0c580a850cd400eb34d108 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Thu, 3 Jul 2025 15:09:09 -0400 Subject: [PATCH 09/11] Interactions for the logic block From c33b962043c533925012d20ef69ec6bc806c301b Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:04:32 -0400 Subject: [PATCH 10/11] misc fix --- .../com/hbm/entity/mob/EntityUndeadSoldier.java | 14 ++++++++++---- .../hbm/world/gen/util/DungeonSpawnerActions.java | 12 +++++++++--- .../world/gen/util/DungeonSpawnerConditions.java | 6 ++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/hbm/entity/mob/EntityUndeadSoldier.java b/src/main/java/com/hbm/entity/mob/EntityUndeadSoldier.java index 1a18c36c7..f2b042085 100644 --- a/src/main/java/com/hbm/entity/mob/EntityUndeadSoldier.java +++ b/src/main/java/com/hbm/entity/mob/EntityUndeadSoldier.java @@ -16,10 +16,11 @@ import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; public class EntityUndeadSoldier extends EntityMob { - + public static final int DW_TYPE = 12; public static final byte TYPE_ZOMBIE = 0; public static final byte TYPE_SKELETON = 1; @@ -66,7 +67,7 @@ public class EntityUndeadSoldier extends EntityMob { this.setCurrentItemOrArmor(3, new ItemStack(ModItems.taurun_plate)); this.setCurrentItemOrArmor(2, new ItemStack(ModItems.taurun_legs)); this.setCurrentItemOrArmor(1, new ItemStack(ModItems.taurun_boots)); - + int gun = rand.nextInt(5); if(gun == 0) this.setCurrentItemOrArmor(0, new ItemStack(ModItems.gun_heavy_revolver)); if(gun == 1) this.setCurrentItemOrArmor(0, new ItemStack(ModItems.gun_light_revolver)); @@ -74,7 +75,7 @@ public class EntityUndeadSoldier extends EntityMob { if(gun == 3) this.setCurrentItemOrArmor(0, new ItemStack(ModItems.gun_maresleg)); if(gun == 4) this.setCurrentItemOrArmor(0, new ItemStack(ModItems.gun_greasegun)); } - + @Override protected String getLivingSound() { byte type = this.dataWatcher.getWatchableObjectByte(DW_TYPE); @@ -110,7 +111,12 @@ public class EntityUndeadSoldier extends EntityMob { public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.UNDEAD; } - + + @Override + public boolean getCanSpawnHere() { + return this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox); + } + @Override protected void dropFewItems(boolean player, int loot) { } @Override protected void dropEquipment(boolean player, int loot) { } } diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java index fee835c2e..252bc543b 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java @@ -40,19 +40,25 @@ public class DungeonSpawnerActions { int y = tile.yCoord; int z = tile.zCoord; if (tile.phase == 1 || tile.phase == 2) { + tile.player = world.getClosestPlayer(x,y,z, 25); if (tile.timer == 0) { - Vec3NT vec = new Vec3NT(10, 0, 0); + Vec3NT vec = new Vec3NT(20, 0, 0); for (int i = 0; i < 10; i++) { + + if(vec.xCoord > 8) vec.xCoord += world.rand.nextInt(10) - 5; + EntityUndeadSoldier mob = new EntityUndeadSoldier(world); for (int j = 0; j < 7; j++) { - mob.setPositionAndRotation(x + 0.5 + vec.xCoord, y - 5, z + 0.5 + vec.zCoord, i * 36F, 0); + mob.setPositionAndRotation(x + 0.5 + vec.xCoord, world.getHeightValue((int) (x + 0.5 + vec.xCoord),(int) (z + 0.5 + vec.zCoord)), z + 0.5 + vec.zCoord, i * 36F, 0); if (mob.getCanSpawnHere()) { mob.onSpawnWithEgg(null); + if(tile.player != null){ + mob.setTarget(tile.player); + } world.spawnEntityInWorld(mob); break; } } - vec.rotateAroundYDeg(36D); } } diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java index 83dd773e8..1e0cc9d5a 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java +++ b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java @@ -32,13 +32,15 @@ public class DungeonSpawnerConditions { int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; + + boolean aoeCheck = !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(10, 10, 10)).isEmpty(); if(tile.phase == 0) { if(world.getTotalWorldTime() % 20 != 0) return false; - return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(20, 10, 20)).isEmpty(); + return aoeCheck; } if(tile.phase < 3) { if(world.getTotalWorldTime() % 20 != 0 || tile.timer < 60) return false; - return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty(); + return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty() && aoeCheck; } return false; }; From e7ebc7dd07846f847f18d40937218fce9c8d0d67 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Wed, 9 Jul 2025 13:03:48 -0400 Subject: [PATCH 11/11] thunder fire all your generation --- src/main/java/com/hbm/blocks/ModBlocks.java | 14 +- ...ckWandSpawner.java => BlockWandLogic.java} | 100 ++++----- .../hbm/blocks/generic/DungeonSpawner.java | 191 +++++++----------- .../com/hbm/blocks/generic/LogicBlock.java | 162 +++++++++++++++ .../hbm/tileentity/TileEntityDoorGeneric.java | 13 +- .../java/com/hbm/tileentity/TileMappings.java | 6 +- ...nerActions.java => LogicBlockActions.java} | 22 +- ...ditions.java => LogicBlockConditions.java} | 18 +- ...tions.java => LogicBlockInteractions.java} | 26 +-- src/main/resources/assets/hbm/lang/en_US.lang | 4 +- .../hbm/textures/blocks/logic_block.png | Bin 0 -> 910 bytes .../{wand_spawner.png => wand_logic.png} | Bin ...and_spawner_top.png => wand_logic_top.png} | Bin 13 files changed, 347 insertions(+), 209 deletions(-) rename src/main/java/com/hbm/blocks/generic/{BlockWandSpawner.java => BlockWandLogic.java} (74%) create mode 100644 src/main/java/com/hbm/blocks/generic/LogicBlock.java rename src/main/java/com/hbm/world/gen/util/{DungeonSpawnerActions.java => LogicBlockActions.java} (91%) rename src/main/java/com/hbm/world/gen/util/{DungeonSpawnerConditions.java => LogicBlockConditions.java} (79%) rename src/main/java/com/hbm/world/gen/util/{DungeonSpawnerInteractions.java => LogicBlockInteractions.java} (73%) create mode 100644 src/main/resources/assets/hbm/textures/blocks/logic_block.png rename src/main/resources/assets/hbm/textures/blocks/{wand_spawner.png => wand_logic.png} (100%) rename src/main/resources/assets/hbm/textures/blocks/{wand_spawner_top.png => wand_logic_top.png} (100%) diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index f69f85497..5f3de7f83 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -1243,7 +1243,9 @@ public class ModBlocks { public static Block wand_air; public static Block wand_loot; public static Block wand_jigsaw; - public static Block wand_spawner; + public static Block wand_logic; + + public static Block logic_block; public static Material materialGas = new MaterialGas(); @@ -1978,7 +1980,7 @@ public class ModBlocks { ladder_cobalt = new BlockNTMLadder().setBlockName("ladder_cobalt").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_cobalt"); ladder_steel = new BlockNTMLadder().setBlockName("ladder_steel").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_steel"); ladder_tungsten = new BlockNTMLadder().setBlockName("ladder_tungsten").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_tungsten"); - + trapdoor_steel = new BlockNTMTrapdoor(Material.iron).setBlockName("trapdoor_steel").setHardness(3F).setResistance(8.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":trapdoor_steel"); barrel_plastic = new BlockFluidBarrel(Material.iron, 12000).setBlockName("barrel_plastic").setStepSound(Block.soundTypeStone).setHardness(2.0F).setResistance(5.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":barrel_plastic"); @@ -2397,7 +2399,9 @@ public class ModBlocks { wand_air = new BlockWand(Blocks.air).setBlockName("wand_air").setBlockTextureName(RefStrings.MODID + ":wand_air"); wand_loot = new BlockWandLoot().setBlockName("wand_loot").setBlockTextureName(RefStrings.MODID + ":wand_loot"); wand_jigsaw = new BlockWandJigsaw().setBlockName("wand_jigsaw").setBlockTextureName(RefStrings.MODID + ":wand_jigsaw"); - wand_spawner = new BlockWandSpawner().setBlockName("wand_spawner").setBlockTextureName(RefStrings.MODID + ":wand_spawner"); + wand_logic = new BlockWandLogic().setBlockName("wand_logic").setBlockTextureName(RefStrings.MODID + ":wand_logic"); + + logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block"); } @@ -3545,7 +3549,9 @@ public class ModBlocks { register(wand_air); register(wand_loot); register(wand_jigsaw); - register(wand_spawner); + register(wand_logic); + + register(logic_block); } private static void register(Block b) { diff --git a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java b/src/main/java/com/hbm/blocks/generic/BlockWandLogic.java similarity index 74% rename from src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java rename to src/main/java/com/hbm/blocks/generic/BlockWandLogic.java index b6c042838..01d8df298 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/BlockWandLogic.java @@ -13,10 +13,10 @@ import com.hbm.main.MainRegistry; import com.hbm.tileentity.TileEntityLoadedBase; import com.hbm.util.BufferUtil; import com.hbm.util.i18n.I18nUtil; +import com.hbm.world.gen.util.LogicBlockActions; import com.hbm.world.gen.INBTTileEntityTransformable; -import com.hbm.world.gen.util.DungeonSpawnerActions; -import com.hbm.world.gen.util.DungeonSpawnerConditions; -import com.hbm.world.gen.util.DungeonSpawnerInteractions; +import com.hbm.world.gen.util.LogicBlockConditions; +import com.hbm.world.gen.util.LogicBlockInteractions; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -43,19 +43,19 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import java.util.List; -public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb { +public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb { @SideOnly(Side.CLIENT) protected IIcon iconTop; - public BlockWandSpawner() { + public BlockWandLogic() { super(Material.iron); } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { - this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_spawner"); - this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_spawner_top"); + this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_logic"); + this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_logic_top"); } @Override @@ -92,8 +92,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT case 3: dir = ForgeDirection.EAST; break; } TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileEntityWandSpawner) - ((TileEntityWandSpawner)te).placedRotation = dir.ordinal(); + if(te instanceof TileEntityWandLogic) + ((TileEntityWandLogic)te).placedRotation = dir.ordinal(); } @Override @@ -109,10 +109,10 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof TileEntityWandSpawner){ - TileEntityWandSpawner spawner = (TileEntityWandSpawner) tile; - spawner.disguise = block; - spawner.disguiseMeta = stack.getItemDamage() & 15; + if(tile instanceof TileEntityWandLogic){ + TileEntityWandLogic logic = (TileEntityWandLogic) tile; + logic.disguise = block; + logic.disguiseMeta = stack.getItemDamage() & 15; return true; } } @@ -124,38 +124,38 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { TileEntity te = world.getTileEntity(x, y, z); - if(!(te instanceof TileEntityWandSpawner)) return false; + if(!(te instanceof TileEntityWandLogic)) return false; - TileEntityWandSpawner spawner = (TileEntityWandSpawner) te; + TileEntityWandLogic logic = (TileEntityWandLogic) te; switch(tool) { case SCREWDRIVER: - List actionNames = DungeonSpawnerActions.getActionNames(); - int indexA = actionNames.indexOf(spawner.actionID); + List actionNames = LogicBlockActions.getActionNames(); + int indexA = actionNames.indexOf(logic.actionID); indexA += player.isSneaking() ? -1 : 1; indexA = MathHelper.clamp_int(indexA, 0, actionNames.size() - 1); - spawner.actionID = actionNames.get(indexA); + logic.actionID = actionNames.get(indexA); return true; case DEFUSER: - List conditionNames = DungeonSpawnerConditions.getConditionNames(); - int indexC = conditionNames.indexOf(spawner.conditionID); + List conditionNames = LogicBlockConditions.getConditionNames(); + int indexC = conditionNames.indexOf(logic.conditionID); indexC += player.isSneaking() ? -1 : 1; indexC = MathHelper.clamp_int(indexC, 0, conditionNames.size() - 1); - spawner.conditionID = conditionNames.get(indexC); + logic.conditionID = conditionNames.get(indexC); return true; case HAND_DRILL: - List interactionNames = DungeonSpawnerInteractions.getInteractionNames(); - int indexI = interactionNames.indexOf(spawner.interactionID); + List interactionNames = LogicBlockInteractions.getInteractionNames(); + int indexI = interactionNames.indexOf(logic.interactionID); indexI += player.isSneaking() ? -1 : 1; indexI = MathHelper.clamp_int(indexI, 0, interactionNames.size() - 1); - spawner.interactionID = interactionNames.get(indexI); + logic.interactionID = interactionNames.get(indexI); return true; @@ -167,19 +167,19 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(!(te instanceof TileEntityWandSpawner)) return; + if(!(te instanceof TileEntityWandLogic)) return; - TileEntityWandSpawner spawner = (TileEntityWandSpawner) te; + TileEntityWandLogic logic = (TileEntityWandLogic) te; List text = new ArrayList<>(); - text.add("Action: " + spawner.actionID); - text.add("Condition: " + spawner.conditionID); - text.add("Interaction: " + (spawner.interactionID != null ? spawner.interactionID : "None")); + text.add("Action: " + logic.actionID); + text.add("Condition: " + logic.conditionID); + text.add("Interaction: " + (logic.interactionID != null ? logic.interactionID : "None")); String block; - if(spawner.disguise != null && spawner.disguise != Blocks.air) - block = I18nUtil.resolveKey(spawner.disguise.getUnlocalizedName() + ".name"); + if(logic.disguise != null && logic.disguise != Blocks.air) + block = I18nUtil.resolveKey(logic.disguise.getUnlocalizedName() + ".name"); else block = "None"; @@ -198,21 +198,21 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT @Override public TileEntity createNewTileEntity(World worldIn, int meta) { - return new TileEntityWandSpawner(); + return new TileEntityWandLogic(); } @Override public BombReturnCode explode(World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(!(te instanceof TileEntityWandSpawner)) return null; + if(!(te instanceof TileEntityWandLogic)) return null; - ((TileEntityWandSpawner) te).triggerReplace = true; + ((TileEntityWandLogic) te).triggerReplace = true; return BombReturnCode.TRIGGERED; } - public static class TileEntityWandSpawner extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable { + public static class TileEntityWandLogic extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable { private boolean triggerReplace; public int placedRotation; @@ -220,8 +220,8 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT Block disguise; int disguiseMeta = -1; - public String actionID = "PHASE_ABERRATOR"; - public String conditionID = "EMPTY"; + public String actionID = "FODDER_WAVE"; + public String conditionID = "PLAYER_CUBE_5"; public String interactionID; @Override @@ -237,28 +237,28 @@ public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IT } private void replace() { - if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandSpawner)) { - MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a dungeon spawner block but we're doing a TE update as if it is, cancelling!"); + if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandLogic)) { + 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.dungeon_spawner); + worldObj.setBlock(xCoord,yCoord,zCoord, ModBlocks.logic_block); TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord); if(te == null || te instanceof BlockWandLoot.TileEntityWandLoot) { - MainRegistry.logger.warn("TE for dungeon spawner set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!"); - te = ModBlocks.wand_spawner.createTileEntity(worldObj, 0); + MainRegistry.logger.warn("TE for logic block set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!"); + te = ModBlocks.wand_logic.createTileEntity(worldObj, 0); worldObj.setTileEntity(xCoord, yCoord, zCoord, te); } - if(te instanceof DungeonSpawner.TileEntityDungeonSpawner){ - DungeonSpawner.TileEntityDungeonSpawner spawner = (DungeonSpawner.TileEntityDungeonSpawner) te; - spawner.actionID = actionID; - spawner.conditionID = conditionID; - spawner.interactionID = interactionID; - spawner.direction = ForgeDirection.getOrientation(placedRotation); - spawner.disguise = disguise; - spawner.disguiseMeta = disguiseMeta; + if(te instanceof LogicBlock.TileEntityLogicBlock){ + LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) te; + logic.actionID = actionID; + logic.conditionID = conditionID; + logic.interactionID = interactionID; + logic.direction = ForgeDirection.getOrientation(placedRotation); + logic.disguise = disguise; + logic.disguiseMeta = disguiseMeta; } } diff --git a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java index 52dbb6099..4a6fc10d8 100644 --- a/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/DungeonSpawner.java @@ -7,32 +7,18 @@ import com.hbm.blocks.generic.BlockSkeletonHolder.TileEntitySkeletonHolder; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ItemEnums.EnumSecretType; import com.hbm.items.ModItems; -import com.hbm.util.BufferUtil; -import com.hbm.world.gen.util.DungeonSpawnerActions; -import com.hbm.world.gen.util.DungeonSpawnerConditions; +import com.hbm.util.EnumUtil; import com.hbm.util.Vec3NT; -import com.hbm.world.gen.util.DungeonSpawnerInteractions; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import io.netty.buffer.ByteBuf; -import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class DungeonSpawner extends BlockContainer { @@ -44,76 +30,19 @@ public class DungeonSpawner extends BlockContainer { public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityDungeonSpawner(); } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityDungeonSpawner){ - TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) tile; - if(spawner.disguise != null){ - return spawner.disguise.getIcon(side, spawner.disguiseMeta); - } - } - - return super.getIcon(world, x, y, z, side); - } - - @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); - if(te instanceof TileEntityDungeonSpawner && ((TileEntityDungeonSpawner) te).interaction != null) { - ((TileEntityDungeonSpawner) te).interaction.accept(new Object[]{worldIn, te, x, y, z, player, side, subX, subY, subZ}); - return true; - } - - return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ); - } - + public static class TileEntityDungeonSpawner extends TileEntity { - - //phase is incremented per condition check, timer counts since last condition check by default + public int phase = 0; public int timer = 0; - - public Block disguise; - public int disguiseMeta; - - /**Actions always get called before conditions, use the phase and timer variables in order to control behavior via conditions*/ - public String conditionID = "ABERRATOR"; - public String actionID = "ABERRATOR"; - /**Interactions are called on right click, and passes on the parameters of the right click to consumer*/ - public String interactionID; - - public Function condition; - public Consumer action; - /**Consists of world instance, TileEntity instance, three ints for coordinates, one int for block side, and player instance, in that order **/ - public Consumer interaction; - - public EntityPlayer player; - - public ForgeDirection direction = ForgeDirection.UNKNOWN; + public EnumSpawnerType type = EnumSpawnerType.ABERRATOR; + @Override public void updateEntity() { - + if(!worldObj.isRemote) { - if(action == null){ - action = DungeonSpawnerActions.actions.get(actionID); - } - if(condition == null){ - condition = DungeonSpawnerConditions.conditions.get(conditionID); - } - if(interaction == null && interactionID != null){ - interaction = DungeonSpawnerInteractions.interactions.get(interactionID); - } - - if(action == null || condition == null){ - worldObj.setBlock(xCoord,yCoord,zCoord, Blocks.air); - return; - } - action.accept(this); - if(condition.apply(this)) { + type.phase.accept(this); + if(type.phaseCondition.apply(this)) { phase++; timer = 0; } else { @@ -126,47 +55,83 @@ public class DungeonSpawner extends BlockContainer { public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("phase", phase); - - nbt.setString("actionID", actionID); - nbt.setString("conditionID", conditionID); - if(interactionID != null) - nbt.setString("interactionID", interactionID); - - nbt.setInteger("direction", direction.ordinal()); - if(disguise != null){ - nbt.setInteger("disguiseMeta", disguiseMeta); - nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); - } + nbt.setByte("type", (byte) type.ordinal()); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.phase = nbt.getInteger("phase"); - - this.actionID = nbt.getString("actionID"); - this.conditionID = nbt.getString("conditionID"); - if(nbt.hasKey("interactionID")) this.interactionID = nbt.getString("interactionID"); - - this.direction = ForgeDirection.getOrientation(nbt.getInteger("direction")); - - if(nbt.hasKey("disguise")){ - disguiseMeta = nbt.getInteger("disguiseMeta"); - disguise = Block.getBlockFromName(nbt.getString("disguise")); - } - } - - @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbt = new NBTTagCompound(); - this.writeToNBT(nbt); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); - } - - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - this.readFromNBT(pkt.func_148857_g()); + this.type = EnumUtil.grabEnumSafely(EnumSpawnerType.class, nbt.getByte("type")); } } + + public static enum EnumSpawnerType { + + ABERRATOR(CON_ABERRATOR, PHASE_ABERRATOR); + public Function phaseCondition; + public Consumer phase; + + private EnumSpawnerType(Function con, Consumer ph) { + this.phaseCondition = con; + this.phase = ph; + } + } + + public static Function CON_ABERRATOR = (tile) -> { + World world = tile.getWorldObj(); + if(world.difficultySetting.ordinal() == 0) return false; + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + if(tile.phase == 0) { + if(world.getTotalWorldTime() % 20 != 0) return false; + return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(20, 10, 20)).isEmpty(); + } + if(tile.phase < 3) { + if(world.getTotalWorldTime() % 20 != 0 || tile.timer < 60) return false; + return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty(); + } + return false; + }; + + public static Consumer PHASE_ABERRATOR = (tile) -> { + World world = tile.getWorldObj(); + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + if(tile.phase == 1 || tile.phase == 2) { + if(tile.timer == 0) { + Vec3NT vec = new Vec3NT(10, 0, 0); + for(int i = 0; i < 10; i++) { + EntityUndeadSoldier mob = new EntityUndeadSoldier(world); + for(int j = 0; j < 7; j++) { + mob.setPositionAndRotation(x + 0.5 + vec.xCoord, y - 5, z + 0.5 + vec.zCoord, i * 36F, 0); + if(mob.getCanSpawnHere()) { + mob.onSpawnWithEgg(null); + world.spawnEntityInWorld(mob); + break; + } + } + + vec.rotateAroundYDeg(36D); + } + } + } + if(tile.phase > 2) { + TileEntity te = world.getTileEntity(x, y + 18, z); + if(te instanceof TileEntitySkeletonHolder) { + TileEntitySkeletonHolder skeleton = (TileEntitySkeletonHolder) te; + if(world.rand.nextInt(5) == 0) { + skeleton.item = new ItemStack(ModItems.item_secret, 1, EnumSecretType.ABERRATOR.ordinal()); + } else { + skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 1); + } + skeleton.markDirty(); + world.markBlockForUpdate(x, y + 18, z); + } + world.setBlock(x, y, z, Blocks.obsidian); + } + }; } diff --git a/src/main/java/com/hbm/blocks/generic/LogicBlock.java b/src/main/java/com/hbm/blocks/generic/LogicBlock.java new file mode 100644 index 000000000..462755811 --- /dev/null +++ b/src/main/java/com/hbm/blocks/generic/LogicBlock.java @@ -0,0 +1,162 @@ +package com.hbm.blocks.generic; + +import com.hbm.world.gen.util.LogicBlockActions; +import com.hbm.world.gen.util.LogicBlockConditions; +import com.hbm.world.gen.util.LogicBlockInteractions; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.function.Consumer; +import java.util.function.Function; + +public class LogicBlock extends BlockContainer { + + public LogicBlock() { + super(Material.rock); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new LogicBlock.TileEntityLogicBlock(); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof LogicBlock.TileEntityLogicBlock){ + LogicBlock.TileEntityLogicBlock logicBlock = (LogicBlock.TileEntityLogicBlock) tile; + if(logicBlock.disguise != null){ + return logicBlock.disguise.getIcon(side, logicBlock.disguiseMeta); + } + } + + return super.getIcon(world, x, y, z, side); + } + + @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); + if(te instanceof LogicBlock.TileEntityLogicBlock && ((LogicBlock.TileEntityLogicBlock) te).interaction != null) { + ((LogicBlock.TileEntityLogicBlock) te).interaction.accept(new Object[]{worldIn, te, x, y, z, player, side, subX, subY, subZ}); + return true; + } + + return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ); + } + + public static class TileEntityLogicBlock extends TileEntity { + + //phase is incremented per condition check, timer counts since last condition check by default + public int phase = 0; + public int timer = 0; + + public Block disguise; + public int disguiseMeta; + + /**Actions always get called before conditions, use the phase and timer variables in order to control behavior via conditions*/ + public String conditionID = "PLAYER_CUBE_5"; + public String actionID = "FODDER_WAVE"; + /**Interactions are called on right click, and passes on the parameters of the right click to consumer*/ + public String interactionID; + + public Function condition; + public Consumer action; + /**Consists of world instance, TileEntity instance, three ints for coordinates, one int for block side, and player instance, in that order **/ + public Consumer interaction; + + public EntityPlayer player; + + public ForgeDirection direction = ForgeDirection.UNKNOWN; + @Override + public void updateEntity() { + + if(!worldObj.isRemote) { + if(action == null){ + action = LogicBlockActions.actions.get(actionID); + } + if(condition == null){ + condition = LogicBlockConditions.conditions.get(conditionID); + } + if(interaction == null && interactionID != null){ + interaction = LogicBlockInteractions.interactions.get(interactionID); + } + + if(action == null || condition == null){ + worldObj.setBlock(xCoord,yCoord,zCoord, Blocks.air); + return; + } + action.accept(this); + if(condition.apply(this)) { + phase++; + timer = 0; + } else { + timer++; + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("phase", phase); + + nbt.setString("actionID", actionID); + nbt.setString("conditionID", conditionID); + if(interactionID != null) + nbt.setString("interactionID", interactionID); + + nbt.setInteger("direction", direction.ordinal()); + if(disguise != null){ + nbt.setInteger("disguiseMeta", disguiseMeta); + nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.phase = nbt.getInteger("phase"); + + this.actionID = nbt.getString("actionID"); + this.conditionID = nbt.getString("conditionID"); + if(nbt.hasKey("interactionID")) this.interactionID = nbt.getString("interactionID"); + + this.direction = ForgeDirection.getOrientation(nbt.getInteger("direction")); + + if(nbt.hasKey("disguise")){ + disguiseMeta = nbt.getInteger("disguiseMeta"); + disguise = Block.getBlockFromName(nbt.getString("disguise")); + } + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbt = new NBTTagCompound(); + this.writeToNBT(nbt); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + this.readFromNBT(pkt.func_148857_g()); + } + } + +} diff --git a/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java b/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java index 9b8751d05..e460bc08b 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java +++ b/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java @@ -21,7 +21,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityDoorGeneric extends TileEntityLockableBase { +public class TileEntityDoorGeneric extends TileEntityLockableBase { //0: closed, 1: open, 2: closing, 3: opening public byte state = 0; @@ -318,6 +318,15 @@ public class TileEntityDoorGeneric extends TileEntityLockableBase { return true; } + /**Useful for logic block interactions, as a way to close/open doors**/ + public void open(){ + if(state == 0) state = 3; + } + + public void close() { + if(state == 1) state = 2; + } + @Override public AxisAlignedBB getRenderBoundingBox() { return INFINITE_EXTENT_AABB; @@ -404,4 +413,4 @@ public class TileEntityDoorGeneric extends TileEntityLockableBase { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index f688059be..1c938ab18 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -19,8 +19,9 @@ import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe; import com.hbm.blocks.generic.BlockSupplyCrate.TileEntitySupplyCrate; import com.hbm.blocks.generic.BlockWandJigsaw.TileEntityWandJigsaw; import com.hbm.blocks.generic.BlockWandLoot.TileEntityWandLoot; -import com.hbm.blocks.generic.BlockWandSpawner.TileEntityWandSpawner; +import com.hbm.blocks.generic.BlockWandLogic.TileEntityWandLogic; import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner; +import com.hbm.blocks.generic.LogicBlock; import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter; import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF; import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR; @@ -209,6 +210,7 @@ public class TileMappings { put(TileEntityPedestal.class, "tileentity_ntm_pedestal"); put(TileEntitySkeletonHolder.class, "tileentity_ntm_skeleton"); put(TileEntityDungeonSpawner.class, "tileentity_ntm_dungeon_spawner"); + put(LogicBlock.TileEntityLogicBlock.class, "tileentity_ntm_logic_block"); put(TileEntityBobble.class, "tileentity_ntm_bobblehead"); put(TileEntitySnowglobe.class, "tileentity_ntm_snowglobe"); put(TileEntityPlushie.class, "tileentity_ntm_plushie"); @@ -237,7 +239,7 @@ public class TileMappings { put(TileEntityWandLoot.class, "tileentity_wand_loot"); put(TileEntityWandJigsaw.class, "tileentity_wand_jigsaw"); - put(TileEntityWandSpawner.class, "tileentity_wand_spawner"); + put(TileEntityWandLogic.class, "tileentity_wand_spawner"); putNetwork(); putBombs(); diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java b/src/main/java/com/hbm/world/gen/util/LogicBlockActions.java similarity index 91% rename from src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java rename to src/main/java/com/hbm/world/gen/util/LogicBlockActions.java index 252bc543b..2b3682c7c 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java +++ b/src/main/java/com/hbm/world/gen/util/LogicBlockActions.java @@ -4,6 +4,7 @@ import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockSkeletonHolder; import com.hbm.blocks.generic.DungeonSpawner; +import com.hbm.blocks.generic.LogicBlock; import com.hbm.entity.item.EntityFallingBlockNT; import com.hbm.entity.missile.EntityMissileTier2; import com.hbm.entity.mob.EntityUndeadSoldier; @@ -30,11 +31,11 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.*; import java.util.function.Consumer; -public class DungeonSpawnerActions { +public class LogicBlockActions { - public static LinkedHashMap> actions = new LinkedHashMap<>(); + public static LinkedHashMap> actions = new LinkedHashMap<>(); - public static Consumer PHASE_ABERRATOR = (tile) -> { + public static Consumer PHASE_ABERRATOR = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -79,7 +80,7 @@ public class DungeonSpawnerActions { } }; - public static Consumer COLLAPSE_ROOF_RAD_5 = (tile) -> { + public static Consumer COLLAPSE_ROOF_RAD_5 = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -115,7 +116,7 @@ public class DungeonSpawnerActions { }; - public static Consumer FODDER_WAVE = (tile) -> { + public static Consumer FODDER_WAVE = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -134,7 +135,7 @@ public class DungeonSpawnerActions { } }; - public static Consumer PUZZLE_TEST = (tile) -> { + public static Consumer PUZZLE_TEST = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -151,7 +152,7 @@ public class DungeonSpawnerActions { } }; - public static Consumer MISSILE_STRIKE = (tile) -> { + public static Consumer MISSILE_STRIKE = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -176,7 +177,7 @@ public class DungeonSpawnerActions { world.setBlock(x,y,z, ModBlocks.block_electrical_scrap); }; - public static Consumer RAD_CONTAINMENT_SYSTEM = (tile) -> { + public static Consumer RAD_CONTAINMENT_SYSTEM = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -254,9 +255,10 @@ public class DungeonSpawnerActions { //register new actions here static{ - actions.put("PHASE_ABERRATOR", PHASE_ABERRATOR); - actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5); + //example actions actions.put("FODDER_WAVE", FODDER_WAVE); + actions.put("ABERRATOR", PHASE_ABERRATOR); + actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5); actions.put("PUZZLE_TEST", PUZZLE_TEST); actions.put("MISSILE_STRIKE", MISSILE_STRIKE); actions.put("IRRADIATE_ENTITIES_AOE", RAD_CONTAINMENT_SYSTEM); diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java b/src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java similarity index 79% rename from src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java rename to src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java index 1e0cc9d5a..5065a38fd 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java +++ b/src/main/java/com/hbm/world/gen/util/LogicBlockConditions.java @@ -3,9 +3,9 @@ package com.hbm.world.gen.util; import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockPedestal; import com.hbm.blocks.generic.DungeonSpawner; +import com.hbm.blocks.generic.LogicBlock; import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.items.ModItems; -import com.hbm.tileentity.machine.storage.TileEntityCrateBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; @@ -14,19 +14,18 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.function.Function; -public class DungeonSpawnerConditions { +public class LogicBlockConditions { - public static LinkedHashMap> conditions = new LinkedHashMap<>(); + public static LinkedHashMap> conditions = new LinkedHashMap<>(); /**For use with interactions, for having them handle all conditional tasks*/ - public static Function EMPTY = (tile) -> false; + public static Function EMPTY = (tile) -> false; - public static Function ABERRATOR = (tile) -> { + public static Function ABERRATOR = (tile) -> { World world = tile.getWorldObj(); if(world.difficultySetting.ordinal() == 0) return false; int x = tile.xCoord; @@ -45,7 +44,7 @@ public class DungeonSpawnerConditions { return false; }; - public static Function PLAYER_CUBE_5 = (tile) -> { + public static Function PLAYER_CUBE_5 = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -53,7 +52,7 @@ public class DungeonSpawnerConditions { return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(5, 5, 5)).isEmpty(); }; - public static Function REDSTONE = (tile) -> { + public static Function REDSTONE = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -62,7 +61,7 @@ public class DungeonSpawnerConditions { return world.isBlockIndirectlyGettingPowered(x,y,z); }; - public static Function PUZZLE_TEST = (tile) -> { + public static Function PUZZLE_TEST = (tile) -> { World world = tile.getWorldObj(); int x = tile.xCoord; int y = tile.yCoord; @@ -88,6 +87,7 @@ public class DungeonSpawnerConditions { //register new conditions here static { + //example conditions conditions.put("EMPTY", EMPTY); conditions.put("ABERRATOR", ABERRATOR); conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5); diff --git a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java b/src/main/java/com/hbm/world/gen/util/LogicBlockInteractions.java similarity index 73% rename from src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java rename to src/main/java/com/hbm/world/gen/util/LogicBlockInteractions.java index 32c19b81d..decf997a6 100644 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java +++ b/src/main/java/com/hbm/world/gen/util/LogicBlockInteractions.java @@ -1,30 +1,22 @@ package com.hbm.world.gen.util; -import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner; -import com.hbm.entity.missile.EntityMissileTier2; +import com.hbm.blocks.generic.LogicBlock; +import com.hbm.blocks.generic.LogicBlock.TileEntityLogicBlock; import com.hbm.items.ModItems; import com.hbm.potion.HbmPotion; -import com.hbm.tileentity.TileEntityDoorGeneric; -import com.hbm.util.Vec3NT; -import com.hbm.world.WorldUtil; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.function.Consumer; /**Interactions are called when the player right-clicks the block**/ -public class DungeonSpawnerInteractions { +public class LogicBlockInteractions { /**Consumer consists of world instance, tile entity instance, three ints for coordinates, one int for block side, and player instance, * in that order **/ @@ -32,23 +24,23 @@ public class DungeonSpawnerInteractions { public static Consumer TEST = (array) -> { World world = (World) array[0]; - TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) array[1]; + LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) array[1]; int x = (int) array[2]; int y = (int) array[3]; int z = (int) array[4]; EntityPlayer player = (EntityPlayer) array[5]; int side = (int) array[6]; - if(spawner.phase > 1) return; + if(logic.phase > 1) return; if(player.getHeldItem() != null) player.getHeldItem().stackSize--; - spawner.phase++; + logic.phase++; }; public static Consumer RAD_CONTAINMENT_SYSTEM = (array) -> { - TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) array[1]; + LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) array[1]; EntityPlayer player = (EntityPlayer) array[5]; if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.key){ @@ -58,8 +50,8 @@ public class DungeonSpawnerInteractions { EnumChatFormatting.RESET + " Radiation treatment administered")); player.addPotionEffect(new PotionEffect(HbmPotion.radaway.getId(), 3 * 60 * 20, 4)); player.addPotionEffect(new PotionEffect(HbmPotion.radx.getId(), 3 * 60 * 20, 4)); - spawner.phase = 2; - spawner.timer = 0; + logic.phase = 2; + logic.timer = 0; } }; diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index dcb6d68b3..c5fd461eb 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -5279,7 +5279,7 @@ tile.ducrete_smooth_stairs.name=Ducrete Stairs tile.dummy_block.name=Dummy Block tile.dummy_port.name=Dummy Block (Electricity Port) tile.dungeon_chain.name=Metal Chain -tile.dungeon_spawner.name=Dungeon Action Block +tile.logic_block.name=Dungeon Action Block tile.dynamite.name=Dynamite tile.emp_bomb.name=EMP Device tile.factory_advanced_conductor.name=Advanced Factory Electricity Port @@ -6062,7 +6062,7 @@ tile.volcano_rad_core.name=Rad Volcano Core tile.wand_air.name=Structure Wand Block (Air) tile.wand_loot.name=Structure Wand Block (Lootable) tile.wand_jigsaw.name=Structure Wand Block (Jigsaw) -tile.wand_spawner.name=Structure Wand Block (Actions) +tile.wand_logic.name=Structure Wand Block (Logic) tile.waste_earth.name=Dead Grass tile.waste_leaves.name=Dead Leaves tile.waste_log.name=Charred Log diff --git a/src/main/resources/assets/hbm/textures/blocks/logic_block.png b/src/main/resources/assets/hbm/textures/blocks/logic_block.png new file mode 100644 index 0000000000000000000000000000000000000000..9e0d69e2f3a978d2bf12ddc5b5cbfb1842ba7510 GIT binary patch literal 910 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv=}#LT=BJwMkF1yemk zJqzi~S1W*OwxvdRrg?g5F>nAmtPE0&tPG4mmKP99L)jqLXfQH^#X;^dWMl%nE(*xb zY-a(BX93wDkO0IW{V*EMQU+$Aci0(NfGP}(j13qUKuiVcU|j$)X$p`H0!%=2n7}H7 zEG>X6s4hbT1CZ?M21ViEc@`Q#b+(=^jv*HQzCpSEw*o}=>F?dEtN)5U!RbuG4&KgV zE{oqaci#N3F7Vi4ruQ+EnJOGSncgqo?tMGYY15mUjB}@p=K-O2eqNr%b4LM-zRAlp zmx|QsO&5035$mq8>(82`k|<$x?Ad3_z5DjX>4{yuJ^QTXNoG&U`_ogS;hZ4FDZYqw~rU$lJ8xq{k3lIKhI1bj>8vh zk8jMCo@>20aBI}s+_h16Cl=M$%l|CenG-q9Q>ck;%?S=i9^RutFaQ0kGm!Z5yY_l% zYp$}TRDb*7hwJag`ets7ND;8&W%6j5yDci-jIEYqr@*Cc$@lGnpi8MeHR0Lseac53 zU%veIZSMBlXWNX}cFy%v*Jn|Smg$|z{54Y4G`!<*bMxfM!pS~+4DWpW^y$-=H#{5+ z+e8+8x8a{YO--1D8D1it-Rb>DsQqh|{(-fj4_hd;{s>7^O>l{;j1w;tN< z#rnm7!E32d+%tB?*D4zet`%5MnQ(sVtQFS_x9{F^q(96+N#5J1z z(8F|LpIJ)ta?j+OJ>MKDaD4sx^^;Gs%zj`!*N^dmPV(~b@bK=NXRcYXEWft1rcSmk zq4A~4#mrsLcYVk`9W+Nf*`mZ{hF>Pr#vmp^$-_CbA8lMB67;CuxJT2e>8cmUNAY#m VmCt%+=9_>Lm8Ywp%Q~loCIFqXPX_=1 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/blocks/wand_spawner.png b/src/main/resources/assets/hbm/textures/blocks/wand_logic.png similarity index 100% rename from src/main/resources/assets/hbm/textures/blocks/wand_spawner.png rename to src/main/resources/assets/hbm/textures/blocks/wand_logic.png diff --git a/src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png b/src/main/resources/assets/hbm/textures/blocks/wand_logic_top.png similarity index 100% rename from src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png rename to src/main/resources/assets/hbm/textures/blocks/wand_logic_top.png