diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index f69f85497..f6dcd2065 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -1243,7 +1243,6 @@ 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(); @@ -2397,8 +2396,6 @@ 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() { @@ -3545,7 +3542,6 @@ 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 deleted file mode 100644 index b6c042838..000000000 --- a/src/main/java/com/hbm/blocks/generic/BlockWandSpawner.java +++ /dev/null @@ -1,343 +0,0 @@ -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 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.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; -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 net.minecraftforge.common.util.ForgeDirection; - -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); - - 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 = 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); - - 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; - 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; - } - } - - @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); - text.add("Interaction: " + (spawner.interactionID != null ? spawner.interactionID : "None")); - - 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); - } - - @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.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 - 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; - - Block disguise; - int disguiseMeta = -1; - - public String actionID = "PHASE_ABERRATOR"; - public String conditionID = "EMPTY"; - public String interactionID; - - @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; - spawner.interactionID = interactionID; - spawner.direction = ForgeDirection.getOrientation(placedRotation); - spawner.disguise = disguise; - spawner.disguiseMeta = disguiseMeta; - } - - } - - @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.setString("interactionID", interactionID); - nbt.setInteger("rotation", placedRotation); - if(disguise != null){ - nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString()); - nbt.setInteger("disguiseMeta", disguiseMeta); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbt) { - 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")); - disguiseMeta = nbt.getInteger("disguiseMeta"); - } - } - - @Override - public void serialize(ByteBuf buf) { - buf.writeInt(placedRotation); - BufferUtil.writeString(buf, actionID); - BufferUtil.writeString(buf, conditionID); - BufferUtil.writeString(buf, interactionID); - buf.writeInt(Block.getIdFromBlock(disguise)); - buf.writeInt(disguiseMeta); - } - - @Override - public void deserialize(ByteBuf buf) { - placedRotation = buf.readInt(); - actionID = BufferUtil.readString(buf); - conditionID = BufferUtil.readString(buf); - interactionID = BufferUtil.readString(buf); - disguise = Block.getBlockById(buf.readInt()); - disguiseMeta = buf.readInt(); - } - - @Override - public NBTTagCompound getSettings(World world, int x, int y, int z) { - 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", GameRegistry.findUniqueIdentifierFor(disguise).toString()); - nbt.setInteger("disguiseMeta", disguiseMeta); - } - - 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"); - 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 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/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index 199127431..0d64ee670 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -877,8 +877,6 @@ 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 655656174..cd368b165 100644 --- a/src/main/java/com/hbm/main/ModEventHandler.java +++ b/src/main/java/com/hbm/main/ModEventHandler.java @@ -387,18 +387,74 @@ public class ModEventHandler { if(entity instanceof EntityZombie) { if(world.rand.nextFloat() < 0.005F && soot > 2) { // full hazmat zombine - MobUtil.equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots); + equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots); return; } - slotPools = MobUtil.slotPoolCommon; + + 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} + })); } else if(entity instanceof EntitySkeleton) { - slotPools = MobUtil.slotPoolRanged; + + 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} + })); + ItemStack bowReplacement = getSkelegun(soot, world.rand); slotPools.put(0, createSlotPool(50, bowReplacement != null ? new Object[][]{{bowReplacement, 1}} : new Object[][]{})); } - MobUtil.assignItemsToEntity(entity, slotPools, rand); + 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)); } private List createSlotPool(int nullWeight, Object[][] items) { @@ -417,30 +473,74 @@ public class ModEventHandler { return pool; } - private static ItemStack getSkelegun(float soot, Random rand) { - if (!MobConfig.enableMobWeapons) return null; - if (rand.nextDouble() > Math.log(soot) * 0.25) return null; - ArrayList pool = new ArrayList<>(); + public void assignItemsToEntity(EntityLivingBase entity, Map> slotPools) { + for (Map.Entry> entry : slotPools.entrySet()) { + int slot = entry.getKey(); + List pool = entry.getValue(); - 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 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; + + 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)); + + 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)); 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; @@ -449,7 +549,7 @@ public class ModEventHandler { ItemStack held = living.getHeldItem(); if(held != null && held.getItem() instanceof ItemGunBaseNT) { - MobUtil.addFireTask(living); + addFireTask(living); } } diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index f688059be..ca3281bd1 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -19,7 +19,6 @@ 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; @@ -237,7 +236,6 @@ public class TileMappings { put(TileEntityWandLoot.class, "tileentity_wand_loot"); put(TileEntityWandJigsaw.class, "tileentity_wand_jigsaw"); - put(TileEntityWandSpawner.class, "tileentity_wand_spawner"); putNetwork(); putBombs(); @@ -430,7 +428,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 deleted file mode 100644 index 8779c1ed2..000000000 --- a/src/main/java/com/hbm/util/MobUtil.java +++ /dev/null @@ -1,197 +0,0 @@ -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 deleted file mode 100644 index fee835c2e..000000000 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerActions.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.hbm.world.gen.util; - -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.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; -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.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.*; -import java.util.function.Consumer; - -public class DungeonSpawnerActions { - - public static LinkedHashMap> actions = new LinkedHashMap<>(); - - 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); - 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); - } - }; - - 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) + 2, z); - world.spawnEntityInWorld(blitz); - - TileEntityCrateBase crate = (TileEntityCrateBase) world.getTileEntity(x,y,z); - ((IInventory)crate).setInventorySlotContents(15, new ItemStack(ModItems.gun_bolter)); - } - }; - - 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 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()); - } - - //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); - 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 deleted file mode 100644 index 83dd773e8..000000000 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerConditions.java +++ /dev/null @@ -1,96 +0,0 @@ -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.LinkedHashMap; -import java.util.List; -import java.util.function.Function; - -public class DungeonSpawnerConditions { - - 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(); - 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("EMPTY", EMPTY); - 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/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java b/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java deleted file mode 100644 index 32c19b81d..000000000 --- a/src/main/java/com/hbm/world/gen/util/DungeonSpawnerInteractions.java +++ /dev/null @@ -1,80 +0,0 @@ -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); - } - - - -} diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index dcb6d68b3..74c5a343b 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -5279,7 +5279,6 @@ 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 @@ -6062,7 +6061,6 @@ 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 deleted file mode 100644 index 4561c8e4e..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/wand_spawner.png and /dev/null differ 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 deleted file mode 100644 index 65e3106a9..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/wand_spawner_top.png and /dev/null differ