Worked on custom damage and damage entity

This commit is contained in:
Robert Seifert 2013-06-09 05:33:55 -04:00
parent e33f0b98e3
commit a8d4560cba
3 changed files with 83 additions and 23 deletions

View file

@ -2,16 +2,23 @@ package dark.library.damage;
import universalelectricity.core.vector.Vector3;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Entity designed to take damage and apply it to the tile from an Entity. Simulates the tile is
@ -29,32 +36,21 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
public EntityTileDamage(World par1World)
{
super(par1World);
this.setSize(1F, 1F);
}
public EntityTileDamage(World par1World, TileEntity c)
{
this(par1World);
this.isImmuneToFire = true;
this.setPosition(c.xCoord + 0.5, c.yCoord + 0.5, c.zCoord + 0.5);
this.host = c;
this.setSize(1.1F, 1.1F);
}
@Override
protected void entityInit()
public EntityTileDamage(TileEntity c)
{
// TODO Auto-generated method stub
this(c.worldObj);
this.setPosition(c.xCoord + 0.5, c.yCoord, c.zCoord + 0.5);
this.host = c;
}
@Override
public boolean attackEntityFrom(DamageSource source, int ammount)
{
if (this.isEntityInvulnerable())
{
return false;
}
else if (this.host instanceof IHpTile)
if (this.host instanceof IHpTile)
{
return ((IHpTile) this.host).onDamageTaken(source, ammount);
}
@ -78,7 +74,7 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
this.setDead();
}
return false;
return true;
}
}
@ -113,11 +109,15 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
this.setDead();
return;
}
if (this.host instanceof IHpTile && !((IHpTile) this.host).isAlive())
else if (this.host instanceof IHpTile && !((IHpTile) this.host).isAlive())
{
this.setDead();
return;
}
else
{
this.setPosition(this.host.xCoord + 0.5, this.host.yCoord, this.host.zCoord + 0.5);
}
}
@Override
@ -127,6 +127,11 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
}
public void moveEntity(double par1, double par3, double par5)
{
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
@ -140,4 +145,56 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
return false;
}
@Override
public AxisAlignedBB getCollisionBox(Entity par1Entity)
{
return AxisAlignedBB.getBoundingBox(this.posX - .6, this.posY - .6, this.posZ - .6, this.posX + .6, this.posY + .6, this.posZ + .6);
}
@Override
protected void entityInit()
{
// TODO Auto-generated method stub
}
@Override
public boolean canBeCollidedWith()
{
return true;
}
@SideOnly(Side.CLIENT)
public boolean func_98034_c(EntityPlayer par1EntityPlayer)
{
return true;
}
@SideOnly(Side.CLIENT)
@Override
public boolean isInRangeToRenderVec3D(Vec3 par1Vec3)
{
return false;
}
@SideOnly(Side.CLIENT)
@Override
public boolean isInRangeToRenderDist(double par1)
{
return false;
}
@Override
public void setVelocity(double par1, double par3, double par5)
{
}
@Override
public boolean isInsideOfMaterial(Material par1Material)
{
return false;
}
}

View file

@ -13,8 +13,8 @@ public class TileDamageSource extends CustomDamageSource
{
protected Object damageSource;
public static final CustomDamageSource bullets = ((CustomDamageSource) new CustomDamageSource("Bullets")).setDeathMessage("%1$s was filled with holes!");
public static final CustomDamageSource laser = ((CustomDamageSource) new CustomDamageSource("Laser")).setDeathMessage("%1$s was vaporized!");
public static final CustomDamageSource bullets = ((CustomDamageSource) new CustomDamageSource("Bullets").setProjectile()).setDeathMessage("%1$s was filled with holes!");
public static final CustomDamageSource laser = ((CustomDamageSource) new CustomDamageSource("Laser").setFireDamage()).setDeathMessage("%1$s was vaporized!");
public TileDamageSource(String damageName, Object attacker)
{

View file

@ -186,7 +186,7 @@ public abstract class TileEntityTerminal extends TileEntityRunnableMachine imple
}
catch (Exception e)
{
FMLLog.severe("DarkLib>>>TerminalInstance>>>PacketReadError>>>ForTile>>>"+this.toString());
FMLLog.severe("DarkLib>>>TerminalInstance>>>PacketReadError>>>ForTile>>>" + this.toString());
e.printStackTrace();
}
}
@ -256,7 +256,10 @@ public abstract class TileEntityTerminal extends TileEntityRunnableMachine imple
}
if (removeList != null && removeList.size() > 0)
{
return this.users.removeAll(removeList);
boolean bool = this.users.removeAll(removeList);
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
return bool;
}
return false;
}