Fix RF support
This commit is contained in:
parent
82933393c7
commit
150c5dee0b
9 changed files with 203 additions and 24 deletions
33
common/cofh/api/block/IBlockDebug.java
Normal file
33
common/cofh/api/block/IBlockDebug.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package cofh.api.block;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on blocks which have some debug method which can be activated via a tool or other means.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IBlockDebug {
|
||||
|
||||
/**
|
||||
* This function debugs a block.
|
||||
*
|
||||
* @param world
|
||||
* Reference to the world.
|
||||
* @param x
|
||||
* X coordinate of the block.
|
||||
* @param y
|
||||
* Y coordinate of the block.
|
||||
* @param z
|
||||
* Z coordinate of the block.
|
||||
* @param side
|
||||
* The side of the block.
|
||||
* @param player
|
||||
* Player doing the debugging.
|
||||
*/
|
||||
public void debugBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player);
|
||||
|
||||
}
|
39
common/cofh/api/block/IBlockInfo.java
Normal file
39
common/cofh/api/block/IBlockInfo.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package cofh.api.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on blocks which can provide information about themselves.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IBlockInfo {
|
||||
|
||||
/**
|
||||
* This function appends information to a list provided to it.
|
||||
*
|
||||
* @param world
|
||||
* Reference to the world.
|
||||
* @param x
|
||||
* X coordinate of the block.
|
||||
* @param y
|
||||
* Y coordinate of the block.
|
||||
* @param z
|
||||
* Z coordinate of the block.
|
||||
* @param side
|
||||
* The side of the block that is being queried.
|
||||
* @param player
|
||||
* Player doing the querying - this can be NULL.
|
||||
* @param info
|
||||
* The list that the information should be appended to.
|
||||
* @param debug
|
||||
* If true, the Block should return "debug" information.
|
||||
*/
|
||||
public void getBlockInfo(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player, List<String> info, boolean debug);
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack;
|
|||
public interface IEnergyContainerItem {
|
||||
|
||||
/**
|
||||
* Adds energy to an item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
|
||||
* Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
|
||||
*
|
||||
* @param container
|
||||
* ItemStack to be charged.
|
||||
|
@ -26,7 +26,8 @@ public interface IEnergyContainerItem {
|
|||
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from an item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally discharged.
|
||||
* Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
|
||||
* discharged.
|
||||
*
|
||||
* @param container
|
||||
* ItemStack to be discharged.
|
||||
|
@ -39,12 +40,12 @@ public interface IEnergyContainerItem {
|
|||
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Get the amount of energy currently stored in the item.
|
||||
* Get the amount of energy currently stored in the container item.
|
||||
*/
|
||||
int getEnergyStored(ItemStack container);
|
||||
|
||||
/**
|
||||
* Get the max amount of energy that can be stored in the item.
|
||||
* Get the max amount of energy that can be stored in the container item.
|
||||
*/
|
||||
int getMaxEnergyStored(ItemStack container);
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@ public interface IItemConduit {
|
|||
|
||||
/**
|
||||
* Insert items into the conduit. Returns the ItemStack left (null if fully routed). Will only accept items if they have an valid destination.
|
||||
*
|
||||
* Pass the conduit the side *opposite* the one you are ejecting from!
|
||||
*/
|
||||
public ItemStack sendItems(ItemStack item, ForgeDirection side);
|
||||
public ItemStack sendItems(ItemStack item, ForgeDirection from);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
*/
|
||||
public interface IItemConduitConnection {
|
||||
|
||||
public boolean canConduitConnect(ForgeDirection side);
|
||||
public boolean canConduitConnect(ForgeDirection from);
|
||||
|
||||
}
|
||||
|
|
|
@ -254,15 +254,41 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II
|
|||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean doReceive)
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(recharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doReceive)*Mekanism.TO_TE);
|
||||
if(canReceive(theItem))
|
||||
{
|
||||
double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem);
|
||||
double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) + toReceive);
|
||||
}
|
||||
|
||||
return (int)Math.round(toReceive*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean doTransfer)
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(discharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doTransfer)*Mekanism.TO_TE);
|
||||
if(canSend(theItem))
|
||||
{
|
||||
double energyRemaining = getEnergy(theItem);
|
||||
double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) - toSend);
|
||||
}
|
||||
|
||||
return (int)Math.round(toSend*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -818,15 +818,41 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean doReceive)
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(recharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doReceive)*Mekanism.TO_TE);
|
||||
if(canReceive(theItem))
|
||||
{
|
||||
double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem);
|
||||
double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) + toReceive);
|
||||
}
|
||||
|
||||
return (int)Math.round(toReceive*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean doTransfer)
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(discharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doTransfer)*Mekanism.TO_TE);
|
||||
if(canSend(theItem))
|
||||
{
|
||||
double energyRemaining = getEnergy(theItem);
|
||||
double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) - toSend);
|
||||
}
|
||||
|
||||
return (int)Math.round(toSend*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -162,27 +162,53 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem
|
|||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean doReceive)
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(recharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doReceive)*Mekanism.TO_TE);
|
||||
if(canReceive(theItem))
|
||||
{
|
||||
double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem);
|
||||
double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) + toReceive);
|
||||
}
|
||||
|
||||
return (int)Math.round(toReceive*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean doTransfer)
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(discharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doTransfer)*Mekanism.TO_TE);
|
||||
if(canSend(theItem))
|
||||
{
|
||||
double energyRemaining = getEnergy(theItem);
|
||||
double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) - toSend);
|
||||
}
|
||||
|
||||
return (int)Math.round(toSend*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack theItem)
|
||||
{
|
||||
return (int)(getEnergy(theItem)*Mekanism.TO_TE);
|
||||
return (int)Math.round(getEnergy(theItem)*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack theItem)
|
||||
{
|
||||
return (int)(getMaxEnergy(theItem)*Mekanism.TO_TE);
|
||||
return (int)Math.round(getMaxEnergy(theItem)*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -323,15 +323,41 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
|
|||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean doReceive)
|
||||
public int receiveEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(recharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doReceive)*Mekanism.TO_TE);
|
||||
if(canReceive(theItem))
|
||||
{
|
||||
double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem);
|
||||
double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) + toReceive);
|
||||
}
|
||||
|
||||
return (int)Math.round(toReceive*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean doTransfer)
|
||||
public int extractEnergy(ItemStack theItem, int energy, boolean simulate)
|
||||
{
|
||||
return (int)(discharge(theItem, (int)((energy*Mekanism.FROM_TE)*Mekanism.TO_UE), !doTransfer)*Mekanism.TO_TE);
|
||||
if(canSend(theItem))
|
||||
{
|
||||
double energyRemaining = getEnergy(theItem);
|
||||
double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) - toSend);
|
||||
}
|
||||
|
||||
return (int)Math.round(toSend*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue