diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..d197eef --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.debug=true +org.gradle.daemon=true \ No newline at end of file diff --git a/src/main/java/emt/client/renderer/RenderLaser.java b/src/main/java/emt/client/renderer/RenderLaser.java index 00bfd6b..854b057 100644 --- a/src/main/java/emt/client/renderer/RenderLaser.java +++ b/src/main/java/emt/client/renderer/RenderLaser.java @@ -15,12 +15,12 @@ public class RenderLaser extends Render { private static final ResourceLocation laserTexture = new ResourceLocation(EMT.TEXTURE_PATH, "textures/models/lasermodel.png"); @Override - public void doRender(Entity entityLaser, double x, double y, double z, float par8, float par9) { + public void doRender(Entity entityLaser, double x, double y, double z, float par8, float pTick) { this.bindEntityTexture(entityLaser); GL11.glPushMatrix(); GL11.glTranslated(x, y, z); - GL11.glRotatef(entityLaser.prevRotationYaw + (entityLaser.rotationYaw - entityLaser.prevRotationYaw) * par9 - 90, 0, 1, 0); - GL11.glRotatef(entityLaser.prevRotationPitch + (entityLaser.rotationPitch - entityLaser.prevRotationPitch) * par9, 0, 0, 1); + GL11.glRotatef(entityLaser.rotationYaw - 90, 0, 1, 0); + GL11.glRotatef(entityLaser.rotationPitch, 0, 0, 1); Tessellator tess = Tessellator.instance; byte b0 = 0; float f2 = 0.4f; diff --git a/src/main/java/emt/entity/EntityLaser.java b/src/main/java/emt/entity/EntityLaser.java index 9f23ee0..d93625f 100644 --- a/src/main/java/emt/entity/EntityLaser.java +++ b/src/main/java/emt/entity/EntityLaser.java @@ -1,7 +1,10 @@ package emt.entity; +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.common.registry.IThrowableEntity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -18,15 +21,15 @@ import net.minecraft.world.World; import java.util.List; -public class EntityLaser extends Entity implements IProjectile { +public class EntityLaser extends Entity implements IThrowableEntity, IProjectile { private Block inTile; public Entity shootingEntity; - private int xTile = -1; - private int yTile = -1; - private int zTile = -1; - private int inData; - private boolean inGround; + 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; @@ -38,15 +41,6 @@ public class EntityLaser extends Entity implements IProjectile { this.setSize(0.5F, 0.5F); } - public EntityLaser(World world, double x, double y, double z) { - super(world); - - this.renderDistanceWeight = 10.0D; - this.setSize(0.5F, 0.5F); - this.setPosition(x, y, z); - this.yOffset = 0.0F; - } - public EntityLaser(World world, EntityLivingBase entity, float speed) { super(world); this.renderDistanceWeight = 10.0D; @@ -57,14 +51,15 @@ public class EntityLaser extends Entity implements IProjectile { 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.setPosition(this.posX, this.posY, this.posZ); 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.5F, 1.0F); + + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, 1.0F); } - + public void setExplosionStrengthModifier(float f) { explosionStrength = f; } @@ -75,22 +70,9 @@ public class EntityLaser extends Entity implements IProjectile { @Override public void setThrowableHeading(double x, double y, double z, float speed, float scale) { - float len = MathHelper.sqrt_double(x * x + y * y + z * z); - x /= (double) len; - y /= (double) len; - z /= (double) len; - x += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) scale; - y += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) scale; - z += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) scale; - x *= (double) speed; - y *= (double) speed; - z *= (double) speed; - this.motionX = x; - this.motionY = y; - this.motionZ = z; - float f3 = MathHelper.sqrt_double(x * x + z * z); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(y, (double) f3) * 180.0D / Math.PI); + this.motionX = x * speed; + this.motionY = y * speed; + this.motionZ = z * speed; this.ticksInGround = 0; } @@ -101,33 +83,20 @@ public class EntityLaser extends Entity implements IProjectile { } @SideOnly(Side.CLIENT) + @Override public void setVelocity(double velX, double velY, double velZ) { this.motionX = velX; this.motionY = velY; this.motionZ = velZ; - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(velX + velZ); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(velX, velZ) / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(velY, (double) f) / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } } @Override public void onUpdate() { super.onUpdate(); - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); - } - 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); @@ -136,24 +105,22 @@ public class EntityLaser extends Entity implements IProjectile { this.inGround = true; } } - Block tile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); - tile.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); - AxisAlignedBB axisalignedbb = tile.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); + block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); + AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { this.inGround = true; } if (this.inGround) { - Block j = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); 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 (j == this.inTile && k == this.inData) { + if (block == this.inTile && k == this.meta) { ++this.ticksInGround; if (this.ticksInGround == 1200) { @@ -185,14 +152,14 @@ public class EntityLaser extends Entity implements IProjectile { 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 f1; + float down; for (l = 0; l < list.size(); ++l) { Entity entity1 = (Entity) list.get(l); if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) f1, (double) f1, (double) f1); + down = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) down, (double) down, (double) down); MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3next, vec3); if (movingobjectposition1 != null) { @@ -234,7 +201,7 @@ public class EntityLaser extends Entity implements IProjectile { this.yTile = movingobjectposition.blockY; this.zTile = movingobjectposition.blockZ; this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); - this.inData = this.worldObj.getBlockMetadata(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; @@ -266,10 +233,6 @@ public class EntityLaser extends Entity implements IProjectile { this.prevRotationYaw += 360.0F; } - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; - float f4 = 0.99F; - f1 = 0.05F; if (this.isInWater()) { for (int j1 = 0; j1 < 4; ++j1) { @@ -277,13 +240,7 @@ public class EntityLaser extends Entity implements IProjectile { 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); } - f4 = 0.8F; } - - this.motionX *= (double) f4; - this.motionY *= (double) f4; - this.motionZ *= (double) f4; - this.motionY -= (double) f1; this.setPosition(this.posX, this.posY, this.posZ); } } @@ -294,7 +251,7 @@ public class EntityLaser extends Entity implements IProjectile { 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.inData); + nbt.setByte("inData", (byte) this.meta); nbt.setBoolean("inGround", this.inGround); nbt.setFloat("explosionStrength", this.explosionStrength); } @@ -305,12 +262,12 @@ public class EntityLaser extends Entity implements IProjectile { this.yTile = nbt.getShort("yTile"); this.zTile = nbt.getShort("zTile"); this.inTile = Block.getBlockById(nbt.getShort("inTile")); - this.inData = nbt.getByte("inData") & 255; + this.meta = nbt.getByte("inData") & 255; this.inGround = nbt.getBoolean("inGround"); this.explosionStrength = nbt.getFloat("explosionStrength"); } - public void onCollide(Entity par1Entity) { + public void onCollide(Entity entity) { if (!this.worldObj.isRemote) { this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, explosionStrength, true); } @@ -321,4 +278,14 @@ public class EntityLaser extends Entity implements IProjectile { public float getShadowSize() { return 0.0F; } + + @Override + public Entity getThrower() { + return shootingEntity; + } + + @Override + public void setThrower(Entity entity) { + shootingEntity = entity; + } } \ No newline at end of file diff --git a/src/main/java/emt/item/focus/ItemExplosionFocus.java b/src/main/java/emt/item/focus/ItemExplosionFocus.java index 81b173b..a32baa6 100644 --- a/src/main/java/emt/item/focus/ItemExplosionFocus.java +++ b/src/main/java/emt/item/focus/ItemExplosionFocus.java @@ -40,7 +40,7 @@ public class ItemExplosionFocus extends ItemBaseFocus { if (player.capabilities.isCreativeMode || wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true)) { if (!world.isRemote) { EntityLaser laser; - laser = new EntityLaser(world, player, 2); + laser = new EntityLaser(world, player, 1); laser.setExplosionStrengthModifier(getUpgradeLevel(itemstack, FocusUpgradeType.potency) * 0.5f + 1); world.spawnEntityInWorld(laser); }