mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 00:22:19 +00:00
Merge branch 'louis-pathing' into dev
This commit is contained in:
commit
d520c98578
11 files changed
+588
-309
No files matched your search
@@ -1,8 +1,7 @@
|
||||
package noppes.npcs.entity;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
@@ -48,13 +47,24 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
|
||||
public void moveFlyingWithHeading(float strafe, float forward)
|
||||
{
|
||||
if(!this.canFly() || this.hurtTime != 0) {
|
||||
super.moveEntityWithHeading(strafe, forward);
|
||||
if(!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) {
|
||||
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean aboveLimit = false;
|
||||
double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ);
|
||||
if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
||||
if (heightOffGround < 0) {
|
||||
Vec3 pos = Vec3.createVectorHelper(this.posX,this.posY,this.posZ);
|
||||
Vec3 posLimit = Vec3.createVectorHelper(this.posX,this.posY - this.ai.flyHeightLimit,this.posZ);
|
||||
MovingObjectPosition mob = this.worldObj.rayTraceBlocks(pos,posLimit,true);
|
||||
if (mob == null || mob.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) {
|
||||
aboveLimit = true;
|
||||
}
|
||||
} else if (heightOffGround > this.ai.flyHeightLimit) {
|
||||
aboveLimit = true;
|
||||
}
|
||||
if (aboveLimit && this.ai.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
||||
this.flyLimitAllow = false;
|
||||
if (!this.getNavigator().noPath() && this.motionY > 0) {
|
||||
this.motionY = 0;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.*;
|
||||
@@ -20,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -220,7 +222,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
|
||||
public int getMaxSafePointTries()
|
||||
{
|
||||
return 10;
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -415,16 +417,20 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBreathe() {
|
||||
return this.isInWater() && this.stats.drowningType == 2 || !this.isInWater() && this.stats.drowningType == 1 || this.stats.drowningType == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateAITasks()
|
||||
{
|
||||
if (this.isInWater() || this.stats.drowningType != 2) {
|
||||
this.getNavigator().onUpdateNavigation();
|
||||
this.getMoveHelper().onUpdateMoveHelper();
|
||||
try {
|
||||
super.updateAITasks();
|
||||
} catch (ConcurrentModificationException ignored){}
|
||||
} else {
|
||||
this.getNavigator().onUpdateNavigation();
|
||||
this.getMoveHelper().onUpdateMoveHelper();
|
||||
try {
|
||||
super.updateAITasks();
|
||||
} catch (ConcurrentModificationException ignored){}
|
||||
|
||||
if (!this.canBreathe()) {
|
||||
this.setAir(this.decreaseAirSupply(this.getAir()));
|
||||
|
||||
if (this.getAir() <= -20) {
|
||||
@@ -1054,7 +1060,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
this.setRevengeTarget(null);
|
||||
this.deathTime = 0;
|
||||
//fleeingTick = 0;
|
||||
if(ai.returnToStart && !hasOwner())
|
||||
if(ai.returnToStart && !hasOwner() && !this.isRemote())
|
||||
setLocationAndAngles(getStartXPos(), getStartYPos(), getStartZPos(), rotationYaw, rotationPitch);
|
||||
killedtime = 0;
|
||||
extinguish();
|
||||
@@ -1336,18 +1342,30 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
int k = getStartPos()[2];
|
||||
double yy = 0;
|
||||
for (int ii = j; ii >= 0; ii--) {
|
||||
Block block = worldObj.getBlock(i, ii, k);
|
||||
if (block == null)
|
||||
continue;
|
||||
AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(worldObj, i, ii, k);
|
||||
if (bb == null)
|
||||
continue;
|
||||
yy = bb.maxY;
|
||||
break;
|
||||
if (this.canFly()) {
|
||||
if (ii < j - 1) {
|
||||
yy = j;
|
||||
break;
|
||||
}
|
||||
Block block = worldObj.getBlock(i, ii, k);
|
||||
AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(worldObj, i, ii, k);
|
||||
if (bb != null) {
|
||||
yy = bb.maxY;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Block block = worldObj.getBlock(i, ii, k);
|
||||
if (block == null || block == Blocks.air)
|
||||
continue;
|
||||
AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(worldObj, i, ii, k);
|
||||
if (bb == null)
|
||||
continue;
|
||||
yy = bb.maxY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (yy <= 0)
|
||||
setDead();
|
||||
yy += 0.5;
|
||||
return yy;
|
||||
}
|
||||
|
||||
@@ -1620,6 +1638,32 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
this.isImmuneToFire = immuneToFire;
|
||||
stats.immuneToFire = immuneToFire;
|
||||
}
|
||||
|
||||
public boolean handleLavaMovement()
|
||||
{
|
||||
return !stats.immuneToFire && super.handleLavaMovement();
|
||||
}
|
||||
|
||||
public boolean handleWaterMovement()
|
||||
{
|
||||
if (stats.drowningType != 1) {
|
||||
if (this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -this.height/2.0D, 0.0D).contract(0.001D, 0.001D, 0.001D), Material.water, this)) {
|
||||
this.fallDistance = 0.0F;
|
||||
this.inWater = true;
|
||||
this.setFire(0);
|
||||
} else {
|
||||
this.inWater = false;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return super.handleWaterMovement();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBreatheUnderwater()
|
||||
{
|
||||
return stats.drowningType != 1;
|
||||
}
|
||||
|
||||
public void setAvoidWater(boolean avoidWater) {
|
||||
this.getNavigator().setAvoidsWater(avoidWater);
|
||||
|
||||
Reference in new issue
Block a user