diff --git a/src/main/java/assets/hbm/textures/blocks/brick_base.png b/src/main/java/assets/hbm/textures/blocks/brick_base.png new file mode 100644 index 000000000..9718c05ad Binary files /dev/null and b/src/main/java/assets/hbm/textures/blocks/brick_base.png differ diff --git a/src/main/java/assets/hbm/textures/blocks/brick_cracked_base.png b/src/main/java/assets/hbm/textures/blocks/brick_cracked_base.png new file mode 100644 index 000000000..070a7d9b4 Binary files /dev/null and b/src/main/java/assets/hbm/textures/blocks/brick_cracked_base.png differ diff --git a/src/main/java/assets/hbm/textures/blocks/brick_jungle.png b/src/main/java/assets/hbm/textures/blocks/brick_jungle.png new file mode 100644 index 000000000..3161b13ff Binary files /dev/null and b/src/main/java/assets/hbm/textures/blocks/brick_jungle.png differ diff --git a/src/main/java/assets/hbm/textures/blocks/brick_jungle_cracked.png b/src/main/java/assets/hbm/textures/blocks/brick_jungle_cracked.png new file mode 100644 index 000000000..6df658048 Binary files /dev/null and b/src/main/java/assets/hbm/textures/blocks/brick_jungle_cracked.png differ diff --git a/src/main/java/assets/hbm/textures/blocks/brick_jungle_trap.png b/src/main/java/assets/hbm/textures/blocks/brick_jungle_trap.png new file mode 100644 index 000000000..b11a1ae6b Binary files /dev/null and b/src/main/java/assets/hbm/textures/blocks/brick_jungle_trap.png differ diff --git a/src/main/java/assets/hbm/textures/models/machines/breeder.png b/src/main/java/assets/hbm/textures/models/machines/breeder.png new file mode 100644 index 000000000..70182684c Binary files /dev/null and b/src/main/java/assets/hbm/textures/models/machines/breeder.png differ diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 52bb8f972..3a5be3fd4 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -205,6 +205,9 @@ public class ModBlocks { public static Block meteor_spawner; public static Block meteor_battery; + public static Block brick_jungle; + public static Block brick_jungle_cracked; + public static Block tape_recorder; public static Block steel_poles; public static Block pole_top; @@ -972,6 +975,9 @@ public class ModBlocks { meteor_pillar = new BlockRotatablePillar(Material.rock, RefStrings.MODID + ":meteor_pillar_top").setBlockName("meteor_pillar").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(900.0F).setBlockTextureName(RefStrings.MODID + ":meteor_pillar"); meteor_spawner = new BlockCybercrab(Material.rock).setBlockName("meteor_spawner").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(900.0F); meteor_battery = new BlockPillar(Material.rock, RefStrings.MODID + ":meteor_power").setBlockName("meteor_battery").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(900.0F).setBlockTextureName(RefStrings.MODID + ":meteor_spawner_side"); + + brick_jungle = new BlockGeneric(Material.rock).setBlockName("brick_jungle").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(900.0F).setBlockTextureName(RefStrings.MODID + ":brick_jungle"); + brick_jungle_cracked = new BlockGeneric(Material.rock).setBlockName("brick_jungle_cracked").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(900.0F).setBlockTextureName(RefStrings.MODID + ":brick_jungle_cracked"); tape_recorder = new DecoTapeRecorder(Material.rock).setBlockName("tape_recorder").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(15.0F).setBlockTextureName(RefStrings.MODID + ":deco_tape_recorder"); steel_poles = new DecoSteelPoles(Material.rock).setBlockName("steel_poles").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(15.0F).setBlockTextureName(RefStrings.MODID + ":steel_beam"); @@ -1622,6 +1628,8 @@ public class ModBlocks { GameRegistry.registerBlock(meteor_pillar, meteor_pillar.getUnlocalizedName()); GameRegistry.registerBlock(meteor_spawner, meteor_spawner.getUnlocalizedName()); GameRegistry.registerBlock(meteor_battery, ItemBlockLore.class, meteor_battery.getUnlocalizedName()); + GameRegistry.registerBlock(brick_jungle, brick_jungle.getUnlocalizedName()); + GameRegistry.registerBlock(brick_jungle_cracked, brick_jungle_cracked.getUnlocalizedName()); GameRegistry.registerBlock(tape_recorder, tape_recorder.getUnlocalizedName()); GameRegistry.registerBlock(steel_poles, steel_poles.getUnlocalizedName()); GameRegistry.registerBlock(pole_top, pole_top.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeBase.java b/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeBase.java new file mode 100644 index 000000000..159fdf03d --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeBase.java @@ -0,0 +1,57 @@ +package com.hbm.entity.mob.botprime; + +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public abstract class EntityBOTPrimeBase extends EntityWormBaseNT { + + public int attackCounter = 0; + + protected final IEntitySelector selector = new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity ent) { + + if(ent instanceof EntityWormBaseNT && ((EntityWormBaseNT)ent).getHeadID() == EntityBOTPrimeBase.this.getHeadID()) + return false; + + return true; + } + + }; + + public EntityBOTPrimeBase(World world) { + super(world); + this.setSize(2.0F, 2.0F); + this.isImmuneToFire = true; + this.isAirBorne = true; + this.noClip = true; + this.renderDistanceWeight = 15.0D; + this.dragInAir = 0.995F; + this.dragInGround = 0.98F; + this.knockbackDivider = 1.0D; + } + + public boolean canEntityBeSeenThroughNonSolids(Entity p_70685_1_) { + return this.worldObj.func_147447_a(Vec3.createVectorHelper(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ), Vec3.createVectorHelper(p_70685_1_.posX, p_70685_1_.posY + (double)p_70685_1_.getEyeHeight(), p_70685_1_.posZ), false, true, false) == null; + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5000.0D); + } + + @Override + protected boolean isAIEnabled() { + return true; + } + + @Override + protected boolean canDespawn() { + return false; + } +} diff --git a/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeBody.java b/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeBody.java new file mode 100644 index 000000000..1d76b5e76 --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeBody.java @@ -0,0 +1,86 @@ +package com.hbm.entity.mob.botprime; + +import com.hbm.entity.mob.EntityAINearestAttackableTargetNT; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityBOTPrimeBody extends EntityBOTPrimeBase { + + private WormMovementBodyNT movement = new WormMovementBodyNT(this); + + public EntityBOTPrimeBody(World world) { + super(world); + this.bodySpeed = 0.6D; + this.rangeForParts = 70.0D; + this.segmentDistance = 1.9D; + this.maxBodySpeed = 1.4D; + this.targetTasks.addTask(1, new EntityAINearestAttackableTargetNT(this, EntityLivingBase.class, 0, true, false, this.selector, 128.0D)); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(17, (byte)0); + } + + @Override + public float getAttackStrength(Entity target) { + + if(target instanceof EntityLivingBase) { + return ((EntityLivingBase) target).getHealth() * 0.75F; + } + + return 100; + } + + @Override + protected void updateAITasks() { + this.movement.updateMovement(); + + if((this.followed != null) && (getPartNumber() == 0)) { + //this.dataWatcher.updateObject(17, Byte.valueOf((byte) (((EntityBallsOTronHead) this.followed).isArmored() ? 1 : 0))); + } else if(this.targetedEntity != null) { + this.dataWatcher.updateObject(17, Byte.valueOf(this.targetedEntity.getDataWatcher().getWatchableObjectByte(17))); + } + if(this.didCheck) { + if(this.targetedEntity == null || !this.targetedEntity.isEntityAlive()) { + setHealth(getHealth() - 1999.0F); + } + if(((this.followed == null) || (!this.followed.isEntityAlive())) && (this.rand.nextInt(60) == 0)) { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 2.0F, false); + } + } + if((this.followed != null) && (getAttackTarget() != null)) { + if(canEntityBeSeenThroughNonSolids(getAttackTarget())) { + this.attackCounter += 1; + if(this.attackCounter == 10) { + //useLaser(o(), false); + + this.attackCounter = -20; + } + } else if(this.attackCounter > 0) { + this.attackCounter -= 1; + } + } else if(this.attackCounter > 0) { + this.attackCounter -= 1; + } + + float f3 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(motionX, motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(motionY, f3) * 180.0D / Math.PI); + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setInteger("partID", this.getPartNumber()); + } + + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + setPartNumber(nbt.getInteger("partID")); + } +} diff --git a/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeHead.java b/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeHead.java new file mode 100644 index 000000000..c4124d06c --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/EntityBOTPrimeHead.java @@ -0,0 +1,156 @@ +package com.hbm.entity.mob.botprime; + +import com.hbm.entity.mob.EntityAINearestAttackableTargetNT; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityBOTPrimeHead extends EntityBOTPrimeBase implements IBossDisplayData { + + /* ___ _ _ _ ___ ___ _____ ___ ___ _ _ ___ ___ _ _ _ ___ + * | _ ) /_\ | | | | / __| ___ | | ___ |_ _| _ )| | \| | | _ \ _ )| | \ / | __| + * | _ \/ _ \| |_| |_\__ \ |___| | | | |___| | | | \| | | | | _/ \| | V | _| + * |___/_/ \_\___|___|___/ |___| |_| |_|\_\___|_|\_| |_| |_|\_\_|_|V|_|___| + */ + + private final WormMovementHeadNT movement = new WormMovementHeadNT(this); + + public EntityBOTPrimeHead(World world) { + super(world); + this.experienceValue = 1000; + this.wasNearGround = false; + this.attackRange = 150.0D; + this.setSize(3.0F, 3.0F); + this.maxSpeed = 1.0D; + this.fallSpeed = 0.006D; + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTargetNT(this, EntityPlayer.class, 0, false, false, null, 128.0D)); + this.targetTasks.addTask(3, new EntityAINearestAttackableTargetNT(this, Entity.class, 0, false, false, this.selector, 50.0D)); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.15D); + } + + @Override + public boolean getIsHead() { + return true; + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + + if(super.attackEntityFrom(par1DamageSource, par2)) { + this.dmgCooldown = 4; + return true; + } + + return false; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + + //TODO: check if this is even needed + setHeadID(this.getEntityId()); + + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.posY); + int z = MathHelper.floor_double(this.posZ); + + for (int i = 0; i < 119; i++) { + + EntityBOTPrimeBody bodyPart = new EntityBOTPrimeBody(this.worldObj); + bodyPart.setPartNumber(i); + bodyPart.setPosition(x, y, z); + bodyPart.setHeadID(getEntityId()); + this.worldObj.spawnEntityInWorld(bodyPart); + } + + setPosition(x, y, z); + this.spawnPoint.set(x, y, z); + + this.aggroCooldown = 60; + + return super.onSpawnWithEgg(data); + } + + @Override + protected void updateAITasks() { + + super.updateAITasks(); + + this.movement.updateMovement(); + + if ((getHealth() < getMaxHealth()) && (this.ticksExisted % 6 == 0)) { + if (this.targetedEntity != null) { + heal(1.0F); + } else if (this.recentlyHit == 0) { + heal(4.0F); + } + } + if ((this.targetedEntity != null) && (this.targetedEntity.getDistanceSqToEntity(this) < this.attackRange * this.attackRange)) + { + if (canEntityBeSeenThroughNonSolids(this.targetedEntity)) + { + this.attackCounter += 1; + if (this.attackCounter == 10) + { + //useLaser(this.targetedEntity, true); + + this.attackCounter = -20; + } + } + else if (this.attackCounter > 0) + { + this.attackCounter -= 1; + } + } + else if (this.attackCounter > 0) { + this.attackCounter -= 1; + } + } + + @Override + public float getAttackStrength(Entity target) { + + if(target instanceof EntityLivingBase) { + return ((EntityLivingBase) target).getHealth() * 0.75F; + } + + return 100; + } + + @Override + public IChatComponent func_145748_c_() { + return super.func_145748_c_(); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("AggroCD", this.aggroCooldown); + par1NBTTagCompound.setInteger("CenterX", this.spawnPoint.posX); + par1NBTTagCompound.setInteger("CenterY", this.spawnPoint.posY); + par1NBTTagCompound.setInteger("CenterZ", this.spawnPoint.posZ); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.aggroCooldown = par1NBTTagCompound.getInteger("AggroCD"); + this.spawnPoint.set(par1NBTTagCompound.getInteger("CenterX"), par1NBTTagCompound.getInteger("CenterY"), par1NBTTagCompound.getInteger("CenterZ")); + } + +} diff --git a/src/main/java/com/hbm/entity/mob/botprime/EntityBurrowingNT.java b/src/main/java/com/hbm/entity/mob/botprime/EntityBurrowingNT.java new file mode 100644 index 000000000..9215d6088 --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/EntityBurrowingNT.java @@ -0,0 +1,52 @@ +package com.hbm.entity.mob.botprime; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.world.World; + +public abstract class EntityBurrowingNT extends EntityCreature { + + protected float dragInAir; + protected float dragInGround; + + public EntityBurrowingNT(World world) { + super(world); + } + + protected void fall(float dist) { } + + public float getEyeHeight() { + return this.height * 0.5F; + } + + public boolean getIsHead() { + return false; + } + + protected void updateFallState(double distFallen, boolean onGround) { } + + public void moveEntityWithHeading(float strafe, float forward) { + + float drag = this.dragInGround; + if ((!isEntityInsideOpaqueBlock()) && (!isInWater()) && (!handleLavaMovement())) + { + drag = this.dragInAir; + } + else + { + //TODO: sounds when tunneling + } + if (!getIsHead()) { + drag *= 0.9F; + } + moveFlying(strafe, forward, 0.02F); + + moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= drag; + this.motionY *= drag; + this.motionZ *= drag; + } + + public boolean isOnLadder() { + return false; + } +} diff --git a/src/main/java/com/hbm/entity/mob/botprime/EntityWormBaseNT.java b/src/main/java/com/hbm/entity/mob/botprime/EntityWormBaseNT.java new file mode 100644 index 000000000..31ac8fadf --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/EntityWormBaseNT.java @@ -0,0 +1,177 @@ +package com.hbm.entity.mob.botprime; + +import java.util.List; + +import com.hbm.entity.mob.sodtekhnologiyah.EntityBurrowing; + +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public abstract class EntityWormBaseNT extends EntityBurrowing { + + public int aggroCooldown = 0; + public int courseChangeCooldown = 0; + public double waypointX; + public double waypointY; + public double waypointZ; + protected Entity targetedEntity = null; + protected boolean canFly = false; + protected int dmgCooldown = 0; + protected boolean wasNearGround; + protected ChunkCoordinates spawnPoint = new ChunkCoordinates(); + protected double attackRange; + protected double maxSpeed; + protected double fallSpeed; + protected double rangeForParts; + protected EntityLivingBase followed; + protected int surfaceY; + private int headID; + private int partNum; + protected boolean didCheck; + protected double bodySpeed; + protected double maxBodySpeed; + protected double segmentDistance; + protected double knockbackDivider; + + public static final IEntitySelector wormSelector = new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity target) { + return target instanceof EntityWormBaseNT; + } + }; + + public EntityWormBaseNT(World world) { + super(world); + this.setSize(1.0F, 1.0F); + this.surfaceY = 60; + this.renderDistanceWeight = 5.0D; + } + + public int getPartNumber() { + return this.partNum; + } + + public void setPartNumber(int num) { + this.partNum = num; + } + + public int getHeadID() { + return this.headID; + } + + public void setHeadID(int id) { + this.headID = id; + } + + @Override + public boolean attackEntityFrom(DamageSource source, float amount) { + + if(this.isEntityInvulnerable() || source == DamageSource.drown || source == DamageSource.inWall || ((source.getEntity() instanceof EntityWormBaseNT) && ((EntityWormBaseNT) source.getEntity()).getHeadID() == this.getHeadID())) { + return false; + } else { + this.setBeenAttacked(); + return super.attackEntityFrom(source, amount); + } + } + + //TODO: test this with onUpdate instead + protected void updateEntityActionState() { + + if((!this.worldObj.isRemote) && (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)) { + setDead(); + } + if((this.targetedEntity != null) && (this.targetedEntity.isDead)) { + this.targetedEntity = null; + } + /*if((getIsHead()) && (this.targetedEntity != null) && ((this.targetedEntity instanceof EntityPlayer))) { + this.entityAge = 0; + }*/ + if(this.posY < -10.0D) { + setPositionAndUpdate(this.posX, 128.0D, this.posZ); + this.motionY = 0.0D; + } else if(this.posY < 3.0D) { + this.motionY = 0.3D; + } + + if(this.ticksExisted % 10 == 0) { + attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.5D, 0.5D, 0.5D))); + } + } + + protected void attackEntitiesInList(List targets) { + + for(Entity target : targets) { + if(((target instanceof EntityLivingBase)) && (canAttackClass(target.getClass())) && ((!(target instanceof EntityWormBaseNT)) || (((EntityWormBaseNT) target).getHeadID() != this.getHeadID()))) { + attackEntityAsMob(target); + } + } + } + + @Override + public boolean canAttackClass(Class clazz) { + return true; + } + + @Override + public boolean attackEntityAsMob(Entity target) { + + boolean var2 = target.attackEntityFrom(DamageSource.causeMobDamage(this), getAttackStrength(target)); + + if(var2) { + this.entityAge = 0; + double tx = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D; + double tz = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D; + double ty = (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D; + double deltaX = target.posX - tx; + double deltaZ = target.posZ - tz; + double deltaY = target.posY - ty; + double knockback = this.knockbackDivider * (deltaX * deltaX + deltaZ * deltaZ + deltaY * deltaY + 0.1D); + target.addVelocity(deltaX / knockback, deltaY / knockback, deltaZ / knockback); + } + + return var2; + } + + public abstract float getAttackStrength(Entity paramsa); + + @Override + public void addVelocity(double x, double y, double z) { + } + + @Override + public void faceEntity(Entity entity, float yaw, float pitch) { + } + + protected boolean isCourseTraversable() { + return (this.canFly) || (isEntityInsideOpaqueBlock()); + } + + @Override + protected float getSoundVolume() { + return 5.0F; + } + + @Override + public void setDead() { + playSound(getDeathSound(), getSoundVolume(), getSoundPitch()); + super.setDead(); + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setInteger("wormID", this.getHeadID()); + } + + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + setHeadID(nbt.getInteger("wormID")); + } + +} diff --git a/src/main/java/com/hbm/entity/mob/botprime/WormMovementBodyNT.java b/src/main/java/com/hbm/entity/mob/botprime/WormMovementBodyNT.java new file mode 100644 index 000000000..763a4b4ef --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/WormMovementBodyNT.java @@ -0,0 +1,74 @@ +package com.hbm.entity.mob.botprime; + +import java.util.List; + +import com.hbm.entity.mob.sodtekhnologiyah.EntityWormBase; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.MathHelper; + +public class WormMovementBodyNT { + private EntityWormBaseNT user; + + public WormMovementBodyNT(EntityWormBaseNT user) { + this.user = user; + } + + protected void updateMovement() { + + double targetingRange = 128.0D; + + if((this.user.targetedEntity != null) && (this.user.targetedEntity.getDistanceSqToEntity(this.user) < targetingRange * targetingRange)) { + this.user.waypointX = this.user.targetedEntity.posX; + this.user.waypointY = this.user.targetedEntity.posY; + this.user.waypointZ = this.user.targetedEntity.posZ; + } + + if(((this.user.ticksExisted % 60 == 0) || (this.user.ticksExisted == 1)) && ((this.user.targetedEntity == null) || (this.user.followed == null))) { + findEntityToFollow(this.user.worldObj.selectEntitiesWithinAABB(EntityLiving.class, this.user.boundingBox.expand(this.user.rangeForParts, this.user.rangeForParts, this.user.rangeForParts), EntityWormBase.wormSelector)); + } + + double deltaX = this.user.waypointX - this.user.posX; + double deltaY = this.user.waypointY - this.user.posY; + double deltaZ = this.user.waypointZ - this.user.posZ; + double deltaDist = MathHelper.sqrt_double(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + + if(this.user.targetedEntity != null) { + this.user.faceEntity(this.user.targetedEntity, 180.0F, 180.0F); + } + + this.user.bodySpeed = Math.max(0.0D, Math.min(deltaDist - this.user.segmentDistance, this.user.maxBodySpeed)); + + if(deltaDist < this.user.segmentDistance * 0.895D) { + this.user.motionX *= 0.8D; + this.user.motionY *= 0.8D; + this.user.motionZ *= 0.8D; + } else { + this.user.motionX = (deltaX / deltaDist * this.user.bodySpeed); + this.user.motionY = (deltaY / deltaDist * this.user.bodySpeed); + this.user.motionZ = (deltaZ / deltaDist * this.user.bodySpeed); + } + } + + protected void findEntityToFollow(List segments) { + + for(EntityWormBaseNT segment : segments) { + + if(segment.getHeadID() == this.user.getHeadID()) { + + if(segment.getIsHead()) { + if(this.user.getPartNumber() == 0) { + this.user.targetedEntity = ((Entity) segment); + } + this.user.followed = ((EntityLivingBase) segment); + + } else if(segment.getPartNumber() == this.user.getPartNumber() - 1) { + this.user.targetedEntity = ((Entity) segment); + } + } + } + this.user.didCheck = true; + } +} diff --git a/src/main/java/com/hbm/entity/mob/botprime/WormMovementHeadNT.java b/src/main/java/com/hbm/entity/mob/botprime/WormMovementHeadNT.java new file mode 100644 index 000000000..678c7faf4 --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/botprime/WormMovementHeadNT.java @@ -0,0 +1,92 @@ +package com.hbm.entity.mob.botprime; + +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.util.MathHelper; + +public class WormMovementHeadNT { + + private EntityWormBaseNT user; + + public WormMovementHeadNT(EntityWormBaseNT user) { + this.user = user; + } + + protected void updateMovement() { + + double var1 = this.user.waypointX - this.user.posX; + double var3 = this.user.waypointY - this.user.posY; + double var5 = this.user.waypointZ - this.user.posZ; + double var7 = var1 * var1 + var3 * var3 + var5 * var5; + + if(this.user.courseChangeCooldown-- <= 0) { + + this.user.courseChangeCooldown += this.user.getRNG().nextInt(5) + 2; + var7 = MathHelper.sqrt_double(var7); + + if(this.user.motionX * this.user.motionX + this.user.motionY * this.user.motionY + this.user.motionZ * this.user.motionZ < this.user.maxSpeed) { + + if(!this.user.isCourseTraversable()) { + var7 *= 8.0D; + } + + double moverSpeed = this.user.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue(); + this.user.motionX += var1 / var7 * moverSpeed; + this.user.motionY += var3 / var7 * moverSpeed; + this.user.motionZ += var5 / var7 * moverSpeed; + } + } + + if(!this.user.isCourseTraversable()) { + this.user.motionY -= this.user.fallSpeed; + } + + if(this.user.dmgCooldown > 0) { + this.user.dmgCooldown -= 1; + } + + this.user.aggroCooldown -= 1; + + if(this.user.getAttackTarget() != null) { + + if(this.user.aggroCooldown <= 0) { + this.user.targetedEntity = this.user.getAttackTarget(); + this.user.aggroCooldown = 20; + } + + } else if(this.user.targetedEntity == null) { + this.user.waypointX = (this.user.spawnPoint.posX - 30 + this.user.getRNG().nextInt(60)); + this.user.waypointY = (this.user.spawnPoint.posY - 10 + this.user.getRNG().nextInt(20)); + this.user.waypointZ = (this.user.spawnPoint.posZ - 30 + this.user.getRNG().nextInt(60)); + } + + this.user.rotationYaw = (-(float) Math.atan2(this.user.motionX, this.user.motionZ) * 180.0F / 3.1415927F); + this.user.rotationPitch = ((float) -(Math.atan2(this.user.motionY, + MathHelper.sqrt_double(this.user.motionX * this.user.motionX + this.user.motionZ * this.user.motionZ)) + * 180.0D / 3.141592653589793D)); + + if((this.user.targetedEntity != null) && (this.user.targetedEntity .getDistanceSqToEntity(this.user) < this.user.attackRange * this.user.attackRange)) { + + if((this.user.wasNearGround) || (this.user.canFly)) { + + this.user.waypointX = this.user.targetedEntity.posX; + this.user.waypointY = this.user.targetedEntity.posY; + this.user.waypointZ = this.user.targetedEntity.posZ; + + if((this.user.getRNG().nextInt(80) == 0) && (this.user.posY > this.user.surfaceY) + && (!this.user.isCourseTraversable())) { + this.user.wasNearGround = false; + } + + } else { + + this.user.waypointX = this.user.targetedEntity.posX; + this.user.waypointY = 10.0D; + this.user.waypointZ = this.user.targetedEntity.posZ; + + if(this.user.posY < 15.0D) { + this.user.wasNearGround = true; + } + } + } + } +} diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java index 5324e8297..856753c5d 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java @@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.IChatComponent; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityBallsOTronHead extends EntityBallsOTronBase implements IBossDisplayData { diff --git a/src/main/java/com/hbm/items/tool/ItemWandD.java b/src/main/java/com/hbm/items/tool/ItemWandD.java index c788f8f9f..da1acf00c 100644 --- a/src/main/java/com/hbm/items/tool/ItemWandD.java +++ b/src/main/java/com/hbm/items/tool/ItemWandD.java @@ -3,7 +3,7 @@ package com.hbm.items.tool; import java.util.List; import com.hbm.lib.Library; -import com.hbm.world.dungeon.Ruin001; +import com.hbm.world.generator.CellularDungeonFactory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -27,9 +27,9 @@ public class ItemWandD extends Item { int z = pos.blockZ; int y = world.getHeightValue(x, z); - new Ruin001().generate_r0(world, world.rand, x, y - 8, z); + //new Ruin001().generate_r0(world, world.rand, x, y - 8, z); - //CellularDungeonFactory.test.generate(world, x, y, z, world.rand); + CellularDungeonFactory.jungle.generate(world, x, y, z, world.rand); } return stack; diff --git a/src/main/java/com/hbm/lib/HbmWorldGen.java b/src/main/java/com/hbm/lib/HbmWorldGen.java index 3a3a21c12..517e8bc1a 100644 --- a/src/main/java/com/hbm/lib/HbmWorldGen.java +++ b/src/main/java/com/hbm/lib/HbmWorldGen.java @@ -547,7 +547,7 @@ public class HbmWorldGen implements IWorldGenerator { int x = i + rand.nextInt(16); int z = j + rand.nextInt(16); - CellularDungeonFactory.test.generate(world, x, 10, z, rand); + CellularDungeonFactory.meteor.generate(world, x, 10, z, rand); if(MainRegistry.enableDebugMode) MainRegistry.logger.info("[Debug] Successfully spawned meteor dungeon at " + x + " 10 " + z); diff --git a/src/main/java/com/hbm/world/generator/CellularDungeon.java b/src/main/java/com/hbm/world/generator/CellularDungeon.java index db1cd9cbe..fa57e5de4 100644 --- a/src/main/java/com/hbm/world/generator/CellularDungeon.java +++ b/src/main/java/com/hbm/world/generator/CellularDungeon.java @@ -33,23 +33,26 @@ public class CellularDungeon { //the rooms that the dungeon can use public List rooms = new ArrayList(); int tries; + int branches; - public CellularDungeon(int width, int height, int dimX, int dimZ, int tries) { + public CellularDungeon(int width, int height, int dimX, int dimZ, int tries, int branches) { this.dimX = dimX; this.dimZ = dimZ; this.width = width; this.height = height; this.tries = tries; + this.branches = branches; } - public CellularDungeon(int width, int height, int dimX, int dimZ, int tries, Block floor, Block ceiling, Block wall) { + public CellularDungeon(int width, int height, int dimX, int dimZ, int tries, int branches, Block floor, Block ceiling, Block wall) { this.dimX = dimX; this.dimZ = dimZ; this.width = width; this.height = height; this.tries = tries; + this.branches = branches; this.floor.add(floor); this.ceiling.add(ceiling); this.wall.add(wall); @@ -121,7 +124,7 @@ public class CellularDungeon { order.add(new int[] { x, z }); } - for(int i = 0; i < 3; i++) { + for(int i = 0; i < branches; i++) { ForgeDirection dir = getRandomDir(rand); addRoom(x + dir.offsetX, z + dir.offsetZ, rand, dir.getOpposite(), DungeonToolbox.getRandom(rooms, rand)); } diff --git a/src/main/java/com/hbm/world/generator/CellularDungeonFactory.java b/src/main/java/com/hbm/world/generator/CellularDungeonFactory.java index 0cfab5f20..522ce5d8f 100644 --- a/src/main/java/com/hbm/world/generator/CellularDungeonFactory.java +++ b/src/main/java/com/hbm/world/generator/CellularDungeonFactory.java @@ -5,19 +5,23 @@ import com.hbm.world.generator.room.*; import net.minecraftforge.common.util.ForgeDirection; public class CellularDungeonFactory { - - public static CellularDungeon test; + + public static CellularDungeon meteor; + public static CellularDungeon jungle; public static void init() { - test = new TestDungeon(11, 7, 11, 11, 150); - test.rooms.add(new TestDungeonRoom1(test)); - test.rooms.add(new TestDungeonRoom2(test)); - test.rooms.add(new TestDungeonRoom3(test)); - test.rooms.add(new TestDungeonRoom4(test, new TestDungeonRoom5(test), ForgeDirection.NORTH)); - test.rooms.add(new TestDungeonRoom6(test)); - test.rooms.add(new TestDungeonRoom7(test)); - test.rooms.add(new TestDungeonRoom8(test)); + meteor = new TestDungeon(11, 7, 11, 11, 150, 3); + meteor.rooms.add(new TestDungeonRoom1(meteor)); + meteor.rooms.add(new TestDungeonRoom2(meteor)); + meteor.rooms.add(new TestDungeonRoom3(meteor)); + meteor.rooms.add(new TestDungeonRoom4(meteor, new TestDungeonRoom5(meteor), ForgeDirection.NORTH)); + meteor.rooms.add(new TestDungeonRoom6(meteor)); + meteor.rooms.add(new TestDungeonRoom7(meteor)); + meteor.rooms.add(new TestDungeonRoom8(meteor)); + + jungle = new JungleDungeon(5, 5, 21, 21, 500, 5); + jungle.rooms.add(new JungleDungeonRoom(jungle)); } } diff --git a/src/main/java/com/hbm/world/generator/JungleDungeon.java b/src/main/java/com/hbm/world/generator/JungleDungeon.java new file mode 100644 index 000000000..8e58b230d --- /dev/null +++ b/src/main/java/com/hbm/world/generator/JungleDungeon.java @@ -0,0 +1,18 @@ +package com.hbm.world.generator; + +import com.hbm.blocks.ModBlocks; + +public class JungleDungeon extends CellularDungeon { + + public JungleDungeon(int width, int height, int dimX, int dimZ, int tries, int branches) { + super(width, height, dimX, dimZ, tries, branches); + + this.floor.add(ModBlocks.brick_jungle); + this.floor.add(ModBlocks.brick_jungle_cracked); + this.wall.add(ModBlocks.brick_jungle); + this.wall.add(ModBlocks.brick_jungle_cracked); + this.ceiling.add(ModBlocks.brick_jungle); + this.ceiling.add(ModBlocks.brick_jungle_cracked); + } + +} diff --git a/src/main/java/com/hbm/world/generator/TestDungeon.java b/src/main/java/com/hbm/world/generator/TestDungeon.java index 48eee2ae0..7a14a239a 100644 --- a/src/main/java/com/hbm/world/generator/TestDungeon.java +++ b/src/main/java/com/hbm/world/generator/TestDungeon.java @@ -4,8 +4,8 @@ import com.hbm.blocks.ModBlocks; public class TestDungeon extends CellularDungeon { - public TestDungeon(int width, int height, int dimX, int dimZ, int tries) { - super(width, height, dimX, dimZ, tries); + public TestDungeon(int width, int height, int dimX, int dimZ, int tries, int branches) { + super(width, height, dimX, dimZ, tries, branches); this.floor.add(ModBlocks.meteor_polished); this.wall.add(ModBlocks.meteor_brick); diff --git a/src/main/java/com/hbm/world/generator/room/JungleDungeonRoom.java b/src/main/java/com/hbm/world/generator/room/JungleDungeonRoom.java new file mode 100644 index 000000000..62a4c6d62 --- /dev/null +++ b/src/main/java/com/hbm/world/generator/room/JungleDungeonRoom.java @@ -0,0 +1,47 @@ +package com.hbm.world.generator.room; + +import com.hbm.world.generator.CellularDungeon; +import com.hbm.world.generator.CellularDungeonRoom; +import com.hbm.world.generator.DungeonToolbox; + +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class JungleDungeonRoom extends CellularDungeonRoom { + + public JungleDungeonRoom(CellularDungeon parent) { + super(parent); + } + + public void generateWall(World world, int x, int y, int z, ForgeDirection wall, boolean door) { + + if(wall == ForgeDirection.NORTH) { + DungeonToolbox.generateBox(world, x, y + 1, z, parent.width, parent.height - 2, 1, parent.wall); + + if(door) + DungeonToolbox.generateBox(world, x + parent.width / 2 - 1, y + 1, z, 3, 3, 1, Blocks.air); + } + + if(wall == ForgeDirection.SOUTH) { + DungeonToolbox.generateBox(world, x, y + 1, z + parent.width - 1, parent.width, parent.height - 2, 1, parent.wall); + + if(door) + DungeonToolbox.generateBox(world, x + parent.width / 2 - 1, y + 1, z + parent.width - 1, 3, 3, 1, Blocks.air); + } + + if(wall == ForgeDirection.WEST) { + DungeonToolbox.generateBox(world, x, y + 1, z, 1, parent.height - 2, parent.width, parent.wall); + + if(door) + DungeonToolbox.generateBox(world, x, y + 1, z + parent.width / 2 - 1, 1, 3, 3, Blocks.air); + } + + if(wall == ForgeDirection.EAST) { + DungeonToolbox.generateBox(world, x + parent.width - 1, y + 1, z, 1, parent.height - 2, parent.width, parent.wall); + + if(door) + DungeonToolbox.generateBox(world, x + parent.width - 1, y + 1, z + parent.width / 2 - 1, 1, 3, 3, Blocks.air); + } + } +}