Applied-Energistics-2-tiler.../src/main/java/appeng/parts/automation/PartFormationPlane.java

594 lines
16 KiB
Java
Raw Normal View History

2014-11-14 12:02:52 +01:00
/*
* 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.automation;
2014-02-18 06:51:31 +01:00
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
2014-02-18 06:51:31 +01:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
2014-06-22 09:00:38 +02:00
import net.minecraft.item.ItemFirework;
import net.minecraft.item.ItemReed;
2014-06-03 19:08:33 +02:00
import net.minecraft.item.ItemSkull;
import net.minecraft.item.ItemStack;
2014-02-18 06:51:31 +01:00
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
2015-06-16 02:44:59 +02:00
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
2014-02-18 06:51:31 +01:00
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.IPlantable;
2015-06-16 02:44:59 +02:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2014-02-21 21:36:40 +01:00
import appeng.api.AEApi;
2014-02-18 06:51:31 +01:00
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
2014-02-18 06:51:31 +01:00
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
2014-02-18 06:51:31 +01:00
import appeng.api.networking.security.BaseActionSource;
import appeng.api.parts.IPart;
2014-09-20 22:20:53 +02:00
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
2014-06-03 20:00:10 +02:00
import appeng.api.parts.IPartItem;
import appeng.api.parts.IPartRenderHelper;
2014-02-18 06:51:31 +01:00
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
2015-06-16 02:44:59 +02:00
import appeng.api.util.AEPartLocation;
2014-02-18 06:51:31 +01:00
import appeng.api.util.IConfigManager;
2015-06-22 18:16:25 +02:00
import appeng.client.render.ModelGenerator;
import appeng.client.texture.CableBusTextures;
import appeng.core.AEConfig;
2014-02-18 06:51:31 +01:00
import appeng.core.sync.GuiBridge;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.me.storage.MEInventoryHandler;
2015-08-06 18:59:31 +02:00
import appeng.parts.PartBasicState;
2014-02-18 06:51:31 +01:00
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
2014-02-18 06:51:31 +01:00
public class PartFormationPlane extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory<IAEItemStack>
{
final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS );
final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
2014-02-18 06:51:31 +01:00
int priority = 0;
boolean wasActive = false;
boolean blocked = false;
public PartFormationPlane( ItemStack is )
{
super( is );
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.getConfigManager().registerSetting( Settings.PLACE_BLOCK, YesNo.YES );
2014-12-29 15:13:47 +01:00
this.updateHandler();
2014-02-18 06:51:31 +01:00
}
private void updateHandler()
2014-02-18 06:51:31 +01:00
{
this.myHandler.setBaseAccess( AccessRestriction.WRITE );
this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
this.myHandler.setPriority( this.priority );
2014-02-18 06:51:31 +01:00
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
for( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
{
IAEItemStack is = this.Config.getAEStackInSlot( x );
if( is != null )
2015-04-29 02:30:53 +02:00
{
priorityList.add( is );
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
}
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
2015-04-29 02:30:53 +02:00
{
this.myHandler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
2015-04-29 02:30:53 +02:00
}
else
2015-04-29 02:30:53 +02:00
{
this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) );
2015-04-29 02:30:53 +02:00
}
try
{
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
}
catch( GridAccessException e )
{
// :P
}
2014-02-18 06:51:31 +01:00
}
@Override
2014-02-18 06:51:31 +01:00
protected int getUpgradeSlots()
{
return 5;
}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
this.updateHandler();
this.host.markForSave();
}
2014-02-18 06:51:31 +01:00
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
2014-02-18 06:51:31 +01:00
{
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
2014-02-18 06:51:31 +01:00
if( inv == this.Config )
2015-04-29 02:30:53 +02:00
{
this.updateHandler();
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
}
@Override
public void upgradesChanged()
{
this.updateHandler();
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.Config.readFromNBT( data, "config" );
this.priority = data.getInteger( "priority" );
this.updateHandler();
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
this.Config.writeToNBT( data, "config" );
data.setInteger( "priority", this.priority );
}
@Override
public IInventory getInventoryByName( String name )
{
if( name.equals( "config" ) )
2015-04-29 02:30:53 +02:00
{
return this.Config;
2015-04-29 02:30:53 +02:00
}
return super.getInventoryByName( name );
}
@Override
@MENetworkEventSubscribe
public void powerRender( MENetworkPowerStatusChange c )
{
2014-12-29 15:13:47 +01:00
boolean currentActive = this.proxy.isActive();
if( this.wasActive != currentActive )
{
2014-12-29 15:13:47 +01:00
this.wasActive = currentActive;
this.updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getHost().markForUpdate();
}
}
2014-02-18 06:51:31 +01:00
@MENetworkEventSubscribe
public void updateChannels( MENetworkChannelsChanged changedChannels )
2014-02-18 06:51:31 +01:00
{
2014-12-29 15:13:47 +01:00
boolean currentActive = this.proxy.isActive();
if( this.wasActive != currentActive )
2014-02-18 06:51:31 +01:00
{
2014-12-29 15:13:47 +01:00
this.wasActive = currentActive;
this.updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getHost().markForUpdate();
2014-02-18 06:51:31 +01:00
}
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
int minX = 1;
int minY = 1;
int maxX = 15;
int maxY = 15;
IPartHost host = this.getHost();
if( host != null )
{
TileEntity te = host.getTile();
2015-06-16 02:44:59 +02:00
BlockPos pos = te.getPos();
2015-06-16 02:44:59 +02:00
EnumFacing e = bch.getWorldX();
EnumFacing u = bch.getWorldY();
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( e.getOpposite() ) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
minX = 0;
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( e) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
maxX = 16;
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( u.getOpposite() ) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
minY = 0;
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( u) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
maxY = 16;
2015-04-29 02:30:53 +02:00
}
}
bch.addBox( 5, 5, 14, 11, 11, 15 );
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
}
@Override
@SideOnly( Side.CLIENT )
2015-06-22 18:16:25 +02:00
public void renderInventory( IPartRenderHelper rh, ModelGenerator renderer )
{
2015-06-16 02:44:59 +02:00
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
rh.setBounds( 1, 1, 15, 15, 15, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds( 5, 5, 14, 11, 11, 15 );
rh.renderInventoryBox( renderer );
}
@Override
@SideOnly( Side.CLIENT )
2015-06-22 18:16:25 +02:00
public void renderStatic( BlockPos opos, IPartRenderHelper rh, ModelGenerator renderer )
{
int minX = 1;
int minY = 1;
int maxX = 15;
int maxY = 15;
2015-06-16 02:44:59 +02:00
EnumFacing e = rh.getWorldX();
EnumFacing u = rh.getWorldY();
2014-12-29 15:13:47 +01:00
TileEntity te = this.getHost().getTile();
2015-06-16 02:44:59 +02:00
BlockPos pos = te.getPos();
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( e.getOpposite() ) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
minX = 0;
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
maxX = 16;
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( u.getOpposite() ) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
minY = 0;
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( u ) ), this.side ) )
2015-04-29 02:30:53 +02:00
{
maxY = 16;
2015-04-29 02:30:53 +02:00
}
2015-08-06 18:59:31 +02:00
boolean isActive = ( this.clientFlags & ( PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG ) ) == ( PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG );
2015-06-16 02:44:59 +02:00
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : renderer.getIcon( is ), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
2015-06-16 02:44:59 +02:00
rh.renderBlock( opos, renderer );
2015-06-16 02:44:59 +02:00
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : renderer.getIcon( is ), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds( 5, 5, 14, 11, 11, 15 );
2015-06-16 02:44:59 +02:00
rh.renderBlock( opos, renderer );
2015-06-16 02:44:59 +02:00
this.renderLights( opos, rh, renderer );
}
@Override
public void onNeighborChanged()
{
TileEntity te = this.host.getTile();
2015-06-16 02:44:59 +02:00
World w = te.getWorld();
AEPartLocation side = this.side;
2015-06-16 02:44:59 +02:00
BlockPos tePos = te.getPos().offset( side.getFacing() );
this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
}
@Override
public int cableConnectionRenderTo()
{
return 1;
}
2014-02-18 06:51:31 +01:00
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
2014-02-18 06:51:31 +01:00
{
if( !player.isSneaking() )
2014-02-18 06:51:31 +01:00
{
if( Platform.isClient() )
2015-04-29 02:30:53 +02:00
{
return true;
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE );
return true;
}
2014-02-18 06:51:31 +01:00
return false;
2014-02-18 06:51:31 +01:00
}
2015-06-16 02:44:59 +02:00
private boolean isTransitionPlane( TileEntity blockTileEntity, AEPartLocation side )
{
if( blockTileEntity instanceof IPartHost )
{
IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
return p instanceof PartFormationPlane;
}
return false;
}
2014-02-18 06:51:31 +01:00
@Override
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
2014-02-18 06:51:31 +01:00
{
if( this.proxy.isActive() && channel == StorageChannel.ITEMS )
2014-02-18 06:51:31 +01:00
{
List<IMEInventoryHandler> Handler = new ArrayList<IMEInventoryHandler>( 1 );
Handler.add( this.myHandler );
return Handler;
2014-02-18 06:51:31 +01:00
}
return new ArrayList<IMEInventoryHandler>();
2014-02-18 06:51:31 +01:00
}
@Override
public int getPriority()
2014-02-18 06:51:31 +01:00
{
return this.priority;
2014-02-18 06:51:31 +01:00
}
@Override
public void setPriority( int newValue )
2014-02-18 06:51:31 +01:00
{
this.priority = newValue;
this.host.markForSave();
this.updateHandler();
2014-02-18 06:51:31 +01:00
}
@Override
public void blinkCell( int slot )
2014-02-18 06:51:31 +01:00
{
// :P
}
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src )
2014-02-18 06:51:31 +01:00
{
if( this.blocked || input == null || input.getStackSize() <= 0 )
2015-04-29 02:30:53 +02:00
{
2014-02-18 06:51:31 +01:00
return input;
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK );
2014-02-18 06:51:31 +01:00
ItemStack is = input.getItemStack();
Item i = is.getItem();
long maxStorage = Math.min( input.getStackSize(), is.getMaxStackSize() );
boolean worked = false;
2014-12-29 15:13:47 +01:00
TileEntity te = this.host.getTile();
2015-06-16 02:44:59 +02:00
World w = te.getWorld();
AEPartLocation side = this.side;
2014-02-18 06:51:31 +01:00
2015-06-16 02:44:59 +02:00
BlockPos tePos = te.getPos().offset( side.getFacing() );
2014-02-18 06:51:31 +01:00
2015-06-16 02:44:59 +02:00
if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) )
2014-02-18 06:51:31 +01:00
{
if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i instanceof ItemReed ) )
2014-02-18 06:51:31 +01:00
{
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
2014-12-29 15:13:47 +01:00
Platform.configurePlayer( player, side, this.tile );
2015-06-16 02:44:59 +02:00
// TODO: LIMIT FIREWORKS
/*
if( i instanceof ItemFirework )
2014-06-22 09:00:38 +02:00
{
2015-06-16 02:44:59 +02:00
Chunk c = w.getChunkFromBlockCoords( tePos );
2014-06-22 09:00:38 +02:00
int sum = 0;
2015-06-16 02:44:59 +02:00
for( List Z : c.geten )
2015-04-29 02:30:53 +02:00
{
2014-06-22 09:00:38 +02:00
sum += Z.size();
2015-04-29 02:30:53 +02:00
}
if( sum > 32 )
2015-04-29 02:30:53 +02:00
{
2014-06-22 09:00:38 +02:00
return input;
2015-04-29 02:30:53 +02:00
}
2014-06-22 09:00:38 +02:00
}
2015-06-16 02:44:59 +02:00
*/
2014-02-18 06:51:31 +01:00
maxStorage = is.stackSize;
worked = true;
if( type == Actionable.MODULATE )
2014-02-18 06:51:31 +01:00
{
if( i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemReed )
{
boolean Worked = false;
2015-06-16 02:44:59 +02:00
if( side.xOffset == 0 && side.zOffset == 0 )
2015-04-29 02:30:53 +02:00
{
2015-06-16 02:44:59 +02:00
Worked = i.onItemUse( is, player, w, tePos.offset( side.getFacing() ), side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
if( !Worked && side.xOffset == 0 && side.zOffset == 0 )
2015-04-29 02:30:53 +02:00
{
2015-06-16 02:44:59 +02:00
Worked = i.onItemUse( is, player, w, tePos.offset( side.getFacing().getOpposite() ), side.getFacing(), side.xOffset, side.yOffset, side.zOffset );
2015-04-29 02:30:53 +02:00
}
2014-06-03 19:08:33 +02:00
2015-06-16 02:44:59 +02:00
if( !Worked && side.yOffset == 0 )
2015-04-29 02:30:53 +02:00
{
2015-06-16 02:44:59 +02:00
Worked = i.onItemUse( is, player, w, tePos.offset( EnumFacing.DOWN ), EnumFacing.UP, side.xOffset, side.yOffset, side.zOffset );
2015-04-29 02:30:53 +02:00
}
if( !Worked )
2015-04-29 02:30:53 +02:00
{
2015-06-16 02:44:59 +02:00
i.onItemUse( is, player, w, tePos, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
2015-04-29 02:30:53 +02:00
}
maxStorage -= is.stackSize;
}
else
{
2015-06-16 02:44:59 +02:00
i.onItemUse( is, player, w, tePos, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
maxStorage -= is.stackSize;
}
2014-02-18 06:51:31 +01:00
}
else
2015-04-29 02:30:53 +02:00
{
2014-02-18 06:51:31 +01:00
maxStorage = 1;
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
}
else
{
worked = true;
2015-06-16 02:44:59 +02:00
Chunk c = w.getChunkFromBlockCoords( tePos );
2014-02-18 06:51:31 +01:00
int sum = 0;
2015-06-16 02:44:59 +02:00
// TODO: LIMIT OTHER THIGNS!
/*
for( List Z : c.entityLists )
2015-04-29 02:30:53 +02:00
{
2014-02-18 06:51:31 +01:00
sum += Z.size();
2015-04-29 02:30:53 +02:00
}
2015-06-16 02:44:59 +02:00
*/
if( sum < AEConfig.instance.formationPlaneEntityLimit )
2014-02-18 06:51:31 +01:00
{
if( type == Actionable.MODULATE )
2014-02-18 06:51:31 +01:00
{
is.stackSize = (int) maxStorage;
EntityItem ei = new EntityItem( w, // w
2015-06-16 02:44:59 +02:00
( ( side.xOffset != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.xOffset * -0.3 + tePos.getX(), // spawn
( ( side.yOffset != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.yOffset * -0.3 + tePos.getY(), // spawn
( ( side.zOffset != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.zOffset * -0.3 + tePos.getZ(), // spawn
is.copy() );
Entity result = ei;
2015-06-16 02:44:59 +02:00
ei.motionX = side.xOffset * 0.2;
ei.motionY = side.yOffset * 0.2;
ei.motionZ = side.zOffset * 0.2;
if( is.getItem().hasCustomEntity( is ) )
{
result = is.getItem().createEntity( w, ei, is );
if( result != null )
2015-04-29 02:30:53 +02:00
{
ei.setDead();
2015-04-29 02:30:53 +02:00
}
else
2015-04-29 02:30:53 +02:00
{
result = ei;
2015-04-29 02:30:53 +02:00
}
}
if( !w.spawnEntityInWorld( result ) )
{
result.setDead();
worked = false;
}
2014-02-18 06:51:31 +01:00
}
}
else
2015-04-29 02:30:53 +02:00
{
worked = false;
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
}
}
2015-06-16 02:44:59 +02:00
this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
2014-02-18 06:51:31 +01:00
if( worked )
2014-02-18 06:51:31 +01:00
{
IAEItemStack out = input.copy();
out.decStackSize( maxStorage );
if( out.getStackSize() == 0 )
2015-04-29 02:30:53 +02:00
{
return null;
2015-04-29 02:30:53 +02:00
}
2014-02-18 06:51:31 +01:00
return out;
}
return input;
}
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
return null;
}
@Override
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
{
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
@Override
public void saveChanges( IMEInventory cellInventory )
{
// nope!
}
}