Run formatter

This commit is contained in:
Nicholas Ignoffo 2017-08-15 21:30:48 -07:00
parent 61c44a831b
commit 08258fd6ef
606 changed files with 13464 additions and 22975 deletions

View file

@ -1,24 +1,16 @@
package WayofTime.bloodmagic.alchemyArray;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.fakePlayer.FakePlayerBM;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySilverfish;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.*;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathFinder;
@ -29,17 +21,13 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.fakePlayer.FakePlayerBM;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
import com.mojang.authlib.GameProfile;
import java.util.*;
/**
* Credits for the initial code go to Crazy Pants of EIO.
*/
public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
{
public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect {
private FakePlayer target;
private Set<EntityLiving> tracking = new HashSet<EntityLiving>();
@ -48,26 +36,21 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
private int cooldown = 50;
public AlchemyArrayEffectAttractor(String key)
{
public AlchemyArrayEffectAttractor(String key) {
super(key);
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
if (tile.getWorld().isRemote)
{
public boolean update(TileEntity tile, int ticksActive) {
if (tile.getWorld().isRemote) {
return false;
}
BlockPos pos = tile.getPos();
counter++;
if (counter < 10)
{
if (counter < 10) {
Iterator<EntityLiving> itr = tracking.iterator();
while (itr.hasNext())
{
while (itr.hasNext()) {
EntityLiving ent = itr.next();
onEntityTick(pos, ent);
}
@ -82,8 +65,7 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
Set<EntityLiving> trackingThisTick = new HashSet<EntityLiving>();
List<EntityLiving> entsInBounds = world.getEntitiesWithinAABB(EntityLiving.class, getBounds(pos));
for (EntityLiving ent : entsInBounds)
{
for (EntityLiving ent : entsInBounds) {
if (!ent.isDead)// && isMobInFilter(ent))
{
double x = (pos.getX() + 0.5D - ent.posX);
@ -91,36 +73,30 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
double z = (pos.getZ() + 0.5D - ent.posZ);
double distance = Math.sqrt(x * x + y * y + z * z);
if (distance < 2 && tracking.contains(ent))
{
if (distance < 2 && tracking.contains(ent)) {
setEntityCooldown(pos, ent, cooldown);
removeAssignedAITask(pos, ent);
continue;
}
if (!canEntityBeTracked(pos, ent))
{
if (!canEntityBeTracked(pos, ent)) {
// System.out.println("Cooldown: " + getEntityCooldown(pos, ent));
decrementEntityCooldown(pos, ent);
continue;
}
if (tracking.contains(ent))
{
if (tracking.contains(ent)) {
trackingThisTick.add(ent);
onEntityTick(pos, ent);
} else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent))
{
} else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent)) {
trackingThisTick.add(ent);
onTracked(ent);
}
}
}
for (EntityLiving e : tracking)
{
if (!trackingThisTick.contains(e))
{
for (EntityLiving e : tracking) {
if (!trackingThisTick.contains(e)) {
onUntracked(e);
}
}
@ -130,124 +106,98 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
return false;
}
public boolean canEntityBeTracked(BlockPos pos, EntityLiving entity)
{
public boolean canEntityBeTracked(BlockPos pos, EntityLiving entity) {
return getEntityCooldown(pos, entity) <= 0;
}
private String getPosKey(BlockPos pos)
{
private String getPosKey(BlockPos pos) {
return "BMAttractor:" + pos;
}
public int getEntityCooldown(BlockPos pos, EntityLiving entity)
{
public int getEntityCooldown(BlockPos pos, EntityLiving entity) {
return entity.getEntityData().getInteger(getPosKey(pos));
}
public void setEntityCooldown(BlockPos pos, EntityLiving entity, int cooldown)
{
public void setEntityCooldown(BlockPos pos, EntityLiving entity, int cooldown) {
entity.getEntityData().setInteger(getPosKey(pos), cooldown);
}
public void decrementEntityCooldown(BlockPos pos, EntityLiving entity)
{
public void decrementEntityCooldown(BlockPos pos, EntityLiving entity) {
int cooldown = getEntityCooldown(pos, entity);
if (cooldown > 0)
{
if (cooldown > 0) {
setEntityCooldown(pos, entity, cooldown - 1);
}
}
public AxisAlignedBB getBounds(BlockPos pos)
{
public AxisAlignedBB getBounds(BlockPos pos) {
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
}
public float getRange()
{
public float getRange() {
return 10;
}
private void onUntracked(EntityLiving e)
{
if (e instanceof EntityEnderman)
{
private void onUntracked(EntityLiving e) {
if (e instanceof EntityEnderman) {
e.getEntityData().setBoolean("BM:tracked", false);
}
}
private void onTracked(EntityLiving e)
{
if (e instanceof EntityEnderman)
{
private void onTracked(EntityLiving e) {
if (e instanceof EntityEnderman) {
e.getEntityData().setBoolean("BM:tracked", true);
}
}
private void onEntityTick(BlockPos pos, EntityLiving ent)
{
if (ent instanceof EntitySlime)
{
private void onEntityTick(BlockPos pos, EntityLiving ent) {
if (ent instanceof EntitySlime) {
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
} else if (ent instanceof EntitySilverfish)
{
if (counter < 10)
{
} else if (ent instanceof EntitySilverfish) {
if (counter < 10) {
return;
}
EntitySilverfish sf = (EntitySilverfish) ent;
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
sf.getNavigator().setPath(pathentity, sf.getAIMoveSpeed());
} else if (ent instanceof EntityBlaze)
{
} else if (ent instanceof EntityBlaze) {
double x = (pos.getX() + 0.5D - ent.posX);
double y = (pos.getY() + 1D - ent.posY);
double z = (pos.getZ() + 0.5D - ent.posZ);
double distance = Math.sqrt(x * x + y * y + z * z);
if (distance > 1.25)
{
if (distance > 1.25) {
double speed = 0.01;
ent.motionX += x / distance * speed;
if (y > 0)
{
if (y > 0) {
ent.motionY += (0.3 - ent.motionY) * 0.3;
}
ent.motionZ += z / distance * speed;
}
} else if (ent instanceof EntityPigZombie || ent instanceof EntitySpider)
{
} else if (ent instanceof EntityPigZombie || ent instanceof EntitySpider) {
forceMove(pos, ent);
// ent.setAttackTarget(target);
} else if (ent instanceof EntityEnderman)
{
} else if (ent instanceof EntityEnderman) {
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
}
}
private void forceMove(BlockPos pos, EntityLiving ent)
{
private void forceMove(BlockPos pos, EntityLiving ent) {
double x = (pos.getX() + 0.5D - ent.posX);
double y = (pos.getY() + 1D - ent.posY);
double z = (pos.getZ() + 0.5D - ent.posZ);
double distance = Math.sqrt(x * x + y * y + z * z);
if (distance > 2)
{
if (distance > 2) {
EntityMob mod = (EntityMob) ent;
mod.faceEntity(getTarget(ent.getEntityWorld(), pos), 180, 0);
mod.getMoveHelper().strafe(0, 0.3f);
if (mod.posY < pos.getY())
{
if (mod.posY < pos.getY()) {
mod.setJumping(true);
} else
{
} else {
mod.setJumping(false);
}
}
}
public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range)
{
public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range) {
int targX = MathHelper.floor(targetEntity.posX);
int targY = MathHelper.floor(targetEntity.posY + 1.0D);
int targZ = MathHelper.floor(targetEntity.posZ);
@ -256,74 +206,57 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
return pf.findPath(targetEntity.getEntityWorld(), (EntityLiving) entity, new BlockPos(targX, targY, targZ), range);
}
private boolean trackMob(BlockPos pos, EntityLiving ent)
{
private boolean trackMob(BlockPos pos, EntityLiving ent) {
//TODO: Figure out if this crud is needed
if (useSetTarget(ent))
{
if (useSetTarget(ent)) {
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
return true;
} else if (useSpecialCase(ent))
{
} else if (useSpecialCase(ent)) {
return applySpecialCase(pos, ent);
} else
{
} else {
return attractUsingAITask(pos, ent);
}
}
private boolean useSetTarget(EntityLiving ent)
{
private boolean useSetTarget(EntityLiving ent) {
return ent instanceof EntityPigZombie || ent instanceof EntitySpider || ent instanceof EntitySilverfish;
}
public void removeAssignedAITask(BlockPos pos, EntityLiving ent)
{
public void removeAssignedAITask(BlockPos pos, EntityLiving ent) {
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
EntityAIBase remove = null;
for (EntityAITaskEntry entry : entries)
{
if (entry.action instanceof AttractTask)
{
for (EntityAITaskEntry entry : entries) {
if (entry.action instanceof AttractTask) {
AttractTask at = (AttractTask) entry.action;
if (at.coord.equals(pos))
{
if (at.coord.equals(pos)) {
remove = entry.action;
} else
{
} else {
continue;
}
}
}
if (remove != null)
{
if (remove != null) {
ent.tasks.removeTask(remove);
}
}
private boolean attractUsingAITask(BlockPos pos, EntityLiving ent)
{
private boolean attractUsingAITask(BlockPos pos, EntityLiving ent) {
tracking.add(ent);
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
// boolean hasTask = false;
EntityAIBase remove = null;
// boolean isTracked;
for (EntityAITaskEntry entry : entries)
{
if (entry.action instanceof AttractTask)
{
for (EntityAITaskEntry entry : entries) {
if (entry.action instanceof AttractTask) {
AttractTask at = (AttractTask) entry.action;
if (at.coord.equals(pos) || !at.shouldExecute())
{
if (at.coord.equals(pos) || !at.shouldExecute()) {
remove = entry.action;
} else
{
} else {
return false;
}
}
}
if (remove != null)
{
if (remove != null) {
ent.tasks.removeTask(remove);
}
@ -333,18 +266,14 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
return true;
}
private void cancelCurrentTasks(EntityLiving ent)
{
private void cancelCurrentTasks(EntityLiving ent) {
Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
while (iterator.hasNext())
{
while (iterator.hasNext()) {
EntityAITaskEntry entityaitaskentry = iterator.next();
if (entityaitaskentry != null)
{
if (entityaitaskentry.action instanceof AttractTask)
{
if (entityaitaskentry != null) {
if (entityaitaskentry.action instanceof AttractTask) {
continue;
}
@ -353,42 +282,34 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
}
// Only available way to stop current execution is to remove all current
// tasks, then re-add them
for (EntityAITaskEntry task : currentTasks)
{
for (EntityAITaskEntry task : currentTasks) {
ent.tasks.removeTask(task.action);
ent.tasks.addTask(task.priority, task.action);
}
}
private boolean applySpecialCase(BlockPos pos, EntityLiving ent)
{
if (ent instanceof EntitySlime)
{
private boolean applySpecialCase(BlockPos pos, EntityLiving ent) {
if (ent instanceof EntitySlime) {
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
// ent.setAttackTarget(getTarget(ent.worldObj, pos));
return true;
} else if (ent instanceof EntitySilverfish)
{
} else if (ent instanceof EntitySilverfish) {
EntitySilverfish es = (EntitySilverfish) ent;
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
es.getNavigator().setPath(pathentity, es.getAIMoveSpeed());
return true;
} else if (ent instanceof EntityBlaze)
{
} else if (ent instanceof EntityBlaze) {
return true;
}
return false;
}
private boolean useSpecialCase(EntityLiving ent)
{
private boolean useSpecialCase(EntityLiving ent) {
return ent instanceof EntitySlime || ent instanceof EntitySilverfish || ent instanceof EntityBlaze;
}
public FakePlayer getTarget(World world, BlockPos pos)
{
if (target == null)
{
public FakePlayer getTarget(World world, BlockPos pos) {
if (target == null) {
// System.out.println("...Hi? " + pos);
target = new Target(world, pos);
}
@ -396,17 +317,22 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
return target;
}
private class Target extends FakePlayerBM
{
public Target(World world, BlockPos pos)
{
super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos));
posY += 1;
}
@Override
public void writeToNBT(NBTTagCompound tag) {
}
private static class AttractTask extends EntityAIBase
{
@Override
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectAttractor(key);
}
private static class AttractTask extends EntityAIBase {
private EntityLiving mob;
private BlockPos coord;
private FakePlayer target;
@ -414,21 +340,18 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
private boolean started = false;
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord)
{
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) {
this.mob = mob;
this.coord = coord;
this.target = target;
}
@Override
public boolean shouldExecute()
{
public boolean shouldExecute() {
boolean res = false;
//TODO:
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
if (te instanceof TileAlchemyArray)
{
if (te instanceof TileAlchemyArray) {
res = true;
}
@ -436,55 +359,38 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
}
@Override
public void resetTask()
{
public void resetTask() {
started = false;
updatesSincePathing = 0;
}
@Override
public boolean isInterruptible()
{
public boolean isInterruptible() {
return true;
}
@Override
public void updateTask()
{
if (!started || updatesSincePathing > 20)
{
public void updateTask() {
if (!started || updatesSincePathing > 20) {
started = true;
int speed = 1;
// mob.getNavigator().setAvoidsWater(false);
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
if (!res)
{
if (!res) {
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
}
updatesSincePathing = 0;
} else
{
} else {
updatesSincePathing++;
}
}
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
}
@Override
public AlchemyArrayEffect getNewCopy()
{
return new AlchemyArrayEffectAttractor(key);
private class Target extends FakePlayerBM {
public Target(World world, BlockPos pos) {
super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos));
posY += 1;
}
}
}

View file

@ -1,5 +1,8 @@
package WayofTime.bloodmagic.alchemyArray;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
@ -7,34 +10,25 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
{
public AlchemyArrayEffectBinding(String key, ItemStack outputStack)
{
public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting {
public AlchemyArrayEffectBinding(String key, ItemStack outputStack) {
super(key, outputStack, 200);
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
if (ticksActive >= 50 && ticksActive <= 250)
{
public boolean update(TileEntity tile, int ticksActive) {
if (ticksActive >= 50 && ticksActive <= 250) {
// TODO: Find a way to spawn lightning from only the server side -
// does not render when just spawned on server, not client.
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
}
if (tile.getWorld().isRemote)
{
if (tile.getWorld().isRemote) {
return false;
}
if (ticksActive >= 300)
{
if (ticksActive >= 300) {
BlockPos pos = tile.getPos();
ItemStack output = outputStack.copy();
@ -48,10 +42,8 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
return false;
}
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive)
{
if (ticksActive % 50 == 0)
{
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) {
if (ticksActive % 50 == 0) {
int circle = ticksActive / 50 - 1;
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);
@ -65,20 +57,17 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
public void writeToNBT(NBTTagCompound tag) {
//EMPTY
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
public void readFromNBT(NBTTagCompound tag) {
//EMPTY
}
@Override
public AlchemyArrayEffect getNewCopy()
{
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectBinding(key, outputStack);
}
}

View file

@ -1,5 +1,7 @@
package WayofTime.bloodmagic.alchemyArray;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -7,34 +9,25 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
public class AlchemyArrayEffectBounce extends AlchemyArrayEffect
{
public AlchemyArrayEffectBounce(String key)
{
public class AlchemyArrayEffectBounce extends AlchemyArrayEffect {
public AlchemyArrayEffectBounce(String key) {
super(key);
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
public boolean update(TileEntity tile, int ticksActive) {
return false;
}
@Override
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
{
if (entity.isSneaking())
{
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
if (entity.isSneaking()) {
return;
} else if (entity.motionY < 0.0D)
{
} else if (entity.motionY < 0.0D) {
entity.motionY = -entity.motionY;
if (!(entity instanceof EntityLivingBase))
{
if (!(entity instanceof EntityLivingBase)) {
entity.motionY *= 0.8D;
}
@ -43,20 +36,17 @@ public class AlchemyArrayEffectBounce extends AlchemyArrayEffect
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy()
{
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectBounce(key);
}
}

View file

@ -1,5 +1,7 @@
package WayofTime.bloodmagic.alchemyArray;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
@ -7,25 +9,19 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
public class AlchemyArrayEffectMovement extends AlchemyArrayEffect
{
public AlchemyArrayEffectMovement(String key)
{
public class AlchemyArrayEffectMovement extends AlchemyArrayEffect {
public AlchemyArrayEffectMovement(String key) {
super(key);
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
public boolean update(TileEntity tile, int ticksActive) {
return false;
}
@Override
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
{
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
double motionY = 0.5;
double speed = 3;
EnumFacing direction = array.getRotation();
@ -33,51 +29,47 @@ public class AlchemyArrayEffectMovement extends AlchemyArrayEffect
entity.motionY = motionY;
entity.fallDistance = 0;
switch (direction)
{
case NORTH:
entity.motionX = 0;
entity.motionY = motionY;
entity.motionZ = -speed;
break;
switch (direction) {
case NORTH:
entity.motionX = 0;
entity.motionY = motionY;
entity.motionZ = -speed;
break;
case SOUTH:
entity.motionX = 0;
entity.motionY = motionY;
entity.motionZ = speed;
break;
case SOUTH:
entity.motionX = 0;
entity.motionY = motionY;
entity.motionZ = speed;
break;
case WEST:
entity.motionX = -speed;
entity.motionY = motionY;
entity.motionZ = 0;
break;
case WEST:
entity.motionX = -speed;
entity.motionY = motionY;
entity.motionZ = 0;
break;
case EAST:
entity.motionX = speed;
entity.motionY = motionY;
entity.motionZ = 0;
break;
default:
break;
case EAST:
entity.motionX = speed;
entity.motionY = motionY;
entity.motionZ = 0;
break;
default:
break;
}
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy()
{
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectMovement(key);
}
}

View file

@ -1,26 +1,22 @@
package WayofTime.bloodmagic.alchemyArray;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.ISigil;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class AlchemyArrayEffectSigil extends AlchemyArrayEffect
{
public class AlchemyArrayEffectSigil extends AlchemyArrayEffect {
private final ISigil sigil;
public AlchemyArrayEffectSigil(String key, ISigil sigil)
{
public AlchemyArrayEffectSigil(String key, ISigil sigil) {
super(key);
this.sigil = sigil;
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
public boolean update(TileEntity tile, int ticksActive) {
//TODO: Need particles.
if (sigil.hasArrayEffect())
{
if (sigil.hasArrayEffect()) {
sigil.performArrayEffect(tile.getWorld(), tile.getPos());
}
@ -28,20 +24,17 @@ public class AlchemyArrayEffectSigil extends AlchemyArrayEffect
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy()
{
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectSigil(key, sigil);
}
}

View file

@ -1,9 +1,8 @@
package WayofTime.bloodmagic.alchemyArray;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
import com.google.common.base.Predicate;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIBase;
@ -18,35 +17,29 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
import com.google.common.base.Predicate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Credits for the initial code go to Crazy Pants of EIO.
*/
public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
{
private EntitySkeleton turret;
public static Predicate<EntityMob> checkSkeleton = new Predicate<EntityMob>()
{
public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect {
public static Predicate<EntityMob> checkSkeleton = new Predicate<EntityMob>() {
@Override
public boolean apply(EntityMob input)
{
public boolean apply(EntityMob input) {
return !(input instanceof EntitySkeleton);
}
};
private EntitySkeleton turret;
public AlchemyArrayEffectSkeletonTurret(String key)
{
public AlchemyArrayEffectSkeletonTurret(String key) {
super(key);
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
public boolean update(TileEntity tile, int ticksActive) {
// if (tile.getWorld().isRemote)
// {
// return false;
@ -54,15 +47,13 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
BlockPos pos = tile.getPos();
if (turret != null && !turret.isDead)
{
if (turret != null && !turret.isDead) {
double x = (pos.getX() + 0.5D - turret.posX);
double y = (pos.getY() + 1D - turret.posY);
double z = (pos.getZ() + 0.5D - turret.posZ);
double distance = Math.sqrt(x * x + y * y + z * z);
if (distance < 2)
{
if (distance < 2) {
// turret.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 100));
return false;
}
@ -72,8 +63,7 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
List<EntitySkeleton> skeletonsInRange = world.getEntitiesWithinAABB(EntitySkeleton.class, getBounds(pos));
for (EntitySkeleton entity : skeletonsInRange)
{
for (EntitySkeleton entity : skeletonsInRange) {
if (!entity.isDead)// && isMobInFilter(ent))
{
modifyAITargetTasks(entity);
@ -85,13 +75,11 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
return false;
}
public AxisAlignedBB getBounds(BlockPos pos)
{
public AxisAlignedBB getBounds(BlockPos pos) {
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
}
public float getRange()
{
public float getRange() {
return 0;
}
@ -105,8 +93,7 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
// e.getEntityData().setBoolean("BM:tracked", true);
// }
private boolean modifyAITargetTasks(EntitySkeleton entity)
{
private boolean modifyAITargetTasks(EntitySkeleton entity) {
cancelCurrentTargetTasks(entity);
// entity.setCombatTask();
@ -116,13 +103,11 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
return true;
}
private void cancelCurrentTargetTasks(EntityLiving entity)
{
private void cancelCurrentTargetTasks(EntityLiving entity) {
Iterator<EntityAITaskEntry> iterator = entity.targetTasks.taskEntries.iterator();
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
while (iterator.hasNext())
{
while (iterator.hasNext()) {
EntityAITaskEntry entityaitaskentry = iterator.next();
if (entityaitaskentry != null)// && entityaitaskentry.action instanceof EntityAITarget)
{
@ -130,14 +115,27 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
}
}
for (EntityAITaskEntry task : currentTasks)
{
for (EntityAITaskEntry task : currentTasks) {
entity.targetTasks.removeTask(task.action);
}
}
private static class AttractTask extends EntityAIBase
{
@Override
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectSkeletonTurret(key);
}
private static class AttractTask extends EntityAIBase {
private EntityLiving mob;
private BlockPos coord;
private FakePlayer target;
@ -145,21 +143,18 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
private boolean started = false;
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord)
{
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) {
this.mob = mob;
this.coord = coord;
this.target = target;
}
@Override
public boolean shouldExecute()
{
public boolean shouldExecute() {
boolean res = false;
//TODO:
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
if (te instanceof TileAlchemyArray)
{
if (te instanceof TileAlchemyArray) {
res = true;
}
@ -167,55 +162,31 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
}
@Override
public void resetTask()
{
public void resetTask() {
started = false;
updatesSincePathing = 0;
}
@Override
public boolean isInterruptible()
{
public boolean isInterruptible() {
return true;
}
@Override
public void updateTask()
{
if (!started || updatesSincePathing > 20)
{
public void updateTask() {
if (!started || updatesSincePathing > 20) {
started = true;
int speed = 1;
// mob.getNavigator().setAvoidsWater(false);
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
if (!res)
{
if (!res) {
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
}
updatesSincePathing = 0;
} else
{
} else {
updatesSincePathing++;
}
}
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
}
@Override
public AlchemyArrayEffect getNewCopy()
{
return new AlchemyArrayEffectSkeletonTurret(key);
}
}

View file

@ -1,30 +1,26 @@
package WayofTime.bloodmagic.alchemyArray;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect
{
public AlchemyArrayEffectUpdraft(String key)
{
public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect {
public AlchemyArrayEffectUpdraft(String key) {
super(key);
}
@Override
public boolean update(TileEntity tile, int ticksActive)
{
public boolean update(TileEntity tile, int ticksActive) {
return false;
}
@Override
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
{
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
double motionY = 1.5;
entity.fallDistance = 0;
@ -33,20 +29,17 @@ public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy()
{
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectUpdraft(key);
}
}