Started work on the base sentry prefab
going to actually stop here for the moment and pick this up later
This commit is contained in:
parent
41aa838510
commit
4acb350cfd
9 changed files with 127 additions and 59 deletions
|
@ -1,9 +1,25 @@
|
|||
package dark.api;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/** Applied to tile entities that are sentry guns
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public interface ISentryGun
|
||||
{
|
||||
/** Gets the type of sentry */
|
||||
public SentryType getType();
|
||||
|
||||
/** Gets the tileEntity this sentry is attached too. Null if its self supporting */
|
||||
public TileEntity getPlatform();
|
||||
|
||||
public static enum SentryType
|
||||
{
|
||||
/** Sentry guns that act like entities and are self moving */
|
||||
AUTOMATED(),
|
||||
/** Sentry guns that are manually moved by assisted input and are basically blocks */
|
||||
AIMED(),
|
||||
/** Sentry guns that are mounted by entities like players and are an extension of that entity */
|
||||
MOUNTED();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import dark.core.interfaces.IDamageableTile;
|
|||
public class EntityTileDamage extends EntityLiving implements IEntityAdditionalSpawnData
|
||||
{
|
||||
|
||||
private TileEntity host;
|
||||
public TileEntity host;
|
||||
int hp = 100;
|
||||
|
||||
public EntityTileDamage(World par1World)
|
||||
|
@ -46,6 +46,18 @@ public class EntityTileDamage extends EntityLiving implements IEntityAdditionalS
|
|||
this.host = c;
|
||||
}
|
||||
|
||||
public EntityTileDamage(Vector3 v, TileEntity c)
|
||||
{
|
||||
this(c.worldObj);
|
||||
this.setPosition(v);
|
||||
this.host = c;
|
||||
}
|
||||
|
||||
public void setPosition(Vector3 vec)
|
||||
{
|
||||
this.setPosition(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float ammount)
|
||||
{
|
||||
|
|
|
@ -2,11 +2,12 @@ package dark.core.prefab.sentry;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import com.builtbroken.common.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.builtbroken.common.Pair;
|
||||
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.machine.BlockMachine;
|
||||
import dark.core.registration.ModObjectRegistry;
|
||||
|
@ -94,10 +95,6 @@ public class BlockSentryGun extends BlockMachine
|
|||
sentryBlockIds[b] = block.blockID;
|
||||
}
|
||||
}
|
||||
for (int t = 0; t < sentryGuns.length; t++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package dark.core.prefab.sentry;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** Since we are going to need an entity for the sentries to take damage with we are actually going
|
||||
* to do more with the entity than redirect damage.
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class EntitySentryGun extends Entity
|
||||
{
|
||||
|
||||
public EntitySentryGun(World par1World)
|
||||
{
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,11 @@
|
|||
package dark.core.prefab.sentry;
|
||||
|
||||
public class TileEntityAutoSentry
|
||||
{
|
||||
|
||||
public class TileEntityAutoSentry extends TileEntitySentry
|
||||
{
|
||||
@Override
|
||||
public SentryType getType()
|
||||
{
|
||||
return SentryType.AUTOMATED;
|
||||
}
|
||||
}
|
||||
|
|
8
src/dark/core/prefab/sentry/TileEntityGunPlatform.java
Normal file
8
src/dark/core/prefab/sentry/TileEntityGunPlatform.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package dark.core.prefab.sentry;
|
||||
|
||||
import dark.core.prefab.terminal.TileEntityTerminal;
|
||||
|
||||
public class TileEntityGunPlatform extends TileEntityTerminal
|
||||
{
|
||||
|
||||
}
|
|
@ -1,6 +1,11 @@
|
|||
package dark.core.prefab.sentry;
|
||||
|
||||
public class TileEntityMountedSentry
|
||||
{
|
||||
|
||||
public class TileEntityMountedSentry extends TileEntitySentry
|
||||
{
|
||||
@Override
|
||||
public SentryType getType()
|
||||
{
|
||||
return SentryType.MOUNTED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,77 @@
|
|||
package dark.core.prefab.sentry;
|
||||
|
||||
public class TileEntitySentry
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
import dark.api.ISentryGun;
|
||||
import dark.core.prefab.EntityTileDamage;
|
||||
|
||||
public class TileEntitySentry extends TileEntityAdvanced implements ISentryGun
|
||||
{
|
||||
protected EntityTileDamage entitySentry = null;
|
||||
protected TileEntityGunPlatform platform;
|
||||
protected ForgeDirection mountingSide = ForgeDirection.DOWN;
|
||||
protected boolean isAlive = true;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (this.isAlive && this.entitySentry == null)
|
||||
{
|
||||
this.getDamageEntity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SentryType getType()
|
||||
{
|
||||
return SentryType.AIMED;
|
||||
}
|
||||
|
||||
public EntityTileDamage getDamageEntity()
|
||||
{
|
||||
return this.getDamageEntity(isAlive);
|
||||
}
|
||||
|
||||
public EntityTileDamage getDamageEntity(boolean create)
|
||||
{
|
||||
if (entitySentry == null || entitySentry.isDead && create)
|
||||
{
|
||||
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
|
||||
List<EntityTileDamage> list = this.worldObj.getEntitiesWithinAABB(EntityTileDamage.class, box);
|
||||
for (EntityTileDamage entity : list)
|
||||
{
|
||||
if (!entity.isDead && (entity.host == null || entity.host == this))
|
||||
{
|
||||
entity.host = this;
|
||||
this.entitySentry = entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.entitySentry = new EntityTileDamage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return entitySentry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getPlatform()
|
||||
{
|
||||
Vector3 mountVec = new Vector3(this).modifyPositionFromSide(mountingSide);
|
||||
if (platform == null || platform.isInvalid() || !new Vector3(platform).equals(mountVec))
|
||||
{
|
||||
TileEntity entity = mountVec.getTileEntity(this.worldObj);
|
||||
if (entity instanceof TileEntityGunPlatform)
|
||||
{
|
||||
this.platform = (TileEntityGunPlatform) entity;
|
||||
}
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package dark.core.prefab.sentry;
|
||||
|
||||
public class TileEntityTerminal
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in a new issue