Flamethrowers now properly check collisions, these things are awesome

This commit is contained in:
Aidan C. Brady 2015-02-25 10:02:04 -05:00
parent f5dadf443a
commit 1675b9b1cf
3 changed files with 14 additions and 13 deletions

View file

@ -59,12 +59,12 @@ public class LaserManager
{ {
List<ItemStack> ret = null; List<ItemStack> ret = null;
Block blockHit = blockCoord.getBlock(world); Block blockHit = blockCoord.getBlock(world);
if(dropAtBlock) if(dropAtBlock)
{ {
blockHit.dropBlockAsItem(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockCoord.getMetadata(world), 0); blockHit.dropBlockAsItem(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockCoord.getMetadata(world), 0);
} }
else else {
{
ret = blockHit.getDrops(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockCoord.getMetadata(world), 0); ret = blockHit.getDrops(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockCoord.getMetadata(world), 0);
} }
blockHit.breakBlock(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockHit, blockCoord.getMetadata(world)); blockHit.breakBlock(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockHit, blockCoord.getMetadata(world));

View file

@ -28,8 +28,8 @@ import io.netty.buffer.ByteBuf;
public class EntityFlame extends Entity implements IEntityAdditionalSpawnData public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
{ {
public static final int LIFESPAN = 60; public static final int LIFESPAN = 80;
public static final int DAMAGE = 4; public static final int DAMAGE = 10;
public Entity owner = null; public Entity owner = null;
@ -53,7 +53,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
Pos3D mergedVec = playerPos.clone().translate(flameVec); Pos3D mergedVec = playerPos.clone().translate(flameVec);
setPosition(mergedVec.xPos, mergedVec.yPos, mergedVec.zPos); setPosition(mergedVec.xPos, mergedVec.yPos, mergedVec.zPos);
Pos3D motion = new Pos3D(0.2, 0.2, 0.2); Pos3D motion = new Pos3D(0.4, 0.4, 0.4);
motion.multiply(new Pos3D(player.getLookVec())); motion.multiply(new Pos3D(player.getLookVec()));
setHeading(motion); setHeading(motion);
@ -94,6 +94,8 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
posY += motionY; posY += motionY;
posZ += motionZ; posZ += motionZ;
setPosition(posX, posY, posZ);
calculateVector(); calculateVector();
if(ticksExisted > LIFESPAN) if(ticksExisted > LIFESPAN)
@ -123,9 +125,9 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
for(Entity entity1 : (List<Entity>)list) for(Entity entity1 : (List<Entity>)list)
{ {
if((entity1 instanceof EntityItem || entity1.canBeCollidedWith()) && (entity1 != owner || ticksExisted >= 5)) if((entity1 instanceof EntityItem || entity1.canBeCollidedWith()) && entity1 != owner)
{ {
float boundsScale = 0.4F; float boundsScale = 0.3F;
AxisAlignedBB newBounds = entity1.boundingBox.expand((double)boundsScale, (double)boundsScale, (double)boundsScale); AxisAlignedBB newBounds = entity1.boundingBox.expand((double)boundsScale, (double)boundsScale, (double)boundsScale);
MovingObjectPosition movingobjectposition1 = newBounds.calculateIntercept(localVec, motionVec); MovingObjectPosition movingobjectposition1 = newBounds.calculateIntercept(localVec, motionVec);
@ -159,11 +161,11 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
if(mop != null) if(mop != null)
{ {
if(mop.entityHit != null) if(mop.entityHit != null && !mop.entityHit.isImmuneToFire())
{ {
if(mop.entityHit instanceof EntityItem) if(mop.entityHit instanceof EntityItem)
{ {
if(mop.entityHit.ticksExisted > 40) if(mop.entityHit.ticksExisted > 80)
{ {
if(!smeltItem((EntityItem)mop.entityHit)) if(!smeltItem((EntityItem)mop.entityHit))
{ {

View file

@ -43,8 +43,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj);
} }
} }
else else {
{
if(getEnergy() >= usage.laserUsage) if(getEnergy() >= usage.laserUsage)
{ {
if(!on) if(!on)
@ -67,6 +66,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
Block blockHit = hitCoord.getBlock(worldObj); Block blockHit = hitCoord.getBlock(worldObj);
TileEntity tileHit = hitCoord.getTileEntity(worldObj); TileEntity tileHit = hitCoord.getTileEntity(worldObj);
float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord);
if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig())))
{ {
diggingProgress += usage.laserUsage; diggingProgress += usage.laserUsage;
@ -76,8 +76,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
LaserManager.breakBlock(hitCoord, true, worldObj); LaserManager.breakBlock(hitCoord, true, worldObj);
diggingProgress = 0; diggingProgress = 0;
} }
else else {
{
Minecraft.getMinecraft().effectRenderer.addBlockHitEffects(hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord, mop); Minecraft.getMinecraft().effectRenderer.addBlockHitEffects(hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord, mop);
} }
} }