diff --git a/src/main/java/com/hbm/blocks/generic/BlockGlyphidSpawner.java b/src/main/java/com/hbm/blocks/generic/BlockGlyphidSpawner.java index f2acc1999..0150ad3d5 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockGlyphidSpawner.java +++ b/src/main/java/com/hbm/blocks/generic/BlockGlyphidSpawner.java @@ -4,23 +4,14 @@ import java.util.*; import java.util.function.Function; import com.hbm.config.MobConfig; -import com.hbm.entity.mob.EntityGlyphid; -import com.hbm.entity.mob.EntityGlyphidBehemoth; -import com.hbm.entity.mob.EntityGlyphidBlaster; -import com.hbm.entity.mob.EntityGlyphidBombardier; -import com.hbm.entity.mob.EntityGlyphidBrawler; -import com.hbm.entity.mob.EntityGlyphidBrenda; -import com.hbm.entity.mob.EntityGlyphidNuclear; -import com.hbm.entity.mob.EntityGlyphidScout; +import com.hbm.entity.mob.*; import com.hbm.handler.pollution.PollutionHandler; import com.hbm.handler.pollution.PollutionHandler.PollutionType; import com.hbm.items.ModItems; - import com.hbm.util.Tuple.Pair; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -30,25 +21,27 @@ import net.minecraft.world.World; public class BlockGlyphidSpawner extends BlockContainer { - public BlockGlyphidSpawner(Material p_i45386_1_) { - super(p_i45386_1_); + public BlockGlyphidSpawner(Material mat) { + super(mat); } @Override public Item getItemDropped(int meta, Random rand, int fortune) { return ModItems.egg_glyphid; } + private static final ArrayList, int[]>> spawnMap = new ArrayList<>(); - static{ - //big thanks to martin for the suggestion of using functions - spawnMap.add(new Pair<>(EntityGlyphid::new, MobConfig.glyphidChance)); - spawnMap.add(new Pair<>(EntityGlyphidBombardier::new, MobConfig.bombardierChance)); - spawnMap.add(new Pair<>(EntityGlyphidBrawler::new, MobConfig.brawlerChance)); - spawnMap.add(new Pair<>(EntityGlyphidBlaster::new, MobConfig.blasterChance)); - spawnMap.add(new Pair<>(EntityGlyphidBehemoth::new, MobConfig.behemothChance)); - spawnMap.add(new Pair<>(EntityGlyphidBrenda::new, MobConfig.brendaChance)); - spawnMap.add(new Pair<>(EntityGlyphidNuclear::new, MobConfig.johnsonChance)); + static { + // big thanks to martin for the suggestion of using functions + spawnMap.add(new Pair<>(EntityGlyphid::new, MobConfig.glyphidChance)); + spawnMap.add(new Pair<>(EntityGlyphidBombardier::new, MobConfig.bombardierChance)); + spawnMap.add(new Pair<>(EntityGlyphidBrawler::new, MobConfig.brawlerChance)); + spawnMap.add(new Pair<>(EntityGlyphidDigger::new, MobConfig.diggerChance)); + spawnMap.add(new Pair<>(EntityGlyphidBlaster::new, MobConfig.blasterChance)); + spawnMap.add(new Pair<>(EntityGlyphidBehemoth::new, MobConfig.behemothChance)); + spawnMap.add(new Pair<>(EntityGlyphidBrenda::new, MobConfig.brendaChance)); + spawnMap.add(new Pair<>(EntityGlyphidNuclear::new, MobConfig.johnsonChance)); } @Override @@ -67,47 +60,51 @@ public class BlockGlyphidSpawner extends BlockContainer { @Override public void updateEntity() { - float soot; if(!worldObj.isRemote && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL) { - if (initialSpawn || worldObj.getTotalWorldTime() % MobConfig.swarmCooldown == 0) { - - if (worldObj.getBlock(xCoord, yCoord + 1, zCoord) != Blocks.air) { - return; - } + if(initialSpawn || worldObj.getTotalWorldTime() % MobConfig.swarmCooldown == 0) { + int count = 0; - for (Object e : worldObj.loadedEntityList) { - if (e instanceof EntityGlyphid) { + for(Object e : worldObj.loadedEntityList) { + if(e instanceof EntityGlyphid) { count++; - if (count >= MobConfig.spawnMax) return; + //if(count >= MobConfig.spawnMax) + // return; } } - List list = worldObj.getEntitiesWithinAABB(EntityGlyphid.class, AxisAlignedBB.getBoundingBox(xCoord - 6, yCoord + 1, zCoord - 6, xCoord + 7, yCoord + 9, zCoord + 7)); - soot = PollutionHandler.getPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT); + List list = worldObj.getEntitiesWithinAABB(EntityGlyphid.class, AxisAlignedBB.getBoundingBox(xCoord - 9, yCoord + 1, zCoord - 9, xCoord + 10, yCoord + 8, zCoord + 10)); + float soot = PollutionHandler.getPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT); - if (list.size() <= 3) { + if(list.size() <= 3) { ArrayList currentSwarm = createSwarm(soot); - for (EntityGlyphid glyphid : currentSwarm) { - glyphid.setLocationAndAngles(xCoord + 0.5, yCoord + 1, zCoord + 0.5, worldObj.rand.nextFloat() * 360.0F, 0.0F); - worldObj.spawnEntityInWorld(glyphid); - glyphid.moveEntity(worldObj.rand.nextGaussian(), 0, worldObj.rand.nextGaussian()); + for(EntityGlyphid glyphid : currentSwarm) { + trySpawnEntity(glyphid); } - if (!initialSpawn && worldObj.rand.nextInt(MobConfig.scoutSwarmSpawnChance + 1) == 0 && soot >= MobConfig.scoutThreshold) { - EntityGlyphidScout scout = new EntityGlyphidScout(worldObj); - scout.setLocationAndAngles(xCoord + 0.5, yCoord + 1, zCoord + 0.5, worldObj.rand.nextFloat() * 360.0F, 0.0F); - worldObj.spawnEntityInWorld(scout); + if(!initialSpawn && worldObj.rand.nextInt(MobConfig.scoutSwarmSpawnChance + 1) == 0 && soot >= MobConfig.scoutThreshold) { + trySpawnEntity(new EntityGlyphidScout(worldObj)); } initialSpawn = false; - } - + } + } + } + + public void trySpawnEntity(EntityGlyphid glyphid) { + double offsetX = glyphid.getRNG().nextGaussian() * 3; + double offsetZ = glyphid.getRNG().nextGaussian() * 3; + + for(int i = 0; i < 7; i++) { + glyphid.setLocationAndAngles(xCoord + 0.5 + offsetX, yCoord - 2 + i, zCoord + 0.5 + offsetZ, worldObj.rand.nextFloat() * 360.0F, 0.0F); + if(glyphid.getCanSpawnHere()) { + worldObj.spawnEntityInWorld(glyphid); + return; } } } @@ -115,21 +112,18 @@ public class BlockGlyphidSpawner extends BlockContainer { public ArrayList createSwarm(float soot) { Random rand = new Random(); - ArrayList currentSpawns = new ArrayList<>(); - int swarmAmount = (int) Math.min(MobConfig.baseSwarmSize * Math.max(MobConfig.swarmScalingMult * (soot / MobConfig.sootStep), 1), 10); while(currentSpawns.size() <= swarmAmount) { - //(dys)functional programing - for (Pair, int[]> glyphid : spawnMap) { - - int[] chance = glyphid.getValue(); - int adjustedChance = (int) (chance[0] + (chance[1] - chance[1] / Math.max(((soot + 1)/3 ), 1))); - if (rand.nextInt(100) <= adjustedChance) { - currentSpawns.add(glyphid.getKey().apply(worldObj)); - } - } + // (dys)functional programing + for(Pair, int[]> glyphid : spawnMap) { + int[] chance = glyphid.getValue(); + int adjustedChance = (int) (chance[0] + (chance[1] - chance[1] / Math.max(((soot + 1) / 3), 1))); + if(rand.nextInt(100) <= adjustedChance) { + currentSpawns.add(glyphid.getKey().apply(worldObj)); + } + } } return currentSpawns; } diff --git a/src/main/java/com/hbm/config/MobConfig.java b/src/main/java/com/hbm/config/MobConfig.java index 19d515b5a..2cf744595 100644 --- a/src/main/java/com/hbm/config/MobConfig.java +++ b/src/main/java/com/hbm/config/MobConfig.java @@ -36,7 +36,7 @@ public class MobConfig { public static int largeHiveChance = 5; public static int largeHiveThreshold = 30; - public static int swarmCooldown = 120; + public static int swarmCooldown = 120 * 20; public static int baseSwarmSize = 5; public static double swarmScalingMult = 1.2; @@ -46,6 +46,7 @@ public class MobConfig { public static int[] brawlerChance = {5, 35}; public static int[] bombardierChance = {20, -15}; public static int[] blasterChance = {-15, 40}; + public static int[] diggerChance = {-15, 25}; public static int[] behemothChance = {-30, 45}; public static int[] brendaChance = {-50, 60}; public static int[] johnsonChance = {-50, 60}; @@ -136,9 +137,10 @@ public class MobConfig { brawlerChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC02_brawlerChance", "Base Spawn chance and soot modifier for a glyphid brawler", new int[]{10, 30}); bombardierChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC03_bombardierChance", "Base Spawn chance and soot modifier for a glyphid bombardier", new int[]{20, -15}); blasterChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC04_blasterChance", "Base Spawn chance and soot modifier for a glyphid blaster", new int[]{-5, 40}); - behemothChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC05_behemothChance", "Base Spawn chance and soot modifier for a glyphid behemoth", new int[]{-30, 45}); - brendaChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC06_brendaChance", "Base Spawn chance and soot modifier for a glyphid brenda", new int[]{-50, 60}); - johnsonChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC07_johnsonChance", "Base Spawn chance and soot modifier for Big Man Johnson", new int[]{-50, 60}); + diggerChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC05_diggerChance", "Base Spawn chance and soot modifier for a glyphid digger", new int[]{-15, 25}); + behemothChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC06_behemothChance", "Base Spawn chance and soot modifier for a glyphid behemoth", new int[]{-30, 45}); + brendaChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC07_brendaChance", "Base Spawn chance and soot modifier for a glyphid brenda", new int[]{-50, 60}); + johnsonChance = CommonConfig.createConfigIntList(config, CATEGORY, "12.GC08_johnsonChance", "Base Spawn chance and soot modifier for Big Man Johnson", new int[]{-50, 60}); String rampantDesc = "Rampant Mode changes glyphid behavior and spawning to be more aggressive, changes include:\n" + "\n" diff --git a/src/main/java/com/hbm/entity/EntityMappings.java b/src/main/java/com/hbm/entity/EntityMappings.java index 4c33cab1f..c40457abc 100644 --- a/src/main/java/com/hbm/entity/EntityMappings.java +++ b/src/main/java/com/hbm/entity/EntityMappings.java @@ -265,6 +265,7 @@ public class EntityMappings { addMob(EntityGlyphidBlaster.class, "entity_glyphid_blaster", 0xD83737, 0xDBB79D); addMob(EntityGlyphidScout.class, "entity_glyphid_scout", 0x273038, 0xB9E36B); addMob(EntityGlyphidNuclear.class, "entity_glyphid_nuclear", 0x267F00, 0xA0A0A0); + addMob(EntityGlyphidDigger.class, "entity_glyphid_digger", 0x273038, 0x724A21); addMob(EntityPlasticBag.class, "entity_plastic_bag", 0xd0d0d0, 0x808080); addSpawn(EntityCreeperPhosgene.class, 5, 1, 1, EnumCreatureType.monster, BiomeGenBase.getBiomeGenArray()); diff --git a/src/main/java/com/hbm/entity/mob/EntityGlyphid.java b/src/main/java/com/hbm/entity/mob/EntityGlyphid.java index 08a067063..f6c0ae768 100644 --- a/src/main/java/com/hbm/entity/mob/EntityGlyphid.java +++ b/src/main/java/com/hbm/entity/mob/EntityGlyphid.java @@ -32,7 +32,7 @@ import net.minecraft.util.*; import net.minecraft.potion.Potion; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; - +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import javax.annotation.Nullable; @@ -79,6 +79,9 @@ public class EntityGlyphid extends EntityMob { protected boolean hasWaypoint = false; /** Yeah, fuck, whatever, anything goes now */ protected EntityWaypoint taskWaypoint = null; + + public static final int TYPE_NORMAL = 0; + public static final int TYPE_INFECTED = 1; public EntityGlyphid(World world) { super(world); @@ -98,6 +101,7 @@ public class EntityGlyphid extends EntityMob { super.entityInit(); this.dataWatcher.addObject(16, new Byte((byte) 0)); //wall climbing this.dataWatcher.addObject(17, new Byte((byte) 0b11111)); //armor + this.dataWatcher.addObject(18, new Byte((byte) 0)); //subtype (i.e. normal, infected, etc) } @Override @@ -204,7 +208,8 @@ public class EntityGlyphid extends EntityMob { } if(hasWaypoint) { - if(MobConfig.rampantDig) { + + if(canDig()) { MovingObjectPosition obstacle = findWaypointObstruction(); if (getScale() >= 1 && getCurrentTask() != TASK_DIG && obstacle != null) { @@ -229,6 +234,9 @@ public class EntityGlyphid extends EntityMob { } } + protected boolean canDig() { + return MobConfig.rampantDig; + } public void onBlinded(){ this.entityToAttack = null; @@ -593,4 +601,9 @@ public class EntityGlyphid extends EntityMob { this.currentTask = nbt.getInteger("task"); } + + @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); + } } diff --git a/src/main/java/com/hbm/entity/mob/EntityGlyphidDigger.java b/src/main/java/com/hbm/entity/mob/EntityGlyphidDigger.java new file mode 100644 index 000000000..09801fe4b --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/EntityGlyphidDigger.java @@ -0,0 +1,41 @@ +package com.hbm.entity.mob; + +import com.hbm.main.ResourceManager; + +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class EntityGlyphidDigger extends EntityGlyphid { + + public EntityGlyphidDigger(World world) { + super(world); + } + + public ResourceLocation getSkin() { + return ResourceManager.glyphid_digger_tex; + } + + @Override + public double getScale() { + return 1.25D; + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(35D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5D); + } + + @Override + public boolean isArmorBroken(float amount) { + return this.rand.nextInt(100) <= Math.min(Math.pow(amount * 0.25, 2), 100); + } + + @Override + protected boolean canDig() { + return true; + } +} diff --git a/src/main/java/com/hbm/inventory/fluid/Fluids.java b/src/main/java/com/hbm/inventory/fluid/Fluids.java index 5cc0ee007..b2efa5781 100644 --- a/src/main/java/com/hbm/inventory/fluid/Fluids.java +++ b/src/main/java/com/hbm/inventory/fluid/Fluids.java @@ -331,9 +331,9 @@ public class Fluids { THORIUM_SALT = new FluidType("THORIUM_SALT", 0x7A5542, 2, 0, 3, EnumSymbol.NONE).setTemp(800).addTraits(LIQUID, new FT_Corrosive(65)); THORIUM_SALT_HOT = new FluidType("THORIUM_SALT_HOT", 0x3E3627, 2, 0, 3, EnumSymbol.NONE).setTemp(1600).addTraits(LIQUID, new FT_Corrosive(65)); THORIUM_SALT_DEPLETED = new FluidType("THORIUM_SALT_DEPLETED", 0x302D1C, 2, 0, 3, EnumSymbol.NONE).setTemp(800).addTraits(LIQUID, new FT_Corrosive(65)); - FULLERENE = new FluidType(132, "FULLERENE", 0xFF7FED, 3, 3, 3, EnumSymbol.NONE).addTraits(LIQUID, new FT_Corrosive(65)); + FULLERENE = new FluidType("FULLERENE", 0xFF7FED, 3, 3, 3, EnumSymbol.NONE).addTraits(LIQUID, new FT_Corrosive(65)); PHEROMONE = new FluidType("PHEROMONE", 0x5FA6E8, 0, 0, 0, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS, new FT_Pheromone(1)); - PHEROMONE_M = new FluidType("PHEROMONE_M", 0x48C9B0 , 0, 0, 0, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS, new FT_Pheromone(2)); + PHEROMONE_M = new FluidType(132, "PHEROMONE_M", 0x48C9B0 , 0, 0, 0, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS, new FT_Pheromone(2)); // ^ ^ ^ ^ ^ ^ ^ ^ //ADD NEW FLUIDS HERE diff --git a/src/main/java/com/hbm/main/ResourceManager.java b/src/main/java/com/hbm/main/ResourceManager.java index 9816aee87..0d1a613df 100644 --- a/src/main/java/com/hbm/main/ResourceManager.java +++ b/src/main/java/com/hbm/main/ResourceManager.java @@ -750,6 +750,7 @@ public class ResourceManager { public static final ResourceLocation glyphid_blaster_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_blaster.png"); public static final ResourceLocation glyphid_scout_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_scout.png"); public static final ResourceLocation glyphid_nuclear_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_nuclear.png"); + public static final ResourceLocation glyphid_digger_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/glyphid_digger.png"); //ZIRNOX public static final ResourceLocation zirnox_tex = new ResourceLocation(RefStrings.MODID, "textures/models/zirnox.png"); diff --git a/src/main/resources/assets/hbm/textures/entity/glyphid_digger.png b/src/main/resources/assets/hbm/textures/entity/glyphid_digger.png new file mode 100644 index 000000000..524358e73 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/entity/glyphid_digger.png differ