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
+2 -2
View File
@@ -119,13 +119,13 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
@Override
public void securityBreak()
{
if( this.getItemStack().stackSize > 0 )
if( this.getItemStack().getCount() > 0 )
{
final List<ItemStack> items = new ArrayList<ItemStack>();
items.add( this.is.copy() );
this.host.removePart( this.side, false );
Platform.spawnDrops( this.tile.getWorld(), this.tile.getPos(), items );
this.is.stackSize = 0;
this.is.setCount( 0 );
}
}
@@ -143,7 +143,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
final IPartItem bi = (IPartItem) is.getItem();
is = is.copy();
is.stackSize = 1;
is.setCount( 1 );
final IPart bp = bi.createPartFromItemStack( is );
if( bp != null )
@@ -191,7 +191,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
final IPartItem bi = (IPartItem) is.getItem();
is = is.copy();
is.stackSize = 1;
is.setCount( 1 );
final IPart bp = bi.createPartFromItemStack( is );
if( bp instanceof IPartCable )
@@ -1051,7 +1051,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
if( def != null && extra != null )
{
IPart p = this.getPart( side );
final ItemStack iss = ItemStack.loadItemStackFromNBT( def );
final ItemStack iss = new ItemStack( def );
if( iss == null )
{
continue;
+29 -21
View File
@@ -55,7 +55,7 @@ import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.core.CommonHelper;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.core.sync.packets.PacketPartPlacement;
@@ -104,7 +104,8 @@ public class PartPlacement
if( mop != null )
{
final List<ItemStack> is = new LinkedList<ItemStack>();
final SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() ) );
final SelectedPart sp = selectPart( player, host,
mop.hitVec.addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() ) );
if( sp.part != null )
{
@@ -172,10 +173,11 @@ public class PartPlacement
host.markForUpdate();
if( !player.capabilities.isCreativeMode )
{
held.stackSize--;
if( held.stackSize == 0 )
held.grow( -1 );
;
if( held.getCount() == 0 )
{
player.inventory.mainInventory[player.inventory.currentItem] = null;
player.inventory.mainInventory.add( player.inventory.currentItem, null );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held, hand ) );
}
}
@@ -259,7 +261,8 @@ public class PartPlacement
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent();
final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_pos );
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player, world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) )
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player,
world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) )
{
if( !world.isRemote )
{
@@ -300,7 +303,8 @@ public class PartPlacement
if( blkID == null || blkID.isReplaceable( world, te_pos ) || host != null )
{
return place( held, te_pos, side.getOpposite(), player, hand, world, pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
return place( held, te_pos, side.getOpposite(), player, hand, world,
pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
}
}
return EnumActionResult.PASS;
@@ -314,7 +318,8 @@ public class PartPlacement
if( mop != null )
{
final SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() ) );
final SelectedPart sp = selectPart( player, host,
mop.hitVec.addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() ) );
if( sp.part != null )
{
@@ -334,18 +339,20 @@ public class PartPlacement
final AEPartLocation mySide = host.addPart( held, AEPartLocation.fromFacing( side ), player, hand );
if( mySide != null )
{
multiPart.maybeBlock().ifPresent( multiPartBlock -> {
final SoundType ss = multiPartBlock.getSoundType(state, world, pos, player);
multiPart.maybeBlock().ifPresent( multiPartBlock ->
{
final SoundType ss = multiPartBlock.getSoundType( state, world, pos, player );
world.playSound( null, pos, ss.getPlaceSound(), SoundCategory.BLOCKS, ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F );
});
} );
if( !player.capabilities.isCreativeMode )
{
held.stackSize--;
if( held.stackSize == 0 )
held.grow( -1 );
;
if( held.getCount() == 0 )
{
player.inventory.mainInventory[player.inventory.currentItem] = null;
player.inventory.mainInventory.add( player.inventory.currentItem, null );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held, hand ) );
}
}
@@ -360,7 +367,7 @@ public class PartPlacement
private static float getEyeOffset( final EntityPlayer p )
{
if( p.worldObj.isRemote )
if( p.world.isRemote )
{
return Platform.getEyeOffset( p );
}
@@ -370,9 +377,9 @@ public class PartPlacement
private static SelectedPart selectPart( final EntityPlayer player, final IPartHost host, final Vec3d pos )
{
CommonHelper.proxy.updateRenderMode( player );
AppEng.proxy.updateRenderMode( player );
final SelectedPart sp = host.selectPart( pos );
CommonHelper.proxy.updateRenderMode( null );
AppEng.proxy.updateRenderMode( null );
return sp;
}
@@ -402,7 +409,7 @@ public class PartPlacement
return;
}
if( event instanceof PlayerInteractEvent.RightClickEmpty && event.getEntityPlayer().worldObj.isRemote )
if( event instanceof PlayerInteractEvent.RightClickEmpty && event.getEntityPlayer().world.isRemote )
{
// re-check to see if this event was already channeled, cause these two events are really stupid...
final RayTraceResult mop = Platform.rayTrace( event.getEntityPlayer(), true, false );
@@ -414,7 +421,7 @@ public class PartPlacement
if( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
{
final World w = event.getEntity().worldObj;
final World w = event.getEntity().world;
final TileEntity te = w.getTileEntity( mop.getBlockPos() );
if( te instanceof IPartHost && this.wasCanceled )
{
@@ -435,7 +442,7 @@ public class PartPlacement
}
}
}
else if( event instanceof PlayerInteractEvent.RightClickBlock && !event.getEntityPlayer().worldObj.isRemote )
else if( event instanceof PlayerInteractEvent.RightClickBlock && !event.getEntityPlayer().world.isRemote )
{
if( this.placing.get() != null )
{
@@ -445,7 +452,8 @@ public class PartPlacement
this.placing.set( event );
final ItemStack held = event.getEntityPlayer().getHeldItem( event.getHand() );
if( place( held, event.getPos(), event.getFace(), event.getEntityPlayer(), event.getHand(), event.getEntityPlayer().worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) == EnumActionResult.SUCCESS )
if( place( held, event.getPos(), event.getFace(), event.getEntityPlayer(), event.getHand(), event.getEntityPlayer().world,
PlaceType.INTERACT_FIRST_PASS, 0 ) == EnumActionResult.SUCCESS )
{
event.setCanceled( true );
this.wasCanceled = true;
@@ -56,13 +56,13 @@ import appeng.api.parts.IPartModel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.hooks.TickHandler;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.parts.PartBasicState;
import appeng.server.ServerHelper;
import appeng.util.IWorldCallable;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
@@ -292,8 +292,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
if( changed )
{
ServerHelper.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(),
new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.getSide(), false ) );
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(), new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.getSide(), false ) );
}
}
}
@@ -368,11 +367,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return true;
}
final int oldStackSize = entityItem.getEntityItem().stackSize;
final int oldStackSize = entityItem.getEntityItem().getCount();
final int newStackSize = (int) overflow.getStackSize();
final boolean changed = oldStackSize != newStackSize;
entityItem.getEntityItem().stackSize = newStackSize;
entityItem.getEntityItem().setCount( newStackSize );
return changed;
}
@@ -402,7 +401,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
overflowEntity.motionY = 0;
overflowEntity.motionZ = 0;
w.spawnEntityInWorld( overflowEntity );
w.spawnEntity( overflowEntity );
}
protected boolean isAnnihilationPlane( final TileEntity blockTileEntity, final AEPartLocation side )
@@ -457,8 +456,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
energy.extractAEPower( requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.breakBlockAndStoreItems( w, pos, items );
ServerHelper.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w,
new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w, new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
}
else
{
@@ -531,7 +529,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
float requiredEnergy = 1 + hardness;
for( final ItemStack is : items )
{
requiredEnergy += is.stackSize;
requiredEnergy += is.getCount();
}
return requiredEnergy;
@@ -305,10 +305,10 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
private void pushItemIntoTarget( final InventoryAdaptor d, final IEnergyGrid energy, final IMEInventory<IAEItemStack> inv, IAEItemStack ais )
{
final ItemStack is = ais.getItemStack();
is.stackSize = (int) this.itemToSend;
is.setCount( (int) this.itemToSend );
final ItemStack o = d.simulateAdd( is );
final long canFit = o == null ? this.itemToSend : this.itemToSend - o.stackSize;
final long canFit = o == null ? this.itemToSend : this.itemToSend - o.getCount();
if( canFit > 0 )
{
@@ -323,7 +323,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
final ItemStack failed = d.addItems( itemsToAdd.getItemStack() );
if( failed != null )
{
ais.setStackSize( failed.stackSize );
ais.setStackSize( failed.getCount() );
inv.injectItems( ais, Actionable.MODULATE, this.mySrc );
}
else
@@ -471,7 +471,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
* }
*/
maxStorage = is.stackSize;
maxStorage = is.getCount();
worked = true;
if( type == Actionable.MODULATE )
{
@@ -481,33 +481,33 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
if( side.xOffset == 0 && side.zOffset == 0 )
{
Worked = i.onItemUse( is, player, w, tePos.offset( side.getFacing() ), null, side.getFacing().getOpposite(), side.xOffset,
Worked = i.onItemUse( player, w, tePos.offset( side.getFacing() ), null, side.getFacing().getOpposite(), side.xOffset,
side.yOffset, side.zOffset ) == EnumActionResult.SUCCESS;
}
if( !Worked && side.xOffset == 0 && side.zOffset == 0 )
{
Worked = i.onItemUse( is, player, w, tePos.offset( side.getFacing().getOpposite() ), null, side.getFacing(), side.xOffset,
Worked = i.onItemUse( player, w, tePos.offset( side.getFacing().getOpposite() ), null, side.getFacing(), side.xOffset,
side.yOffset, side.zOffset ) == EnumActionResult.SUCCESS;
}
if( !Worked && side.yOffset == 0 )
{
Worked = i.onItemUse( is, player, w, tePos.offset( EnumFacing.DOWN ), null, EnumFacing.UP, side.xOffset, side.yOffset,
Worked = i.onItemUse( player, w, tePos.offset( EnumFacing.DOWN ), null, EnumFacing.UP, side.xOffset, side.yOffset,
side.zOffset ) == EnumActionResult.SUCCESS;
}
if( !Worked )
{
i.onItemUse( is, player, w, tePos, null, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
i.onItemUse( player, w, tePos, null, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
}
maxStorage -= is.stackSize;
maxStorage -= is.getCount();
}
else
{
i.onItemUse( is, player, w, tePos, null, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
maxStorage -= is.stackSize;
i.onItemUse( player, w, tePos, null, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
maxStorage -= is.getCount();
}
}
else
@@ -534,7 +534,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
{
if( type == Actionable.MODULATE )
{
is.stackSize = (int) maxStorage;
is.setCount( (int) maxStorage );
final double x = ( side.xOffset != 0 ? 0 : .7 * ( Platform.getRandomFloat() - .5 ) ) + side.xOffset + .5 + te.getPos().getX();
final double y = ( side.yOffset != 0 ? 0 : .7 * ( Platform.getRandomFloat() - .5 ) ) + side.yOffset + .5 + te.getPos().getY();
final double z = ( side.zOffset != 0 ? 0 : .7 * ( Platform.getRandomFloat() - .5 ) ) + side.zOffset + .5 + te.getPos().getZ();
@@ -560,7 +560,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
}
}
if( !w.spawnEntityInWorld( result ) )
if( !w.spawnEntity( result ) )
{
result.setDead();
worked = false;
@@ -99,7 +99,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
{
return true;
}
return out.getStackSize() != stack.stackSize;
return out.getStackSize() != stack.getCount();
}
@Override
@@ -226,9 +226,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( newItems != null )
{
newItems.stackSize = (int) ( Math.min( newItems.stackSize,
energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 );
this.itemToSend -= newItems.stackSize;
newItems.setCount( (int) ( Math.min( newItems.getCount(),
energy.extractAEPower( newItems.getCount(), Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 ) );
this.itemToSend -= newItems.getCount();
if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
{
@@ -236,7 +236,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
}
else
{
this.lastItemChecked.setStackSize( newItems.stackSize );
this.lastItemChecked.setStackSize( newItems.getCount() );
}
final IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source );
@@ -288,7 +288,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( itemAmountNotStorable != null )
{
return (int) Math.min( simResult.stackSize - itemAmountNotStorable.getStackSize(), toSend );
return (int) Math.min( simResult.getCount() - itemAmountNotStorable.getStackSize(), toSend );
}
return toSend;
@@ -1,204 +1,204 @@
/*
* 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.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;
}
}
///*
// * 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.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;
// }
//}
@@ -1,207 +1,207 @@
/*
* 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.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;
}
}
///*
// * 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.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;
// }
//
//
//
//}
@@ -100,7 +100,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
ItemStack requestedItemStack = request.getItemStack();
int remainingSize = requestedItemStack.stackSize;
int remainingSize = requestedItemStack.getCount();
// Use this to gather the requested items
ItemStack gathered = null;
@@ -117,7 +117,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
ItemStack extracted;
int stackSizeCurrentSlot = stackInInventorySlot.stackSize;
int stackSizeCurrentSlot = stackInInventorySlot.getCount();
int remainingCurrentSlot = Math.min( remainingSize, stackSizeCurrentSlot );
// We have to loop here because according to the docs, the handler shouldn't return a stack with size >
@@ -127,13 +127,13 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
extracted = itemHandler.extractItem( i, remainingCurrentSlot, simulate );
if( extracted != null )
{
if( extracted.stackSize > remainingCurrentSlot )
if( extracted.getCount() > remainingCurrentSlot )
{
// Something broke. It should never return more than we requested...
// We're going to silently eat the remainder
AELog.warn( "Mod that provided item handler %1 is broken. Returned %2 items, even though we requested %3.",
itemHandler.getClass().getSimpleName(), extracted.stackSize, remainingCurrentSlot );
extracted.stackSize = remainingCurrentSlot;
itemHandler.getClass().getSimpleName(), extracted.getCount(), remainingCurrentSlot );
extracted.setCount( remainingCurrentSlot );
}
// We're just gonna use the first stack we get our hands on as the template for the rest
@@ -143,9 +143,9 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
else
{
gathered.stackSize += extracted.stackSize;
gathered.grow( extracted.getCount() );
}
remainingCurrentSlot -= extracted.stackSize;
remainingCurrentSlot -= extracted.getCount();
}
}
while( extracted != null && remainingCurrentSlot > 0 );
@@ -257,12 +257,12 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private void addPossibleStackSizeChange( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
{
// Still the same item, but amount might have changed
long diff = newIS.stackSize - oldAeIS.getStackSize();
long diff = newIS.getCount() - oldAeIS.getStackSize();
if( diff != 0 )
{
IAEItemStack stack = oldAeIS.copy();
stack.setStackSize( newIS.stackSize );
stack.setStackSize( newIS.getCount() );
cachedStacks[slot] = newIS;
cachedAeStacks[slot] = stack;
@@ -272,9 +272,9 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public boolean isUseableByPlayer( final EntityPlayer entityplayer )
public boolean isUsableByPlayer( final EntityPlayer entityplayer )
{
return this.duality.getStorage().isUseableByPlayer( entityplayer );
return this.duality.getStorage().isUsableByPlayer( entityplayer );
}
@Override
@@ -444,4 +444,11 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
return this.duality.getCapability( capabilityClass, getSide().getFacing() );
}
@Override
public boolean isEmpty()
{
// TODO Auto-generated method stub
return false;
}
}
@@ -105,13 +105,13 @@ public class PartToggleBus extends PartBasicState
@Override
public void securityBreak()
{
if( this.getItemStack().stackSize > 0 )
if( this.getItemStack().getCount() > 0 )
{
final List<ItemStack> items = new ArrayList<ItemStack>();
items.add( this.getItemStack().copy() );
this.getHost().removePart( this.getSide(), false );
Platform.spawnDrops( this.getTile().getWorld(), this.getTile().getPos(), items );
this.getItemStack().stackSize = 0;
this.getItemStack().setCount( 0 );
}
}
@@ -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 );
@@ -167,7 +167,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
if( Platform.isWrench( player, eq, te.getPos() ) )
{
this.isLocked = !this.isLocked;
player.addChatMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
player.sendMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForUpdate();
}
else if( !this.isLocked )
@@ -235,7 +235,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
{
super.onPlacement( player, hand, held, side );
final byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
final byte rotation = (byte) ( MathHelper.floor( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
if( side == AEPartLocation.UP )
{
this.spin = rotation;
@@ -118,7 +118,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
if( input.equals( targetStack ) )
{
final IAEItemStack insertItem = input.copy();
insertItem.setStackSize( targetStack.stackSize );
insertItem.setStackSize( targetStack.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
player.inventory.setInventorySlotContents( x, failedToInsert == null ? null : failedToInsert.getItemStack() );
}
@@ -167,7 +167,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
{
final TileEntity te = this.getTile();
final List<ItemStack> list = Collections.singletonList( newItems );
Platform.spawnDrops( player.worldObj, te.getPos().offset( this.getSide().getFacing() ), list );
Platform.spawnDrops( player.world, te.getPos().offset( this.getSide().getFacing() ), list );
}
if( player.openContainer != null )
@@ -165,7 +165,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
final ItemStack is = this.crafting.getStackInSlot( x );
if( is != null )
{
is.stackSize = 1;
is.setCount( 1 );
}
}
}