Changed EntityTileDamage to extend entityLiving
This allow for entities to target this entity if it was an attack source
This commit is contained in:
parent
0c6b9153ca
commit
e4327c7cc2
2 changed files with 22 additions and 25 deletions
|
@ -4,6 +4,7 @@ import universalelectricity.core.vector.Vector3;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.potion.PotionEffect;
|
import net.minecraft.potion.PotionEffect;
|
||||||
|
@ -27,7 +28,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
* @author DarkGuardsman
|
* @author DarkGuardsman
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnData
|
public class EntityTileDamage extends EntityLiving implements IEntityAdditionalSpawnData
|
||||||
{
|
{
|
||||||
|
|
||||||
private TileEntity host;
|
private TileEntity host;
|
||||||
|
@ -120,7 +121,7 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
|
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
|
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
@ -151,25 +152,12 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void entityInit()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeCollidedWith()
|
public boolean canBeCollidedWith()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public boolean func_98034_c(EntityPlayer par1EntityPlayer)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public boolean isInRangeToRenderVec3D(Vec3 par1Vec3)
|
public boolean isInRangeToRenderVec3D(Vec3 par1Vec3)
|
||||||
|
@ -209,4 +197,10 @@ public class EntityTileDamage extends Entity implements IEntityAdditionalSpawnDa
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHealth()
|
||||||
|
{
|
||||||
|
return this.host != null && host instanceof IHpTile ? ((IHpTile) host).getMaxHealth() : 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,14 @@
|
||||||
package dark.library.damage;
|
package dark.library.damage;
|
||||||
|
|
||||||
import universalelectricity.prefab.CustomDamageSource;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.projectile.EntityArrow;
|
import universalelectricity.prefab.CustomDamageSource;
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
import net.minecraft.util.EntityDamageSourceIndirect;
|
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
|
||||||
|
|
||||||
public class TileDamageSource extends CustomDamageSource
|
public class TileDamageSource extends CustomDamageSource
|
||||||
{
|
{
|
||||||
protected Object damageSource;
|
protected Object damageSource;
|
||||||
|
|
||||||
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)
|
public TileDamageSource(String damageName, Object attacker)
|
||||||
{
|
{
|
||||||
super(damageName);
|
super(damageName);
|
||||||
|
@ -25,7 +18,7 @@ public class TileDamageSource extends CustomDamageSource
|
||||||
@Override
|
@Override
|
||||||
public Entity getEntity()
|
public Entity getEntity()
|
||||||
{
|
{
|
||||||
return damageSource instanceof Entity ? (Entity) damageSource : null;
|
return damageSource instanceof Entity ? ((Entity) damageSource) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,4 +26,14 @@ public class TileDamageSource extends CustomDamageSource
|
||||||
{
|
{
|
||||||
return this.damageSource != null && this.damageSource instanceof EntityLiving && !(this.damageSource instanceof EntityPlayer);
|
return this.damageSource != null && this.damageSource instanceof EntityLiving && !(this.damageSource instanceof EntityPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TileDamageSource doBulletDamage(Object object)
|
||||||
|
{
|
||||||
|
return (TileDamageSource) ((CustomDamageSource) new TileDamageSource("Bullets", object).setProjectile()).setDeathMessage("%1$s was filled with holes!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TileDamageSource doLaserDamage(Object object)
|
||||||
|
{
|
||||||
|
return (TileDamageSource) ((CustomDamageSource) new TileDamageSource("Laser", object).setProjectile()).setDeathMessage("%1$s was vaporized!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue