mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
now i know how megan feels
This commit is contained in:
parent
8a59eb9dbc
commit
31c55c7cfa
@ -2,6 +2,7 @@ package com.hbm.entity.logic;
|
||||
|
||||
import com.hbm.config.MobConfig;
|
||||
import com.hbm.entity.mob.EntityGlyphid;
|
||||
import static com.hbm.entity.mob.EntityGlyphid.*;
|
||||
import com.hbm.entity.mob.EntityGlyphidNuclear;
|
||||
import com.hbm.entity.mob.EntityGlyphidScout;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -9,131 +10,125 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class EntityWaypoint extends Entity {
|
||||
public EntityWaypoint(World world) {
|
||||
super(world);
|
||||
this.isImmuneToFire = true;
|
||||
this.noClip = true;
|
||||
}
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(10, 0);
|
||||
//this.dataWatcher.addObject(11, 0);
|
||||
public EntityWaypoint(World world) {
|
||||
super(world);
|
||||
this.isImmuneToFire = true;
|
||||
this.noClip = true;
|
||||
}
|
||||
|
||||
}
|
||||
public int maxAge = 2400;
|
||||
public int radius = 3;
|
||||
public boolean highPriority = false;
|
||||
protected EntityWaypoint additional;
|
||||
public void setHighPriority(){
|
||||
highPriority = true;
|
||||
}
|
||||
public int getWaypointType(){
|
||||
return this.dataWatcher.getWatchableObjectInt(10);
|
||||
}
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(10, 0);
|
||||
// this.dataWatcher.addObject(11, 0);
|
||||
|
||||
public void setAdditionalWaypoint(EntityWaypoint waypoint){
|
||||
additional = waypoint;
|
||||
}
|
||||
}
|
||||
|
||||
public void setWaypointType(int waypointType) {
|
||||
this.dataWatcher.updateObject(10, waypointType);
|
||||
}
|
||||
boolean hasSpawned = false;
|
||||
public int getColor(){
|
||||
switch(getWaypointType()){
|
||||
public int maxAge = 2400;
|
||||
public int radius = 3;
|
||||
public boolean highPriority = false;
|
||||
protected EntityWaypoint additional;
|
||||
|
||||
case 1: return 0x5FA6E8;
|
||||
public void setHighPriority() {
|
||||
highPriority = true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return 0x127766;
|
||||
public int getWaypointType() {
|
||||
return this.dataWatcher.getWatchableObjectInt(10);
|
||||
}
|
||||
|
||||
default: return 0x566573;
|
||||
}
|
||||
}
|
||||
AxisAlignedBB bb;
|
||||
@Override
|
||||
public void onEntityUpdate() {
|
||||
if (ticksExisted >= maxAge) {
|
||||
this.setDead();
|
||||
}
|
||||
public void setAdditionalWaypoint(EntityWaypoint waypoint) {
|
||||
additional = waypoint;
|
||||
}
|
||||
|
||||
bb = AxisAlignedBB.getBoundingBox(
|
||||
this.posX - radius,
|
||||
this.posY - radius,
|
||||
this.posZ - radius,
|
||||
this.posX + radius,
|
||||
this.posY + radius,
|
||||
this.posZ + radius);
|
||||
public void setWaypointType(int waypointType) {
|
||||
this.dataWatcher.updateObject(10, waypointType);
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
boolean hasSpawned = false;
|
||||
|
||||
if (ticksExisted % 40 == 0) {
|
||||
public int getColor() {
|
||||
switch(getWaypointType()) {
|
||||
|
||||
List<Entity> targets = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
||||
case TASK_RETREAT_FOR_REINFORCEMENTS: return 0x5FA6E8;
|
||||
case TASK_BUILD_HIVE:
|
||||
case TASK_INITIATE_RETREAT: return 0x127766;
|
||||
default: return 0x566573;
|
||||
}
|
||||
}
|
||||
|
||||
for (Entity e : targets) {
|
||||
if (e instanceof EntityGlyphid) {
|
||||
AxisAlignedBB bb;
|
||||
|
||||
EntityGlyphid bug = ((EntityGlyphid) e);
|
||||
@Override
|
||||
public void onEntityUpdate() {
|
||||
if(ticksExisted >= maxAge) {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
if (additional != null && !hasSpawned) {
|
||||
worldObj.spawnEntityInWorld(additional);
|
||||
hasSpawned = true;
|
||||
}
|
||||
bb = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ).expand(radius, radius, radius);
|
||||
|
||||
boolean exceptions = bug.getWaypoint() != this
|
||||
|| e instanceof EntityGlyphidScout
|
||||
|| e instanceof EntityGlyphidNuclear;
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(!exceptions)
|
||||
bug.setCurrentTask(getWaypointType(), additional);
|
||||
if(ticksExisted % 40 == 0) {
|
||||
|
||||
if (getWaypointType() == 2) {
|
||||
if (e instanceof EntityGlyphidScout)
|
||||
setDead();
|
||||
} else {
|
||||
setDead();
|
||||
}
|
||||
List<Entity> targets = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(MobConfig.waypointDebug) {
|
||||
for(Entity e : targets) {
|
||||
if(e instanceof EntityGlyphid) {
|
||||
|
||||
double x = bb.minX + (rand.nextDouble() - 0.5) * (bb.maxX - bb.minX);
|
||||
double y = bb.minY + rand.nextDouble() * (bb.maxY - bb.minY);
|
||||
double z = bb.minZ + (rand.nextDouble() - 0.5) * (bb.maxZ - bb.minZ);
|
||||
EntityGlyphid bug = ((EntityGlyphid) e);
|
||||
|
||||
NBTTagCompound fx = new NBTTagCompound();
|
||||
fx.setString("type", "tower");
|
||||
fx.setFloat("lift", 0.5F);
|
||||
fx.setFloat("base", 0.75F);
|
||||
fx.setFloat("max", 2F);
|
||||
fx.setInteger("life", 50 + worldObj.rand.nextInt(10));
|
||||
fx.setInteger("color", getColor());
|
||||
fx.setDouble("posX", x);
|
||||
fx.setDouble("posY", y);
|
||||
fx.setDouble("posZ", z);
|
||||
MainRegistry.proxy.effectNT(fx);
|
||||
}
|
||||
if(additional != null && !hasSpawned) {
|
||||
worldObj.spawnEntityInWorld(additional);
|
||||
hasSpawned = true;
|
||||
}
|
||||
|
||||
}
|
||||
boolean exceptions = bug.getWaypoint() != this || e instanceof EntityGlyphidScout || e instanceof EntityGlyphidNuclear;
|
||||
|
||||
if(!exceptions)
|
||||
bug.setCurrentTask(getWaypointType(), additional);
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
this.setWaypointType(nbt.getInteger("type"));
|
||||
}
|
||||
if(getWaypointType() == TASK_BUILD_HIVE) {
|
||||
if(e instanceof EntityGlyphidScout)
|
||||
setDead();
|
||||
} else {
|
||||
setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("type", getWaypointType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(MobConfig.waypointDebug) {
|
||||
|
||||
double x = bb.minX + (rand.nextDouble() - 0.5) * (bb.maxX - bb.minX);
|
||||
double y = bb.minY + rand.nextDouble() * (bb.maxY - bb.minY);
|
||||
double z = bb.minZ + (rand.nextDouble() - 0.5) * (bb.maxZ - bb.minZ);
|
||||
|
||||
NBTTagCompound fx = new NBTTagCompound();
|
||||
fx.setString("type", "tower");
|
||||
fx.setFloat("lift", 0.5F);
|
||||
fx.setFloat("base", 0.75F);
|
||||
fx.setFloat("max", 2F);
|
||||
fx.setInteger("life", 50 + worldObj.rand.nextInt(10));
|
||||
fx.setInteger("color", getColor());
|
||||
fx.setDouble("posX", x);
|
||||
fx.setDouble("posY", y);
|
||||
fx.setDouble("posZ", z);
|
||||
MainRegistry.proxy.effectNT(fx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
this.setWaypointType(nbt.getInteger("type"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("type", getWaypointType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class EntityGlyphid extends EntityMob {
|
||||
public int taskZ;
|
||||
|
||||
//used for digging, bigger glyphids have a longer reach
|
||||
public int blastSize = Math.min((int) (3 * (getScale()))/2, 5);
|
||||
public int blastSize = Math.min((int) (3 * (getScale())) / 2, 5);
|
||||
public int blastResToDig = Math.min((int) (50 * (getScale() * 2)), 150);
|
||||
public boolean shouldDig;
|
||||
|
||||
@ -73,10 +73,12 @@ public class EntityGlyphid extends EntityMob {
|
||||
public static final int TASK_FOLLOW = 4;
|
||||
/** Causes nuclear glyphids to immediately self-destruct, also signaling nearby scouts to retreat */
|
||||
public static final int TASK_TERRAFORM = 5;
|
||||
/** Id any task other than IDLE is interrupted by an obstacle, initiates digging behavior which is also communicated to nearby glyohids */
|
||||
/** If any task other than IDLE is interrupted by an obstacle, initiates digging behavior which is also communicated to nearby glyohids */
|
||||
public static final int TASK_DIG = 6;
|
||||
|
||||
EntityWaypoint taskWaypoint = null;
|
||||
protected boolean hasWaypoint = false;
|
||||
/** Yeah, fuck, whatever, anything goes now */
|
||||
protected EntityWaypoint taskWaypoint = null;
|
||||
|
||||
public EntityGlyphid(World world) {
|
||||
super(world);
|
||||
@ -125,7 +127,7 @@ public class EntityGlyphid extends EntityMob {
|
||||
if(getCurrentTask() == TASK_FOLLOW){
|
||||
|
||||
//incase the waypoint somehow doesn't exist and it got this task anyway
|
||||
if(isAtDestination() && taskX == TASK_IDLE) {
|
||||
if(isAtDestination() && !hasWaypoint) {
|
||||
setCurrentTask(TASK_IDLE, null);
|
||||
}
|
||||
//the task cannot be 6 outside of rampant, so this is a non issue p much
|
||||
@ -201,7 +203,7 @@ public class EntityGlyphid extends EntityMob {
|
||||
|
||||
}
|
||||
|
||||
if (taskX != TASK_IDLE) {
|
||||
if(hasWaypoint) {
|
||||
if(MobConfig.rampantDig) {
|
||||
|
||||
MovingObjectPosition obstacle = findWaypointObstruction();
|
||||
@ -292,8 +294,6 @@ public class EntityGlyphid extends EntityMob {
|
||||
}
|
||||
|
||||
if(source.isFireDamage()) {
|
||||
//you might be thinking, why would fire damage be nerfed?
|
||||
//thing is, it bypasses glyphid chitin, making it unbelievably powerful, so this was the most reasonable solution
|
||||
amount *= 0.7F;
|
||||
} else if(source.getDamageType().equals("player")) {
|
||||
amount *= 1.5F;
|
||||
@ -423,8 +423,9 @@ public class EntityGlyphid extends EntityMob {
|
||||
* @param waypoint The waypoint for the task, can be null
|
||||
*/
|
||||
public void setCurrentTask(int task, @Nullable EntityWaypoint waypoint){
|
||||
currentTask = task;
|
||||
taskWaypoint = waypoint;
|
||||
this.currentTask = task;
|
||||
this.taskWaypoint = waypoint;
|
||||
this.hasWaypoint = waypoint != null;
|
||||
if (taskWaypoint != null) {
|
||||
|
||||
taskX = (int) taskWaypoint.posX;
|
||||
@ -448,50 +449,44 @@ public class EntityGlyphid extends EntityMob {
|
||||
|
||||
switch(task){
|
||||
|
||||
//call for reinforcements
|
||||
case TASK_RETREAT_FOR_REINFORCEMENTS: if(taskWaypoint != null){
|
||||
case TASK_RETREAT_FOR_REINFORCEMENTS:
|
||||
if(taskWaypoint != null) {
|
||||
communicate(TASK_FOLLOW, taskWaypoint);
|
||||
setCurrentTask(TASK_FOLLOW, taskWaypoint);
|
||||
} break;
|
||||
|
||||
//expand the hive, used by the scout
|
||||
//case 2: expandHive(null);
|
||||
|
||||
//retreat
|
||||
case TASK_INITIATE_RETREAT:
|
||||
|
||||
if (!worldObj.isRemote && taskWaypoint == null) {
|
||||
|
||||
//Then, Come back later
|
||||
EntityWaypoint additional = new EntityWaypoint(worldObj);
|
||||
additional.setLocationAndAngles(posX, posY, posZ, 0 , 0);
|
||||
|
||||
//First, go home and get reinforcements
|
||||
EntityWaypoint home = new EntityWaypoint(worldObj);
|
||||
home.setWaypointType(TASK_RETREAT_FOR_REINFORCEMENTS);
|
||||
home.setAdditionalWaypoint(additional);
|
||||
home.setHighPriority();
|
||||
home.setLocationAndAngles(homeX, homeY, homeZ, 0, 0);
|
||||
worldObj.spawnEntityInWorld(home);
|
||||
|
||||
this.taskWaypoint = home;
|
||||
communicate(TASK_FOLLOW, home);
|
||||
setCurrentTask(TASK_FOLLOW, taskWaypoint);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
//the fourth task (case 4) is to just follow the waypoint path
|
||||
//fifth task is used only in the scout and big man johnson, for terraforming
|
||||
case TASK_INITIATE_RETREAT:
|
||||
|
||||
if(!worldObj.isRemote && taskWaypoint == null) {
|
||||
|
||||
// Then, Come back later
|
||||
EntityWaypoint additional = new EntityWaypoint(worldObj);
|
||||
additional.setLocationAndAngles(posX, posY, posZ, 0, 0);
|
||||
|
||||
// First, go home and get reinforcements
|
||||
EntityWaypoint home = new EntityWaypoint(worldObj);
|
||||
home.setWaypointType(TASK_RETREAT_FOR_REINFORCEMENTS);
|
||||
home.setAdditionalWaypoint(additional);
|
||||
home.setHighPriority();
|
||||
home.setLocationAndAngles(homeX, homeY, homeZ, 0, 0);
|
||||
worldObj.spawnEntityInWorld(home);
|
||||
|
||||
this.taskWaypoint = home;
|
||||
communicate(TASK_FOLLOW, home);
|
||||
setCurrentTask(TASK_FOLLOW, taskWaypoint);
|
||||
|
||||
//dig
|
||||
case TASK_DIG:
|
||||
shouldDig = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
break;
|
||||
|
||||
case TASK_DIG:
|
||||
shouldDig = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@ -500,19 +495,12 @@ public class EntityGlyphid extends EntityMob {
|
||||
/** Copies tasks and waypoint to nearby glyphids. Does not work on glyphid scouts */
|
||||
public void communicate(int task, @Nullable EntityWaypoint waypoint) {
|
||||
int radius = waypoint != null ? waypoint.radius : 4;
|
||||
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(
|
||||
this.posX - radius,
|
||||
this.posY - radius,
|
||||
this.posZ - radius,
|
||||
this.posX + radius,
|
||||
this.posY + radius,
|
||||
this.posZ + radius);
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ).expand(radius, radius, radius);
|
||||
|
||||
List<Entity> bugs = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
||||
for (Entity e: bugs){
|
||||
if(e instanceof EntityGlyphid && !(e instanceof EntityGlyphidScout)){
|
||||
if(((EntityGlyphid) e).getCurrentTask() != task){
|
||||
for(Entity e : bugs) {
|
||||
if(e instanceof EntityGlyphid && !(e instanceof EntityGlyphidScout)) {
|
||||
if(((EntityGlyphid) e).getCurrentTask() != task) {
|
||||
((EntityGlyphid) e).setCurrentTask(task, waypoint);
|
||||
}
|
||||
}
|
||||
@ -580,6 +568,7 @@ public class EntityGlyphid extends EntityMob {
|
||||
nbt.setInteger("homeY", homeY);
|
||||
nbt.setInteger("homeZ", homeZ);
|
||||
|
||||
nbt.setBoolean("hasWaypoint", hasWaypoint);
|
||||
nbt.setInteger("taskX", taskX);
|
||||
nbt.setInteger("taskY", taskY);
|
||||
nbt.setInteger("taskZ", taskZ);
|
||||
@ -597,6 +586,7 @@ public class EntityGlyphid extends EntityMob {
|
||||
this.homeY = nbt.getInteger("homeY");
|
||||
this.homeZ = nbt.getInteger("homeZ");
|
||||
|
||||
this.hasWaypoint = nbt.getBoolean("hasWaypoint");
|
||||
this.taskX = nbt.getInteger("taskX");
|
||||
this.taskY = nbt.getInteger("taskY");
|
||||
this.taskZ = nbt.getInteger("taskZ");
|
||||
|
||||
@ -135,13 +135,7 @@ public class EntityGlyphidNuclear extends EntityGlyphid {
|
||||
|
||||
if(deathTicks == 90){
|
||||
int radius = 8;
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(
|
||||
this.posX - radius,
|
||||
this.posY - radius,
|
||||
this.posZ - radius,
|
||||
this.posX + radius,
|
||||
this.posY + radius,
|
||||
this.posZ + radius);
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ).expand(radius, radius, radius);
|
||||
|
||||
List<Entity> bugs = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
||||
for (Entity e: bugs){
|
||||
|
||||
@ -74,9 +74,7 @@ public class EntityGlyphidScout extends EntityGlyphid {
|
||||
|
||||
if(MobConfig.rampantGlyphidGuidance && PollutionHandler.targetCoords != null){
|
||||
if(!hasTarget) {
|
||||
Vec3 dirVec = playerBaseDirFinder(
|
||||
Vec3.createVectorHelper(posX, posY, posZ),
|
||||
PollutionHandler.targetCoords);
|
||||
Vec3 dirVec = playerBaseDirFinder(Vec3.createVectorHelper(posX, posY, posZ), getPlayerTargetDirection());
|
||||
|
||||
EntityWaypoint target = new EntityWaypoint(worldObj);
|
||||
target.setLocationAndAngles(dirVec.xCoord, dirVec.yCoord, dirVec.zCoord, 0, 0);
|
||||
@ -157,7 +155,7 @@ public class EntityGlyphidScout extends EntityGlyphid {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Returns true if the position is far enough away from other hives. Also resets the task if unsuccessful. */
|
||||
public boolean canBuildHiveHere() {
|
||||
int length = useLargeHive ? 16 : 8;
|
||||
@ -308,5 +306,9 @@ public class EntityGlyphidScout extends EntityGlyphid {
|
||||
currentLocation.zCoord + dirVec.zCoord * 10
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//TODO: replace that with some actual directions
|
||||
protected Vec3 getPlayerTargetDirection() {
|
||||
return PollutionHandler.targetCoords;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user