Compare commits

...

6 Commits

Author SHA1 Message Date
yueh c720584e49 Fixes #2729: Fix transformer regression introduced during FG downtime. (#2730)
Added a unittest to verify the necessary string returns match the actual
existing classes, in case something screws up the refactoring.
2016-12-31 18:25:16 +01:00
yueh ab89278274 Replaces old fluid handlers with the new capability based ones. (#2727)
* Changed ME Chest and P2P tunnels to use fluid capabilities.
* Renamed all occurrences of liquid to fluids.
2016-12-31 16:01:29 +01:00
yueh 7c5f777e41 Fixes #2713: Call super#onBlockActivated() for wrench interaction. (#2728) 2016-12-31 16:00:45 +01:00
yueh 8b0637d05d Fixes IDE not correctly cleaning up the list of staged files. 2016-12-31 15:21:25 +01:00
yueh 497f1c9ace Fixes #2714: Use a concurrent list to back NetworkList (#2715) 2016-12-29 15:51:17 +01:00
yueh 2ab0528015 Fixes #2724: Use capitalized oredict name for dyes, not uppercase. 2016-12-29 15:50:02 +01:00
21 changed files with 362 additions and 228 deletions
@@ -76,7 +76,7 @@ public interface IParts
IItemDefinition p2PTunnelItems();
IItemDefinition p2PTunnelLiquids();
IItemDefinition p2PTunnelFluids();
IItemDefinition p2PTunnelEU();
@@ -149,6 +149,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
final TileCraftingTile tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
{
if( Platform.isClient() )
@@ -160,7 +161,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
return true;
}
return false;
return super.onBlockActivated( w, pos, state, p, hand, heldItem, side, hitX, hitY, hitZ );
}
public enum CraftingUnitType
@@ -107,6 +107,7 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
return true;
}
return false;
return super.onBlockActivated( w, pos, state, p, hand, heldItem, side, hitX, hitY, hitZ );
}
}
@@ -47,6 +47,7 @@ import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
{
@@ -63,7 +64,6 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
}
}
public static final PropertyEnum<State> STATE = PropertyEnum.create( "state", State.class );
public BlockWireless()
@@ -113,13 +113,9 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
@Override
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
if( player.isSneaking() )
{
return false;
}
final TileWireless tg = this.getTileEntity( w, pos );
if( tg != null )
if( tg != null && !player.isSneaking() )
{
if( Platform.isServer() )
{
@@ -127,7 +123,8 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
}
return true;
}
return false;
return super.onBlockActivated( w, pos, state, player, hand, heldItem, side, hitX, hitY, hitZ );
}
@Override
@@ -61,7 +61,7 @@ public final class ApiParts implements IParts
private final IItemDefinition p2PTunnelME;
private final IItemDefinition p2PTunnelRedstone;
private final IItemDefinition p2PTunnelItems;
private final IItemDefinition p2PTunnelLiquids;
private final IItemDefinition p2PTunnelFluids;
private final IItemDefinition p2PTunnelEU;
// private final IItemDefinition p2PTunnelRF;
private final IItemDefinition p2PTunnelLight;
@@ -112,7 +112,7 @@ public final class ApiParts implements IParts
this.p2PTunnelME = new DamagedItemDefinition( "part.tunnel.me", itemPart.createPart( PartType.P2PTunnelME ) );
this.p2PTunnelRedstone = new DamagedItemDefinition( "part.tunnel.redstone", itemPart.createPart( PartType.P2PTunnelRedstone ) );
this.p2PTunnelItems = new DamagedItemDefinition( "part.tunnel.item", itemPart.createPart( PartType.P2PTunnelItems ) );
this.p2PTunnelLiquids = new DamagedItemDefinition( "part.tunnel.fluid", itemPart.createPart( PartType.P2PTunnelLiquids ) );
this.p2PTunnelFluids = new DamagedItemDefinition( "part.tunnel.fluid", itemPart.createPart( PartType.P2PTunnelFluids ) );
this.p2PTunnelEU = new DamagedItemDefinition( "part.tunnel.eu", itemPart.createPart( PartType.P2PTunnelEU ) );
// this.p2PTunnelRF = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelRF ) );
this.p2PTunnelLight = new DamagedItemDefinition( "part.tunnel.light", itemPart.createPart( PartType.P2PTunnelLight ) );
@@ -281,9 +281,9 @@ public final class ApiParts implements IParts
}
@Override
public IItemDefinition p2PTunnelLiquids()
public IItemDefinition p2PTunnelFluids()
{
return this.p2PTunnelLiquids;
return this.p2PTunnelFluids;
}
@Override
@@ -118,7 +118,7 @@ public enum AEFeature
P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_REDSTONE( "P2PTunnelRedstone", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_EU( "P2PTunnelEU", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_LIQUIDS( "P2PTunnelLiquids", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_FLUIDS( "P2PTunnelFluids", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_LIGHT( "P2PTunnelLight", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_OPEN_COMPUTERS( "P2PTunnelOpenComputers", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_PRESSURE( "P2PTunnelPressure", Constants.CATEGORY_P2P_TUNNELS ),
+1 -1
View File
@@ -64,7 +64,7 @@ public final class AppEngCore extends DummyModContainer implements IFMLLoadingPl
@Override
public String[] getASMTransformerClass()
{
return new String[] { "appeng.coremod.asm.ASMIntegration" };
return new String[] { "appeng.coremod.transformer.ASMIntegration" };
}
@Override
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod.asm;
package appeng.coremod.transformer;
import java.util.Iterator;
@@ -59,10 +59,10 @@ import appeng.parts.networking.PartCableGlass;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartQuartzFiber;
import appeng.parts.p2p.PartP2PFluids;
import appeng.parts.p2p.PartP2PIC2Power;
import appeng.parts.p2p.PartP2PItems;
import appeng.parts.p2p.PartP2PLight;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
@@ -226,8 +226,8 @@ public enum PartType
}
},
P2PTunnelLiquids( 463, "p2p_tunnel_liquids", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIQUIDS ), EnumSet
.noneOf( IntegrationType.class ), PartP2PLiquids.class, GuiText.FluidTunnel )
P2PTunnelFluids( 463, "p2p_tunnel_fluids", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS ), EnumSet
.noneOf( IntegrationType.class ), PartP2PFluids.class, GuiText.FluidTunnel )
{
@Override
String getUnlocalizedName()
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.text.WordUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockStainedGlass;
@@ -86,15 +88,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
static
{
for( final AEColor col : AEColor.values() )
for( final AEColor color : AEColor.VALID_COLORS )
{
if( col == AEColor.TRANSPARENT )
{
continue;
}
final String dyeName = color.dye.getUnlocalizedName();
final String oreDictName = "dye" + WordUtils.capitalize( dyeName );
final int oreDictId = OreDictionary.getOreID( oreDictName );
ORE_TO_COLOR.put( OreDictionary.getOreID( "dye" + col.name() ), col );
ORE_TO_COLOR.put( oreDictId, color );
}
}
@@ -277,7 +277,8 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
list.add( i );
}
Collections.sort( list, new Comparator<IAEItemStack>(){
Collections.sort( list, new Comparator<IAEItemStack>()
{
@Override
public int compare( final IAEItemStack a, final IAEItemStack b )
+3 -3
View File
@@ -21,8 +21,8 @@ package appeng.me;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
@@ -31,7 +31,7 @@ import java.util.List;
public class NetworkList implements Collection<Grid>
{
private List<Grid> networks = new LinkedList<Grid>();
private List<Grid> networks = new CopyOnWriteArrayList<>();
@Override
public int size()
@@ -108,6 +108,6 @@ public class NetworkList implements Collection<Grid>
@Override
public void clear()
{
this.networks = new LinkedList<Grid>();
this.networks.clear();
}
}
@@ -19,28 +19,42 @@
package appeng.parts.p2p;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankProperties;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import appeng.api.parts.IPartModel;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFluidHandler
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_liquids" );
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_fluids" );
private static final ThreadLocal<Deque<PartP2PFluids>> DEPTH = new ThreadLocal<>();
private static final FluidTankProperties[] ACTIVE_TANK = { new FluidTankProperties( null, 10000, true, false ) };
private static final FluidTankProperties[] INACTIVE_TANK = { new FluidTankProperties( null, 0, false, false ) };
private IFluidHandler cachedTank;
private int tmpUsed;
public PartP2PFluids( final ItemStack is )
{
super( is );
}
@PartModels
public static List<IPartModel> getModels()
@@ -48,17 +62,6 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
return MODELS.getModels();
}
private static final ThreadLocal<Stack<PartP2PLiquids>> DEPTH = new ThreadLocal<Stack<PartP2PLiquids>>();
private static final FluidTankInfo[] ACTIVE_TANK = { new FluidTankInfo( null, 10000 ) };
private static final FluidTankInfo[] INACTIVE_TANK = { new FluidTankInfo( null, 0 ) };
private IFluidHandler cachedTank;
private int tmpUsed;
public PartP2PLiquids( final ItemStack is )
{
super( is );
}
public float getPowerDrainPerTick()
{
return 2.0f;
@@ -74,9 +77,10 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
public void onNeighborChanged()
{
this.cachedTank = null;
if( this.isOutput() )
{
final PartP2PLiquids in = this.getInput();
final PartP2PFluids in = this.getInput();
if( in != null )
{
in.onTunnelNetworkChange();
@@ -85,11 +89,54 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
}
@Override
public int fill( final EnumFacing from, final FluidStack resource, final boolean doFill )
public boolean hasCapability( Capability<?> capabilityClass )
{
final Stack<PartP2PLiquids> stack = this.getDepth();
if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
{
return true;
}
for( final PartP2PLiquids t : stack )
return super.hasCapability( capabilityClass );
}
@Override
public <T> T getCapability( Capability<T> capabilityClass )
{
if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
{
return (T) this;
}
return super.getCapability( capabilityClass );
}
@Override
public IPartModel getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
@Override
public IFluidTankProperties[] getTankProperties()
{
if( !this.isOutput() )
{
final PartP2PFluids tun = this.getInput();
if( tun != null )
{
return ACTIVE_TANK;
}
}
return INACTIVE_TANK;
}
@Override
public int fill( FluidStack resource, boolean doFill )
{
final Deque<PartP2PFluids> stack = this.getDepth();
for( final PartP2PFluids t : stack )
{
if( t == this )
{
@@ -99,17 +146,18 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
stack.push( this );
final List<PartP2PLiquids> list = this.getOutputs( resource.getFluid() );
final List<PartP2PFluids> list = this.getOutputs( resource.getFluid() );
int requestTotal = 0;
Iterator<PartP2PLiquids> i = list.iterator();
Iterator<PartP2PFluids> i = list.iterator();
while( i.hasNext() )
{
final PartP2PLiquids l = i.next();
final PartP2PFluids l = i.next();
final IFluidHandler tank = l.getTarget();
if( tank != null )
{
l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), resource.copy(), false );
l.tmpUsed = tank.fill( resource.copy(), false );
}
else
{
@@ -150,9 +198,10 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
i = list.iterator();
int used = 0;
while( i.hasNext() )
{
final PartP2PLiquids l = i.next();
final PartP2PFluids l = i.next();
final FluidStack insert = resource.copy();
insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) );
@@ -164,7 +213,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
final IFluidHandler tank = l.getTarget();
if( tank != null )
{
l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), insert.copy(), true );
l.tmpUsed = tank.fill( insert.copy(), true );
}
else
{
@@ -183,33 +232,43 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
return used;
}
private Stack<PartP2PLiquids> getDepth()
@Override
public FluidStack drain( FluidStack resource, boolean doDrain )
{
Stack<PartP2PLiquids> s = DEPTH.get();
return null;
}
@Override
public FluidStack drain( int maxDrain, boolean doDrain )
{
return null;
}
private Deque<PartP2PFluids> getDepth()
{
Deque<PartP2PFluids> s = DEPTH.get();
if( s == null )
{
DEPTH.set( s = new Stack<PartP2PLiquids>() );
DEPTH.set( s = new LinkedList<>() );
}
return s;
}
private List<PartP2PLiquids> getOutputs( final Fluid input )
private List<PartP2PFluids> getOutputs( final Fluid input )
{
final List<PartP2PLiquids> outs = new LinkedList<PartP2PLiquids>();
final List<PartP2PFluids> outs = new LinkedList<>();
try
{
for( final PartP2PLiquids l : this.getOutputs() )
for( final PartP2PFluids l : this.getOutputs() )
{
final IFluidHandler handler = l.getTarget();
if( handler != null )
{
if( handler.canFill( l.getSide().getFacing().getOpposite(), input ) )
{
outs.add( l );
}
outs.add( l );
}
}
}
@@ -234,79 +293,14 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
}
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) );
if( te instanceof IFluidHandler )
if( te != null && te.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ) )
{
return this.cachedTank = (IFluidHandler) te;
return this.cachedTank = te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
this.getSide().getFacing().getOpposite() );
}
return null;
}
@Override
public FluidStack drain( final EnumFacing from, final FluidStack resource, final boolean doDrain )
{
return null;
}
@Override
public FluidStack drain( final EnumFacing from, final int maxDrain, final boolean doDrain )
{
return null;
}
@Override
public boolean canFill( final EnumFacing from, final Fluid fluid )
{
return !this.isOutput() && from == this.getSide().getFacing() && !this.getOutputs( fluid ).isEmpty();
}
@Override
public boolean canDrain( final EnumFacing from, final Fluid fluid )
{
return false;
}
@Override
public FluidTankInfo[] getTankInfo( final EnumFacing from )
{
if( from == this.getSide().getFacing() )
{
return this.getTank();
}
return new FluidTankInfo[0];
}
private FluidTankInfo[] getTank()
{
if( this.isOutput() )
{
final PartP2PLiquids tun = this.getInput();
if( tun != null )
{
return ACTIVE_TANK;
}
}
else
{
try
{
if( !this.getOutputs().isEmpty() )
{
return ACTIVE_TANK;
}
}
catch( final GridAccessException e )
{
// :(
}
}
return INACTIVE_TANK;
}
@Override
public IPartModel getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -232,7 +232,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
*/
case FLUID:
newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null );
newType = parts.p2PTunnelFluids().maybeStack( 1 ).orElse( null );
break;
case IC2_POWER:
+102 -88
View File
@@ -35,10 +35,11 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankProperties;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
@@ -98,7 +99,7 @@ import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHandler, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickable
public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickable
{
private static final ChestNoHandler NO_HANDLER = new ChestNoHandler();
@@ -118,7 +119,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
private ICellHandler cellHandler;
private MEMonitorHandler itemCell;
private MEMonitorHandler fluidCell;
private final Accessor accessor = new Accessor();
private Accessor accessor;
private IFluidHandler fluidHandler;
public TileChest()
{
@@ -203,6 +205,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.itemCell = null;
this.fluidCell = null;
this.accessor = null;
this.fluidHandler = null;
final ItemStack is = this.inv.getStackInSlot( 1 );
if( is != null )
{
@@ -228,6 +233,17 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.itemCell = this.wrap( itemCell );
this.fluidCell = this.wrap( fluidCell );
if( this.itemCell != null )
{
}
this.accessor = new Accessor();
if( this.fluidCell != null )
{
this.fluidHandler = new FluidHandler();
}
}
}
}
@@ -468,7 +484,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.lastStateChange = this.worldObj.getTotalWorldTime();
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons().isSameItem( oldType, this.storageType );
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons()
.isSameItem( oldType, this.storageType );
}
@TileEvent( TileEventType.WORLD_NBT_READ )
@@ -576,7 +593,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
try
{
final IMEInventory<IAEItemStack> cell = this.getHandler( StorageChannel.ITEMS );
final IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), Actionable.SIMULATE, this.mySrc );
final IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), Actionable.SIMULATE,
this.mySrc );
return returns == null || returns.getStackSize() != insertingItem.stackSize;
}
catch( final ChestNoHandler ignored )
@@ -625,7 +643,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
final IMEInventory<IAEItemStack> cell = this.getHandler( StorageChannel.ITEMS );
final IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), this.mySrc );
final IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ),
this.mySrc );
if( returns == null )
{
@@ -699,84 +718,6 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.recalculateDisplay();
}
@Override
public int fill( final EnumFacing from, final FluidStack resource, final boolean doFill )
{
final double req = resource.amount / 500.0;
final double available = this.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
if( available >= req - 0.01 )
{
try
{
final IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
this.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
final IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE, this.mySrc );
if( results == null )
{
return resource.amount;
}
return resource.amount - (int) results.getStackSize();
}
catch( final ChestNoHandler ignored )
{
}
}
return 0;
}
@Override
public FluidStack drain( final EnumFacing from, final FluidStack resource, final boolean doDrain )
{
return null;
}
@Override
public FluidStack drain( final EnumFacing from, final int maxDrain, final boolean doDrain )
{
return null;
}
@Override
public boolean canFill( final EnumFacing from, final Fluid fluid )
{
try
{
final IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
return h.canAccept( AEFluidStack.create( new FluidStack( fluid, 1 ) ) );
}
catch( final ChestNoHandler ignored )
{
}
return false;
}
@Override
public boolean canDrain( final EnumFacing from, final Fluid fluid )
{
return false;
}
@Override
public FluidTankInfo[] getTankInfo( final EnumFacing from )
{
try
{
final IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
if( h.getChannel() == StorageChannel.FLUIDS )
{
return new FluidTankInfo[] { new FluidTankInfo( null, 1 ) }; // eh?
}
}
catch( final ChestNoHandler ignored )
{
}
return null;
}
public ItemStack getStorageType()
{
if( this.isPowered() )
@@ -990,7 +931,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
{
if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && facing != getForward() )
if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null && facing != getForward() )
{
return true;
}
if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null && facing != getForward() )
{
return true;
}
@@ -1001,7 +946,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && facing != getForward() )
if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null && facing != getForward() )
{
return (T) this.fluidHandler;
}
if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null && facing != getForward() )
{
return (T) accessor;
}
@@ -1022,4 +971,69 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
}
}
private class FluidHandler implements IFluidHandler
{
@Override
public int fill( final FluidStack resource, final boolean doFill )
{
final double req = resource.amount / 500.0;
final double available = TileChest.this.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
if( available >= req - 0.01 )
{
try
{
final IMEInventoryHandler h = TileChest.this.getHandler( StorageChannel.FLUIDS );
TileChest.this.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
final IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE,
TileChest.this.mySrc );
if( results == null )
{
return resource.amount;
}
return resource.amount - (int) results.getStackSize();
}
catch( final ChestNoHandler ignored )
{
}
}
return 0;
}
@Override
public FluidStack drain( final FluidStack resource, final boolean doDrain )
{
return null;
}
@Override
public FluidStack drain( final int maxDrain, final boolean doDrain )
{
return null;
}
@Override
public IFluidTankProperties[] getTankProperties()
{
try
{
final IMEInventoryHandler h = TileChest.this.getHandler( StorageChannel.FLUIDS );
if( h.getChannel() == StorageChannel.FLUIDS )
{
return new IFluidTankProperties[] { new FluidTankProperties( null, 1 ) }; // eh?
}
}
catch( final ChestNoHandler ignored )
{
}
return null;
}
}
}
@@ -1,3 +1,20 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render;
@@ -35,7 +52,8 @@ public class UVLightmapJsonTest
@EventHandler
public void preInit( FMLPreInitializationEvent event )
{
GameRegistry.register( uvlblock = new Block( Material.IRON ){
GameRegistry.register( uvlblock = new Block( Material.IRON )
{
final AxisAlignedBB box = new AxisAlignedBB( 0.25, 0, 7 / 16d, 0.75, 1, 9 / 16d );
@@ -0,0 +1,56 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class AppEngCoreTest
{
private final static String EXPECTED_CONTAINER_CLASS_NAME = appeng.coremod.AppEngCore.class.getName();
private final static String EXPECTED_CONTAINER_MOD_ID = "appliedenergistics2-core";
private final static String[] EXPECTED_TRANSFORMERS = new String[] {
appeng.coremod.transformer.ASMIntegration.class.getName()
};
private AppEngCore coreModContainer = new AppEngCore();
@Test
public void testTransformerStringsMatchActualClasses()
{
assertArrayEquals( EXPECTED_TRANSFORMERS, coreModContainer.getASMTransformerClass() );
}
@Test
public void testContainerClassExists()
{
assertEquals( EXPECTED_CONTAINER_CLASS_NAME, coreModContainer.getModContainerClass() );
}
@Test
public void testContainerModId()
{
assertEquals( EXPECTED_CONTAINER_MOD_ID, coreModContainer.getModId() );
}
}
@@ -1,3 +1,20 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.services.version;
@@ -7,6 +7,24 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
/**
* Test for {@link ISlimReadableNumberConverter}
*
@@ -1,3 +1,20 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util;