mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-24 05:54:49 +00:00
Avatars, part 1
This commit is contained in:
1 parent
ce231bcea5
commit
77d21be8b6
21 files changed
+704
-49
No files matched your search
@@ -34,7 +34,6 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
|
||||
private static final String TAG_TIME = "time";
|
||||
|
||||
EntityLivingBase target;
|
||||
double lockX, lockY = -1, lockZ;
|
||||
int time = 0;
|
||||
|
||||
@@ -52,18 +51,36 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
dataWatcher.addObject(25, (byte) 0);
|
||||
dataWatcher.addObject(26, 0);
|
||||
}
|
||||
|
||||
public void setEvil(boolean evil) {
|
||||
dataWatcher.updateObject(25, (byte) (evil ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
public boolean isEvil() {
|
||||
return dataWatcher.getWatchableObjectByte(25) == 1;
|
||||
}
|
||||
|
||||
public void setTarget(EntityLivingBase e) {
|
||||
dataWatcher.updateObject(26, e == null ? -1 : e.getEntityId());
|
||||
}
|
||||
|
||||
public EntityLivingBase getTargetEntity() {
|
||||
int id = dataWatcher.getWatchableObjectInt(26);
|
||||
Entity e = worldObj.getEntityByID(id);
|
||||
if(e != null && e instanceof EntityLivingBase)
|
||||
return (EntityLivingBase) e;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
double lastTickPosX = this.lastTickPosX;
|
||||
double lastTickPosY = this.lastTickPosY;
|
||||
double lastTickPosZ = this.lastTickPosZ;
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if(!worldObj.isRemote && (!getTarget() || time > 40)) {
|
||||
@@ -89,7 +106,8 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
}
|
||||
Botania.proxy.setSparkleFXCorrupt(false);
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
EntityLivingBase target = getTargetEntity();
|
||||
if(target != null) {
|
||||
if(lockY == -1) {
|
||||
lockX = target.posX;
|
||||
lockY = target.posY;
|
||||
@@ -134,20 +152,23 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
|
||||
|
||||
public boolean getTarget() {
|
||||
EntityLivingBase target = getTargetEntity();
|
||||
if(target != null && target.getHealth() > 0 && !target.isDead && worldObj.loadedEntityList.contains(target))
|
||||
return true;
|
||||
target = null;
|
||||
if(target != null)
|
||||
setTarget(null);
|
||||
|
||||
double range = 12;
|
||||
List entities = worldObj.getEntitiesWithinAABB(isEvil() ? EntityPlayer.class : IMob.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range));
|
||||
while(entities.size() > 0) {
|
||||
Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size()));
|
||||
if(!(e instanceof EntityLivingBase)) { // Just in case...
|
||||
if(!(e instanceof EntityLivingBase) || e.isDead) { // Just in case...
|
||||
entities.remove(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
target = (EntityLivingBase) e;
|
||||
setTarget(target);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -158,7 +179,7 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
protected void onImpact(MovingObjectPosition pos) {
|
||||
Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves) && (pos.entityHit == null || target == pos.entityHit))
|
||||
if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves) && (pos.entityHit == null || getTargetEntity() == pos.entityHit))
|
||||
setDead();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user