Layers and IC2 Tunnel (#2565)

* Re-Activated the IC2 layers to implement an IC2 P2P tunnel.
This commit is contained in:
shartte
2016-11-04 11:20:56 +01:00
committed by GitHub
parent 6f15c2921a
commit f5e4a202cb
21 changed files with 822 additions and 1518 deletions
@@ -1,147 +0,0 @@
/*
* 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.layers;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
public class InvLayerData
{
// a simple empty array for empty stuff..
private static final int[] NULL_SIDES = {};
// cache of inventory state.
private final int[][] sides;
private final List<ISidedInventory> inventories;
private final List<InvSot> slots;
public InvLayerData( final int[][] a, final List<ISidedInventory> b, final List<InvSot> c )
{
this.sides = a;
this.inventories = b;
this.slots = c;
}
public ItemStack decreaseStackSize( final int slot, final int amount )
{
if( this.isSlotValid( slot ) )
{
return this.slots.get( slot ).decreaseStackSize( amount );
}
return null;
}
/**
* check if a slot index is valid, prevent crashes from bad code :)
*
* @param slot slot index
*
* @return true, if the slot exists.
*/
boolean isSlotValid( final int slot )
{
return this.slots != null && slot >= 0 && slot < this.slots.size();
}
int getSizeInventory()
{
if( this.slots == null )
{
return 0;
}
return this.slots.size();
}
public ItemStack getStackInSlot( final int slot )
{
if( this.isSlotValid( slot ) )
{
return this.slots.get( slot ).getStackInSlot();
}
return null;
}
public boolean isItemValidForSlot( final int slot, final ItemStack itemstack )
{
if( this.isSlotValid( slot ) )
{
return this.slots.get( slot ).isItemValidForSlot( itemstack );
}
return false;
}
public void setInventorySlotContents( final int slot, final ItemStack itemstack )
{
if( this.isSlotValid( slot ) )
{
this.slots.get( slot ).setInventorySlotContents( itemstack );
}
}
public boolean canExtractItem( final int slot, final ItemStack itemstack, final EnumFacing side )
{
if( this.isSlotValid( slot ) )
{
return this.slots.get( slot ).canExtractItem( itemstack, side );
}
return false;
}
public boolean canInsertItem( final int slot, final ItemStack itemstack, final EnumFacing side )
{
if( this.isSlotValid( slot ) )
{
return this.slots.get( slot ).canInsertItem( itemstack, side );
}
return false;
}
void markDirty()
{
if( this.inventories != null )
{
for( final IInventory inv : this.inventories )
{
inv.markDirty();
}
}
}
public int[] getSlotsForFace( final EnumFacing side )
{
if( this.sides == null || side == null )
{
return NULL_SIDES;
}
return this.sides[side.ordinal()];
}
}
@@ -1,68 +0,0 @@
/*
* 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.layers;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
public class InvSot
{
private final ISidedInventory partInv;
private final int index;
public InvSot( final ISidedInventory part, final int slot )
{
this.partInv = part;
this.index = slot;
}
public ItemStack decreaseStackSize( final int j )
{
return this.partInv.decrStackSize( this.index, j );
}
ItemStack getStackInSlot()
{
return this.partInv.getStackInSlot( this.index );
}
public boolean isItemValidForSlot( final ItemStack itemstack )
{
return this.partInv.isItemValidForSlot( this.index, itemstack );
}
public void setInventorySlotContents( final ItemStack itemstack )
{
this.partInv.setInventorySlotContents( this.index, itemstack );
}
public boolean canExtractItem( final ItemStack itemstack, final EnumFacing side )
{
return this.partInv.canExtractItem( this.index, itemstack, side );
}
public boolean canInsertItem( final ItemStack itemstack, final EnumFacing side )
{
return this.partInv.canInsertItem( this.index, itemstack, side );
}
}
@@ -19,183 +19,186 @@
package appeng.parts.layers;
//import net.minecraft.tileentity.TileEntity;
//import net.minecraft.world.World;
//import net.minecraftforge.common.MinecraftForge;
//import ic2.api.energy.tile.IEnergyAcceptor;
//import ic2.api.energy.tile.IEnergySink;
//import ic2.api.energy.tile.IEnergyTile;
//import appeng.api.parts.IPart;
//import appeng.api.parts.IPartHost;
//import appeng.api.parts.LayerBase;
//import appeng.api.parts.LayerFlags;
//import appeng.api.util.ForgeDirection;
//import appeng.util.Platform;
//
//
//public class LayerIEnergySink extends LayerBase implements IEnergySink
//{
//
// private TileEntity getEnergySinkTile()
// {
// IPartHost host = (IPartHost) this;
// return host.getTile();
// }
//
// private World getEnergySinkWorld()
// {
// if( this.getEnergySinkTile() == null )
// {
// return null;
// }
//
// return this.getEnergySinkTile().getWorld();
// }
//
// private boolean isTileValid()
// {
// TileEntity te = this.getEnergySinkTile();
//
// if( te == null )
// {
// return false;
// }
//
// return !te.isInvalid() && te.getWorld().blockExists( te.xCoord, te.yCoord, te.zCoord );
// }
//
// private void addToENet()
// {
// if( this.getEnergySinkWorld() == null )
// {
// return;
// }
//
// // re-add
// this.removeFromENet();
//
// if( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
// {
// this.getLayerFlags().add( LayerFlags.IC2_ENET );
// MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergyTile) this.getEnergySinkTile() ) );
// }
// }
//
// private void removeFromENet()
// {
// if( this.getEnergySinkWorld() == null )
// {
// return;
// }
//
// if( this.isInIC2() && Platform.isServer() )
// {
// this.getLayerFlags().remove( LayerFlags.IC2_ENET );
// MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergyTile) this.getEnergySinkTile() ) );
// }
// }
//
// private boolean interestedInIC2()
// {
// if( !( (IPartHost) this ).isInWorld() )
// {
// return false;
// }
//
// int interested = 0;
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergyTile )
// {
// interested++;
// }
// }
// return interested == 1;// if more then one tile is interested we need to abandon...
// }
//
// @Override
// public void partChanged()
// {
// super.partChanged();
//
// if( this.interestedInIC2() )
// {
// this.addToENet();
// }
// else
// {
// this.removeFromENet();
// }
// }
//
// @Override
// public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
// {
// if( !this.isInIC2() )
// {
// return false;
// }
//
// IPart part = this.getPart( direction );
// if( part instanceof IEnergySink )
// {
// return ( (IEnergyAcceptor) part ).acceptsEnergyFrom( emitter, direction );
// }
// return false;
// }
//
// private boolean isInIC2()
// {
// return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
// }
//
// @Override
// public double getDemandedEnergy()
// {
// if( !this.isInIC2() )
// {
// return 0;
// }
//
// // this is a flawed implementation, that requires a change to the IC2 API.
//
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergySink )
// {
// // use lower number cause ic2 deletes power it sends that isn't received.
// return ( (IEnergySink) part ).getDemandedEnergy();
// }
// }
//
// return 0;
// }
//
// @Override
// public int getSinkTier()
// {
// return Integer.MAX_VALUE; // no real options here...
// }
//
// @Override
// public double injectEnergy( ForgeDirection directionFrom, double amount, double voltage )
// {
// if( !this.isInIC2() )
// {
// return amount;
// }
//
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergySink )
// {
// return ( (IEnergySink) part ).injectEnergy( directionFrom, amount, voltage );
// }
// }
//
// return amount;
// }
// }
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.LayerBase;
import appeng.api.parts.LayerFlags;
import appeng.util.Platform;
public class LayerIEnergySink extends LayerBase implements IEnergySink
{
private TileEntity getEnergySinkTile()
{
IPartHost host = (IPartHost) this;
return host.getTile();
}
private World getEnergySinkWorld()
{
if( this.getEnergySinkTile() == null )
{
return null;
}
return this.getEnergySinkTile().getWorld();
}
private boolean isTileValid()
{
TileEntity te = this.getEnergySinkTile();
if( te == null )
{
return false;
}
return !te.isInvalid() && te.getWorld().isBlockLoaded( te.getPos() );
}
private void addToENet()
{
if( this.getEnergySinkWorld() == null )
{
return;
}
// re-add
this.removeFromENet();
if( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
{
this.getLayerFlags().add( LayerFlags.IC2_ENET );
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergyTile) this.getEnergySinkTile() ) );
}
}
private void removeFromENet()
{
if( this.getEnergySinkWorld() == null )
{
return;
}
if( this.isInIC2() && Platform.isServer() )
{
this.getLayerFlags().remove( LayerFlags.IC2_ENET );
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergyTile) this.getEnergySinkTile() ) );
}
}
private boolean interestedInIC2()
{
if( !( (IPartHost) this ).isInWorld() )
{
return false;
}
int interested = 0;
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergyTile )
{
interested++;
}
}
return interested == 1;// if more then one tile is interested we need to abandon...
}
@Override
public void partChanged()
{
super.partChanged();
if( this.interestedInIC2() )
{
this.addToENet();
}
else
{
this.removeFromENet();
}
}
@Override
public boolean acceptsEnergyFrom( IEnergyEmitter emitter, EnumFacing direction )
{
if( !this.isInIC2() )
{
return false;
}
IPart part = this.getPart( direction );
if( part instanceof IEnergySink )
{
return ( (IEnergyAcceptor) part ).acceptsEnergyFrom( emitter, direction );
}
return false;
}
private boolean isInIC2()
{
return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
}
@Override
public double getDemandedEnergy()
{
if( !this.isInIC2() )
{
return 0;
}
// this is a flawed implementation, that requires a change to the IC2 API.
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergySink )
{
// use lower number cause ic2 deletes power it sends that isn't received.
return ( (IEnergySink) part ).getDemandedEnergy();
}
}
return 0;
}
@Override
public int getSinkTier()
{
return Integer.MAX_VALUE; // no real options here...
}
@Override
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
{
if( !this.isInIC2() )
{
return amount;
}
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergySink )
{
return ( (IEnergySink) part ).injectEnergy( directionFrom, amount, voltage );
}
}
return amount;
}
}
@@ -19,188 +19,189 @@
package appeng.parts.layers;
//import net.minecraft.tileentity.TileEntity;
//import net.minecraft.world.World;
//import net.minecraftforge.common.MinecraftForge;
//import ic2.api.energy.tile.IEnergyEmitter;
//import ic2.api.energy.tile.IEnergySink;
//import ic2.api.energy.tile.IEnergySource;
//import ic2.api.energy.tile.IEnergyTile;
//import appeng.api.parts.IPart;
//import appeng.api.parts.IPartHost;
//import appeng.api.parts.LayerBase;
//import appeng.api.parts.LayerFlags;
//import appeng.api.util.ForgeDirection;
//import appeng.util.Platform;
//
//
//public class LayerIEnergySource extends LayerBase implements IEnergySource
//{
//
// private TileEntity getEnergySourceTile()
// {
// IPartHost host = (IPartHost) this;
// return host.getTile();
// }
//
// private World getEnergySourceWorld()
// {
// if( this.getEnergySourceTile() == null )
// {
// return null;
// }
// return this.getEnergySourceTile().getWorld();
// }
//
// private boolean isTileValid()
// {
// TileEntity te = this.getEnergySourceTile();
// if( te == null )
// {
// return false;
// }
// return !te.isInvalid();
// }
//
// private void addToENet()
// {
// if( this.getEnergySourceWorld() == null )
// {
// return;
// }
//
// // re-add
// this.removeFromENet();
//
// if( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
// {
// this.getLayerFlags().add( LayerFlags.IC2_ENET );
// MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergyTile) this.getEnergySourceTile() ) );
// }
// }
//
// private void removeFromENet()
// {
// if( this.getEnergySourceWorld() == null )
// {
// return;
// }
//
// if( this.isInIC2() && Platform.isServer() )
// {
// this.getLayerFlags().remove( LayerFlags.IC2_ENET );
// MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergyTile) this.getEnergySourceTile() ) );
// }
// }
//
// private boolean interestedInIC2()
// {
// if( !( (IPartHost) this ).isInWorld() )
// {
// return false;
// }
//
// int interested = 0;
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergyTile )
// {
// interested++;
// }
// }
// return interested == 1;// if more then one tile is interested we need to abandon...
// }
//
// @Override
// public void partChanged()
// {
// super.partChanged();
//
// if( this.interestedInIC2() )
// {
// this.addToENet();
// }
// else
// {
// this.removeFromENet();
// }
// }
//
// @Override
// public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction )
// {
// if( !this.isInIC2() )
// {
// return false;
// }
//
// IPart part = this.getPart( direction );
// if( part instanceof IEnergySink )
// {
// return ( (IEnergyEmitter) part ).emitsEnergyTo( receiver, direction );
// }
// return false;
// }
//
// private boolean isInIC2()
// {
// return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
// }
//
// @Override
// public double getOfferedEnergy()
// {
// if( !this.isInIC2() )
// {
// return 0;
// }
//
// // this is a flawed implementation, that requires a change to the IC2 API.
//
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergySource )
// {
// // use lower number cause ic2 deletes power it sends that isn't received.
// return ( (IEnergySource) part ).getOfferedEnergy();
// }
// }
//
// return 0;
// }
//
// @Override
// public void drawEnergy( double amount )
// {
// // this is a flawed implementation, that requires a change to the IC2 API.
//
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergySource )
// {
// ( (IEnergySource) part ).drawEnergy( amount );
// return;
// }
// }
// }
//
// @Override
// public int getSourceTier()
// {
// // this is a flawed implementation, that requires a change to the IC2 API.
//
// for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
// {
// IPart part = this.getPart( dir );
// if( part instanceof IEnergySource )
// {
// return ( (IEnergySource) part ).getSourceTier();
// }
// }
//
// return 0;
// }
// }
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.energy.tile.IEnergyTile;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.LayerBase;
import appeng.api.parts.LayerFlags;
import appeng.util.Platform;
public class LayerIEnergySource extends LayerBase implements IEnergySource
{
private TileEntity getEnergySourceTile()
{
IPartHost host = (IPartHost) this;
return host.getTile();
}
private World getEnergySourceWorld()
{
if( this.getEnergySourceTile() == null )
{
return null;
}
return this.getEnergySourceTile().getWorld();
}
private boolean isTileValid()
{
TileEntity te = this.getEnergySourceTile();
return te != null && !te.isInvalid();
}
private void addToENet()
{
if( this.getEnergySourceWorld() == null )
{
return;
}
// re-add
this.removeFromENet();
if( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
{
this.getLayerFlags().add( LayerFlags.IC2_ENET );
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergyTile) this.getEnergySourceTile() ) );
}
}
private void removeFromENet()
{
if( this.getEnergySourceWorld() == null )
{
return;
}
if( this.isInIC2() && Platform.isServer() )
{
this.getLayerFlags().remove( LayerFlags.IC2_ENET );
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergyTile) this.getEnergySourceTile() ) );
}
}
private boolean interestedInIC2()
{
if( !( (IPartHost) this ).isInWorld() )
{
return false;
}
int interested = 0;
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergyTile )
{
interested++;
}
}
return interested == 1;// if more then one tile is interested we need to abandon...
}
@Override
public void partChanged()
{
super.partChanged();
if( this.interestedInIC2() )
{
this.addToENet();
}
else
{
this.removeFromENet();
}
}
@Override
public boolean emitsEnergyTo( IEnergyAcceptor receiver, EnumFacing direction )
{
if( !this.isInIC2() )
{
return false;
}
IPart part = this.getPart( direction );
if( part instanceof IEnergyEmitter )
{
return ( (IEnergyEmitter) part ).emitsEnergyTo( receiver, direction );
}
return false;
}
private boolean isInIC2()
{
return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
}
@Override
public double getOfferedEnergy()
{
if( !this.isInIC2() )
{
return 0;
}
// this is a flawed implementation, that requires a change to the IC2 API.
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergySource )
{
// use lower number cause ic2 deletes power it sends that isn't received.
return ( (IEnergySource) part ).getOfferedEnergy();
}
}
return 0;
}
@Override
public void drawEnergy( double amount )
{
// this is a flawed implementation, that requires a change to the IC2 API.
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergySource )
{
( (IEnergySource) part ).drawEnergy( amount );
return;
}
}
}
@Override
public int getSourceTier()
{
// this is a flawed implementation, that requires a change to the IC2 API.
for( EnumFacing dir : EnumFacing.values() )
{
IPart part = this.getPart( dir );
if( part instanceof IEnergySource )
{
return ( (IEnergySource) part ).getSourceTier();
}
}
return 0;
}
}
@@ -1,100 +0,0 @@
/*
* 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.layers;
//import net.minecraftforge.fluids.FluidStack;
//import net.minecraftforge.fluids.FluidTankInfo;
//import net.minecraftforge.fluids.IFluidHandler;
//import appeng.api.parts.IPart;
//import appeng.api.parts.LayerBase;
//import appeng.api.util.ForgeDirection;
//
//
//public class LayerIFluidHandler extends LayerBase implements IFluidHandler
//{
//
// private static final FluidTankInfo[] EMPTY_LIST = new FluidTankInfo[0];
//
// @Override
// public int fill( ForgeDirection from, FluidStack resource, boolean doFill )
// {
// IPart part = this.getPart( from );
// if( part instanceof IFluidHandler )
// {
// return ( (IFluidHandler) part ).fill( from, resource, doFill );
// }
// return 0;
// }
//
// @Override
// public FluidStack drain( ForgeDirection from, FluidStack resource, boolean doDrain )
// {
// IPart part = this.getPart( from );
// if( part instanceof IFluidHandler )
// {
// return ( (IFluidHandler) part ).drain( from, resource, doDrain );
// }
// return null;
// }
//
// @Override
// public FluidStack drain( ForgeDirection from, int maxDrain, boolean doDrain )
// {
// IPart part = this.getPart( from );
// if( part instanceof IFluidHandler )
// {
// return ( (IFluidHandler) part ).drain( from, maxDrain, doDrain );
// }
// return null;
// }
//
// @Override
// public boolean canFill( ForgeDirection from, net.minecraftforge.fluids.Fluid fluid )
// {
// IPart part = this.getPart( from );
// if( part instanceof IFluidHandler )
// {
// return ( (IFluidHandler) part ).canFill( from, fluid );
// }
// return false;
// }
//
// @Override
// public boolean canDrain( ForgeDirection from, net.minecraftforge.fluids.Fluid fluid )
// {
// IPart part = this.getPart( from );
// if( part instanceof IFluidHandler )
// {
// return ( (IFluidHandler) part ).canDrain( from, fluid );
// }
// return false;
// }
//
// @Override
// public FluidTankInfo[] getTankInfo( ForgeDirection from )
// {
// IPart part = this.getPart( from );
// if( part instanceof IFluidHandler )
// {
// return ( (IFluidHandler) part ).getTankInfo( from );
// }
// return EMPTY_LIST;
// }
// }
@@ -1,44 +0,0 @@
/*
* 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.layers;
//import buildcraft.api.transport.IPipeConnection;
//import buildcraft.api.transport.IPipeTile.PipeType;
//import appeng.api.parts.IPart;
//import appeng.api.parts.LayerBase;
//import appeng.api.util.ForgeDirection;
//import appeng.helpers.Reflected;
//
//
//@Reflected
//public class LayerIPipeConnection extends LayerBase implements IPipeConnection
//{
//
// @Override
// public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
// {
// IPart part = this.getPart( with );
// if( part instanceof IPipeConnection )
// {
// return ( (IPipeConnection) part ).overridePipeConnection( type, with );
// }
// return ConnectOverride.DEFAULT;
// }
// }
@@ -1,300 +0,0 @@
/*
* 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.layers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.ITextComponent;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.LayerBase;
import appeng.api.util.AEPartLocation;
/**
* Inventory wrapper for parts,
*
* this is considerably more complicated then the other wrappers as it requires creating a "unified inventory".
*
* You must use {@link ISidedInventory} instead of {@link IInventory}.
*
* If your inventory changes in between placement and removal, you must trigger a PartChange on the {@link IPartHost} so
* it can recalculate the inventory wrapper.
*/
public class LayerISidedInventory extends LayerBase implements ISidedInventory
{
// a simple empty array for empty stuff..
private static final int[] NULL_SIDES = {};
private InvLayerData invLayer = null;
/**
* Recalculate inventory wrapper cache.
*/
@Override
public void notifyNeighbors()
{
// cache of inventory state.
int[][] sideData = null;
List<ISidedInventory> inventories = null;
List<InvSot> slots = null;
inventories = new ArrayList<ISidedInventory>();
int slotCount = 0;
for( final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS )
{
final IPart bp = this.getPart( side );
if( bp instanceof ISidedInventory )
{
final ISidedInventory part = (ISidedInventory) bp;
slotCount += part.getSizeInventory();
inventories.add( part );
}
}
if( inventories.isEmpty() || slotCount == 0 )
{
inventories = null;
}
else
{
sideData = new int[][] { NULL_SIDES, NULL_SIDES, NULL_SIDES, NULL_SIDES, NULL_SIDES, NULL_SIDES };
slots = new ArrayList<InvSot>( Collections.nCopies( slotCount, (InvSot) null ) );
int offsetForLayer = 0;
int offsetForPart = 0;
for( final ISidedInventory sides : inventories )
{
offsetForPart = 0;
slotCount = sides.getSizeInventory();
AEPartLocation currentSide = AEPartLocation.INTERNAL;
for( final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS )
{
if( this.getPart( side ) == sides )
{
currentSide = side;
break;
}
}
final int[] cSidesList = sideData[currentSide.ordinal()] = new int[slotCount];
for( int cSlot = 0; cSlot < slotCount; cSlot++ )
{
cSidesList[cSlot] = offsetForLayer;
slots.set( offsetForLayer, new InvSot( sides, offsetForPart ) );
offsetForLayer++;
offsetForPart++;
}
}
}
if( sideData == null || slots == null )
{
this.invLayer = null;
}
else
{
this.invLayer = new InvLayerData( sideData, inventories, slots );
}
// make sure inventory is updated before we call FMP.
super.notifyNeighbors();
}
@Override
public int getSizeInventory()
{
if( this.invLayer == null )
{
return 0;
}
return this.invLayer.getSizeInventory();
}
@Override
public ItemStack getStackInSlot( final int slot )
{
if( this.invLayer == null )
{
return null;
}
return this.invLayer.getStackInSlot( slot );
}
@Override
public ItemStack decrStackSize( final int slot, final int amount )
{
if( this.invLayer == null )
{
return null;
}
return this.invLayer.decreaseStackSize( slot, amount );
}
@Override
public ItemStack removeStackFromSlot( final int slot )
{
return null;
}
@Override
public void setInventorySlotContents( final int slot, final ItemStack itemstack )
{
if( this.invLayer == null )
{
return;
}
this.invLayer.setInventorySlotContents( slot, itemstack );
}
@Override
public String getName()
{
return "AEMultiPart";
}
@Override
public boolean hasCustomName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 64; // no options here.
}
@Override
public boolean isUseableByPlayer( final EntityPlayer entityplayer )
{
return false;
}
@Override
public void openInventory( final EntityPlayer player )
{
}
@Override
public void closeInventory( final EntityPlayer player )
{
}
@Override
public boolean isItemValidForSlot( final int slot, final ItemStack itemstack )
{
if( this.invLayer == null )
{
return false;
}
return this.invLayer.isItemValidForSlot( slot, itemstack );
}
@Override
public void markDirty()
{
if( this.invLayer != null )
{
this.invLayer.markDirty();
}
super.markForSave();
}
@Override
public int[] getSlotsForFace( final EnumFacing side )
{
if( this.invLayer != null )
{
return this.invLayer.getSlotsForFace( side );
}
return NULL_SIDES;
}
@Override
public boolean canInsertItem( final int slot, final ItemStack itemstack, final EnumFacing side )
{
if( this.invLayer == null )
{
return false;
}
return this.invLayer.canInsertItem( slot, itemstack, side );
}
@Override
public boolean canExtractItem( final int slot, final ItemStack itemstack, final EnumFacing side )
{
if( this.invLayer == null )
{
return false;
}
return this.invLayer.canExtractItem( slot, itemstack, side );
}
@Override
public int getField( final int id )
{
return 0;
}
@Override
public void setField( final int id, final int value )
{
}
@Override
public int getFieldCount()
{
return 0;
}
@Override
public void clear()
{
}
@Override
public ITextComponent getDisplayName()
{
return null;
}
}
@@ -1,49 +0,0 @@
/*
* 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.layers;
//import javax.annotation.Nullable;
//
//import net.minecraftforge.common.util.ForgeDirection;
//
//import pneumaticCraft.api.tileentity.IAirHandler;
//import pneumaticCraft.api.tileentity.ISidedPneumaticMachine;
//
//import appeng.api.parts.IPart;
//import appeng.api.parts.LayerBase;
//
//
//public class LayerPressure extends LayerBase implements ISidedPneumaticMachine
//{
//
// @Nullable
// @Override
// public IAirHandler getAirHandler( ForgeDirection side )
// {
// IPart part = this.getPart( side );
// if( part instanceof ISidedPneumaticMachine )
// {
// return ( (ISidedPneumaticMachine) part ).getAirHandler( side );
// }
//
// return null;
// }
//
// }
@@ -1,62 +0,0 @@
/*
* 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.layers;
//import javax.annotation.Nullable;
//
//import net.minecraftforge.fml.common.event.FMLInitializationEvent;
//import li.cil.oc.api.network.Node;
//import li.cil.oc.api.network.SidedEnvironment;
//import appeng.api.parts.IPart;
//import appeng.api.parts.LayerBase;
//import appeng.api.util.ForgeDirection;
//import appeng.core.Registration;
//import appeng.helpers.Reflected;
//
//
///**
// * Reflected in {@link Registration#initialize(FMLInitializationEvent)}
// */
//@Reflected
//public class LayerSidedEnvironment extends LayerBase implements SidedEnvironment
//{
// @Nullable
// @Override
// public Node sidedNode( ForgeDirection side )
// {
// final IPart part = this.getPart( side );
// if( part instanceof SidedEnvironment )
// {
// return ( (SidedEnvironment) part ).sidedNode( side );
// }
// return null;
// }
//
// @Override
// public boolean canConnect( ForgeDirection side )
// {
// final IPart part = this.getPart( side );
// if( part instanceof SidedEnvironment )
// {
// return ( (SidedEnvironment) part ).canConnect( side );
// }
// return false;
// }
// }
@@ -19,247 +19,245 @@
package appeng.parts.p2p;
//import java.util.LinkedList;
//
//import net.minecraft.init.Blocks;
//import net.minecraft.item.ItemStack;
//import net.minecraft.nbt.NBTTagCompound;
//import net.minecraft.tileentity.TileEntity;
//import net.minecraft.util.IIcon;
//import net.minecraftforge.common.util.ForgeDirection;
//
//import cpw.mods.fml.relauncher.Side;
//import cpw.mods.fml.relauncher.SideOnly;
//
//import appeng.api.config.PowerUnits;
//import appeng.integration.IntegrationType;
//import appeng.me.GridAccessException;
//import appeng.me.cache.helpers.TunnelCollection;
//import appeng.transformer.annotations.Integration.Interface;
//import appeng.transformer.annotations.Integration.InterfaceList;
//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 ic2.api.energy.tile.IEnergySink, ic2.api.energy.tile.IEnergySource
//{
//
// // two packet buffering...
// double OutputEnergyA;
// double OutputEnergyB;
// // two packet buffering...
// double OutputVoltageA;
// double OutputVoltageB;
//
// public PartP2PIC2Power( ItemStack is )
// {
// super( is );
// }
//
// @Override
// @SideOnly( Side.CLIENT )
// public IIcon getTypeTexture()
// {
// return Blocks.diamond_block.getBlockTextureFromSide( 0 );
// }
//
// @Override
// public void readFromNBT( NBTTagCompound tag )
// {
// super.readFromNBT( tag );
// this.OutputEnergyA = tag.getDouble( "OutputPacket" );
// this.OutputEnergyB = tag.getDouble( "OutputPacket2" );
// this.OutputVoltageA = tag.getDouble( "OutputVoltageA" );
// this.OutputVoltageB = tag.getDouble( "OutputVoltageB" );
// }
//
// @Override
// public void writeToNBT( NBTTagCompound tag )
// {
// super.writeToNBT( tag );
// tag.setDouble( "OutputPacket", this.OutputEnergyA );
// tag.setDouble( "OutputPacket2", this.OutputEnergyB );
// tag.setDouble( "OutputVoltageA", this.OutputVoltageA );
// tag.setDouble( "OutputVoltageB", this.OutputVoltageB );
// }
//
// @Override
// public void onTunnelConfigChange()
// {
// this.getHost().partChanged();
// }
//
// @Override
// public void onTunnelNetworkChange()
// {
// this.getHost().notifyNeighbors();
// }
//
// @Override
// public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
// {
// if( !this.output )
// {
// return direction == this.side;
// }
// return false;
// }
//
// @Override
// public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction )
// {
// if( this.output )
// {
// return direction == this.side;
// }
// return false;
// }
//
// @Override
// public double getDemandedEnergy()
// {
// if( this.output )
// {
// return 0;
// }
//
// try
// {
// for( PartP2PIC2Power t : this.getOutputs() )
// {
// if( t.OutputEnergyA <= 0.0001 || t.OutputEnergyB <= 0.0001 )
// {
// return 2048;
// }
// }
// }
// catch( GridAccessException e )
// {
// return 0;
// }
//
// return 0;
// }
//
// @Override
// public int getSinkTier()
// {
// return 4;
// }
//
// @Override
// public double injectEnergy( ForgeDirection 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<PartP2PIC2Power>();
// for( PartP2PIC2Power o : outs )
// {
// if( o.OutputEnergyA <= 0.01 )
// {
// options.add( o );
// }
// }
//
// if( options.isEmpty() )
// {
// for( PartP2PIC2Power o : outs )
// {
// if( o.OutputEnergyB <= 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.OutputEnergyA <= 0.001 )
// {
// this.queueTunnelDrain( PowerUnits.EU, amount );
// x.OutputEnergyA = amount;
// x.OutputVoltageA = voltage;
// return 0;
// }
//
// if( x != null && x.OutputEnergyB <= 0.001 )
// {
// this.queueTunnelDrain( PowerUnits.EU, amount );
// x.OutputEnergyB = amount;
// x.OutputVoltageB = voltage;
// return 0;
// }
//
// return amount;
// }
//
// public float getPowerDrainPerTick()
// {
// return 0.5f;
// }
//
// @Override
// public double getOfferedEnergy()
// {
// if( this.output )
// {
// return this.OutputEnergyA;
// }
// return 0;
// }
//
// @Override
// public void drawEnergy( double amount )
// {
// this.OutputEnergyA -= amount;
// if( this.OutputEnergyA < 0.001 )
// {
// this.OutputEnergyA = this.OutputEnergyB;
// this.OutputEnergyB = 0;
//
// this.OutputVoltageA = this.OutputVoltageB;
// this.OutputVoltageB = 0;
// }
// }
//
// @Override
// public int getSourceTier()
// {
// if( this.output )
// {
// return this.calculateTierFromVoltage( this.OutputVoltageA );
// }
// return 4;
// }
//
// private int calculateTierFromVoltage( double voltage )
// {
// return ic2.api.energy.EnergyNet.instance.getTierFromPower( voltage );
// }
// }
import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
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.integration.IntegrationType;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
import appeng.transformer.annotations.Integration.Interface;
import appeng.transformer.annotations.Integration.InterfaceList;
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<ResourceLocation> 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 List<ResourceLocation> getStaticModels()
{
return MODELS.getModel( isPowered(), isActive() );
}
}
@@ -235,14 +235,9 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null );
break;
/*
* case IC2_POWER:
* for( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() )
* {
* newType = stack;
* }
* break;
*/
case IC2_POWER:
newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( null );
break;
case ITEM:
newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( null );