mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Drop that RF, like a big fat rock
This commit is contained in:
parent
a70468ff72
commit
f469f77f4f
52 changed files with 286 additions and 1509 deletions
|
@ -1,11 +0,0 @@
|
|||
package cofh.api;
|
||||
|
||||
public class CoFHAPIProps {
|
||||
|
||||
private CoFHAPIProps() {
|
||||
|
||||
}
|
||||
|
||||
public static final String VERSION = "1.8.9R1.2.0B1";
|
||||
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class EnergyStorage implements IEnergyStorage {
|
||||
|
||||
protected int energy;
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public EnergyStorage(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
this.energy = nbt.getInteger("Energy");
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
}
|
||||
nbt.setInteger("Energy", energy);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public EnergyStorage setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnergyStorage setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnergyStorage setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnergyStorage setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMaxReceive() {
|
||||
|
||||
return maxReceive;
|
||||
}
|
||||
|
||||
public int getMaxExtract() {
|
||||
|
||||
return maxExtract;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
|
||||
* are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void setEnergyStored(int energy) {
|
||||
|
||||
this.energy = energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
|
||||
* externally, as not all IEnergyHandlers are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void modifyEnergyStored(int energy) {
|
||||
|
||||
this.energy += energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* IEnergyStorage */
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
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
|
||||
* accept it; otherwise just use IEnergyHandler.
|
||||
* <p>
|
||||
* Note that {@link IEnergyHandler} is an extension of this.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Returns TRUE if the TileEntity can connect on a given side.
|
||||
*/
|
||||
boolean canConnectEnergy(EnumFacing from);
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this interface on Item classes that support external manipulation of their internal energy storages.
|
||||
* <p>
|
||||
* A reference implementation is provided {@link ItemEnergyContainer}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyContainerItem {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be sent into the item.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received by the item.
|
||||
*/
|
||||
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted from the item.
|
||||
* @param simulate
|
||||
* If TRUE, the discharge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
|
||||
*/
|
||||
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* 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 container item.
|
||||
*/
|
||||
int getMaxEnergyStored(ItemStack container);
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
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.
|
||||
* <p>
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
* <p>
|
||||
* Note that {@link IEnergyReceiver} and {@link IEnergyProvider} are extensions of this.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyHandler extends IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(EnumFacing from);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(EnumFacing from);
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
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.
|
||||
* <p>
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyProvider extends IEnergyHandler {
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is extracted from.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to extract.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
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.
|
||||
* <p>
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyReceiver extends IEnergyHandler {
|
||||
|
||||
/**
|
||||
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is received from.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to receive.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate);
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
/**
|
||||
* An energy storage is the unit of interaction with Energy inventories.<br>
|
||||
* This is not to be implemented on TileEntities. This is for internal use only.
|
||||
* <p>
|
||||
* A reference implementation can be found at {@link EnergyStorage}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyStorage {
|
||||
|
||||
/**
|
||||
* Adds energy to the storage. Returns quantity of energy that was accepted.
|
||||
*
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be inserted.
|
||||
* @param simulate
|
||||
* If TRUE, the insertion will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
|
||||
*/
|
||||
int receiveEnergy(int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from the storage. Returns quantity of energy that was removed.
|
||||
*
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
|
||||
*/
|
||||
int extractEnergy(int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored();
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored();
|
||||
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public ItemEnergyContainer() {
|
||||
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public ItemEnergyContainer setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemEnergyContainer setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemEnergyContainer setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemEnergyContainer setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* IEnergyContainerItem */
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
|
||||
if (!container.hasTagCompound()) {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
int energy = container.getTagCompound().getInteger("Energy");
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
container.getTagCompound().setInteger("Energy", energy);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
|
||||
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
int energy = container.getTagCompound().getInteger("Energy");
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
container.getTagCompound().setInteger("Energy", energy);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack container) {
|
||||
|
||||
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
return container.getTagCompound().getInteger("Energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack container) {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
/**
|
||||
* (C) 2014-2016 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 net.minecraftforge.fml.common.API;
|
||||
import cofh.api.CoFHAPIProps;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
/**
|
||||
* (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
|
||||
package cofh.api;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
|
@ -95,7 +94,7 @@ public class ContainerEnergizer extends Container{
|
|||
//Other Slots in Inventory excluded
|
||||
else if(slot >= inventoryStart){
|
||||
//Shift from Inventory
|
||||
if(newStack.getItem() instanceof IEnergyContainerItem || (ActuallyAdditions.teslaLoaded && newStack.hasCapability(TeslaUtil.teslaConsumer, null)) || newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if((ActuallyAdditions.teslaLoaded && newStack.hasCapability(TeslaUtil.teslaConsumer, null)) || newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if(!this.mergeItemStack(newStack, 0, 1, false)){
|
||||
return StackUtil.getNull();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
|
@ -94,7 +93,7 @@ public class ContainerEnervator extends Container{
|
|||
//Other Slots in Inventory excluded
|
||||
else if(slot >= inventoryStart){
|
||||
//Shift from Inventory
|
||||
if(newStack.getItem() instanceof IEnergyContainerItem || (ActuallyAdditions.teslaLoaded && newStack.hasCapability(TeslaUtil.teslaProducer, null)) || newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if((ActuallyAdditions.teslaLoaded && newStack.hasCapability(TeslaUtil.teslaProducer, null)) || newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if(!this.mergeItemStack(newStack, 0, 1, false)){
|
||||
return StackUtil.getNull();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
|
@ -60,10 +59,7 @@ public class ItemBattery extends ItemEnergy{
|
|||
int extractable = this.extractEnergy(stack, Integer.MAX_VALUE, true);
|
||||
int received = 0;
|
||||
|
||||
if(slot.getItem() instanceof IEnergyContainerItem){
|
||||
received = ((IEnergyContainerItem)slot.getItem()).receiveEnergy(slot, extractable, false);
|
||||
}
|
||||
else if(slot.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if(slot.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(cap != null){
|
||||
received = cap.receiveEnergy(extractable, false);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import com.google.common.collect.Multimap;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||
|
|
|
@ -10,13 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
import cofh.api.energy.ItemEnergyContainer;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.ItemTeslaWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -29,43 +25,26 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ItemEnergy extends ItemEnergyContainer{
|
||||
public abstract class ItemEnergy extends ItemBase{
|
||||
|
||||
private final String name;
|
||||
private final int maxPower;
|
||||
private final int transfer;
|
||||
|
||||
public ItemEnergy(int maxPower, int transfer, String name){
|
||||
super(maxPower, transfer);
|
||||
super(name);
|
||||
this.maxPower = maxPower;
|
||||
this.transfer = transfer;
|
||||
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxStackSize(1);
|
||||
this.name = name;
|
||||
|
||||
this.register();
|
||||
}
|
||||
|
||||
private void register(){
|
||||
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
|
||||
|
||||
this.registerRendering();
|
||||
}
|
||||
|
||||
protected String getBaseName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean shouldAddCreative(){
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void registerRendering(){
|
||||
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,8 +54,13 @@ public abstract class ItemEnergy extends ItemEnergyContainer{
|
|||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
list.add(format.format(this.getEnergyStored(stack))+"/"+format.format(this.getMaxEnergyStored(stack))+" Crystal Flux");
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
list.add(format.format(storage.getEnergyStored())+"/"+format.format(storage.getMaxEnergyStored())+" Crystal Flux");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,8 +73,13 @@ public abstract class ItemEnergy extends ItemEnergyContainer{
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tabs, NonNullList list){
|
||||
ItemStack stackFull = new ItemStack(this);
|
||||
this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
|
||||
list.add(stackFull);
|
||||
if(stackFull.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stackFull.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
this.setEnergy(stackFull, storage.getMaxEnergyStored());
|
||||
list.add(stackFull);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stackEmpty = new ItemStack(this);
|
||||
this.setEnergy(stackEmpty, 0);
|
||||
|
@ -104,25 +93,97 @@ public abstract class ItemEnergy extends ItemEnergyContainer{
|
|||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack){
|
||||
double maxAmount = this.getMaxEnergyStored(stack);
|
||||
double energyDif = maxAmount-this.getEnergyStored(stack);
|
||||
return energyDif/maxAmount;
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
double maxAmount = storage.getMaxEnergyStored();
|
||||
double energyDif = maxAmount-storage.getEnergyStored();
|
||||
return energyDif/maxAmount;
|
||||
}
|
||||
}
|
||||
return super.getDurabilityForDisplay(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack){
|
||||
int currEnergy = this.getEnergyStored(stack);
|
||||
int maxEnergy = this.getMaxEnergyStored(stack);
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float)currEnergy/maxEnergy)/3.0F, 1.0F, 1.0F);
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
int currEnergy = storage.getEnergyStored();
|
||||
int maxEnergy = storage.getMaxEnergyStored();
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float)currEnergy/maxEnergy)/3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
return super.getRGBDurabilityForDisplay(stack);
|
||||
}
|
||||
|
||||
public void setEnergy(ItemStack stack, int energy){
|
||||
NBTTagCompound compound = stack.getTagCompound();
|
||||
if(compound == null){
|
||||
compound = new NBTTagCompound();
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage instanceof CustomEnergyStorage){
|
||||
((CustomEnergyStorage)storage).setEnergyStored(energy);
|
||||
}
|
||||
}
|
||||
compound.setInteger("Energy", energy);
|
||||
stack.setTagCompound(compound);
|
||||
}
|
||||
|
||||
public int receiveEnergyInternal(ItemStack stack, int maxReceive, boolean simulate){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage instanceof CustomEnergyStorage){
|
||||
((CustomEnergyStorage)storage).receiveEnergyInternal(maxReceive, simulate);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage instanceof CustomEnergyStorage){
|
||||
((CustomEnergyStorage)storage).extractEnergyInternal(maxExtract, simulate);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int receiveEnergy(ItemStack stack, int maxReceive, boolean simulate){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
return storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int extractEnergy(ItemStack stack, int maxExtract, boolean simulate){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getEnergyStored(ItemStack stack){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
return storage.getEnergyStored();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getMaxEnergyStored(ItemStack stack){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(storage != null){
|
||||
return storage.getMaxEnergyStored();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,57 +191,30 @@ public abstract class ItemEnergy extends ItemEnergyContainer{
|
|||
return new EnergyCapabilityProvider(stack, this);
|
||||
}
|
||||
|
||||
public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate){
|
||||
int before = this.maxExtract;
|
||||
this.setMaxExtract(Integer.MAX_VALUE);
|
||||
|
||||
int toReturn = this.extractEnergy(stack, maxExtract, simulate);
|
||||
|
||||
this.setMaxExtract(before);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public int receiveEnergyInternal(ItemStack stack, int maxReceive, boolean simulate){
|
||||
int before = this.maxReceive;
|
||||
this.setMaxReceive(Integer.MAX_VALUE);
|
||||
|
||||
int toReturn = this.receiveEnergy(stack, maxReceive, simulate);
|
||||
|
||||
this.setMaxReceive(before);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static class EnergyCapabilityProvider implements ICapabilityProvider{
|
||||
|
||||
private final Object forgeUnitsWrapper;
|
||||
private final CustomEnergyStorage storage;
|
||||
private Object teslaWrapper;
|
||||
|
||||
private final IEnergyContainerItem item;
|
||||
private final ItemStack stack;
|
||||
|
||||
public EnergyCapabilityProvider(final ItemStack stack, final IEnergyContainerItem item){
|
||||
this.stack = stack;
|
||||
this.item = item;
|
||||
|
||||
this.forgeUnitsWrapper = new IEnergyStorage(){
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate){
|
||||
return item.receiveEnergy(stack, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate){
|
||||
return item.extractEnergy(stack, maxExtract, simulate);
|
||||
}
|
||||
|
||||
public EnergyCapabilityProvider(final ItemStack stack, ItemEnergy item){
|
||||
this.storage = new CustomEnergyStorage(item.maxPower, item.transfer, item.transfer){
|
||||
@Override
|
||||
public int getEnergyStored(){
|
||||
return item.getEnergyStored(stack);
|
||||
if(stack.hasTagCompound()){
|
||||
return stack.getTagCompound().getInteger("Energy");
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(){
|
||||
return item.getMaxEnergyStored(stack);
|
||||
public void setEnergyStored(int energy){
|
||||
if(!stack.hasTagCompound()){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("Energy", energy);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -194,12 +228,12 @@ public abstract class ItemEnergy extends ItemEnergyContainer{
|
|||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(capability == CapabilityEnergy.ENERGY){
|
||||
return (T)this.forgeUnitsWrapper;
|
||||
return (T)this.storage;
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
if(capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer || capability == TeslaUtil.teslaHolder){
|
||||
if(this.teslaWrapper == null){
|
||||
this.teslaWrapper = new ItemTeslaWrapper(this.stack, this.item);
|
||||
this.teslaWrapper = new TeslaForgeUnitsWrapper(this.storage);
|
||||
}
|
||||
return (T)this.teslaWrapper;
|
||||
}
|
||||
|
|
|
@ -15,14 +15,6 @@ import net.minecraftforge.energy.EnergyStorage;
|
|||
|
||||
public class CustomEnergyStorage extends EnergyStorage{
|
||||
|
||||
public CustomEnergyStorage(int capacity){
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public CustomEnergyStorage(int capacity, int maxTransfer){
|
||||
super(capacity, maxTransfer);
|
||||
}
|
||||
|
||||
public CustomEnergyStorage(int capacity, int maxReceive, int maxExtract){
|
||||
super(capacity, maxReceive, maxExtract);
|
||||
}
|
||||
|
@ -47,12 +39,41 @@ public class CustomEnergyStorage extends EnergyStorage{
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate){
|
||||
if(!this.canReceive()){
|
||||
return 0;
|
||||
}
|
||||
int energy = this.getEnergyStored();
|
||||
|
||||
int energyReceived = Math.min(this.capacity-energy, Math.min(this.maxReceive, maxReceive));
|
||||
if(!simulate){
|
||||
this.setEnergyStored(energy+energyReceived);
|
||||
}
|
||||
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate){
|
||||
if(!this.canExtract()){
|
||||
return 0;
|
||||
}
|
||||
int energy = this.getEnergyStored();
|
||||
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
if(!simulate){
|
||||
this.setEnergyStored(energy-energyExtracted);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
this.energy = compound.getInteger("Energy");
|
||||
this.setEnergyStored(compound.getInteger("Energy"));
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
compound.setInteger("Energy", this.energy);
|
||||
compound.setInteger("Energy", this.getEnergyStored());
|
||||
}
|
||||
|
||||
public void setEnergyStored(int energy){
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* This file ("ICustomEnergyReceiver.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
public interface ICustomEnergyReceiver extends IEnergyReceiver{
|
||||
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface ISharingEnergyProvider extends IEnergyProvider{
|
||||
public interface ISharingEnergyProvider{
|
||||
|
||||
int getEnergyToSplitShare();
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||
|
@ -28,10 +27,10 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements ICustomEnergyReceiver, IEnergyDisplay, IAtomicReconstructor{
|
||||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor{
|
||||
|
||||
public static final int ENERGY_USE = 1000;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 5000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 5000, 0);
|
||||
public int counter;
|
||||
private int currentTime;
|
||||
private int oldEnergy;
|
||||
|
@ -162,26 +161,6 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
this.sendUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
|
|
|
@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
|||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -29,7 +30,6 @@ import net.minecraft.util.ITickable;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
|
@ -49,6 +49,8 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
protected TileEntity[] tilesAround = new TileEntity[6];
|
||||
protected boolean hasSavedDataOnChangeOrWorldStart;
|
||||
|
||||
private Object teslaWrapper;
|
||||
|
||||
public TileEntityBase(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -329,9 +331,11 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
T cap = TeslaUtil.wrapTeslaToRF(this, capability, facing);
|
||||
if(cap != null){
|
||||
return cap;
|
||||
if(capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer || capability == TeslaUtil.teslaHolder){
|
||||
if(this.teslaWrapper == null){
|
||||
this.teslaWrapper = new TeslaForgeUnitsWrapper(this.getEnergyStorage(facing));
|
||||
}
|
||||
return (T)this.teslaWrapper;
|
||||
}
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
|
@ -353,15 +357,6 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(){
|
||||
super.invalidate();
|
||||
|
||||
if(ActuallyAdditions.teslaLoaded){
|
||||
TeslaUtil.removeTile(this);
|
||||
}
|
||||
}
|
||||
|
||||
public enum NBTType{
|
||||
SAVE_TILE,
|
||||
SYNC,
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
|
@ -28,7 +27,7 @@ import java.util.List;
|
|||
|
||||
public class TileEntityBioReactor extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 800);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 0, 800);
|
||||
|
||||
public int burnTime;
|
||||
public int maxBurnTime;
|
||||
|
@ -143,26 +142,6 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
|||
return isValidItem(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return this.storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
|
@ -26,12 +25,12 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityCanolaPress extends TileEntityInventoryBase implements ICustomEnergyReceiver, ISharingFluidHandler{
|
||||
public class TileEntityCanolaPress extends TileEntityInventoryBase implements ISharingFluidHandler{
|
||||
|
||||
public static final int PRODUCE = 80;
|
||||
public static final int ENERGY_USE = 35;
|
||||
private static final int TIME = 30;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(40000, 100);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(40000, 100, 0);
|
||||
public final FluidTank tank = new FluidTank(2*Util.BUCKET){
|
||||
@Override
|
||||
public boolean canFill(){
|
||||
|
@ -131,26 +130,6 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IC
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getFluidHandler(EnumFacing facing){
|
||||
return facing != EnumFacing.UP ? this.tank : null;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -23,7 +22,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public static final int PRODUCE = 30;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 80);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 0, 80);
|
||||
public int maxBurnTime;
|
||||
public int currentBurnTime;
|
||||
private int lastEnergy;
|
||||
|
@ -110,26 +109,6 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
return TileEntityFurnace.getItemBurnTime(this.slots.get(0)) <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.extractEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||
|
@ -31,7 +30,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, ICustomEnergyReceiver, ISharingFluidHandler{
|
||||
public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, ISharingFluidHandler{
|
||||
|
||||
public static final int SLOT_COFFEE_BEANS = 0;
|
||||
public static final int SLOT_INPUT = 1;
|
||||
|
@ -41,7 +40,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
public static final int WATER_USE = 500;
|
||||
public static final int COFFEE_CACHE_MAX_AMOUNT = 300;
|
||||
private static final int TIME_USED = 500;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250, 0);
|
||||
public final FluidTank tank = new FluidTank(4*Util.BUCKET){
|
||||
@Override
|
||||
public boolean canDrain(){
|
||||
|
@ -193,26 +192,6 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getFluidHandler(EnumFacing facing){
|
||||
return facing != EnumFacing.DOWN ? this.tank : null;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -25,11 +24,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
||||
|
||||
public static final int RANGE = 8;
|
||||
public static final int ENERGY_USE = 5;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20, 0);
|
||||
private int lastEnergy;
|
||||
private int currentTime;
|
||||
|
||||
|
@ -123,27 +122,6 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRedstoneToggle(){
|
||||
return true;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -21,9 +20,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay, ICustomEnergyReceiver{
|
||||
public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay{
|
||||
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000, 0);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityDisplayStand(){
|
||||
|
@ -114,26 +113,6 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return from != EnumFacing.UP ? this.storage.receiveEnergy(maxReceive, simulate) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return from != EnumFacing.UP ? this.storage.getEnergyStored() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return from != EnumFacing.UP ? this.storage.getMaxEnergyStored() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return from != EnumFacing.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit(){
|
||||
return 1;
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
|
@ -25,9 +23,9 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityEnergizer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
public class TileEntityEnergizer extends TileEntityInventoryBase{
|
||||
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000, 0);
|
||||
private int lastEnergy;
|
||||
|
||||
public TileEntityEnergizer(){
|
||||
|
@ -55,12 +53,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements ICus
|
|||
int received = 0;
|
||||
boolean canTakeUp = false;
|
||||
|
||||
if(this.slots.get(0).getItem() instanceof IEnergyContainerItem){
|
||||
IEnergyContainerItem item = (IEnergyContainerItem)this.slots.get(0).getItem();
|
||||
received = (item.receiveEnergy(this.slots.get(0), this.storage.getEnergyStored(), false));
|
||||
canTakeUp = item.getEnergyStored(this.slots.get(0)) >= item.getMaxEnergyStored(this.slots.get(0));
|
||||
}
|
||||
else if(this.slots.get(0).hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if(this.slots.get(0).hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage cap = this.slots.get(0).getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(cap != null){
|
||||
received = cap.receiveEnergy(this.storage.getEnergyStored(), false);
|
||||
|
@ -100,7 +93,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements ICus
|
|||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return i == 0 && (stack.getItem() instanceof IEnergyContainerItem || (ActuallyAdditions.teslaLoaded && stack.hasCapability(TeslaUtil.teslaConsumer, null)) || stack.hasCapability(CapabilityEnergy.ENERGY, null));
|
||||
return i == 0 && ((ActuallyAdditions.teslaLoaded && stack.hasCapability(TeslaUtil.teslaConsumer, null)) || stack.hasCapability(CapabilityEnergy.ENERGY, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,26 +111,6 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements ICus
|
|||
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
|
@ -26,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, 1000);
|
||||
private int lastEnergy;
|
||||
|
||||
public TileEntityEnervator(){
|
||||
|
@ -55,12 +54,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
|
|||
boolean canTakeUp = false;
|
||||
|
||||
int maxExtract = this.storage.getMaxEnergyStored()-this.storage.getEnergyStored();
|
||||
if(this.slots.get(0).getItem() instanceof IEnergyContainerItem){
|
||||
IEnergyContainerItem item = (IEnergyContainerItem)this.slots.get(0).getItem();
|
||||
extracted = item.extractEnergy(this.slots.get(0), maxExtract, false);
|
||||
canTakeUp = item.getEnergyStored(this.slots.get(0)) <= 0;
|
||||
}
|
||||
else if(this.slots.get(0).hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if(this.slots.get(0).hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage cap = this.slots.get(0).getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(cap != null){
|
||||
extracted = cap.extractEnergy(maxExtract, false);
|
||||
|
@ -100,27 +94,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
|
|||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return i == 0 && (stack.getItem() instanceof IEnergyContainerItem || (ActuallyAdditions.teslaLoaded && stack.hasCapability(TeslaUtil.teslaProducer, null)) || stack.hasCapability(CapabilityEnergy.ENERGY, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return this.storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
return i == 0 && ((ActuallyAdditions.teslaLoaded && stack.hasCapability(TeslaUtil.teslaProducer, null)) || stack.hasCapability(CapabilityEnergy.ENERGY, null));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -33,10 +32,10 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityFarmer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
public class TileEntityFarmer extends TileEntityInventoryBase{
|
||||
|
||||
public static final int USE_PER_OPERATION = 1500;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(100000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(100000, 1000, 0);
|
||||
|
||||
private int waitTime;
|
||||
private int checkX;
|
||||
|
@ -217,26 +216,6 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements ICustom
|
|||
return slot >= 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemDye;
|
||||
|
@ -22,10 +21,10 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class TileEntityFireworkBox extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisplay{
|
||||
|
||||
public static final int USE_PER_SHOT = 300;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(20000, 200);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(20000, 200, 0);
|
||||
private int timeUntilNextFirework;
|
||||
private int oldEnergy;
|
||||
|
||||
|
@ -132,26 +131,6 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRedstoneToggle(){
|
||||
return true;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
|
@ -26,7 +25,7 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor{
|
||||
public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IButtonReactor{
|
||||
|
||||
public static final int SLOT_INPUT_1 = 0;
|
||||
public static final int SLOT_OUTPUT_1 = 1;
|
||||
|
@ -34,7 +33,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
|||
public static final int SLOT_OUTPUT_2 = 3;
|
||||
public static final int ENERGY_USE = 25;
|
||||
private static final int SMELT_TIME = 80;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 80);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 80, 0);
|
||||
public int firstSmeltTime;
|
||||
public int secondSmeltTime;
|
||||
public boolean isAutoSplit;
|
||||
|
@ -199,26 +198,6 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
|||
return slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonPressed(int buttonID, EntityPlayer player){
|
||||
if(buttonID == 0){
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -20,33 +19,13 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{
|
||||
|
||||
public static final int PRODUCE = 8;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 100);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 100);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityFurnaceSolar(){
|
||||
super("solarPanel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return this.storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return from != EnumFacing.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||
super.writeSyncableNBT(compound, type);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||
|
@ -28,7 +27,7 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityGrinder extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor{
|
||||
public class TileEntityGrinder extends TileEntityInventoryBase implements IButtonReactor{
|
||||
|
||||
public static final int SLOT_INPUT_1 = 0;
|
||||
public static final int SLOT_OUTPUT_1_1 = 1;
|
||||
|
@ -37,7 +36,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
|
|||
public static final int SLOT_OUTPUT_2_1 = 4;
|
||||
public static final int SLOT_OUTPUT_2_2 = 5;
|
||||
public static final int ENERGY_USE = 40;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 100);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 100, 0);
|
||||
public int firstCrushTime;
|
||||
public int secondCrushTime;
|
||||
public boolean isDouble;
|
||||
|
@ -56,26 +55,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
|
|||
this.isDouble = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||
if(type != NBTType.SAVE_BLOCK){
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -26,7 +25,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
|
|||
|
||||
public static final int ENERGY_PRODUCE = 40;
|
||||
public static final int BLOCKS_NEEDED = 4;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 80);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 80);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityHeatCollector(){
|
||||
|
@ -77,26 +76,6 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return this.storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return from == EnumFacing.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -21,12 +20,12 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityItemRepairer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
public class TileEntityItemRepairer extends TileEntityInventoryBase{
|
||||
|
||||
public static final int SLOT_INPUT = 0;
|
||||
public static final int SLOT_OUTPUT = 1;
|
||||
public static final int ENERGY_USE = 2500;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 6000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 6000, 0);
|
||||
public int nextRepairTick;
|
||||
private int lastEnergy;
|
||||
|
||||
|
@ -142,26 +141,6 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
|
|||
return slot == SLOT_OUTPUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||
|
@ -25,41 +24,63 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements ICustomEnergyReceiver{
|
||||
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
|
||||
|
||||
public static final int CAP = 1000;
|
||||
public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
||||
|
||||
private final IEnergyStorage[] energyStorages = new IEnergyStorage[6];
|
||||
|
||||
public TileEntityLaserRelayEnergy(String name){
|
||||
super(name, LaserType.ENERGY);
|
||||
|
||||
for(int i = 0; i < this.energyStorages.length; i++){
|
||||
final EnumFacing facing = EnumFacing.values()[i];
|
||||
this.energyStorages[i] = new IEnergyStorage(){
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int amount, boolean simulate){
|
||||
return TileEntityLaserRelayEnergy.this.transmitEnergy(facing, amount, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(){
|
||||
return TileEntityLaserRelayEnergy.this.getEnergyCap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive(){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntityLaserRelayEnergy(){
|
||||
this("laserRelay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.transmitEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.getEnergyCap();
|
||||
}
|
||||
|
||||
private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate){
|
||||
int transmitted = 0;
|
||||
if(maxTransmit > 0){
|
||||
|
@ -72,8 +93,8 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.energyStorages[facing == null ? 0 : facing.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,7 +112,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
|||
BlockPos pos = this.getPos().offset(side);
|
||||
TileEntity tile = this.worldObj.getTileEntity(pos);
|
||||
if(tile != null && !(tile instanceof TileEntityLaserRelay)){
|
||||
if(tile instanceof IEnergyReceiver || (ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, side.getOpposite())) || tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())){
|
||||
if((ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, side.getOpposite())) || tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())){
|
||||
this.receiversAround.put(side, tile);
|
||||
|
||||
TileEntity oldTile = old.get(side);
|
||||
|
@ -152,22 +173,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
|||
if(!alreadyChecked.contains(tile.getPos())){
|
||||
alreadyChecked.add(tile.getPos());
|
||||
if(theRelay != this || side != from){
|
||||
if(tile instanceof IEnergyReceiver){
|
||||
IEnergyReceiver iReceiver = (IEnergyReceiver)tile;
|
||||
if(iReceiver.canConnectEnergy(opp)){
|
||||
int theoreticalReceived = iReceiver.receiveEnergy(opp, Math.min(amountPer, lowestCap), true);
|
||||
if(theoreticalReceived > 0){
|
||||
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
|
||||
if(deduct >= theoreticalReceived){ //Happens with small numbers
|
||||
deduct = 0;
|
||||
}
|
||||
|
||||
transmitted += iReceiver.receiveEnergy(opp, theoreticalReceived-deduct, simulate);
|
||||
transmitted += deduct;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tile.hasCapability(CapabilityEnergy.ENERGY, opp)){
|
||||
if(tile.hasCapability(CapabilityEnergy.ENERGY, opp)){
|
||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp);
|
||||
if(cap != null){
|
||||
int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true);
|
||||
|
|
|
@ -53,13 +53,11 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
|||
return TileEntityLaserRelayFluids.this.transmitFluid(facing, resource, doFill);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, boolean doDrain){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain){
|
||||
return null;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
|
@ -22,13 +21,13 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class TileEntityLavaFactoryController extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyDisplay{
|
||||
|
||||
public static final int NOT_MULTI = 0;
|
||||
public static final int HAS_LAVA = 1;
|
||||
public static final int HAS_AIR = 2;
|
||||
public static final int ENERGY_USE = 150000;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 2000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 2000, 0);
|
||||
private int currentWorkTime;
|
||||
private int oldEnergy;
|
||||
|
||||
|
@ -99,26 +98,6 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
return NOT_MULTI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return from != EnumFacing.UP ? this.storage.receiveEnergy(maxExtract, simulate) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return from != EnumFacing.UP ? this.storage.getEnergyStored() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return from != EnumFacing.UP ? this.storage.getMaxEnergyStored() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return from != EnumFacing.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -26,7 +25,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
|||
|
||||
public static final int RANGE = 7;
|
||||
public static final int ENERGY_PRODUCED = 300;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 450);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 0, 450);
|
||||
private int nextUseCounter;
|
||||
private int oldEnergy;
|
||||
|
||||
|
@ -95,26 +94,6 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.extractEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
|
@ -31,11 +30,11 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityMiner extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor, IEnergyDisplay{
|
||||
public class TileEntityMiner extends TileEntityInventoryBase implements IButtonReactor, IEnergyDisplay{
|
||||
|
||||
public static final int ENERGY_USE_PER_BLOCK = 650;
|
||||
public static final int DEFAULT_RANGE = 2;
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000, 0);
|
||||
public int layerAt = -1;
|
||||
public boolean onlyMineOres;
|
||||
private int oldLayerAt;
|
||||
|
@ -184,26 +183,6 @@ public class TileEntityMiner extends TileEntityInventoryBase implements ICustomE
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
|
@ -26,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{
|
||||
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 150);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, 150);
|
||||
public final FluidTank tank = new FluidTank(2*Util.BUCKET){
|
||||
@Override
|
||||
public boolean canDrain(){
|
||||
|
@ -145,26 +144,6 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return this.storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidHandler getFluidHandler(EnumFacing facing){
|
||||
return facing != EnumFacing.DOWN ? this.tank : null;
|
||||
|
|
|
@ -10,146 +10,33 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ICustomEnergyReceiver, ISharingEnergyProvider{
|
||||
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider{
|
||||
|
||||
public TileEntityPhantomEnergyface(){
|
||||
super("energyface");
|
||||
this.type = BlockPhantom.Type.ENERGYFACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
if(this.isBoundThingInRange()){
|
||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
if(tile instanceof IEnergyReceiver){
|
||||
return ((IEnergyReceiver)tile).receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
else if(tile.hasCapability(CapabilityEnergy.ENERGY, from)){
|
||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, from);
|
||||
if(cap != null){
|
||||
return cap.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, from)){
|
||||
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, from);
|
||||
if(cap != null){
|
||||
return (int)cap.givePower(maxReceive, simulate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
if(this.isBoundThingInRange()){
|
||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
if(tile instanceof IEnergyProvider){
|
||||
return ((IEnergyProvider)tile).extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
else if(tile.hasCapability(CapabilityEnergy.ENERGY, from)){
|
||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, from);
|
||||
if(cap != null){
|
||||
return cap.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaProducer, from)){
|
||||
ITeslaProducer cap = tile.getCapability(TeslaUtil.teslaProducer, from);
|
||||
if(cap != null){
|
||||
return (int)cap.takePower(maxExtract, simulate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
if(this.isBoundThingInRange()){
|
||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
if(tile instanceof IEnergyHandler){
|
||||
return ((IEnergyHandler)tile).getEnergyStored(from);
|
||||
}
|
||||
else if(tile.hasCapability(CapabilityEnergy.ENERGY, from)){
|
||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, from);
|
||||
if(cap != null){
|
||||
return cap.getEnergyStored();
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaHolder, from)){
|
||||
ITeslaHolder cap = tile.getCapability(TeslaUtil.teslaHolder, from);
|
||||
if(cap != null){
|
||||
return (int)cap.getStoredPower();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
if(this.isBoundThingInRange()){
|
||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
if(tile instanceof IEnergyHandler){
|
||||
return ((IEnergyHandler)tile).getMaxEnergyStored(from);
|
||||
}
|
||||
else if(tile.hasCapability(CapabilityEnergy.ENERGY, from)){
|
||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, from);
|
||||
if(cap != null){
|
||||
return cap.getMaxEnergyStored();
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaHolder, from)){
|
||||
ITeslaHolder cap = tile.getCapability(TeslaUtil.teslaHolder, from);
|
||||
if(cap != null){
|
||||
return (int)cap.getCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBoundThingInRange(){
|
||||
if(super.isBoundThingInRange()){
|
||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
if(tile instanceof IEnergyHandler){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
for(EnumFacing facing : EnumFacing.values()){
|
||||
if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)){
|
||||
for(EnumFacing facing : EnumFacing.values()){
|
||||
if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)){
|
||||
return true;
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
if(tile.hasCapability(TeslaUtil.teslaHolder, facing)){
|
||||
return true;
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
if(tile.hasCapability(TeslaUtil.teslaHolder, facing)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,22 +44,6 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
if(this.isBoundThingInRange()){
|
||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
if(tile instanceof IEnergyConnection){
|
||||
return ((IEnergyConnection)tile).canConnectEnergy(from);
|
||||
}
|
||||
else{
|
||||
return tile.hasCapability(CapabilityEnergy.ENERGY, from) || (ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaHolder, from));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return Integer.MAX_VALUE;
|
||||
|
|
|
@ -10,14 +10,11 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -26,10 +23,10 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileEntityPlayerInterface extends TileEntityInventoryBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityPlayerInterface extends TileEntityInventoryBase implements IEnergyDisplay{
|
||||
|
||||
public static final int DEFAULT_RANGE = 32;
|
||||
private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50);
|
||||
private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50, 0);
|
||||
public UUID connectedPlayer;
|
||||
public String playerName;
|
||||
private int oldEnergy;
|
||||
|
@ -65,13 +62,9 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
|
|||
if(this.storage.getEnergyStored() > 0){
|
||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||
if(StackUtil.isValid(slot)){
|
||||
Item item = slot.getItem();
|
||||
|
||||
int received = 0;
|
||||
if(item instanceof IEnergyContainerItem){
|
||||
received = ((IEnergyContainerItem)item).receiveEnergy(slot, this.storage.getEnergyStored(), false);
|
||||
}
|
||||
else if(slot.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
if(slot.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(cap != null){
|
||||
received = cap.receiveEnergy(this.storage.getEnergyStored(), false);
|
||||
|
@ -128,26 +121,6 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side){
|
||||
if(this.getPlayer() != null){
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -18,14 +17,14 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityShockSuppressor extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityShockSuppressor extends TileEntityBase implements IEnergyDisplay{
|
||||
|
||||
public static final List<TileEntityShockSuppressor> SUPPRESSORS = new ArrayList<TileEntityShockSuppressor>();
|
||||
|
||||
public static final int USE_PER = 300;
|
||||
public static final int RANGE = 5;
|
||||
|
||||
public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400);
|
||||
public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400, 0);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityShockSuppressor(){
|
||||
|
@ -77,26 +76,6 @@ public class TileEntityShockSuppressor extends TileEntityBase implements ICustom
|
|||
this.storage.readFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -77,20 +76,6 @@ public final class WorldUtil{
|
|||
|
||||
public static void doEnergyInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing sideTo, int maxTransfer){
|
||||
if(maxTransfer > 0){
|
||||
if(tileFrom instanceof IEnergyProvider && tileTo instanceof IEnergyReceiver){
|
||||
IEnergyReceiver handlerTo = (IEnergyReceiver)tileTo;
|
||||
IEnergyProvider handlerFrom = (IEnergyProvider)tileFrom;
|
||||
|
||||
int drain = handlerFrom.extractEnergy(sideTo, maxTransfer, true);
|
||||
if(drain > 0){
|
||||
if(handlerTo.canConnectEnergy(sideTo.getOpposite())){
|
||||
int filled = handlerTo.receiveEnergy(sideTo.getOpposite(), drain, false);
|
||||
handlerFrom.extractEnergy(sideTo, filled, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileFrom.hasCapability(CapabilityEnergy.ENERGY, sideTo) && tileTo.hasCapability(CapabilityEnergy.ENERGY, sideTo.getOpposite())){
|
||||
IEnergyStorage handlerFrom = tileFrom.getCapability(CapabilityEnergy.ENERGY, sideTo);
|
||||
IEnergyStorage handlerTo = tileTo.getCapability(CapabilityEnergy.ENERGY, sideTo.getOpposite());
|
||||
|
@ -106,7 +91,18 @@ public final class WorldUtil{
|
|||
}
|
||||
|
||||
if(ActuallyAdditions.teslaLoaded){
|
||||
TeslaUtil.doWrappedTeslaRFInteraction(tileFrom, tileTo, sideTo, maxTransfer);
|
||||
if(tileTo.hasCapability(TeslaUtil.teslaConsumer, sideTo.getOpposite()) && tileFrom.hasCapability(TeslaUtil.teslaProducer, sideTo)){
|
||||
ITeslaConsumer handlerTo = tileTo.getCapability(TeslaUtil.teslaConsumer, sideTo.getOpposite());
|
||||
ITeslaProducer handlerFrom = tileFrom.getCapability(TeslaUtil.teslaProducer, sideTo);
|
||||
|
||||
if(handlerTo != null && handlerFrom != null){
|
||||
long drain = handlerFrom.takePower(maxTransfer, true);
|
||||
if(drain > 0){
|
||||
long filled = handlerTo.givePower(drain, false);
|
||||
handlerFrom.takePower(filled, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,39 +10,38 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.util.compat;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class ItemTeslaWrapper implements ITeslaProducer, ITeslaHolder, ITeslaConsumer{
|
||||
public class TeslaForgeUnitsWrapper implements ITeslaProducer, ITeslaHolder, ITeslaConsumer{
|
||||
|
||||
private final ItemStack stack;
|
||||
private final IEnergyContainerItem item;
|
||||
private final IEnergyStorage storage;
|
||||
|
||||
public ItemTeslaWrapper(ItemStack stack, IEnergyContainerItem item){
|
||||
this.stack = stack;
|
||||
this.item = item;
|
||||
public TeslaForgeUnitsWrapper(IEnergyStorage storage){
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated){
|
||||
return this.item.receiveEnergy(this.stack, (int)power, simulated);
|
||||
return this.storage.receiveEnergy((int)power, simulated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredPower(){
|
||||
return this.item.getEnergyStored(this.stack);
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity(){
|
||||
return this.item.getMaxEnergyStored(this.stack);
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long takePower(long power, boolean simulated){
|
||||
return this.item.extractEnergy(this.stack, (int)power, simulated);
|
||||
return this.storage.extractEnergy((int)power, simulated);
|
||||
}
|
||||
}
|
|
@ -10,75 +10,21 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.util.compat;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class TeslaUtil{
|
||||
|
||||
private static final Map<TileEntityBase, TileTeslaWrapper[]> TESLA_MAP = new HashMap<TileEntityBase, TileTeslaWrapper[]>();
|
||||
@CapabilityInject(ITeslaConsumer.class)
|
||||
public static Capability<ITeslaConsumer> teslaConsumer;
|
||||
|
||||
@CapabilityInject(ITeslaProducer.class)
|
||||
public static Capability<ITeslaProducer> teslaProducer;
|
||||
|
||||
@CapabilityInject(ITeslaHolder.class)
|
||||
public static Capability<ITeslaHolder> teslaHolder;
|
||||
|
||||
public static <T> T wrapTeslaToRF(TileEntityBase tile, Capability<T> capability, EnumFacing facing){
|
||||
boolean receive = tile instanceof IEnergyReceiver && capability == teslaConsumer;
|
||||
boolean provide = tile instanceof IEnergyProvider && capability == teslaProducer;
|
||||
boolean hold = tile instanceof IEnergyHandler && capability == teslaHolder;
|
||||
if(receive || provide || hold){
|
||||
return (T)getHandler(tile, facing);
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeTile(TileEntityBase tile){
|
||||
TESLA_MAP.remove(tile);
|
||||
}
|
||||
|
||||
public static boolean doWrappedTeslaRFInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing side, int maxTransfer){
|
||||
if(tileTo.hasCapability(teslaConsumer, side.getOpposite()) && tileFrom.hasCapability(teslaProducer, side)){
|
||||
ITeslaConsumer handlerTo = tileTo.getCapability(teslaConsumer, side.getOpposite());
|
||||
ITeslaProducer handlerFrom = tileFrom.getCapability(teslaProducer, side);
|
||||
|
||||
if(handlerTo != null && handlerFrom != null){
|
||||
long drain = handlerFrom.takePower(maxTransfer, true);
|
||||
if(drain > 0){
|
||||
long filled = handlerTo.givePower(drain, false);
|
||||
handlerFrom.takePower(filled, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static TileTeslaWrapper getHandler(TileEntityBase tile, EnumFacing facing){
|
||||
TileTeslaWrapper[] handlers = TESLA_MAP.get(tile);
|
||||
if(handlers == null || handlers.length != 6){
|
||||
handlers = new TileTeslaWrapper[6];
|
||||
TESLA_MAP.put(tile, handlers);
|
||||
}
|
||||
|
||||
int side = facing == null ? 0 : facing.ordinal();
|
||||
if(handlers[side] == null){
|
||||
handlers[side] = new TileTeslaWrapper(tile, facing);
|
||||
}
|
||||
return handlers[side];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* This file ("TileTeslaWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.util.compat;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TileTeslaWrapper implements ITeslaProducer, ITeslaHolder, ITeslaConsumer{
|
||||
|
||||
private final EnumFacing side;
|
||||
private final TileEntityBase tile;
|
||||
|
||||
public TileTeslaWrapper(TileEntityBase tile, EnumFacing side){
|
||||
this.tile = tile;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated){
|
||||
if(this.tile instanceof IEnergyReceiver){
|
||||
return ((IEnergyReceiver)this.tile).receiveEnergy(this.side, (int)power, simulated);
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredPower(){
|
||||
if(this.tile instanceof IEnergyHandler){
|
||||
return ((IEnergyHandler)this.tile).getEnergyStored(this.side);
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity(){
|
||||
if(this.tile instanceof IEnergyHandler){
|
||||
return ((IEnergyHandler)this.tile).getMaxEnergyStored(this.side);
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long takePower(long power, boolean simulated){
|
||||
if(this.tile instanceof IEnergyProvider){
|
||||
return ((IEnergyProvider)this.tile).extractEnergy(this.side, (int)power, simulated);
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -996,7 +996,7 @@ booklet.actuallyadditions.chapter.fireworkBox.text.1=The <item>Firework Box<r> i
|
|||
booklet.actuallyadditions.chapter.fireworkBox.text.2=When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>.
|
||||
|
||||
booklet.actuallyadditions.chapter.rf.name=CF - Crystal Flux
|
||||
booklet.actuallyadditions.chapter.rf.text.1=Since the recent diminishment of what is known as RF, a new way of storing power has arisen: <item>Crystal Flux<r>. <n>This stuff is generated by <imp>all<r> Actually Additions <imp>machines<r>, however, it is <imp>compatible<r> with <item>Tesla<r>, <item>Redstone Flux<r> and <item>Forge Units<r>, meaning machines that use <item>Crystal Flux<r> and machines that use any of the other systems mentioned can be <imp>interconnected without<r> needing any sort of <imp>conversion<r>.
|
||||
booklet.actuallyadditions.chapter.rf.text.1=Since the recent diminishment of what was known as Redstone Flux, a new way of storing power has arisen: <item>Crystal Flux<r>. <n>This stuff is generated by <imp>all<r> Actually Additions <imp>machines<r>, however, it is <imp>compatible<r> with <item>Tesla<r> and <item>Forge Units<r>, meaning machines that use <item>Crystal Flux<r> and machines that use any of the other systems mentioned can be <imp>interconnected without<r> needing any sort of <imp>conversion<r>.
|
||||
booklet.actuallyadditions.chapter.rf.text.2=To <imp>transfer<r> <item>Crystal Flux<r>, just place a thing that <imp>generates<r> or transfers it <imp>next to<r> one that <imp>uses<r> or stores it (or any one of the systems mentioned above). You can use an <item>Energizer<r> to <imp>charge up items<r>.
|
||||
|
||||
booklet.actuallyadditions.chapter.enderStar.name=Ender Star
|
||||
|
|
Loading…
Reference in a new issue