mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-22 14:00:47 +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.config.MobConfig;
|
||||||
import com.hbm.entity.mob.EntityGlyphid;
|
import com.hbm.entity.mob.EntityGlyphid;
|
||||||
|
import static com.hbm.entity.mob.EntityGlyphid.*;
|
||||||
import com.hbm.entity.mob.EntityGlyphidNuclear;
|
import com.hbm.entity.mob.EntityGlyphidNuclear;
|
||||||
import com.hbm.entity.mob.EntityGlyphidScout;
|
import com.hbm.entity.mob.EntityGlyphidScout;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
@ -9,30 +10,32 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class EntityWaypoint extends Entity {
|
public class EntityWaypoint extends Entity {
|
||||||
public EntityWaypoint(World world) {
|
public EntityWaypoint(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
this.isImmuneToFire = true;
|
this.isImmuneToFire = true;
|
||||||
this.noClip = true;
|
this.noClip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInit() {
|
protected void entityInit() {
|
||||||
this.dataWatcher.addObject(10, 0);
|
this.dataWatcher.addObject(10, 0);
|
||||||
// this.dataWatcher.addObject(11, 0);
|
// this.dataWatcher.addObject(11, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int maxAge = 2400;
|
public int maxAge = 2400;
|
||||||
public int radius = 3;
|
public int radius = 3;
|
||||||
public boolean highPriority = false;
|
public boolean highPriority = false;
|
||||||
protected EntityWaypoint additional;
|
protected EntityWaypoint additional;
|
||||||
|
|
||||||
public void setHighPriority() {
|
public void setHighPriority() {
|
||||||
highPriority = true;
|
highPriority = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWaypointType() {
|
public int getWaypointType() {
|
||||||
return this.dataWatcher.getWatchableObjectInt(10);
|
return this.dataWatcher.getWatchableObjectInt(10);
|
||||||
}
|
}
|
||||||
@ -44,33 +47,28 @@ public class EntityWaypoint extends Entity {
|
|||||||
public void setWaypointType(int waypointType) {
|
public void setWaypointType(int waypointType) {
|
||||||
this.dataWatcher.updateObject(10, waypointType);
|
this.dataWatcher.updateObject(10, waypointType);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasSpawned = false;
|
boolean hasSpawned = false;
|
||||||
|
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
switch(getWaypointType()) {
|
switch(getWaypointType()) {
|
||||||
|
|
||||||
case 1: return 0x5FA6E8;
|
case TASK_RETREAT_FOR_REINFORCEMENTS: return 0x5FA6E8;
|
||||||
|
case TASK_BUILD_HIVE:
|
||||||
case 2:
|
case TASK_INITIATE_RETREAT: return 0x127766;
|
||||||
case 3:
|
|
||||||
return 0x127766;
|
|
||||||
|
|
||||||
default: return 0x566573;
|
default: return 0x566573;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAlignedBB bb;
|
AxisAlignedBB bb;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityUpdate() {
|
public void onEntityUpdate() {
|
||||||
if(ticksExisted >= maxAge) {
|
if(ticksExisted >= maxAge) {
|
||||||
this.setDead();
|
this.setDead();
|
||||||
}
|
}
|
||||||
|
|
||||||
bb = AxisAlignedBB.getBoundingBox(
|
bb = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ).expand(radius, radius, radius);
|
||||||
this.posX - radius,
|
|
||||||
this.posY - radius,
|
|
||||||
this.posZ - radius,
|
|
||||||
this.posX + radius,
|
|
||||||
this.posY + radius,
|
|
||||||
this.posZ + radius);
|
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
@ -88,14 +86,12 @@ public class EntityWaypoint extends Entity {
|
|||||||
hasSpawned = true;
|
hasSpawned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean exceptions = bug.getWaypoint() != this
|
boolean exceptions = bug.getWaypoint() != this || e instanceof EntityGlyphidScout || e instanceof EntityGlyphidNuclear;
|
||||||
|| e instanceof EntityGlyphidScout
|
|
||||||
|| e instanceof EntityGlyphidNuclear;
|
|
||||||
|
|
||||||
if(!exceptions)
|
if(!exceptions)
|
||||||
bug.setCurrentTask(getWaypointType(), additional);
|
bug.setCurrentTask(getWaypointType(), additional);
|
||||||
|
|
||||||
if (getWaypointType() == 2) {
|
if(getWaypointType() == TASK_BUILD_HIVE) {
|
||||||
if(e instanceof EntityGlyphidScout)
|
if(e instanceof EntityGlyphidScout)
|
||||||
setDead();
|
setDead();
|
||||||
} else {
|
} else {
|
||||||
@ -126,7 +122,6 @@ public class EntityWaypoint extends Entity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||||
this.setWaypointType(nbt.getInteger("type"));
|
this.setWaypointType(nbt.getInteger("type"));
|
||||||
|
|||||||
@ -73,10 +73,12 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
public static final int TASK_FOLLOW = 4;
|
public static final int TASK_FOLLOW = 4;
|
||||||
/** Causes nuclear glyphids to immediately self-destruct, also signaling nearby scouts to retreat */
|
/** Causes nuclear glyphids to immediately self-destruct, also signaling nearby scouts to retreat */
|
||||||
public static final int TASK_TERRAFORM = 5;
|
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;
|
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) {
|
public EntityGlyphid(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -125,7 +127,7 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
if(getCurrentTask() == TASK_FOLLOW){
|
if(getCurrentTask() == TASK_FOLLOW){
|
||||||
|
|
||||||
//incase the waypoint somehow doesn't exist and it got this task anyway
|
//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);
|
setCurrentTask(TASK_IDLE, null);
|
||||||
}
|
}
|
||||||
//the task cannot be 6 outside of rampant, so this is a non issue p much
|
//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) {
|
if(MobConfig.rampantDig) {
|
||||||
|
|
||||||
MovingObjectPosition obstacle = findWaypointObstruction();
|
MovingObjectPosition obstacle = findWaypointObstruction();
|
||||||
@ -292,8 +294,6 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(source.isFireDamage()) {
|
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;
|
amount *= 0.7F;
|
||||||
} else if(source.getDamageType().equals("player")) {
|
} else if(source.getDamageType().equals("player")) {
|
||||||
amount *= 1.5F;
|
amount *= 1.5F;
|
||||||
@ -423,8 +423,9 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
* @param waypoint The waypoint for the task, can be null
|
* @param waypoint The waypoint for the task, can be null
|
||||||
*/
|
*/
|
||||||
public void setCurrentTask(int task, @Nullable EntityWaypoint waypoint){
|
public void setCurrentTask(int task, @Nullable EntityWaypoint waypoint){
|
||||||
currentTask = task;
|
this.currentTask = task;
|
||||||
taskWaypoint = waypoint;
|
this.taskWaypoint = waypoint;
|
||||||
|
this.hasWaypoint = waypoint != null;
|
||||||
if (taskWaypoint != null) {
|
if (taskWaypoint != null) {
|
||||||
|
|
||||||
taskX = (int) taskWaypoint.posX;
|
taskX = (int) taskWaypoint.posX;
|
||||||
@ -448,16 +449,13 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
|
|
||||||
switch(task){
|
switch(task){
|
||||||
|
|
||||||
//call for reinforcements
|
case TASK_RETREAT_FOR_REINFORCEMENTS:
|
||||||
case TASK_RETREAT_FOR_REINFORCEMENTS: if(taskWaypoint != null){
|
if(taskWaypoint != null) {
|
||||||
communicate(TASK_FOLLOW, taskWaypoint);
|
communicate(TASK_FOLLOW, taskWaypoint);
|
||||||
setCurrentTask(TASK_FOLLOW, taskWaypoint);
|
setCurrentTask(TASK_FOLLOW, taskWaypoint);
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
//expand the hive, used by the scout
|
|
||||||
//case 2: expandHive(null);
|
|
||||||
|
|
||||||
//retreat
|
|
||||||
case TASK_INITIATE_RETREAT:
|
case TASK_INITIATE_RETREAT:
|
||||||
|
|
||||||
if(!worldObj.isRemote && taskWaypoint == null) {
|
if(!worldObj.isRemote && taskWaypoint == null) {
|
||||||
@ -483,15 +481,12 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
//dig
|
|
||||||
case TASK_DIG:
|
case TASK_DIG:
|
||||||
shouldDig = true;
|
shouldDig = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,14 +495,7 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
/** Copies tasks and waypoint to nearby glyphids. Does not work on glyphid scouts */
|
/** Copies tasks and waypoint to nearby glyphids. Does not work on glyphid scouts */
|
||||||
public void communicate(int task, @Nullable EntityWaypoint waypoint) {
|
public void communicate(int task, @Nullable EntityWaypoint waypoint) {
|
||||||
int radius = waypoint != null ? waypoint.radius : 4;
|
int radius = waypoint != null ? waypoint.radius : 4;
|
||||||
|
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ).expand(radius, radius, radius);
|
||||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(
|
|
||||||
this.posX - radius,
|
|
||||||
this.posY - radius,
|
|
||||||
this.posZ - radius,
|
|
||||||
this.posX + radius,
|
|
||||||
this.posY + radius,
|
|
||||||
this.posZ + radius);
|
|
||||||
|
|
||||||
List<Entity> bugs = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
List<Entity> bugs = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
||||||
for(Entity e : bugs) {
|
for(Entity e : bugs) {
|
||||||
@ -580,6 +568,7 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
nbt.setInteger("homeY", homeY);
|
nbt.setInteger("homeY", homeY);
|
||||||
nbt.setInteger("homeZ", homeZ);
|
nbt.setInteger("homeZ", homeZ);
|
||||||
|
|
||||||
|
nbt.setBoolean("hasWaypoint", hasWaypoint);
|
||||||
nbt.setInteger("taskX", taskX);
|
nbt.setInteger("taskX", taskX);
|
||||||
nbt.setInteger("taskY", taskY);
|
nbt.setInteger("taskY", taskY);
|
||||||
nbt.setInteger("taskZ", taskZ);
|
nbt.setInteger("taskZ", taskZ);
|
||||||
@ -597,6 +586,7 @@ public class EntityGlyphid extends EntityMob {
|
|||||||
this.homeY = nbt.getInteger("homeY");
|
this.homeY = nbt.getInteger("homeY");
|
||||||
this.homeZ = nbt.getInteger("homeZ");
|
this.homeZ = nbt.getInteger("homeZ");
|
||||||
|
|
||||||
|
this.hasWaypoint = nbt.getBoolean("hasWaypoint");
|
||||||
this.taskX = nbt.getInteger("taskX");
|
this.taskX = nbt.getInteger("taskX");
|
||||||
this.taskY = nbt.getInteger("taskY");
|
this.taskY = nbt.getInteger("taskY");
|
||||||
this.taskZ = nbt.getInteger("taskZ");
|
this.taskZ = nbt.getInteger("taskZ");
|
||||||
|
|||||||
@ -135,13 +135,7 @@ public class EntityGlyphidNuclear extends EntityGlyphid {
|
|||||||
|
|
||||||
if(deathTicks == 90){
|
if(deathTicks == 90){
|
||||||
int radius = 8;
|
int radius = 8;
|
||||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(
|
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ).expand(radius, radius, radius);
|
||||||
this.posX - radius,
|
|
||||||
this.posY - radius,
|
|
||||||
this.posZ - radius,
|
|
||||||
this.posX + radius,
|
|
||||||
this.posY + radius,
|
|
||||||
this.posZ + radius);
|
|
||||||
|
|
||||||
List<Entity> bugs = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
List<Entity> bugs = worldObj.getEntitiesWithinAABBExcludingEntity(this, bb);
|
||||||
for (Entity e: bugs){
|
for (Entity e: bugs){
|
||||||
|
|||||||
@ -74,9 +74,7 @@ public class EntityGlyphidScout extends EntityGlyphid {
|
|||||||
|
|
||||||
if(MobConfig.rampantGlyphidGuidance && PollutionHandler.targetCoords != null){
|
if(MobConfig.rampantGlyphidGuidance && PollutionHandler.targetCoords != null){
|
||||||
if(!hasTarget) {
|
if(!hasTarget) {
|
||||||
Vec3 dirVec = playerBaseDirFinder(
|
Vec3 dirVec = playerBaseDirFinder(Vec3.createVectorHelper(posX, posY, posZ), getPlayerTargetDirection());
|
||||||
Vec3.createVectorHelper(posX, posY, posZ),
|
|
||||||
PollutionHandler.targetCoords);
|
|
||||||
|
|
||||||
EntityWaypoint target = new EntityWaypoint(worldObj);
|
EntityWaypoint target = new EntityWaypoint(worldObj);
|
||||||
target.setLocationAndAngles(dirVec.xCoord, dirVec.yCoord, dirVec.zCoord, 0, 0);
|
target.setLocationAndAngles(dirVec.xCoord, dirVec.yCoord, dirVec.zCoord, 0, 0);
|
||||||
@ -309,4 +307,8 @@ public class EntityGlyphidScout extends EntityGlyphid {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: replace that with some actual directions
|
||||||
|
protected Vec3 getPlayerTargetDirection() {
|
||||||
|
return PollutionHandler.targetCoords;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user