Update IC2 API, minor enhancements and fixes
This commit is contained in:
parent
155978aefd
commit
9735363dc1
8 changed files with 156 additions and 56 deletions
|
@ -19,6 +19,9 @@ import ic2.api.energy.tile.IEnergySink;
|
|||
* It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a
|
||||
* one-time configurable input energy buffer, thus providing a common use case for machines.
|
||||
*
|
||||
* Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended.
|
||||
* The delegate can be extended with additional functionality through a sub class though.
|
||||
*
|
||||
* The constraints set by BasicSink like the strict tank-like energy buffering should provide a
|
||||
* more easy to use and stable interface than using IEnergySink directly while aiming for
|
||||
* optimal performance.
|
||||
|
@ -42,14 +45,14 @@ import ic2.api.energy.tile.IEnergySink;
|
|||
*
|
||||
* @Override
|
||||
* public void invalidate() {
|
||||
* ic2EnergySink.onInvalidate(); // notify the energy sink
|
||||
* ic2EnergySink.invalidate(); // notify the energy sink
|
||||
* ...
|
||||
* super.invalidate(); // this is important for mc!
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void onChunkUnload() {
|
||||
* ic2EnergySink.onOnChunkUnload(); // notify the energy sink
|
||||
* ic2EnergySink.onChunkUnload(); // notify the energy sink
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
|
@ -57,7 +60,7 @@ import ic2.api.energy.tile.IEnergySink;
|
|||
* public void readFromNBT(NBTTagCompound tag) {
|
||||
* super.readFromNBT(tag);
|
||||
*
|
||||
* ic2EnergySink.onReadFromNbt(tag);
|
||||
* ic2EnergySink.readFromNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
|
@ -65,15 +68,15 @@ import ic2.api.energy.tile.IEnergySink;
|
|||
* public void writeToNBT(NBTTagCompound tag) {
|
||||
* super.writeToNBT(tag);
|
||||
*
|
||||
* ic2EnergySink.onWriteToNbt(tag);
|
||||
* ic2EnergySink.writeToNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void updateEntity() {
|
||||
* ic2EnergySink.onUpdateEntity(); // notify the energy sink
|
||||
* ic2EnergySink.updateEntity(); // notify the energy sink
|
||||
* ...
|
||||
* if (ic2EnergySink.addEnergy(5)) { // use 5 eu from the sink's buffer this tick
|
||||
* if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick
|
||||
* ... // do something with the energy
|
||||
* }
|
||||
* ...
|
||||
|
@ -105,16 +108,17 @@ public class BasicSink extends TileEntity implements IEnergySink {
|
|||
// in-world te forwards >>
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's updateEntity(), used for creating the energy net link.
|
||||
* Either onUpdateEntity or onLoaded have to be used.
|
||||
* Forward for the base TileEntity's updateEntity(), used for creating the energy net link.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
public void onUpdateEntity() {
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!addedToEnet) onLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the TileEntity finished loaded, for advanced uses.
|
||||
* Either onUpdateEntity or onLoaded have to be used.
|
||||
* Notification that the base TileEntity finished loaded, for advanced uses.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
public void onLoaded() {
|
||||
if (!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
|
@ -130,10 +134,22 @@ public class BasicSink extends TileEntity implements IEnergySink {
|
|||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both onInvalidate and onOnChunkUnload have to be used.
|
||||
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
public void onInvalidate() {
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (addedToEnet) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
|
||||
|
@ -142,30 +158,32 @@ public class BasicSink extends TileEntity implements IEnergySink {
|
|||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both onInvalidate and onOnChunkUnload have to be used.
|
||||
*/
|
||||
public void onOnChunkUnload() {
|
||||
onInvalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's readFromNBT(), used for loading the state.
|
||||
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
|
||||
*/
|
||||
public void onReadFromNbt(NBTTagCompound tag) {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagCompound data = tag.getCompoundTag("IC2BasicSink");
|
||||
|
||||
energyStored = data.getDouble("energy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's writeToNBT(), used for saving the state.
|
||||
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
|
||||
*/
|
||||
public void onWriteToNbt(NBTTagCompound tag) {
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
try {
|
||||
super.writeToNBT(tag);
|
||||
} catch (RuntimeException e) {
|
||||
// happens if this is a delegate, ignore
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
data.setDouble("energy", energyStored);
|
||||
|
@ -225,6 +243,35 @@ public class BasicSink extends TileEntity implements IEnergySink {
|
|||
|
||||
// << methods for using this adapter
|
||||
|
||||
// backwards compatibility (ignore these) >>
|
||||
|
||||
@Deprecated
|
||||
public void onUpdateEntity() {
|
||||
updateEntity();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onInvalidate() {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onOnChunkUnload() {
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onReadFromNbt(NBTTagCompound tag) {
|
||||
readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onWriteToNbt(NBTTagCompound tag) {
|
||||
writeToNBT(tag);
|
||||
}
|
||||
|
||||
// << backwards compatibility
|
||||
|
||||
// ******************************
|
||||
// *** Methods for use by ic2 ***
|
||||
// ******************************
|
||||
|
|
|
@ -21,6 +21,9 @@ import ic2.api.item.ElectricItem;
|
|||
* It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a
|
||||
* one-time configurable output energy buffer, thus providing a common use case for generators.
|
||||
*
|
||||
* Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended.
|
||||
* The delegate can be extended with additional functionality through a sub class though.
|
||||
*
|
||||
* The constraints set by BasicSource like the strict tank-like energy buffering should provide a
|
||||
* more easy to use and stable interface than using IEnergySource directly while aiming for
|
||||
* optimal performance.
|
||||
|
@ -44,14 +47,14 @@ import ic2.api.item.ElectricItem;
|
|||
*
|
||||
* @Override
|
||||
* public void invalidate() {
|
||||
* ic2EnergySource.onInvalidate(); // notify the energy source
|
||||
* ic2EnergySource.invalidate(); // notify the energy source
|
||||
* ...
|
||||
* super.invalidate(); // this is important for mc!
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void onChunkUnload() {
|
||||
* ic2EnergySource.onOnChunkUnload(); // notify the energy source
|
||||
* ic2EnergySource.onChunkUnload(); // notify the energy source
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
|
@ -59,7 +62,7 @@ import ic2.api.item.ElectricItem;
|
|||
* public void readFromNBT(NBTTagCompound tag) {
|
||||
* super.readFromNBT(tag);
|
||||
*
|
||||
* ic2EnergySource.onReadFromNbt(tag);
|
||||
* ic2EnergySource.readFromNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
|
@ -67,13 +70,13 @@ import ic2.api.item.ElectricItem;
|
|||
* public void writeToNBT(NBTTagCompound tag) {
|
||||
* super.writeToNBT(tag);
|
||||
*
|
||||
* ic2EnergySource.onWriteToNbt(tag);
|
||||
* ic2EnergySource.writeToNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void updateEntity() {
|
||||
* ic2EnergySource.onUpdateEntity(); // notify the energy source
|
||||
* ic2EnergySource.updateEntity(); // notify the energy source
|
||||
* ...
|
||||
* ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick
|
||||
* ...
|
||||
|
@ -92,7 +95,7 @@ public class BasicSource extends TileEntity implements IEnergySource {
|
|||
/**
|
||||
* Constructor for a new BasicSource delegate.
|
||||
*
|
||||
* @param parent TileEntity represented by this energy source.
|
||||
* @param parent Base TileEntity represented by this energy source.
|
||||
* @param capacity Maximum amount of eu to store.
|
||||
* @param tier IC2 tier, 1=LV, 2=MV, ...
|
||||
*/
|
||||
|
@ -107,16 +110,17 @@ public class BasicSource extends TileEntity implements IEnergySource {
|
|||
// in-world te forwards >>
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's updateEntity(), used for creating the energy net link.
|
||||
* Either onUpdateEntity or onLoaded have to be used.
|
||||
* Forward for the base TileEntity's updateEntity(), used for creating the energy net link.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
public void onUpdateEntity() {
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!addedToEnet) onLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the TileEntity finished loaded, for advanced uses.
|
||||
* Either onUpdateEntity or onLoaded have to be used.
|
||||
* Notification that the base TileEntity finished loading, for advanced uses.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
public void onLoaded() {
|
||||
if (!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
|
@ -132,10 +136,22 @@ public class BasicSource extends TileEntity implements IEnergySource {
|
|||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both onInvalidate and onOnChunkUnload have to be used.
|
||||
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
public void onInvalidate() {
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (addedToEnet) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
|
||||
|
@ -144,30 +160,32 @@ public class BasicSource extends TileEntity implements IEnergySource {
|
|||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both onInvalidate and onOnChunkUnload have to be used.
|
||||
*/
|
||||
public void onOnChunkUnload() {
|
||||
onInvalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's readFromNBT(), used for loading the state.
|
||||
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
|
||||
*/
|
||||
public void onReadFromNbt(NBTTagCompound tag) {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagCompound data = tag.getCompoundTag("IC2BasicSource");
|
||||
|
||||
energyStored = data.getDouble("energy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the TileEntity's writeToNBT(), used for saving the state.
|
||||
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
|
||||
*/
|
||||
public void onWriteToNbt(NBTTagCompound tag) {
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
try {
|
||||
super.writeToNBT(tag);
|
||||
} catch (RuntimeException e) {
|
||||
// happens if this is a delegate, ignore
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
data.setDouble("energy", energyStored);
|
||||
|
@ -241,6 +259,35 @@ public class BasicSource extends TileEntity implements IEnergySource {
|
|||
|
||||
// << methods for using this adapter
|
||||
|
||||
// backwards compatibility (ignore these) >>
|
||||
|
||||
@Deprecated
|
||||
public void onUpdateEntity() {
|
||||
updateEntity();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onInvalidate() {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onOnChunkUnload() {
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onReadFromNbt(NBTTagCompound tag) {
|
||||
readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onWriteToNbt(NBTTagCompound tag) {
|
||||
writeToNBT(tag);
|
||||
}
|
||||
|
||||
// << backwards compatibility
|
||||
|
||||
// ******************************
|
||||
// *** Methods for use by ic2 ***
|
||||
// ******************************
|
||||
|
|
|
@ -332,8 +332,7 @@ public class MekanismRenderer
|
|||
{
|
||||
return Arrays.equals(boolArray, (boolean[])o);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
|||
renderAModelAt((TileEntityLogisticalTransporter)tileEntity, x, y, z, partialTick);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter" + (tileEntity.isActive ? "Active" : "") + ".png"));
|
||||
|
|
|
@ -158,6 +158,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private DisplayInteger getListAndRender(ForgeDirection side, EnumGas type)
|
||||
{
|
||||
if(side == ForgeDirection.UNKNOWN)
|
||||
|
|
|
@ -118,6 +118,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private static Model3D[] assignEnergy()
|
||||
{
|
||||
Model3D[] energyArray = new Model3D[7];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
@ -55,6 +56,11 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(packetTick == 0)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
}
|
||||
|
||||
if(getEnergy() < getMaxEnergy() && powerHandler.getEnergyStored() > 0)
|
||||
{
|
||||
setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
|
||||
|
|
|
@ -208,7 +208,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
|||
|
||||
public int getFuel(ItemStack itemstack)
|
||||
{
|
||||
return itemstack.itemID == MekanismGenerators.BioFuel.itemID ? 100 : 0;
|
||||
return itemstack.itemID == MekanismGenerators.BioFuel.itemID ? 200 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue