diff --git a/src/main/java/openblocks/common/entity/EntityItemProjectile.java b/src/main/java/openblocks/common/entity/EntityItemProjectile.java index c5f8f0208..369bb27df 100644 --- a/src/main/java/openblocks/common/entity/EntityItemProjectile.java +++ b/src/main/java/openblocks/common/entity/EntityItemProjectile.java @@ -39,64 +39,16 @@ public static void registerFixes(DataFixer fixer) { @Override public void onUpdate() { - final double x = posX; - final double y = posY; - final double z = posZ; - - final double vx = motionX; - final double vy = motionY; - final double vz = motionZ; - // let vanilla run super.onUpdate(); - if (!isDead) return; - // and then overwrite position calculations - - this.posX = x; - this.posY = y; - this.posZ = z; - - this.motionX = vx; - this.motionY = vy; - this.motionZ = vz; - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.motionY -= 0.03999999910593033D; - - move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); - - boolean hasMoved = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ; - if (hasMoved || this.ticksExisted % 25 == 0) { - if (this.world.getBlockState(new BlockPos(this)).getMaterial() == Material.LAVA) { - this.motionY = 0.20000000298023224D; - this.motionX = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F; - this.motionZ = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F; - playSound(SoundEvents.ENTITY_GENERIC_BURN, 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); - } + // Remove the air drag that EntityItem.onUpdate adds to our velocity + if (!this.onGround) { + double f = 0.98F; + this.motionX = this.motionX / f; + this.motionY = this.motionY / f; + this.motionZ = this.motionZ / f; } - - // Zero Air Friction - float f = 1F; - - // Keep ground friction - if (this.onGround) { - BlockPos underPos = new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ)); - IBlockState underState = this.world.getBlockState(underPos); - f = underState.getBlock().getSlipperiness(underState, this.world, underPos, this) * 0.98F; - } - - this.motionX *= f; - // Y would there be Y resistance :D - // ^ not my pun, I'm just porting :P, ~B - // motionY *= 0.98; - this.motionZ *= f; - - if (this.onGround) this.motionY *= -0.5D; - - handleWaterMovement(); } -} +} \ No newline at end of file diff --git a/src/main/java/openblocks/common/tileentity/TileEntityCannon.java b/src/main/java/openblocks/common/tileentity/TileEntityCannon.java index 6c3d4f551..b11411af7 100644 --- a/src/main/java/openblocks/common/tileentity/TileEntityCannon.java +++ b/src/main/java/openblocks/common/tileentity/TileEntityCannon.java @@ -127,8 +127,17 @@ private void fireStack(@Nonnull ItemStack stack) { final ITriggerable rpc = createServerRpcProxy(ITriggerable.class); rpc.trigger(); + // spawn the item approximately at the end of the barrel + double yawr = Math.toRadians(currentYaw); + double pitchr = Math.toRadians(currentPitch); + double barrelLength = 0.5; + double barrelBaseHeight = 0.3; + double x = pos.getX() + 0.5 - Math.sin(yawr) * Math.cos(pitchr) * barrelLength; + double y = pos.getY() + barrelBaseHeight + Math.sin(pitchr) * barrelLength; + double z = pos.getZ() + 0.5 + Math.cos(yawr) * Math.cos(pitchr) * barrelLength; + // projectileOrigin is not used here, it's used for the calculations below. - EntityItem item = new EntityItemProjectile(world, pos.getX() + 0.5, pos.getY(), pos.getZ(), stack); + EntityItem item = new EntityItemProjectile(world, x, y, z, stack); item.setDefaultPickupDelay(); // Now that we generate vectors instead of eular angles, this should be revised.