initial 1.8 port
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
package cofh.api;
|
||||
|
||||
public class CoFHAPIProps {
|
||||
|
||||
private CoFHAPIProps() {
|
||||
|
||||
}
|
||||
|
||||
public static final String VERSION = "1.7.10R1.0.2";
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
|
||||
@@ -16,6 +16,6 @@ public interface IEnergyConnection {
|
||||
/**
|
||||
* Returns TRUE if the TileEntity can connect on a given side.
|
||||
*/
|
||||
boolean canConnectEnergy(ForgeDirection from);
|
||||
boolean canConnectEnergy(EnumFacing facing);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
@@ -26,7 +27,7 @@ public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver {
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
@Override
|
||||
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
|
||||
int receiveEnergy(EnumFacing facing, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
|
||||
@@ -40,19 +41,19 @@ public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver {
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
@Override
|
||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||
int extractEnergy(EnumFacing facing, int maxExtract, boolean simulate);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
@Override
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
int getEnergyStored(EnumFacing facing);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
@Override
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
int getMaxEnergyStored(EnumFacing facing);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
@@ -23,16 +24,16 @@ public interface IEnergyProvider extends IEnergyConnection {
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||
int extractEnergy(EnumFacing facing, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
int getEnergyStored(EnumFacing facing);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
int getMaxEnergyStored(EnumFacing facing);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
@@ -23,16 +24,16 @@ public interface IEnergyReceiver extends IEnergyConnection {
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
|
||||
int receiveEnergy(EnumFacing facing, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
int getEnergyStored(EnumFacing facing);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
int getMaxEnergyStored(EnumFacing facing);
|
||||
|
||||
}
|
||||
|
||||
@@ -63,15 +63,15 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null) {
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
if (container.getTagCompound() == null) {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energy = container.getTagCompound().getInteger("Energy");
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
container.getTagCompound().setInteger("Energy", energy);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
@@ -79,15 +79,15 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energy = container.getTagCompound().getInteger("Energy");
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
container.getTagCompound().setInteger("Energy", energy);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
@@ -95,10 +95,10 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack container) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
return container.stackTagCompound.getInteger("Energy");
|
||||
return container.getTagCompound().getInteger("Energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
|
||||
@@ -30,34 +30,34 @@ public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||
|
||||
/* IEnergyConnection */
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
public boolean canConnectEnergy(EnumFacing facing) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* IEnergyReceiver */
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
public int receiveEnergy(EnumFacing facing, int maxReceive, boolean simulate) {
|
||||
|
||||
return storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
/* IEnergyProvider */
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
public int extractEnergy(EnumFacing facing, int maxExtract, boolean simulate) {
|
||||
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
/* IEnergyReceiver and IEnergyProvider */
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
public int getEnergyStored(EnumFacing facing) {
|
||||
|
||||
return storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
public int getMaxEnergyStored(EnumFacing facing) {
|
||||
|
||||
return storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
|
||||
package cofh.api.energy;
|
||||
|
||||
import cofh.api.CoFHAPIProps;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
|
||||
package cofh.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
Reference in New Issue
Block a user