mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-24 22:14:45 +00:00
Added the hardmode gaia guardian.
This commit is contained in:
1 parent
afb1b87db3
commit
b901f1a9d1
18 files changed
+207
-64
No files matched your search
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -31,17 +32,32 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
public class EntityMagicMissile extends EntityThrowable {
|
||||
|
||||
EntityLivingBase target;
|
||||
double lockX, lockY = -1, lockZ;
|
||||
|
||||
public EntityMagicMissile(World world) {
|
||||
super(world);
|
||||
setSize(0F, 0F);
|
||||
}
|
||||
|
||||
public EntityMagicMissile(EntityPlayer player) {
|
||||
this(player.worldObj);
|
||||
ReflectionHelper.setPrivateValue(EntityThrowable.class, this, player, LibObfuscation.THROWER);
|
||||
public EntityMagicMissile(EntityLivingBase thrower, boolean evil) {
|
||||
this(thrower.worldObj);
|
||||
ReflectionHelper.setPrivateValue(EntityThrowable.class, this, thrower, LibObfuscation.THROWER);
|
||||
setEvil(evil);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
dataWatcher.addObject(25, (byte) 0);
|
||||
}
|
||||
|
||||
public void setEvil(boolean evil) {
|
||||
dataWatcher.updateObject(25, (byte) (evil ? 1 : 0));
|
||||
}
|
||||
|
||||
public boolean isEvil() {
|
||||
return dataWatcher.getWatchableObjectByte(25) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@@ -51,6 +67,7 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean evil = isEvil();
|
||||
Vector3 thisVec = Vector3.fromEntityCenter(this);
|
||||
Vector3 oldPos = new Vector3(lastTickPosX, lastTickPosY, lastTickPosZ);
|
||||
Vector3 diff = thisVec.copy().sub(oldPos);
|
||||
@@ -58,30 +75,42 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
int steps = (int) (diff.mag() / step.mag());
|
||||
Vector3 particlePos = oldPos.copy();
|
||||
|
||||
Botania.proxy.setSparkleFXCorrupt(evil);
|
||||
for(int i = 0; i < steps; i++) {
|
||||
Botania.proxy.sparkleFX(worldObj, particlePos.x, particlePos.y, particlePos.z, 1F, 0.4F, 1F, 0.8F, 2);
|
||||
Botania.proxy.sparkleFX(worldObj, particlePos.x, particlePos.y, particlePos.z, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2);
|
||||
if(worldObj.rand.nextInt(steps) <= 1)
|
||||
Botania.proxy.sparkleFX(worldObj, particlePos.x + (Math.random() - 0.5) * 0.4, particlePos.y + (Math.random() - 0.5) * 0.4, particlePos.z + (Math.random() - 0.5) * 0.4, 1F, 0.4F, 1F, 0.8F, 2);
|
||||
Botania.proxy.sparkleFX(worldObj, particlePos.x + (Math.random() - 0.5) * 0.4, particlePos.y + (Math.random() - 0.5) * 0.4, particlePos.z + (Math.random() - 0.5) * 0.4, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2);
|
||||
|
||||
particlePos.add(step);
|
||||
}
|
||||
Botania.proxy.setSparkleFXCorrupt(false);
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
Vector3 targetVec = Vector3.fromEntityCenter(target);
|
||||
Vector3 motionVec = targetVec.copy().sub(thisVec).normalize().multiply(0.6);
|
||||
if(lockY == -1) {
|
||||
lockX = target.posX;
|
||||
lockY = target.posY;
|
||||
lockZ = target.posZ;
|
||||
}
|
||||
|
||||
Vector3 targetVec = evil ? new Vector3(lockX, lockY, lockZ) : Vector3.fromEntityCenter(target);
|
||||
Vector3 diffVec = targetVec.copy().sub(thisVec);
|
||||
Vector3 motionVec = diffVec.copy().normalize().multiply(evil ? 0.5 : 0.6);
|
||||
motionX = motionVec.x;
|
||||
motionY = motionVec.y;
|
||||
if(ticksExisted < 10)
|
||||
motionY = Math.abs(motionY);
|
||||
motionZ = motionVec.z;
|
||||
|
||||
|
||||
List<EntityLivingBase> targetList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5));
|
||||
if(targetList.contains(target) && target != null) {
|
||||
EntityLivingBase thrower = getThrower();
|
||||
EntityPlayer player = thrower instanceof EntityPlayer ? (EntityPlayer) thrower : null;
|
||||
target.attackEntityFrom(player == null ? DamageSource.generic : DamageSource.causePlayerDamage(player), 7);
|
||||
target.attackEntityFrom(player == null ? DamageSource.causeMobDamage(thrower) : DamageSource.causePlayerDamage(player), evil ? 12 : 7);
|
||||
setDead();
|
||||
}
|
||||
|
||||
if(evil && diffVec.mag() < 1)
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,15 +120,15 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
target = null;
|
||||
|
||||
double range = 12;
|
||||
List<IMob> entities = worldObj.getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range));
|
||||
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) {
|
||||
IMob mob = entities.get(worldObj.rand.nextInt(entities.size()));
|
||||
if(!(mob instanceof EntityLivingBase)) { // Just in case...
|
||||
entities.remove(mob);
|
||||
Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size()));
|
||||
if(!(e instanceof EntityLivingBase)) { // Just in case...
|
||||
entities.remove(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
target = (EntityLivingBase) mob;
|
||||
target = (EntityLivingBase) e;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user