mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Remove the weird energy and fluid pulling and also make them split into all devices around
Closes #221
This commit is contained in:
parent
b3a428e50f
commit
e636ab14f1
32 changed files with 396 additions and 151 deletions
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.recipe;
|
|||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This file ("IDontWannaUseRFReceiver.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{
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* This file ("IEnergyProviderBetter.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.IEnergyProvider;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface ISharingEnergyProvider extends IEnergyProvider{
|
||||
|
||||
int getEnergyToSplitShare();
|
||||
|
||||
boolean doesShareEnergy();
|
||||
|
||||
EnumFacing[] getEnergyShareSides();
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* This file ("ISharingFluidHandler.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 net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public interface ISharingFluidHandler extends IFluidHandler{
|
||||
|
||||
int getFluidAmountToSplitShare();
|
||||
|
||||
boolean doesShareFluid();
|
||||
|
||||
EnumFacing[] getFluidShareSides();
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||
|
@ -28,7 +27,7 @@ import net.minecraft.util.SoundCategory;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergyDisplay, IAtomicReconstructor{
|
||||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements ICustomEnergyReceiver, IEnergyDisplay, IAtomicReconstructor{
|
||||
|
||||
public static final int ENERGY_USE = 1000;
|
||||
public final EnergyStorage storage = new EnergyStorage(300000);
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
|
@ -219,12 +217,26 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
this.ticksElapsed++;
|
||||
|
||||
if(!this.worldObj.isRemote){
|
||||
if(this instanceof IEnergyReceiver || this instanceof IEnergyProvider){
|
||||
WorldUtil.doEnergyInteraction(this);
|
||||
if(this instanceof ISharingEnergyProvider){
|
||||
ISharingEnergyProvider provider = (ISharingEnergyProvider)this;
|
||||
if(provider.doesShareEnergy()){
|
||||
EnumFacing[] sides = provider.getEnergyShareSides();
|
||||
int amount = provider.getEnergyToSplitShare()/sides.length;
|
||||
for(EnumFacing side : sides){
|
||||
WorldUtil.doEnergyInteraction(this, side, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this instanceof net.minecraftforge.fluids.IFluidHandler || this.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)){
|
||||
WorldUtil.doFluidInteraction(this);
|
||||
if(this instanceof ISharingFluidHandler){
|
||||
ISharingFluidHandler handler = (ISharingFluidHandler)this;
|
||||
if(handler.doesShareFluid()){
|
||||
EnumFacing[] sides = handler.getFluidShareSides();
|
||||
int amount = handler.getFluidAmountToSplitShare()/sides.length;
|
||||
for(EnumFacing side : sides){
|
||||
WorldUtil.doFluidInteraction(this, side, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
|
@ -25,7 +24,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, net.minecraftforge.fluids.IFluidHandler{
|
||||
public class TileEntityCanolaPress extends TileEntityInventoryBase implements ICustomEnergyReceiver, ISharingFluidHandler{
|
||||
|
||||
public static final int PRODUCE = 80;
|
||||
public static final int ENERGY_USE = 35;
|
||||
|
@ -212,4 +211,19 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmountToSplitShare(){
|
||||
return this.tank.getFluidAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareFluid(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getFluidShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider{
|
||||
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public static final int PRODUCE = 30;
|
||||
public final EnergyStorage storage = new EnergyStorage(60000);
|
||||
|
@ -131,4 +131,19 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
|
@ -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, IEnergyReceiver, net.minecraftforge.fluids.IFluidHandler{
|
||||
public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, ICustomEnergyReceiver, ISharingFluidHandler{
|
||||
|
||||
public static final int SLOT_COFFEE_BEANS = 0;
|
||||
public static final int SLOT_INPUT = 1;
|
||||
|
@ -281,4 +280,19 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmountToSplitShare(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareFluid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getFluidShareSides(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
|
@ -28,7 +27,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver{
|
||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
|
||||
public static final int RANGE = 8;
|
||||
public static final int ENERGY_USE = 5;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -20,7 +19,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay, IEnergyReceiver{
|
||||
public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay, ICustomEnergyReceiver{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(800000);
|
||||
private int oldEnergy;
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
|
@ -23,7 +22,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver{
|
||||
public class TileEntityEnergizer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(500000);
|
||||
private int lastEnergy;
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider{
|
||||
public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(500000);
|
||||
private int lastEnergy;
|
||||
|
@ -132,4 +132,19 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
|
|||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import net.minecraftforge.fluids.capability.templates.FluidHandlerFluidMap;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityFermentingBarrel extends TileEntityBase implements net.minecraftforge.fluids.IFluidHandler{
|
||||
public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler{
|
||||
|
||||
private static final int PROCESS_TIME = 100;
|
||||
public final FluidTank canolaTank = new FluidTank(2*Util.BUCKET){
|
||||
|
@ -176,4 +176,19 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements net.mi
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmountToSplitShare(){
|
||||
return this.oilTank.getFluidAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareFluid(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getFluidShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.init.Items;
|
||||
|
@ -23,7 +22,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityFireworkBox extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
|
||||
public static final int USE_PER_SHOT = 300;
|
||||
public final EnergyStorage storage = new EnergyStorage(20000);
|
||||
|
|
|
@ -29,7 +29,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityFluidCollector extends TileEntityBase implements net.minecraftforge.fluids.IFluidHandler{
|
||||
public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler{
|
||||
|
||||
public boolean isPlacer;
|
||||
public final FluidTank tank = new FluidTank(8*Util.BUCKET){
|
||||
|
@ -225,4 +225,19 @@ public class TileEntityFluidCollector extends TileEntityBase implements net.mine
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmountToSplitShare(){
|
||||
return this.tank.getFluidAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareFluid(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getFluidShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -24,7 +23,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor{
|
||||
public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor{
|
||||
|
||||
public static final int SLOT_INPUT_1 = 0;
|
||||
public static final int SLOT_OUTPUT_1 = 1;
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider, IEnergyDisplay{
|
||||
public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{
|
||||
|
||||
public static final int PRODUCE = 8;
|
||||
public final EnergyStorage storage = new EnergyStorage(30000);
|
||||
|
@ -96,4 +96,19 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
|
|||
public boolean needsHoldShift(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
|
@ -30,7 +29,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor{
|
||||
public class TileEntityGrinder extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor{
|
||||
|
||||
public static final int SLOT_INPUT_1 = 0;
|
||||
public static final int SLOT_OUTPUT_1_1 = 1;
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider, IEnergyDisplay{
|
||||
public class TileEntityHeatCollector extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{
|
||||
|
||||
public static final int ENERGY_PRODUCE = 40;
|
||||
public static final int BLOCKS_NEEDED = 4;
|
||||
|
@ -107,4 +107,19 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
public boolean needsHoldShift(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -20,7 +19,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver{
|
||||
public class TileEntityItemRepairer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
|
||||
public static final int SLOT_INPUT = 0;
|
||||
public static final int SLOT_OUTPUT = 1;
|
||||
|
|
|
@ -21,13 +21,14 @@ import net.darkhax.tesla.api.ITeslaConsumer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements IEnergyReceiver{
|
||||
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements ICustomEnergyReceiver{
|
||||
|
||||
public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
||||
|
||||
|
@ -92,6 +93,9 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
|||
//Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times
|
||||
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();
|
||||
|
||||
List<TileEntityLaserRelayEnergy> relaysThatWork = new ArrayList<TileEntityLaserRelayEnergy>();
|
||||
int totalReceiverAmount = 0;
|
||||
|
||||
for(ConnectionPair pair : network.connections){
|
||||
for(BlockPos relay : pair.positions){
|
||||
if(relay != null && !alreadyChecked.contains(relay)){
|
||||
|
@ -99,52 +103,65 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
|||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||
if(relayTile instanceof TileEntityLaserRelayEnergy){
|
||||
TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile;
|
||||
double highestLoss = Math.max(theRelay.getLossPercentage(), this.getLossPercentage());
|
||||
int lowestCap = Math.min(theRelay.getEnergyCap(), this.getEnergyCap());
|
||||
for(Map.Entry<EnumFacing, TileEntity> receiver : theRelay.receiversAround.entrySet()){
|
||||
if(receiver != null){
|
||||
EnumFacing side = receiver.getKey();
|
||||
EnumFacing opp = side.getOpposite();
|
||||
TileEntity tile = receiver.getValue();
|
||||
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(maxTransfer, lowestCap)-transmitted, true);
|
||||
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
|
||||
transmitted += iReceiver.receiveEnergy(opp, theoreticalReceived-deduct, simulate);
|
||||
transmitted += deduct;
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
|
||||
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
|
||||
if(cap != null){
|
||||
int theoreticalReceived = (int)cap.givePower(Math.min(maxTransfer, lowestCap)-transmitted, true);
|
||||
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
|
||||
transmitted += cap.givePower(theoreticalReceived-deduct, simulate);
|
||||
transmitted += deduct;
|
||||
}
|
||||
}
|
||||
int amount = theRelay.receiversAround.size();
|
||||
if(amount > 0){
|
||||
relaysThatWork.add(theRelay);
|
||||
totalReceiverAmount += amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If everything that could be transmitted was transmitted
|
||||
if(transmitted >= maxTransfer){
|
||||
return transmitted;
|
||||
}
|
||||
if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
|
||||
int amountPer = maxTransfer/totalReceiverAmount;
|
||||
|
||||
for(TileEntityLaserRelayEnergy theRelay : relaysThatWork){
|
||||
double highestLoss = Math.max(theRelay.getLossPercentage(), this.getLossPercentage());
|
||||
int lowestCap = Math.min(theRelay.getEnergyCap(), this.getEnergyCap());
|
||||
for(Map.Entry<EnumFacing, TileEntity> receiver : theRelay.receiversAround.entrySet()){
|
||||
if(receiver != null){
|
||||
EnumFacing side = receiver.getKey();
|
||||
EnumFacing opp = side.getOpposite();
|
||||
TileEntity tile = receiver.getValue();
|
||||
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);
|
||||
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
|
||||
transmitted += iReceiver.receiveEnergy(opp, theoreticalReceived-deduct, simulate);
|
||||
transmitted += deduct;
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
|
||||
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
|
||||
if(cap != null){
|
||||
int theoreticalReceived = (int)cap.givePower(Math.min(amountPer, lowestCap), true);
|
||||
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
|
||||
transmitted += cap.givePower(theoreticalReceived-deduct, simulate);
|
||||
transmitted += deduct;
|
||||
}
|
||||
}
|
||||
|
||||
//If everything that could be transmitted was transmitted
|
||||
if(transmitted >= maxTransfer){
|
||||
return transmitted;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return transmitted;
|
||||
}
|
||||
|
||||
private int calcDeduction(int theoreticalReceived, double highestLoss){
|
||||
return ConfigBoolValues.LASER_RELAY_LOSS.isEnabled() ? (int)(theoreticalReceived*(highestLoss/100)) : 0;
|
||||
return ConfigBoolValues.LASER_RELAY_LOSS.isEnabled() ? MathHelper.ceiling_double_int(theoreticalReceived*(highestLoss/100)) : 0;
|
||||
}
|
||||
|
||||
public int getEnergyCap(){
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
|
@ -22,7 +21,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityLavaFactoryController extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
|
||||
public static final int NOT_MULTI = 0;
|
||||
public static final int HAS_LAVA = 1;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyProvider, IEnergyDisplay{
|
||||
public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{
|
||||
|
||||
public static final int RANGE = 7;
|
||||
public static final int ENERGY_PRODUCED = 300;
|
||||
|
@ -129,4 +129,19 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
public boolean needsHoldShift(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||
|
@ -33,7 +32,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergyDisplay{
|
||||
public class TileEntityMiner extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor, IEnergyDisplay{
|
||||
|
||||
public static final int ENERGY_USE_PER_BLOCK = 1500;
|
||||
public static final int DEFAULT_RANGE = 2;
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityOilGenerator extends TileEntityBase implements IEnergyProvider, net.minecraftforge.fluids.IFluidHandler{
|
||||
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{
|
||||
|
||||
public static final int ENERGY_PRODUCED = 76;
|
||||
private static final int BURN_TIME = 100;
|
||||
|
@ -192,4 +192,34 @@ public class TileEntityOilGenerator extends TileEntityBase implements IEnergyPro
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmountToSplitShare(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareFluid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getFluidShareSides(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.darkhax.tesla.api.ITeslaProducer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements IEnergyReceiver, IEnergyProvider{
|
||||
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ICustomEnergyReceiver, ISharingEnergyProvider{
|
||||
|
||||
public TileEntityPhantomEnergyface(){
|
||||
super("energyface");
|
||||
|
@ -132,4 +132,19 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,10 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{
|
||||
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler{
|
||||
|
||||
public TileEntityPhantomLiquiface(){
|
||||
super("liquiface");
|
||||
|
@ -88,4 +85,19 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmountToSplitShare(){
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareFluid(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getFluidShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
|
@ -24,7 +23,7 @@ import net.minecraft.util.EnumFacing;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileEntityPlayerInterface extends TileEntityInventoryBase implements IEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityPlayerInterface extends TileEntityInventoryBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
|
||||
public static final int DEFAULT_RANGE = 32;
|
||||
private final EnergyStorage storage = new EnergyStorage(30000);
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityShockSuppressor extends TileEntityBase implements IEnergyReceiver, IEnergyDisplay{
|
||||
public class TileEntityShockSuppressor extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
|
||||
public static final List<TileEntityShockSuppressor> SUPPRESSORS = new ArrayList<TileEntityShockSuppressor>();
|
||||
|
||||
|
|
|
@ -91,70 +91,51 @@ public final class WorldUtil{
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void doEnergyInteraction(TileEntity tile){
|
||||
for(EnumFacing side : EnumFacing.values()){
|
||||
TileEntity otherTile = tile.getWorld().getTileEntity(tile.getPos().offset(side));
|
||||
if(otherTile != null){
|
||||
IEnergyReceiver handlerTo = null;
|
||||
IEnergyProvider handlerFrom = null;
|
||||
public static void doEnergyInteraction(TileEntity tileFrom, EnumFacing sideTo, int maxTransfer){
|
||||
TileEntity tileTo = tileFrom.getWorld().getTileEntity(tileFrom.getPos().offset(sideTo));
|
||||
if(tileTo != null){
|
||||
if(tileFrom instanceof IEnergyProvider && tileTo instanceof IEnergyReceiver){
|
||||
IEnergyReceiver handlerTo = (IEnergyReceiver)tileTo;
|
||||
IEnergyProvider handlerFrom = (IEnergyProvider)tileFrom;
|
||||
|
||||
//Push RF
|
||||
if(tile instanceof IEnergyProvider && otherTile instanceof IEnergyReceiver){
|
||||
handlerTo = (IEnergyReceiver)otherTile;
|
||||
handlerFrom = (IEnergyProvider)tile;
|
||||
}
|
||||
//Pull RF
|
||||
else if(tile instanceof IEnergyReceiver && otherTile instanceof IEnergyProvider){
|
||||
handlerTo = (IEnergyReceiver)tile;
|
||||
handlerFrom = (IEnergyProvider)otherTile;
|
||||
}
|
||||
|
||||
if(handlerFrom != null && handlerTo != null){
|
||||
int drain = handlerFrom.extractEnergy(side, Integer.MAX_VALUE, true);
|
||||
if(drain > 0){
|
||||
if(handlerTo.canConnectEnergy(side.getOpposite())){
|
||||
int filled = handlerTo.receiveEnergy(side.getOpposite(), drain, false);
|
||||
handlerFrom.extractEnergy(side, filled, false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
TeslaUtil.doWrappedTeslaRFInteraction(tile, otherTile, side);
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
TeslaUtil.doWrappedTeslaRFInteraction(tileFrom, tileTo, sideTo, maxTransfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void doFluidInteraction(TileEntity tile){
|
||||
for(EnumFacing side : EnumFacing.values()){
|
||||
TileEntity otherTile = tile.getWorld().getTileEntity(tile.getPos().offset(side));
|
||||
if(otherTile != null){
|
||||
for(int i = 0; i < 2; i++){
|
||||
//Push and pull with old fluid system
|
||||
if(tile instanceof net.minecraftforge.fluids.IFluidHandler && otherTile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||
net.minecraftforge.fluids.IFluidHandler handlerTo = (net.minecraftforge.fluids.IFluidHandler)(i == 0 ? tile : otherTile);
|
||||
net.minecraftforge.fluids.IFluidHandler handlerFrom = (net.minecraftforge.fluids.IFluidHandler)(i == 0 ? otherTile : tile);
|
||||
FluidStack drain = handlerFrom.drain(side, Integer.MAX_VALUE, false);
|
||||
if(drain != null){
|
||||
if(handlerTo.canFill(side.getOpposite(), drain.getFluid())){
|
||||
int filled = handlerTo.fill(side.getOpposite(), drain.copy(), true);
|
||||
handlerFrom.drain(side, filled, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void doFluidInteraction(TileEntity tileFrom, EnumFacing sideTo, int maxTransfer){
|
||||
TileEntity tileTo = tileFrom.getWorld().getTileEntity(tileFrom.getPos().offset(sideTo));
|
||||
if(tileTo != null){
|
||||
//Push and pull with old fluid system
|
||||
if(tileFrom instanceof net.minecraftforge.fluids.IFluidHandler && tileTo instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||
net.minecraftforge.fluids.IFluidHandler handlerTo = (net.minecraftforge.fluids.IFluidHandler)tileTo;
|
||||
net.minecraftforge.fluids.IFluidHandler handlerFrom = (net.minecraftforge.fluids.IFluidHandler)tileFrom;
|
||||
FluidStack drain = handlerFrom.drain(sideTo, maxTransfer, false);
|
||||
if(drain != null){
|
||||
if(handlerTo.canFill(sideTo.getOpposite(), drain.getFluid())){
|
||||
int filled = handlerTo.fill(sideTo.getOpposite(), drain.copy(), true);
|
||||
handlerFrom.drain(sideTo, filled, true);
|
||||
}
|
||||
//Push and pull with new fluid system
|
||||
else{
|
||||
IFluidHandler handlerFrom = (i == 0 ? tile : otherTile).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, i == 0 ? side : side.getOpposite());
|
||||
IFluidHandler handlerTo = (i == 0 ? otherTile : tile).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, i == 0 ? side.getOpposite() : side);
|
||||
if(handlerFrom != null && handlerTo != null){
|
||||
FluidStack drain = handlerFrom.drain(Integer.MAX_VALUE, false);
|
||||
if(drain != null){
|
||||
int filled = handlerTo.fill(drain.copy(), true);
|
||||
handlerFrom.drain(filled, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Push and pull with new fluid system
|
||||
else{
|
||||
if(tileFrom.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo) && tileTo.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo.getOpposite())){
|
||||
IFluidHandler handlerFrom = tileFrom.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo);
|
||||
IFluidHandler handlerTo = tileTo.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo.getOpposite());
|
||||
FluidStack drain = handlerFrom.drain(maxTransfer, false);
|
||||
if(drain != null){
|
||||
int filled = handlerTo.fill(drain.copy(), true);
|
||||
handlerFrom.drain(filled, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,19 +47,12 @@ public final class TeslaUtil{
|
|||
}
|
||||
}
|
||||
|
||||
public static void doWrappedTeslaRFInteraction(TileEntity tile, TileEntity otherTile, EnumFacing side){
|
||||
ITeslaConsumer handlerTo = null;
|
||||
ITeslaProducer handlerFrom = null;
|
||||
public static void 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);
|
||||
|
||||
for(int i = 0; i < 2; i++){
|
||||
if(handlerFrom == null && handlerTo == null){
|
||||
handlerFrom = (i == 0 ? tile : otherTile).getCapability(teslaProducer, i == 0 ? side : side.getOpposite());
|
||||
handlerTo = (i == 0 ? otherTile : tile).getCapability(teslaConsumer, i == 0 ? side.getOpposite() : side);
|
||||
}
|
||||
}
|
||||
|
||||
if(handlerFrom != null && handlerTo != null){
|
||||
long drain = handlerFrom.takePower(Long.MAX_VALUE, true);
|
||||
long drain = handlerFrom.takePower(maxTransfer, true);
|
||||
if(drain > 0){
|
||||
long filled = handlerTo.givePower(drain, false);
|
||||
handlerFrom.takePower(filled, false);
|
||||
|
|
Loading…
Reference in a new issue