mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-23 21:39:44 +00:00
Refractored Code
+added Solar Factory -removed unnessecary solar and essentia generator classes +started gtnh researches +added tooltip clearance on solars (maximal output) Signed-off-by: bartimaeusnek <[email protected]>
This commit is contained in:
1 parent
980df8516a
commit
0fecf28b65
397 files changed
+8693
-9288
No files matched your search
@@ -24,95 +24,95 @@ import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
|
||||
public class EntityArcher extends EntitySnowman implements IExtendedEntityProperties {
|
||||
|
||||
public EntityArcher(World world) {
|
||||
super(world);
|
||||
|
||||
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||
this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
|
||||
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true, false, IMob.mobSelector));
|
||||
this.tasks.addTask(4, new EntityAIWander(this, 0.30D));
|
||||
}
|
||||
public EntityArcher(World world) {
|
||||
super(world);
|
||||
|
||||
@Override
|
||||
protected void applyEntityAttributes() {
|
||||
super.applyEntityAttributes();
|
||||
|
||||
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D);
|
||||
}
|
||||
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||
this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
|
||||
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true, false, IMob.mobSelector));
|
||||
this.tasks.addTask(4, new EntityAIWander(this, 0.30D));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource damageSource) {
|
||||
super.onDeath(damageSource);
|
||||
|
||||
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 1, true);
|
||||
this.setDead();
|
||||
}
|
||||
@Override
|
||||
protected void applyEntityAttributes() {
|
||||
super.applyEntityAttributes();
|
||||
|
||||
@Override
|
||||
protected Item getDropItem() {
|
||||
return Items.arrow;
|
||||
}
|
||||
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropFewItems(boolean hitByPlayer, int levelOfLooting) {
|
||||
int j;
|
||||
int k;
|
||||
@Override
|
||||
public void onDeath(DamageSource damageSource) {
|
||||
super.onDeath(damageSource);
|
||||
|
||||
j = this.rand.nextInt(3 + levelOfLooting);
|
||||
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 1, true);
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
for (k = 0; k < j; ++k) {
|
||||
this.dropItem(Items.arrow, 1);
|
||||
}
|
||||
j = this.rand.nextInt(3 + levelOfLooting);
|
||||
@Override
|
||||
protected Item getDropItem() {
|
||||
return Items.arrow;
|
||||
}
|
||||
|
||||
for (k = 0; k < j; ++k) {
|
||||
this.dropItem(Items.bone, 1);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void dropFewItems(boolean hitByPlayer, int levelOfLooting) {
|
||||
int j;
|
||||
int k;
|
||||
|
||||
@Override
|
||||
protected void dropRareDrop(int ch) {
|
||||
this.entityDropItem(new ItemStack(Items.snowball, 1, 1), 0.0F);
|
||||
}
|
||||
j = this.rand.nextInt(3 + levelOfLooting);
|
||||
|
||||
protected void addRandomArmor() {
|
||||
super.addRandomArmor();
|
||||
this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
|
||||
}
|
||||
for (k = 0; k < j; ++k) {
|
||||
this.dropItem(Items.arrow, 1);
|
||||
}
|
||||
j = this.rand.nextInt(3 + levelOfLooting);
|
||||
|
||||
@Override
|
||||
public void attackEntityWithRangedAttack(EntityLivingBase entity, float par2) {
|
||||
EntityArrow entityarrow = new EntityArrow(this.worldObj, this, entity, 1.6F, (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4));
|
||||
int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
|
||||
int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
|
||||
entityarrow.setDamage((double) (par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F));
|
||||
for (k = 0; k < j; ++k) {
|
||||
this.dropItem(Items.bone, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (powerLevel > 0) {
|
||||
entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5D + 0.5D);
|
||||
}
|
||||
@Override
|
||||
protected void dropRareDrop(int ch) {
|
||||
this.entityDropItem(new ItemStack(Items.snowball, 1, 1), 0.0F);
|
||||
}
|
||||
|
||||
if (punchLevel > 0) {
|
||||
entityarrow.setKnockbackStrength(punchLevel);
|
||||
}
|
||||
protected void addRandomArmor() {
|
||||
super.addRandomArmor();
|
||||
this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0) {
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
@Override
|
||||
public void attackEntityWithRangedAttack(EntityLivingBase entity, float par2) {
|
||||
EntityArrow entityarrow = new EntityArrow(this.worldObj, this, entity, 1.6F, (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4));
|
||||
int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
|
||||
int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
|
||||
entityarrow.setDamage((double) (par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F));
|
||||
|
||||
this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
|
||||
this.worldObj.spawnEntityInWorld(entityarrow);
|
||||
}
|
||||
if (powerLevel > 0) {
|
||||
entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5D + 0.5D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNBTData(NBTTagCompound compound) {
|
||||
}
|
||||
if (punchLevel > 0) {
|
||||
entityarrow.setKnockbackStrength(punchLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
}
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0) {
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Entity entity, World world) {
|
||||
}
|
||||
this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
|
||||
this.worldObj.spawnEntityInWorld(entityarrow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNBTData(NBTTagCompound compound) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Entity entity, World world) {
|
||||
}
|
||||
}
|
||||
@@ -20,213 +20,215 @@ import thaumcraft.common.Thaumcraft;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EntityEnergyBall extends Entity implements IProjectile, IEntityAdditionalSpawnData {
|
||||
public static final int RADIUS = 8;
|
||||
public static final int MAX_TICKS_IN_TILE = 60;
|
||||
|
||||
public EntityLivingBase shootingEntity;
|
||||
|
||||
public boolean inTile = false;
|
||||
public int ticksAlive = 1; /** Pls, don't ask me why 1 =) **/
|
||||
public int ticksInAir = 1;
|
||||
public double accelerationX = 0;
|
||||
public double accelerationY = 0;
|
||||
public double accelerationZ = 0;
|
||||
public static final int RADIUS = 8;
|
||||
public static final int MAX_TICKS_IN_TILE = 60;
|
||||
|
||||
public EntityEnergyBall(World world, EntityLivingBase shootingEntity, double rotX, double rotY, double rotZ) {
|
||||
this(world, shootingEntity);
|
||||
public EntityLivingBase shootingEntity;
|
||||
|
||||
rotX += this.rand.nextGaussian() * 0.4D;
|
||||
rotY += this.rand.nextGaussian() * 0.4D;
|
||||
rotZ += this.rand.nextGaussian() * 0.4D;
|
||||
double len = (double) MathHelper.sqrt_double((rotX * rotX) + (rotY * rotY) + (rotZ * rotZ));
|
||||
this.accelerationX = rotX / len * 0.1D;
|
||||
this.accelerationY = rotY / len * 0.1D;
|
||||
this.accelerationZ = rotZ / len * 0.1D;
|
||||
}
|
||||
public boolean inTile = false;
|
||||
public int ticksAlive = 1;
|
||||
/**
|
||||
* Pls, don't ask me why 1 =)
|
||||
**/
|
||||
public int ticksInAir = 1;
|
||||
public double accelerationX = 0;
|
||||
public double accelerationY = 0;
|
||||
public double accelerationZ = 0;
|
||||
|
||||
public EntityEnergyBall(World world, EntityLivingBase shootingEntity) {
|
||||
this(world);
|
||||
public EntityEnergyBall(World world, EntityLivingBase shootingEntity, double rotX, double rotY, double rotZ) {
|
||||
this(world, shootingEntity);
|
||||
|
||||
this.shootingEntity = shootingEntity;
|
||||
this.setLocationAndAngles(shootingEntity.posX, shootingEntity.posY + shootingEntity.getEyeHeight(), shootingEntity.posZ, shootingEntity.rotationYaw, shootingEntity.rotationPitch);
|
||||
}
|
||||
rotX += this.rand.nextGaussian() * 0.4D;
|
||||
rotY += this.rand.nextGaussian() * 0.4D;
|
||||
rotZ += this.rand.nextGaussian() * 0.4D;
|
||||
double len = (double) MathHelper.sqrt_double((rotX * rotX) + (rotY * rotY) + (rotZ * rotZ));
|
||||
this.accelerationX = rotX / len * 0.1D;
|
||||
this.accelerationY = rotY / len * 0.1D;
|
||||
this.accelerationZ = rotZ / len * 0.1D;
|
||||
}
|
||||
|
||||
public EntityEnergyBall(World world) {
|
||||
super(world);
|
||||
public EntityEnergyBall(World world, EntityLivingBase shootingEntity) {
|
||||
this(world);
|
||||
|
||||
this.setSize(1.0F, 1.0F);
|
||||
this.ignoreFrustumCheck = true;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.yOffset = 0.0F;
|
||||
this.motionX = this.motionY = this.motionZ = 0.0D;
|
||||
}
|
||||
this.shootingEntity = shootingEntity;
|
||||
this.setLocationAndAngles(shootingEntity.posX, shootingEntity.posY + shootingEntity.getEyeHeight(), shootingEntity.posZ, shootingEntity.rotationYaw, shootingEntity.rotationPitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf buffer) {
|
||||
buffer.writeDouble(accelerationX);
|
||||
buffer.writeDouble(accelerationY);
|
||||
buffer.writeDouble(accelerationZ);
|
||||
}
|
||||
public EntityEnergyBall(World world) {
|
||||
super(world);
|
||||
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf buffer) {
|
||||
accelerationX = buffer.readDouble();
|
||||
accelerationY = buffer.readDouble();
|
||||
accelerationZ = buffer.readDouble();
|
||||
}
|
||||
this.setSize(1.0F, 1.0F);
|
||||
this.ignoreFrustumCheck = true;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.yOffset = 0.0F;
|
||||
this.motionX = this.motionY = this.motionZ = 0.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf buffer) {
|
||||
buffer.writeDouble(accelerationX);
|
||||
buffer.writeDouble(accelerationY);
|
||||
buffer.writeDouble(accelerationZ);
|
||||
}
|
||||
|
||||
/** If in Tile **/
|
||||
if (this.inTile) {
|
||||
this.ticksAlive++;
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf buffer) {
|
||||
accelerationX = buffer.readDouble();
|
||||
accelerationY = buffer.readDouble();
|
||||
accelerationZ = buffer.readDouble();
|
||||
}
|
||||
|
||||
if (this.ticksAlive >= MAX_TICKS_IN_TILE) {
|
||||
this.setDead();
|
||||
}
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
/** Generating Coords for every Entity **/
|
||||
ArrayList<Entity> entities = new ArrayList();
|
||||
/** If in Tile **/
|
||||
if (this.inTile) {
|
||||
this.ticksAlive++;
|
||||
|
||||
int chunkSize = ((RADIUS - 1) >> 4) + 2;
|
||||
if (this.ticksAlive >= MAX_TICKS_IN_TILE) {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
for (int chX = -chunkSize; chX < chunkSize; chX++) {
|
||||
for (int chZ = -chunkSize; chZ < chunkSize; chZ++) {
|
||||
Chunk chunk = worldObj.getChunkFromChunkCoords(chX + (int) (this.posX / 16), chZ + (int) (this.posZ / 16));
|
||||
/** Generating Coords for every Entity **/
|
||||
ArrayList<Entity> entities = new ArrayList();
|
||||
|
||||
if (chunk.isChunkLoaded && chunk.hasEntities) {
|
||||
for (int i = 0; i < chunk.entityLists.length; i++) {
|
||||
for (int k = 0; k < chunk.entityLists[i].size(); k++) {
|
||||
Entity entity = (Entity) chunk.entityLists[i].get(k);
|
||||
double width = entity.posX - this.posX;
|
||||
double height = entity.posY - this.posY;
|
||||
double length = entity.posZ - this.posZ;
|
||||
double hyp = MathHelper.sqrt_double((width * width) + (length * length) + (height * height));
|
||||
int chunkSize = ((RADIUS - 1) >> 4) + 2;
|
||||
|
||||
if (hyp <= RADIUS) {
|
||||
entities.add(entity);
|
||||
/** Closer - Harder */
|
||||
entity.attackEntityFrom(DamageSource.magic, (float) (RADIUS - hyp));
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
Thaumcraft.proxy.bolt(worldObj, this, entity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/************************************************************************/
|
||||
}
|
||||
/** If not in Tile **/
|
||||
else {
|
||||
/** Collision detection **/
|
||||
Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec3next = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(vec3, vec3next);
|
||||
for (int chX = -chunkSize; chX < chunkSize; chX++) {
|
||||
for (int chZ = -chunkSize; chZ < chunkSize; chZ++) {
|
||||
Chunk chunk = worldObj.getChunkFromChunkCoords(chX + (int) (this.posX / 16), chZ + (int) (this.posZ / 16));
|
||||
|
||||
this.ticksInAir++;
|
||||
if (mop != null) {
|
||||
inTile = true;
|
||||
}
|
||||
if (chunk.isChunkLoaded && chunk.hasEntities) {
|
||||
for (int i = 0; i < chunk.entityLists.length; i++) {
|
||||
for (int k = 0; k < chunk.entityLists[i].size(); k++) {
|
||||
Entity entity = (Entity) chunk.entityLists[i].get(k);
|
||||
double width = entity.posX - this.posX;
|
||||
double height = entity.posY - this.posY;
|
||||
double length = entity.posZ - this.posZ;
|
||||
double hyp = MathHelper.sqrt_double((width * width) + (length * length) + (height * height));
|
||||
|
||||
/** Updating position */
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F;
|
||||
if (hyp <= RADIUS) {
|
||||
entities.add(entity);
|
||||
/** Closer - Harder */
|
||||
entity.attackEntityFrom(DamageSource.magic, (float) (RADIUS - hyp));
|
||||
|
||||
for (this.rotationPitch = (float) (Math.atan2((double) f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
|
||||
;
|
||||
}
|
||||
if (worldObj.isRemote) {
|
||||
Thaumcraft.proxy.bolt(worldObj, this, entity);
|
||||
}
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/************************************************************************/
|
||||
}
|
||||
/** If not in Tile **/
|
||||
else {
|
||||
/** Collision detection **/
|
||||
Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec3next = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(vec3, vec3next);
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
this.ticksInAir++;
|
||||
if (mop != null) {
|
||||
inTile = true;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
/** Updating position */
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F;
|
||||
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
for (this.rotationPitch = (float) (Math.atan2((double) f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
|
||||
;
|
||||
}
|
||||
|
||||
double factor = this.getMotionFactor();
|
||||
this.motionX += this.accelerationX;
|
||||
this.motionY += this.accelerationY;
|
||||
this.motionZ += this.accelerationZ;
|
||||
this.motionX *= factor;
|
||||
this.motionY *= factor;
|
||||
this.motionZ *= factor;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
/************************************************************************/
|
||||
}
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3 && worldObj.isRemote; i ++) {
|
||||
float rndX = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posX);
|
||||
float rndY = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posY);
|
||||
float rndZ = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posZ);
|
||||
Thaumcraft.proxy.nodeBolt(worldObj, (float)posX, (float)posY, (float)posZ, rndX, rndY, rndZ);
|
||||
}
|
||||
}
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
|
||||
protected float getMotionFactor() {
|
||||
return 0.85F;
|
||||
}
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBrightnessForRender(float p_70070_1_) {
|
||||
return 240;
|
||||
}
|
||||
double factor = this.getMotionFactor();
|
||||
this.motionX += this.accelerationX;
|
||||
this.motionY += this.accelerationY;
|
||||
this.motionZ += this.accelerationZ;
|
||||
this.motionX *= factor;
|
||||
this.motionY *= factor;
|
||||
this.motionZ *= factor;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
/************************************************************************/
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isInRangeToRender3d(double x, double y, double z) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < 3 && worldObj.isRemote; i++) {
|
||||
float rndX = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posX);
|
||||
float rndY = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posY);
|
||||
float rndZ = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posZ);
|
||||
Thaumcraft.proxy.nodeBolt(worldObj, (float) posX, (float) posY, (float) posZ, rndX, rndY, rndZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
}
|
||||
protected float getMotionFactor() {
|
||||
return 0.85F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setByte("inTile", (byte) (this.inTile ? 1 : 0));
|
||||
nbt.setTag("direction", this.newDoubleNBTList(new double[] { this.motionX, this.motionY, this.motionZ }));
|
||||
}
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
if (!inTile) {
|
||||
this.inTile = nbt.getByte("inTile") == 1;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBrightnessForRender(float p_70070_1_) {
|
||||
return 240;
|
||||
}
|
||||
|
||||
if (nbt.hasKey("direction", 9)) {
|
||||
NBTTagList nbttaglist = nbt.getTagList("direction", 6);
|
||||
this.motionX = nbttaglist.func_150309_d(0);
|
||||
this.motionY = nbttaglist.func_150309_d(1);
|
||||
this.motionZ = nbttaglist.func_150309_d(2);
|
||||
}
|
||||
else {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isInRangeToRender3d(double x, double y, double z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrowableHeading(double x, double y, double z, float p1, float p2) {
|
||||
}
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setByte("inTile", (byte) (this.inTile ? 1 : 0));
|
||||
nbt.setTag("direction", this.newDoubleNBTList(new double[]{this.motionX, this.motionY, this.motionZ}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
if (!inTile) {
|
||||
this.inTile = nbt.getByte("inTile") == 1;
|
||||
}
|
||||
|
||||
if (nbt.hasKey("direction", 9)) {
|
||||
NBTTagList nbttaglist = nbt.getTagList("direction", 6);
|
||||
this.motionX = nbttaglist.func_150309_d(0);
|
||||
this.motionY = nbttaglist.func_150309_d(1);
|
||||
this.motionZ = nbttaglist.func_150309_d(2);
|
||||
} else {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrowableHeading(double x, double y, double z, float p1, float p2) {
|
||||
}
|
||||
}
|
||||
@@ -19,270 +19,267 @@ import net.minecraft.world.World;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityLaser extends Entity implements IThrowableEntity, IProjectile {
|
||||
private Block inTile;
|
||||
public Entity shootingEntity;
|
||||
|
||||
private int xTile;
|
||||
private int yTile;
|
||||
private int zTile;
|
||||
private int meta;
|
||||
private boolean inGround = false;
|
||||
private int ticksInGround;
|
||||
private int ticksInAir;
|
||||
private float explosionStrength = 2f;
|
||||
public Entity shootingEntity;
|
||||
private Block inTile;
|
||||
private int xTile;
|
||||
private int yTile;
|
||||
private int zTile;
|
||||
private int meta;
|
||||
private boolean inGround = false;
|
||||
private int ticksInGround;
|
||||
private int ticksInAir;
|
||||
private float explosionStrength = 2f;
|
||||
|
||||
public EntityLaser(World world) {
|
||||
super(world);
|
||||
public EntityLaser(World world) {
|
||||
super(world);
|
||||
|
||||
this.renderDistanceWeight = 10.0D;
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
this.renderDistanceWeight = 10.0D;
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
public EntityLaser(World world, EntityLivingBase entity, float speed) {
|
||||
super(world);
|
||||
this.renderDistanceWeight = 10.0D;
|
||||
this.shootingEntity = entity;
|
||||
public EntityLaser(World world, EntityLivingBase entity, float speed) {
|
||||
super(world);
|
||||
this.renderDistanceWeight = 10.0D;
|
||||
this.shootingEntity = entity;
|
||||
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setLocationAndAngles(entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ, entity.rotationYaw, entity.rotationPitch);
|
||||
this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
|
||||
this.posY -= 0.10000000149011612D;
|
||||
this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
|
||||
this.yOffset = 0.0F;
|
||||
|
||||
this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
|
||||
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, 1.0F);
|
||||
}
|
||||
|
||||
public void setExplosionStrengthModifier(float f) {
|
||||
explosionStrength = f;
|
||||
}
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setLocationAndAngles(entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ, entity.rotationYaw, entity.rotationPitch);
|
||||
this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
|
||||
this.posY -= 0.10000000149011612D;
|
||||
this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
|
||||
this.yOffset = 0.0F;
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
}
|
||||
this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
|
||||
@Override
|
||||
public void setThrowableHeading(double x, double y, double z, float speed, float scale) {
|
||||
this.motionX = x * speed;
|
||||
this.motionY = y * speed;
|
||||
this.motionZ = z * speed;
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, 1.0F);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setPositionAndRotation2(double x, double y, double z, float rotX, float rotY, int rotZ) {
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(rotX, rotY);
|
||||
}
|
||||
public void setExplosionStrengthModifier(float f) {
|
||||
explosionStrength = f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void setVelocity(double velX, double velY, double velZ) {
|
||||
this.motionX = velX;
|
||||
this.motionY = velY;
|
||||
this.motionZ = velZ;
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setThrowableHeading(double x, double y, double z, float speed, float scale) {
|
||||
this.motionX = x * speed;
|
||||
this.motionY = y * speed;
|
||||
this.motionZ = z * speed;
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setPositionAndRotation2(double x, double y, double z, float rotX, float rotY, int rotZ) {
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(rotX, rotY);
|
||||
}
|
||||
|
||||
Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
|
||||
|
||||
if (block.getMaterial() != Material.air) {
|
||||
block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void setVelocity(double velX, double velY, double velZ) {
|
||||
this.motionX = velX;
|
||||
this.motionY = velY;
|
||||
this.motionZ = velZ;
|
||||
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
|
||||
this.inGround = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
|
||||
this.inGround = true;
|
||||
}
|
||||
Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
|
||||
|
||||
if (this.inGround) {
|
||||
int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.worldObj.createExplosion(this, (int) this.posX, (int) this.posY, (int) this.posZ, explosionStrength, true);
|
||||
this.setDead();
|
||||
}
|
||||
if (block.getMaterial() != Material.air) {
|
||||
block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
|
||||
if (block == this.inTile && k == this.meta) {
|
||||
++this.ticksInGround;
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
|
||||
this.inGround = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ticksInGround == 1200) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.inGround = false;
|
||||
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.ticksInGround = 0;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
++this.ticksInAir;
|
||||
Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec3next = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec3next, false, true, false);
|
||||
vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
vec3next = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
vec3next = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
|
||||
this.inGround = true;
|
||||
}
|
||||
|
||||
Entity entity = null;
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d0 = 0.0D;
|
||||
int l;
|
||||
float down;
|
||||
if (this.inGround) {
|
||||
int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.worldObj.createExplosion(this, (int) this.posX, (int) this.posY, (int) this.posZ, explosionStrength, true);
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
for (l = 0; l < list.size(); ++l) {
|
||||
Entity entity1 = (Entity) list.get(l);
|
||||
if (block == this.inTile && k == this.meta) {
|
||||
++this.ticksInGround;
|
||||
|
||||
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
|
||||
down = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) down, (double) down, (double) down);
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3next, vec3);
|
||||
if (this.ticksInGround == 1200) {
|
||||
this.setDead();
|
||||
}
|
||||
} else {
|
||||
this.inGround = false;
|
||||
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.ticksInGround = 0;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
} else {
|
||||
++this.ticksInAir;
|
||||
Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec3next = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec3next, false, true, false);
|
||||
vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
vec3next = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (movingobjectposition1 != null) {
|
||||
double d1 = vec3next.distanceTo(movingobjectposition1.hitVec);
|
||||
if (movingobjectposition != null) {
|
||||
vec3next = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
|
||||
if (d1 < d0 || d0 == 0.0D) {
|
||||
entity = entity1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Entity entity = null;
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d0 = 0.0D;
|
||||
int l;
|
||||
float down;
|
||||
|
||||
if (entity != null) {
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
}
|
||||
for (l = 0; l < list.size(); ++l) {
|
||||
Entity entity1 = (Entity) list.get(l);
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
|
||||
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
|
||||
down = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) down, (double) down, (double) down);
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3next, vec3);
|
||||
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
|
||||
movingobjectposition = null;
|
||||
}
|
||||
}
|
||||
if (movingobjectposition1 != null) {
|
||||
double d1 = vec3next.distanceTo(movingobjectposition1.hitVec);
|
||||
|
||||
float f2;
|
||||
float f3;
|
||||
if (d1 < d0 || d0 == 0.0D) {
|
||||
entity = entity1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
if (movingobjectposition.entityHit != null) {
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.worldObj.createExplosion(this, (int) this.posX, (int) this.posY, (int) this.posZ, explosionStrength, true);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.xTile = movingobjectposition.blockX;
|
||||
this.yTile = movingobjectposition.blockY;
|
||||
this.zTile = movingobjectposition.blockZ;
|
||||
this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
|
||||
this.meta = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
|
||||
this.motionX = movingobjectposition.hitVec.xCoord - this.posX;
|
||||
this.motionY = movingobjectposition.hitVec.yCoord - this.posY;
|
||||
this.motionZ = movingobjectposition.hitVec.zCoord - this.posZ;
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / (double) f2 * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / (double) f2 * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D;
|
||||
this.inGround = true;
|
||||
}
|
||||
}
|
||||
if (entity != null) {
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
}
|
||||
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
|
||||
|
||||
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F);
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
|
||||
movingobjectposition = null;
|
||||
}
|
||||
}
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
float f2;
|
||||
float f3;
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
if (movingobjectposition != null) {
|
||||
if (movingobjectposition.entityHit != null) {
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.worldObj.createExplosion(this, (int) this.posX, (int) this.posY, (int) this.posZ, explosionStrength, true);
|
||||
this.setDead();
|
||||
}
|
||||
} else {
|
||||
this.xTile = movingobjectposition.blockX;
|
||||
this.yTile = movingobjectposition.blockY;
|
||||
this.zTile = movingobjectposition.blockZ;
|
||||
this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
|
||||
this.meta = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
|
||||
this.motionX = movingobjectposition.hitVec.xCoord - this.posX;
|
||||
this.motionY = movingobjectposition.hitVec.yCoord - this.posY;
|
||||
this.motionZ = movingobjectposition.hitVec.zCoord - this.posZ;
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / (double) f2 * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / (double) f2 * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D;
|
||||
this.inGround = true;
|
||||
}
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
|
||||
;
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
|
||||
|
||||
if (this.isInWater()) {
|
||||
for (int j1 = 0; j1 < 4; ++j1) {
|
||||
f3 = 0.25F;
|
||||
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ);
|
||||
}
|
||||
if (this.isInWater()) {
|
||||
for (int j1 = 0; j1 < 4; ++j1) {
|
||||
f3 = 0.25F;
|
||||
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ);
|
||||
}
|
||||
|
||||
}
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setShort("xTile", (short) this.xTile);
|
||||
nbt.setShort("yTile", (short) this.yTile);
|
||||
nbt.setShort("zTile", (short) this.zTile);
|
||||
nbt.setShort("inTile", (short) Block.getIdFromBlock(this.inTile));
|
||||
nbt.setByte("inData", (byte) this.meta);
|
||||
nbt.setBoolean("inGround", this.inGround);
|
||||
nbt.setFloat("explosionStrength", this.explosionStrength);
|
||||
}
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setShort("xTile", (short) this.xTile);
|
||||
nbt.setShort("yTile", (short) this.yTile);
|
||||
nbt.setShort("zTile", (short) this.zTile);
|
||||
nbt.setShort("inTile", (short) Block.getIdFromBlock(this.inTile));
|
||||
nbt.setByte("inData", (byte) this.meta);
|
||||
nbt.setBoolean("inGround", this.inGround);
|
||||
nbt.setFloat("explosionStrength", this.explosionStrength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
this.xTile = nbt.getShort("xTile");
|
||||
this.yTile = nbt.getShort("yTile");
|
||||
this.zTile = nbt.getShort("zTile");
|
||||
this.inTile = Block.getBlockById(nbt.getShort("inTile"));
|
||||
this.meta = nbt.getByte("inData") & 255;
|
||||
this.inGround = nbt.getBoolean("inGround");
|
||||
this.explosionStrength = nbt.getFloat("explosionStrength");
|
||||
}
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
this.xTile = nbt.getShort("xTile");
|
||||
this.yTile = nbt.getShort("yTile");
|
||||
this.zTile = nbt.getShort("zTile");
|
||||
this.inTile = Block.getBlockById(nbt.getShort("inTile"));
|
||||
this.meta = nbt.getByte("inData") & 255;
|
||||
this.inGround = nbt.getBoolean("inGround");
|
||||
this.explosionStrength = nbt.getFloat("explosionStrength");
|
||||
}
|
||||
|
||||
public void onCollide(Entity entity) {
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, explosionStrength, true);
|
||||
}
|
||||
}
|
||||
public void onCollide(Entity entity) {
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, explosionStrength, true);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public float getShadowSize() {
|
||||
return 0.0F;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public float getShadowSize() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getThrower() {
|
||||
return shootingEntity;
|
||||
}
|
||||
@Override
|
||||
public Entity getThrower() {
|
||||
return shootingEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrower(Entity entity) {
|
||||
shootingEntity = entity;
|
||||
}
|
||||
@Override
|
||||
public void setThrower(Entity entity) {
|
||||
shootingEntity = entity;
|
||||
}
|
||||
}
|
||||
@@ -9,99 +9,99 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityShield extends Entity {
|
||||
public EntityPlayer owner;
|
||||
public EntityPlayer owner;
|
||||
|
||||
public boolean needCheck = true;
|
||||
public boolean needCheck = true;
|
||||
|
||||
public EntityShield(World world) {
|
||||
super(world);
|
||||
this.ignoreFrustumCheck = true;
|
||||
}
|
||||
public EntityShield(World world) {
|
||||
super(world);
|
||||
this.ignoreFrustumCheck = true;
|
||||
}
|
||||
|
||||
public EntityShield(World world, EntityPlayer player) {
|
||||
super(world);
|
||||
this.setSize(4, 4);
|
||||
owner = player;
|
||||
this.dataWatcher.updateObject(11, owner.getDisplayName());
|
||||
this.setPosition(player.posX, player.posY, player.posZ);
|
||||
this.ignoreFrustumCheck = true;
|
||||
}
|
||||
public EntityShield(World world, EntityPlayer player) {
|
||||
super(world);
|
||||
this.setSize(4, 4);
|
||||
owner = player;
|
||||
this.dataWatcher.updateObject(11, owner.getDisplayName());
|
||||
this.setPosition(player.posX, player.posY, player.posZ);
|
||||
this.ignoreFrustumCheck = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(11, "");
|
||||
}
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePushed() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canBePushed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
this.posX = x;
|
||||
this.posY = y + 0.5f;
|
||||
this.posZ = z;
|
||||
float f = this.width / 2.0F;
|
||||
float f1 = this.height;
|
||||
this.boundingBox.setBounds(x - (double) f, y - (double) this.yOffset - 2 + (double) this.ySize, z - (double) f, x + (double) f, y - (double) this.yOffset - 2 + (double) this.ySize + (double) f1, z + (double) f);
|
||||
}
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
this.posX = x;
|
||||
this.posY = y + 0.5f;
|
||||
this.posZ = z;
|
||||
float f = this.width / 2.0F;
|
||||
float f1 = this.height;
|
||||
this.boundingBox.setBounds(x - (double) f, y - (double) this.yOffset - 2 + (double) this.ySize, z - (double) f, x + (double) f, y - (double) this.yOffset - 2 + (double) this.ySize + (double) f1, z + (double) f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (needCheck && owner == null) {
|
||||
owner = this.worldObj.getPlayerEntityByName(dataWatcher.getWatchableObjectString(11));
|
||||
needCheck = false;
|
||||
}
|
||||
if (!needCheck && owner == null) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
if (needCheck && owner == null) {
|
||||
owner = this.worldObj.getPlayerEntityByName(dataWatcher.getWatchableObjectString(11));
|
||||
needCheck = false;
|
||||
}
|
||||
if (!needCheck && owner == null) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.worldObj.isRemote && owner != null) {
|
||||
this.setPosition(owner.posX, owner.posY, owner.posZ);
|
||||
if (!owner.isUsingItem()) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.worldObj.isRemote && owner != null) {
|
||||
this.setPosition(owner.posX, owner.posY, owner.posZ);
|
||||
if (!owner.isUsingItem()) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBrightnessForRender(float p_70070_1_) {
|
||||
return 240;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBrightnessForRender(float p_70070_1_) {
|
||||
return 240;
|
||||
}
|
||||
|
||||
public void applyEntityCollision(Entity entity) {
|
||||
if (entity.riddenByEntity != this && entity.ridingEntity != this) {
|
||||
double ePosX = entity.posX - this.posX;
|
||||
double ePosZ = entity.posZ - this.posZ;
|
||||
entity.addVelocity(ePosX / 5D, 0.0D, ePosZ / 5D);
|
||||
}
|
||||
}
|
||||
public void applyEntityCollision(Entity entity) {
|
||||
if (entity.riddenByEntity != this && entity.ridingEntity != this) {
|
||||
double ePosX = entity.posX - this.posX;
|
||||
double ePosZ = entity.posZ - this.posZ;
|
||||
entity.addVelocity(ePosX / 5D, 0.0D, ePosZ / 5D);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isInRangeToRender3d(double x, double y, double z) {
|
||||
return true;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isInRangeToRender3d(double x, double y, double z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user