Port to 1.11

This commit is contained in:
yueh
2016-12-08 12:42:00 +01:00
parent 589730bfad
commit ed9e6dd21c
262 changed files with 4027 additions and 3954 deletions
@@ -1,263 +1,263 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, 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.parts.p2p;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import appeng.api.config.PowerUnits;
import appeng.api.parts.IPartModel;
import appeng.coremod.annotations.Integration.Interface;
import appeng.coremod.annotations.Integration.InterfaceList;
import appeng.integration.IntegrationType;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
import appeng.util.Platform;
@InterfaceList( value = {
@Interface( iface = "ic2.api.energy.tile.IEnergySink", iname = IntegrationType.IC2 ),
@Interface( iface = "ic2.api.energy.tile.IEnergySource", iname = IntegrationType.IC2 )
} )
public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements IEnergySink, IEnergySource
{
private static final String TAG_BUFFERED_ENERGY_1 = "bufferedEnergy1";
private static final String TAG_BUFFERED_ENERGY_2 = "bufferedEnergy2";
private static final String TAG_BUFFERED_VOLTAGE_1 = "outputPacket1";
private static final String TAG_BUFFERED_VOLTAGE_2 = "outputPacket2";
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_ic2" );
@PartModels
public static List<IPartModel> getModels()
{
return MODELS.getModels();
}
// Buffer the energy + voltage for two IC2 ENET packets
private double bufferedEnergy1;
private double bufferedVoltage1;
private double bufferedEnergy2;
private double bufferedVoltage2;
public PartP2PIC2Power( ItemStack is )
{
super( is );
}
@Override
public void readFromNBT( NBTTagCompound tag )
{
super.readFromNBT( tag );
this.bufferedEnergy1 = tag.getDouble( TAG_BUFFERED_ENERGY_1 );
this.bufferedEnergy2 = tag.getDouble( TAG_BUFFERED_ENERGY_2 );
this.bufferedVoltage1 = tag.getDouble( TAG_BUFFERED_VOLTAGE_1 );
this.bufferedVoltage2 = tag.getDouble( TAG_BUFFERED_VOLTAGE_2 );
}
@Override
public void writeToNBT( NBTTagCompound tag )
{
super.writeToNBT( tag );
tag.setDouble( TAG_BUFFERED_ENERGY_1, this.bufferedEnergy1 );
tag.setDouble( TAG_BUFFERED_ENERGY_2, this.bufferedEnergy2 );
tag.setDouble( TAG_BUFFERED_VOLTAGE_1, this.bufferedVoltage1 );
tag.setDouble( TAG_BUFFERED_VOLTAGE_2, this.bufferedVoltage2 );
}
@Override
public void onTunnelConfigChange()
{
this.getHost().partChanged();
}
@Override
public void onTunnelNetworkChange()
{
this.getHost().notifyNeighbors();
}
@Override
public boolean acceptsEnergyFrom( IEnergyEmitter emitter, EnumFacing direction )
{
return !this.isOutput() && direction == this.getSide().getFacing();
}
@Override
public boolean emitsEnergyTo( IEnergyAcceptor receiver, EnumFacing direction )
{
return this.isOutput() && direction == this.getSide().getFacing();
}
@Override
public double getDemandedEnergy()
{
if( this.isOutput() )
{
return 0;
}
try
{
for( PartP2PIC2Power t : this.getOutputs() )
{
if( t.bufferedEnergy1 <= 0.0001 || t.bufferedEnergy2 <= 0.0001 )
{
return 2048;
}
}
}
catch( GridAccessException e )
{
return 0;
}
return 0;
}
@Override
public int getSinkTier()
{
return 4;
}
@Override
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
{
TunnelCollection<PartP2PIC2Power> outs;
try
{
outs = this.getOutputs();
}
catch( GridAccessException e )
{
return amount;
}
if( outs.isEmpty() )
{
return amount;
}
LinkedList<PartP2PIC2Power> options = new LinkedList<>();
for( PartP2PIC2Power o : outs )
{
if( o.bufferedEnergy1 <= 0.01 )
{
options.add( o );
}
}
if( options.isEmpty() )
{
for( PartP2PIC2Power o : outs )
{
if( o.bufferedEnergy2 <= 0.01 )
{
options.add( o );
}
}
}
if( options.isEmpty() )
{
for( PartP2PIC2Power o : outs )
{
options.add( o );
}
}
if( options.isEmpty() )
{
return amount;
}
PartP2PIC2Power x = Platform.pickRandom( options );
if( x != null && x.bufferedEnergy1 <= 0.001 )
{
this.queueTunnelDrain( PowerUnits.EU, amount );
x.bufferedEnergy1 = amount;
x.bufferedVoltage1 = voltage;
return 0;
}
if( x != null && x.bufferedEnergy2 <= 0.001 )
{
this.queueTunnelDrain( PowerUnits.EU, amount );
x.bufferedEnergy2 = amount;
x.bufferedVoltage2 = voltage;
return 0;
}
return amount;
}
@Override
public double getOfferedEnergy()
{
if( this.isOutput() )
{
return this.bufferedEnergy1;
}
return 0;
}
@Override
public void drawEnergy( double amount )
{
this.bufferedEnergy1 -= amount;
if( this.bufferedEnergy1 < 0.001 )
{
this.bufferedEnergy1 = this.bufferedEnergy2;
this.bufferedEnergy2 = 0;
this.bufferedVoltage1 = this.bufferedVoltage2;
this.bufferedVoltage2 = 0;
}
}
@Override
public int getSourceTier()
{
// Sadly IC2 doesn't support changing the tier once we're registered, so we
// go with the highest here... At this point it's somewhat unclear as to what effect
// this realistically has.
return 4;
}
@Override
public IPartModel getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
///*
// * This file is part of Applied Energistics 2.
// * Copyright (c) 2013 - 2015, 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.parts.p2p;
//
//
//import java.util.LinkedList;
//import java.util.List;
//
//import net.minecraft.item.ItemStack;
//import net.minecraft.nbt.NBTTagCompound;
//import net.minecraft.util.EnumFacing;
//
//import ic2.api.energy.tile.IEnergyAcceptor;
//import ic2.api.energy.tile.IEnergyEmitter;
//import ic2.api.energy.tile.IEnergySink;
//
//import appeng.api.config.PowerUnits;
//import appeng.api.networking.energy.IEnergySource;
//import appeng.api.parts.IPartModel;
//import appeng.coremod.annotations.Integration.Interface;
//import appeng.coremod.annotations.Integration.InterfaceList;
//import appeng.integration.IntegrationType;
//import appeng.items.parts.PartModels;
//import appeng.me.GridAccessException;
//import appeng.me.cache.helpers.TunnelCollection;
//import appeng.util.Platform;
//
//
//@InterfaceList( value = {
// @Interface( iface = "ic2.api.energy.tile.IEnergySink", iname = IntegrationType.IC2 ),
// @Interface( iface = "ic2.api.energy.tile.IEnergySource", iname = IntegrationType.IC2 )
//} )
//public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements IEnergySink, IEnergySource
//{
//
// private static final String TAG_BUFFERED_ENERGY_1 = "bufferedEnergy1";
// private static final String TAG_BUFFERED_ENERGY_2 = "bufferedEnergy2";
// private static final String TAG_BUFFERED_VOLTAGE_1 = "outputPacket1";
// private static final String TAG_BUFFERED_VOLTAGE_2 = "outputPacket2";
//
// private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_ic2" );
//
// @PartModels
// public static List<IPartModel> getModels()
// {
// return MODELS.getModels();
// }
//
// // Buffer the energy + voltage for two IC2 ENET packets
// private double bufferedEnergy1;
// private double bufferedVoltage1;
// private double bufferedEnergy2;
// private double bufferedVoltage2;
//
// public PartP2PIC2Power( ItemStack is )
// {
// super( is );
// }
//
// @Override
// public void readFromNBT( NBTTagCompound tag )
// {
// super.readFromNBT( tag );
// this.bufferedEnergy1 = tag.getDouble( TAG_BUFFERED_ENERGY_1 );
// this.bufferedEnergy2 = tag.getDouble( TAG_BUFFERED_ENERGY_2 );
// this.bufferedVoltage1 = tag.getDouble( TAG_BUFFERED_VOLTAGE_1 );
// this.bufferedVoltage2 = tag.getDouble( TAG_BUFFERED_VOLTAGE_2 );
// }
//
// @Override
// public void writeToNBT( NBTTagCompound tag )
// {
// super.writeToNBT( tag );
// tag.setDouble( TAG_BUFFERED_ENERGY_1, this.bufferedEnergy1 );
// tag.setDouble( TAG_BUFFERED_ENERGY_2, this.bufferedEnergy2 );
// tag.setDouble( TAG_BUFFERED_VOLTAGE_1, this.bufferedVoltage1 );
// tag.setDouble( TAG_BUFFERED_VOLTAGE_2, this.bufferedVoltage2 );
// }
//
// @Override
// public void onTunnelConfigChange()
// {
// this.getHost().partChanged();
// }
//
// @Override
// public void onTunnelNetworkChange()
// {
// this.getHost().notifyNeighbors();
// }
//
// @Override
// public boolean acceptsEnergyFrom( IEnergyEmitter emitter, EnumFacing direction )
// {
// return !this.isOutput() && direction == this.getSide().getFacing();
// }
//
// @Override
// public boolean emitsEnergyTo( IEnergyAcceptor receiver, EnumFacing direction )
// {
// return this.isOutput() && direction == this.getSide().getFacing();
// }
//
// @Override
// public double getDemandedEnergy()
// {
// if( this.isOutput() )
// {
// return 0;
// }
//
// try
// {
// for( PartP2PIC2Power t : this.getOutputs() )
// {
// if( t.bufferedEnergy1 <= 0.0001 || t.bufferedEnergy2 <= 0.0001 )
// {
// return 2048;
// }
// }
// }
// catch( GridAccessException e )
// {
// return 0;
// }
//
// return 0;
// }
//
// @Override
// public int getSinkTier()
// {
// return 4;
// }
//
// @Override
// public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
// {
// TunnelCollection<PartP2PIC2Power> outs;
// try
// {
// outs = this.getOutputs();
// }
// catch( GridAccessException e )
// {
// return amount;
// }
//
// if( outs.isEmpty() )
// {
// return amount;
// }
//
// LinkedList<PartP2PIC2Power> options = new LinkedList<>();
// for( PartP2PIC2Power o : outs )
// {
// if( o.bufferedEnergy1 <= 0.01 )
// {
// options.add( o );
// }
// }
//
// if( options.isEmpty() )
// {
// for( PartP2PIC2Power o : outs )
// {
// if( o.bufferedEnergy2 <= 0.01 )
// {
// options.add( o );
// }
// }
// }
//
// if( options.isEmpty() )
// {
// for( PartP2PIC2Power o : outs )
// {
// options.add( o );
// }
// }
//
// if( options.isEmpty() )
// {
// return amount;
// }
//
// PartP2PIC2Power x = Platform.pickRandom( options );
//
// if( x != null && x.bufferedEnergy1 <= 0.001 )
// {
// this.queueTunnelDrain( PowerUnits.EU, amount );
// x.bufferedEnergy1 = amount;
// x.bufferedVoltage1 = voltage;
// return 0;
// }
//
// if( x != null && x.bufferedEnergy2 <= 0.001 )
// {
// this.queueTunnelDrain( PowerUnits.EU, amount );
// x.bufferedEnergy2 = amount;
// x.bufferedVoltage2 = voltage;
// return 0;
// }
//
// return amount;
// }
//
// @Override
// public double getOfferedEnergy()
// {
// if( this.isOutput() )
// {
// return this.bufferedEnergy1;
// }
// return 0;
// }
//
// @Override
// public void drawEnergy( double amount )
// {
// this.bufferedEnergy1 -= amount;
// if( this.bufferedEnergy1 < 0.001 )
// {
// this.bufferedEnergy1 = this.bufferedEnergy2;
// this.bufferedEnergy2 = 0;
//
// this.bufferedVoltage1 = this.bufferedVoltage2;
// this.bufferedVoltage2 = 0;
// }
// }
//
// @Override
// public int getSourceTier()
// {
// // Sadly IC2 doesn't support changing the tier once we're registered, so we
// // go with the highest here... At this point it's somewhat unclear as to what effect
// // this realistically has.
// return 4;
// }
//
// @Override
// public IPartModel getStaticModels()
// {
// return MODELS.getModel( isPowered(), isActive() );
// }
//
//}
@@ -315,7 +315,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
}
@Override
public boolean isUseableByPlayer( final EntityPlayer entityplayer )
public boolean isUsableByPlayer( final EntityPlayer entityplayer )
{
return false;
}
@@ -396,4 +396,11 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
return MODELS.getModel( isPowered(), isActive() );
}
@Override
public boolean isEmpty()
{
// TODO Auto-generated method stub
return false;
}
}
+312 -312
View File
@@ -1,312 +1,312 @@
/*
* 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.parts.p2p;
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.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.parts.IPartModel;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_liquids" );
@PartModels
public static List<IPartModel> getModels()
{
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;
}
@Override
public void onTunnelNetworkChange()
{
this.cachedTank = null;
}
@Override
public void onNeighborChanged()
{
this.cachedTank = null;
if( this.isOutput() )
{
final PartP2PLiquids in = this.getInput();
if( in != null )
{
in.onTunnelNetworkChange();
}
}
}
@Override
public int fill( final EnumFacing from, final FluidStack resource, final boolean doFill )
{
final Stack<PartP2PLiquids> stack = this.getDepth();
for( final PartP2PLiquids t : stack )
{
if( t == this )
{
return 0;
}
}
stack.push( this );
final List<PartP2PLiquids> list = this.getOutputs( resource.getFluid() );
int requestTotal = 0;
Iterator<PartP2PLiquids> i = list.iterator();
while( i.hasNext() )
{
final PartP2PLiquids l = i.next();
final IFluidHandler tank = l.getTarget();
if( tank != null )
{
l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), resource.copy(), false );
}
else
{
l.tmpUsed = 0;
}
if( l.tmpUsed <= 0 )
{
i.remove();
}
else
{
requestTotal += l.tmpUsed;
}
}
if( requestTotal <= 0 )
{
if( stack.pop() != this )
{
throw new IllegalStateException( "Invalid Recursion detected." );
}
return 0;
}
if( !doFill )
{
if( stack.pop() != this )
{
throw new IllegalStateException( "Invalid Recursion detected." );
}
return Math.min( resource.amount, requestTotal );
}
int available = resource.amount;
i = list.iterator();
int used = 0;
while( i.hasNext() )
{
final PartP2PLiquids l = i.next();
final FluidStack insert = resource.copy();
insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) );
if( insert.amount > available )
{
insert.amount = available;
}
final IFluidHandler tank = l.getTarget();
if( tank != null )
{
l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), insert.copy(), true );
}
else
{
l.tmpUsed = 0;
}
available -= insert.amount;
used += insert.amount;
}
if( stack.pop() != this )
{
throw new IllegalStateException( "Invalid Recursion detected." );
}
return used;
}
private Stack<PartP2PLiquids> getDepth()
{
Stack<PartP2PLiquids> s = DEPTH.get();
if( s == null )
{
DEPTH.set( s = new Stack<PartP2PLiquids>() );
}
return s;
}
private List<PartP2PLiquids> getOutputs( final Fluid input )
{
final List<PartP2PLiquids> outs = new LinkedList<PartP2PLiquids>();
try
{
for( final PartP2PLiquids l : this.getOutputs() )
{
final IFluidHandler handler = l.getTarget();
if( handler != null )
{
if( handler.canFill( l.getSide().getFacing().getOpposite(), input ) )
{
outs.add( l );
}
}
}
}
catch( final GridAccessException e )
{
// :P
}
return outs;
}
private IFluidHandler getTarget()
{
if( !this.getProxy().isActive() )
{
return null;
}
if( this.cachedTank != null )
{
return this.cachedTank;
}
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) );
if( te instanceof IFluidHandler )
{
return this.cachedTank = (IFluidHandler) te;
}
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() );
}
}
///*
// * 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.parts.p2p;
//
//
//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.fluids.Fluid;
//import net.minecraftforge.fluids.FluidStack;
//import net.minecraftforge.fluids.FluidTankInfo;
//import net.minecraftforge.fluids.capability.IFluidHandler;
//
//import appeng.api.parts.IPartModel;
//import appeng.items.parts.PartModels;
//import appeng.me.GridAccessException;
//
//
//public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
//{
//
// private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_liquids" );
//
// @PartModels
// public static List<IPartModel> getModels()
// {
// 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;
// }
//
// @Override
// public void onTunnelNetworkChange()
// {
// this.cachedTank = null;
// }
//
// @Override
// public void onNeighborChanged()
// {
// this.cachedTank = null;
// if( this.isOutput() )
// {
// final PartP2PLiquids in = this.getInput();
// if( in != null )
// {
// in.onTunnelNetworkChange();
// }
// }
// }
//
// @Override
// public int fill( final EnumFacing from, final FluidStack resource, final boolean doFill )
// {
// final Stack<PartP2PLiquids> stack = this.getDepth();
//
// for( final PartP2PLiquids t : stack )
// {
// if( t == this )
// {
// return 0;
// }
// }
//
// stack.push( this );
//
// final List<PartP2PLiquids> list = this.getOutputs( resource.getFluid() );
// int requestTotal = 0;
//
// Iterator<PartP2PLiquids> i = list.iterator();
// while( i.hasNext() )
// {
// final PartP2PLiquids l = i.next();
// final IFluidHandler tank = l.getTarget();
// if( tank != null )
// {
// l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), resource.copy(), false );
// }
// else
// {
// l.tmpUsed = 0;
// }
//
// if( l.tmpUsed <= 0 )
// {
// i.remove();
// }
// else
// {
// requestTotal += l.tmpUsed;
// }
// }
//
// if( requestTotal <= 0 )
// {
// if( stack.pop() != this )
// {
// throw new IllegalStateException( "Invalid Recursion detected." );
// }
//
// return 0;
// }
//
// if( !doFill )
// {
// if( stack.pop() != this )
// {
// throw new IllegalStateException( "Invalid Recursion detected." );
// }
//
// return Math.min( resource.amount, requestTotal );
// }
//
// int available = resource.amount;
//
// i = list.iterator();
// int used = 0;
// while( i.hasNext() )
// {
// final PartP2PLiquids l = i.next();
//
// final FluidStack insert = resource.copy();
// insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) );
// if( insert.amount > available )
// {
// insert.amount = available;
// }
//
// final IFluidHandler tank = l.getTarget();
// if( tank != null )
// {
// l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), insert.copy(), true );
// }
// else
// {
// l.tmpUsed = 0;
// }
//
// available -= insert.amount;
// used += insert.amount;
// }
//
// if( stack.pop() != this )
// {
// throw new IllegalStateException( "Invalid Recursion detected." );
// }
//
// return used;
// }
//
// private Stack<PartP2PLiquids> getDepth()
// {
// Stack<PartP2PLiquids> s = DEPTH.get();
//
// if( s == null )
// {
// DEPTH.set( s = new Stack<PartP2PLiquids>() );
// }
//
// return s;
// }
//
// private List<PartP2PLiquids> getOutputs( final Fluid input )
// {
// final List<PartP2PLiquids> outs = new LinkedList<PartP2PLiquids>();
//
// try
// {
// for( final PartP2PLiquids l : this.getOutputs() )
// {
// final IFluidHandler handler = l.getTarget();
// if( handler != null )
// {
// if( handler.canFill( l.getSide().getFacing().getOpposite(), input ) )
// {
// outs.add( l );
// }
// }
// }
// }
// catch( final GridAccessException e )
// {
// // :P
// }
//
// return outs;
// }
//
// private IFluidHandler getTarget()
// {
// if( !this.getProxy().isActive() )
// {
// return null;
// }
//
// if( this.cachedTank != null )
// {
// return this.cachedTank;
// }
//
// final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) );
// if( te instanceof IFluidHandler )
// {
// return this.cachedTank = (IFluidHandler) te;
// }
//
// 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() );
// }
//
//}
@@ -170,7 +170,7 @@ package appeng.parts.p2p;
// if( !this.cachedTarget )
// {
// TileEntity self = this.getTile();
// TileEntity te = self.getWorldObj().getTileEntity( self.xCoord + this.side.offsetX, self.yCoord + this.side.offsetY, self.zCoord + this.side.offsetZ );
// TileEntity te = self.getworld().getTileEntity( self.xCoord + this.side.offsetX, self.yCoord + this.side.offsetY, self.zCoord + this.side.offsetZ );
// this.outputTarget = te instanceof IEnergyReceiver ? (IEnergyReceiver) te : null;
// this.cachedTarget = true;
// }
@@ -99,14 +99,14 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
private void notifyNeighbors()
{
final World worldObj = this.getTile().getWorld();
final World world = this.getTile().getWorld();
Platform.notifyBlocksOfNeighbors( worldObj, this.getTile().getPos() );
Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos() );
// and this cause sometimes it can go thought walls.
for( final EnumFacing face : EnumFacing.VALUES )
{
Platform.notifyBlocksOfNeighbors( worldObj, this.getTile().getPos().offset( face ) );
Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos().offset( face ) );
}
}
@@ -171,7 +171,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final IMemoryCard mc = (IMemoryCard) is.getItem();
final NBTTagCompound data = mc.getData( is );
final ItemStack newType = ItemStack.loadItemStackFromNBT( data );
final ItemStack newType = new ItemStack( data );
final long freq = data.getLong( "freq" );
if( newType != null )
@@ -231,13 +231,13 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
* break;
*/
case FLUID:
newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null );
break;
//case FLUID:
// newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null );
// break;
case IC2_POWER:
newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( null );
break;
//case IC2_POWER:
// newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( null );
// break;
case ITEM:
newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( null );