support fricker units

This commit is contained in:
Ellpeck 2016-11-26 08:58:42 +01:00
parent 65bc4ce327
commit c334b31761
26 changed files with 193 additions and 12 deletions

View file

@ -10,7 +10,8 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.energy.EnergyStorage;
public class CustomEnergyStorage extends EnergyStorage{ public class CustomEnergyStorage extends EnergyStorage{
@ -28,21 +29,33 @@ public class CustomEnergyStorage extends EnergyStorage{
public int extractEnergyInternal(int maxExtract, boolean simulate){ public int extractEnergyInternal(int maxExtract, boolean simulate){
int before = this.maxExtract; int before = this.maxExtract;
this.setMaxExtract(Integer.MAX_VALUE); this.maxExtract = Integer.MAX_VALUE;
int toReturn = this.extractEnergy(maxExtract, simulate); int toReturn = this.extractEnergy(maxExtract, simulate);
this.setMaxExtract(before); this.maxExtract = before;
return toReturn; return toReturn;
} }
public int receiveEnergyInternal(int maxReceive, boolean simulate){ public int receiveEnergyInternal(int maxReceive, boolean simulate){
int before = this.maxReceive; int before = this.maxReceive;
this.setMaxReceive(Integer.MAX_VALUE); this.maxReceive = Integer.MAX_VALUE;
int toReturn = this.receiveEnergy(maxReceive, simulate); int toReturn = this.receiveEnergy(maxReceive, simulate);
this.setMaxReceive(before); this.maxReceive = before;
return toReturn; return toReturn;
} }
public void readFromNBT(NBTTagCompound compound){
this.energy = compound.getInteger("Energy");
}
public void writeToNBT(NBTTagCompound compound){
compound.setInteger("Energy", this.energy);
}
public void setEnergyStored(int energy){
this.energy = energy;
}
} }

View file

@ -26,6 +26,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; 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 ICustomEnergyReceiver, IEnergyDisplay, IAtomicReconstructor{
@ -215,4 +216,9 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
public void activateOnPulse(){ public void activateOnPulse(){
this.doWork(); this.doWork();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -32,6 +32,8 @@ import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
@ -320,6 +322,12 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
return (T)tank; return (T)tank;
} }
} }
else if(capability == CapabilityEnergy.ENERGY){
IEnergyStorage storage = this.getEnergyStorage(facing);
if(storage != null){
return (T)storage;
}
}
else if(ActuallyAdditions.teslaLoaded){ else if(ActuallyAdditions.teslaLoaded){
T cap = TeslaUtil.wrapTeslaToRF(this, capability, facing); T cap = TeslaUtil.wrapTeslaToRF(this, capability, facing);
if(cap != null){ if(cap != null){
@ -333,6 +341,10 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
return null; return null;
} }
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return null;
}
public boolean isRedstoneToggle(){ public boolean isRedstoneToggle(){
return false; return false;
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -176,4 +177,9 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fluids.capability.IFluidTankProperties;
@ -169,4 +170,9 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IC
public EnumFacing[] getFluidShareSides(){ public EnumFacing[] getFluidShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -143,4 +144,9 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fluids.capability.IFluidTankProperties;
@ -231,4 +232,9 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public EnumFacing[] getFluidShareSides(){ public EnumFacing[] getFluidShareSides(){
return null; return null;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -152,4 +153,9 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
public void activateOnPulse(){ public void activateOnPulse(){
this.doWork(); this.doWork();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -19,6 +19,7 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; 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, ICustomEnergyReceiver{
@ -137,4 +138,9 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
public int getInventoryStackLimit(){ public int getInventoryStackLimit(){
return 1; return 1;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -20,6 +20,7 @@ import net.darkhax.tesla.api.ITeslaHolder;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -128,4 +129,9 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements ICus
public boolean canConnectEnergy(EnumFacing from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -20,6 +20,7 @@ import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -144,4 +145,9 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -28,6 +28,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -235,4 +236,9 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements ICustom
public boolean canConnectEnergy(EnumFacing from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -20,6 +20,7 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.energy.IEnergyStorage;
public class TileEntityFireworkBox extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
@ -170,4 +171,9 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
public boolean needsHoldShift(){ public boolean needsHoldShift(){
return false; return false;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -22,6 +22,7 @@ import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -225,4 +226,9 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
this.markDirty(); this.markDirty();
} }
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -15,6 +15,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.energy.IEnergyStorage;
public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{
@ -121,4 +122,9 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEn
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -257,4 +258,9 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
this.markDirty(); this.markDirty();
} }
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -18,6 +18,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList; import java.util.ArrayList;
@ -120,4 +121,10 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -17,6 +17,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -160,4 +161,9 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
public boolean canConnectEnergy(EnumFacing from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -20,6 +20,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; 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 ICustomEnergyReceiver, IEnergyDisplay{
@ -127,4 +128,9 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
public boolean needsHoldShift(){ public boolean needsHoldShift(){
return false; return false;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -16,6 +16,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -138,4 +139,9 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@ -233,4 +234,9 @@ public class TileEntityMiner extends TileEntityInventoryBase implements ICustomE
public boolean needsHoldShift(){ public boolean needsHoldShift(){
return false; return false;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
@ -198,4 +199,9 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
public EnumFacing[] getEnergyShareSides(){ public EnumFacing[] getEnergyShareSides(){
return EnumFacing.values(); return EnumFacing.values();
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.UUID; import java.util.UUID;
@ -239,4 +240,9 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
public boolean needsHoldShift(){ public boolean needsHoldShift(){
return false; return false;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -105,4 +106,9 @@ public class TileEntityShockSuppressor extends TileEntityBase implements ICustom
public boolean needsHoldShift(){ public boolean needsHoldShift(){
return false; return false;
} }
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
} }

View file

@ -43,6 +43,8 @@ import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
@ -84,11 +86,28 @@ public final class WorldUtil{
if(handlerTo.canConnectEnergy(sideTo.getOpposite())){ if(handlerTo.canConnectEnergy(sideTo.getOpposite())){
int filled = handlerTo.receiveEnergy(sideTo.getOpposite(), drain, false); int filled = handlerTo.receiveEnergy(sideTo.getOpposite(), drain, false);
handlerFrom.extractEnergy(sideTo, filled, false); handlerFrom.extractEnergy(sideTo, filled, false);
return;
} }
} }
} }
else if(ActuallyAdditions.teslaLoaded){
TeslaUtil.doWrappedTeslaRFInteraction(tileFrom, tileTo, sideTo, maxTransfer); if(ActuallyAdditions.teslaLoaded){
if(TeslaUtil.doWrappedTeslaRFInteraction(tileFrom, tileTo, sideTo, maxTransfer)){
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());
if(handlerFrom != null && handlerTo != null){
int drain = handlerFrom.extractEnergy(maxTransfer, true);
if(drain > 0){
int filled = handlerTo.receiveEnergy(drain, false);
handlerFrom.extractEnergy(filled, false);
}
}
} }
} }
} }

View file

@ -47,18 +47,22 @@ public final class TeslaUtil{
} }
} }
public static void doWrappedTeslaRFInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing side, int maxTransfer){ public static boolean doWrappedTeslaRFInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing side, int maxTransfer){
if(tileTo.hasCapability(teslaConsumer, side.getOpposite()) && tileFrom.hasCapability(teslaProducer, side)){ if(tileTo.hasCapability(teslaConsumer, side.getOpposite()) && tileFrom.hasCapability(teslaProducer, side)){
ITeslaConsumer handlerTo = tileTo.getCapability(teslaConsumer, side.getOpposite()); ITeslaConsumer handlerTo = tileTo.getCapability(teslaConsumer, side.getOpposite());
ITeslaProducer handlerFrom = tileFrom.getCapability(teslaProducer, side); ITeslaProducer handlerFrom = tileFrom.getCapability(teslaProducer, side);
if(handlerTo != null && handlerFrom != null){
long drain = handlerFrom.takePower(maxTransfer, true); long drain = handlerFrom.takePower(maxTransfer, true);
if(drain > 0){ if(drain > 0){
long filled = handlerTo.givePower(drain, false); long filled = handlerTo.givePower(drain, false);
handlerFrom.takePower(filled, false); handlerFrom.takePower(filled, false);
return true;
} }
} }
} }
return false;
}
private static TileTeslaWrapper getHandler(TileEntityBase tile, EnumFacing facing){ private static TileTeslaWrapper getHandler(TileEntityBase tile, EnumFacing facing){
TileTeslaWrapper[] handlers = TESLA_MAP.get(tile); TileTeslaWrapper[] handlers = TESLA_MAP.get(tile);