worked on some prefabs

This commit is contained in:
Robert 2013-11-21 23:03:39 -05:00
parent 676ce13d34
commit 574491d126
8 changed files with 184 additions and 4 deletions

BIN
docs/JHC-0803-lg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
models/TankBodyA.tcn Normal file

Binary file not shown.

10
src/dark/api/IDrone.java Normal file
View file

@ -0,0 +1,10 @@
package dark.api;
/** Drone does not imply robot it simply means entity by which is controlled by another entity such
* as a player or a hivemind.
*
* @author DarkGuardsman */
public interface IDrone
{
}

View file

@ -12,7 +12,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.client.models.ModelTestCar;
import dark.core.common.DarkMain;
import dark.core.prefab.EntityAdvanced;
import dark.core.prefab.entities.EntityAdvanced;
@SideOnly(Side.CLIENT)
public class RenderTestCar extends Render

View file

@ -1,4 +1,4 @@
package dark.core.prefab;
package dark.core.prefab.entities;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -0,0 +1,170 @@
package dark.core.prefab.entities;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.electricity.ElectricityPack;
import dark.api.IDrone;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.RangedAttribute;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class EntityDroneBase extends EntityCreature implements IDrone, IElectrical, IElectricalStorage
{
private float energyStored = 0.0f;
public static final Attribute maxEnergy = (new RangedAttribute("drone.maxEnergy", 100.0D, 0.0D, Double.MAX_VALUE)).func_111117_a("Max Energy").setShouldWatch(true);
public EntityDroneBase(World par1World)
{
super(par1World);
this.getNavigator().setAvoidsWater(true);
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(100.0D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.25D);
}
@Override
protected String getLivingSound()
{
return "none";
}
@Override
protected String getHurtSound()
{
return "none";
}
@Override
protected String getDeathSound()
{
return "none";
}
@Override
protected boolean canDespawn()
{
return false;
}
public boolean consumePower(float watts, boolean doDrain)
{
if (this.getEnergyStored() >= watts)
{
if (doDrain)
{
this.setEnergyStored(this.getEnergyStored() - watts);
}
return true;
}
return false;
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return false;
}
@Override
public void setEnergyStored(float energy)
{
this.energyStored = energy;
}
@Override
public float getEnergyStored()
{
return this.energyStored;
}
@Override
public float getMaxEnergyStored()
{
return 10;
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
{
if (receive != null && this.canConnect(from))
{
return this.receiveElectricity(receive.getWatts(), doReceive);
}
return 0;
}
/** A non-side specific version of receiveElectricity for you to optionally use it internally. */
public float receiveElectricity(ElectricityPack receive, boolean doReceive)
{
if (receive != null)
{
float prevEnergyStored = this.getEnergyStored();
float newStoredEnergy = Math.min(this.getEnergyStored() + receive.getWatts(), this.getMaxEnergyStored());
if (doReceive)
{
this.setEnergyStored(newStoredEnergy);
}
return Math.max(newStoredEnergy - prevEnergyStored, 0);
}
return 0;
}
public float receiveElectricity(float energy, boolean doReceive)
{
return this.receiveElectricity(ElectricityPack.getFromWatts(energy, this.getVoltage()), doReceive);
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
return null;
}
@Override
public float getRequest(ForgeDirection direction)
{
return this.getEnergyStored() - this.getMaxEnergyStored();
}
@Override
public float getProvide(ForgeDirection direction)
{
return 0;
}
@Override
public float getVoltage()
{
return 30;
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.energyStored = nbt.getFloat("energyStored");
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setFloat("energyStored", this.energyStored);
}
}

View file

@ -1,4 +1,4 @@
package dark.core.prefab;
package dark.core.prefab.entities;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -22,7 +22,7 @@ import dark.core.interfaces.IControlReceiver;
import dark.core.network.ISimplePacketReceiver;
import dark.core.network.PacketManagerEntity;
import dark.core.network.PacketManagerKeyEvent;
import dark.core.prefab.EntityAdvanced;
import dark.core.prefab.entities.EntityAdvanced;
public abstract class EntityVehicle extends EntityAdvanced implements IControlReceiver, ISimplePacketReceiver
{