2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts.automation;
|
|
|
|
|
2014-02-18 06:51:31 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
2014-02-23 07:55:46 +01:00
|
|
|
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;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-02-18 06:51:31 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
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;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
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.networking.events.MENetworkCellArrayUpdate;
|
|
|
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
|
|
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
2014-02-19 06:26:43 +01:00
|
|
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
2014-02-18 06:51:31 +01:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
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;
|
|
|
|
import appeng.api.util.IConfigManager;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.texture.CableBusTextures;
|
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;
|
|
|
|
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-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-18 06:51:31 +01:00
|
|
|
public class PartFormationPlane extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory<IAEItemStack>
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-02-18 06:51:31 +01:00
|
|
|
int priority = 0;
|
|
|
|
boolean wasActive = false;
|
|
|
|
boolean blocked = false;
|
2014-02-21 21:36:40 +01:00
|
|
|
MEInventoryHandler myHandler = new MEInventoryHandler( this, IAEItemStack.class );
|
2014-02-18 06:51:31 +01:00
|
|
|
AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public PartFormationPlane(ItemStack is) {
|
|
|
|
super( PartFormationPlane.class, is );
|
2014-02-18 06:51:31 +01:00
|
|
|
settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
|
|
|
updateHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 06:18:49 +01:00
|
|
|
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
2014-02-18 06:51:31 +01:00
|
|
|
{
|
|
|
|
if ( !player.isSneaking() )
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_FPLANE );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getUpgradeSlots()
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IInventory getInventoryByName(String name)
|
|
|
|
{
|
|
|
|
if ( name.equals( "config" ) )
|
|
|
|
return Config;
|
|
|
|
|
|
|
|
return super.getInventoryByName( name );
|
|
|
|
}
|
|
|
|
|
2014-02-19 06:26:43 +01:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void powerRender(MENetworkPowerStatusChange c)
|
|
|
|
{
|
|
|
|
boolean currentActive = proxy.isActive();
|
|
|
|
if ( wasActive != currentActive )
|
|
|
|
{
|
|
|
|
wasActive = currentActive;
|
|
|
|
updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 06:51:31 +01:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void updateChannels(MENetworkChannelsChanged chann)
|
|
|
|
{
|
|
|
|
boolean currentActive = proxy.isActive();
|
|
|
|
if ( wasActive != currentActive )
|
|
|
|
{
|
|
|
|
wasActive = currentActive;
|
2014-02-19 06:26:43 +01:00
|
|
|
updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
2014-02-18 06:51:31 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
2014-02-20 05:20:38 +01:00
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
|
|
|
|
CableBusTextures.PartTransitionPlaneBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(),
|
|
|
|
CableBusTextures.PartMonitorSides.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rh.setBounds( 1, 1, 15, 15, 15, 16 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
int minX = 1;
|
|
|
|
int minY = 1;
|
|
|
|
int maxX = 15;
|
|
|
|
int maxY = 15;
|
|
|
|
|
|
|
|
ForgeDirection e = rh.getWorldX();
|
|
|
|
ForgeDirection u = rh.getWorldY();
|
|
|
|
|
|
|
|
TileEntity te = getHost().getTile();
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
minX = 0;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
maxX = 16;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
minY = 0;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
maxY = 16;
|
|
|
|
|
|
|
|
boolean isActive = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
|
|
|
|
2014-02-15 07:30:06 +01:00
|
|
|
renderCache = rh.useSimpliedRendering( x, y, z, this, renderCache );
|
2013-12-27 23:59:59 +01:00
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
|
|
|
|
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : is.getIconIndex(),
|
|
|
|
CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
|
|
|
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : is.getIconIndex(),
|
|
|
|
CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
renderLights( x, y, z, rh, renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isTransitionPlane(TileEntity blockTileEntity, ForgeDirection side)
|
|
|
|
{
|
|
|
|
if ( blockTileEntity instanceof IPartHost )
|
|
|
|
{
|
|
|
|
IPart p = ((IPartHost) blockTileEntity).getPart( side );
|
|
|
|
return p instanceof PartFormationPlane;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getBoxes(IPartCollsionHelper bch)
|
|
|
|
{
|
|
|
|
int minX = 1;
|
|
|
|
int minY = 1;
|
|
|
|
int maxX = 15;
|
|
|
|
int maxY = 15;
|
|
|
|
|
|
|
|
TileEntity te = getHost().getTile();
|
|
|
|
|
|
|
|
int x = te.xCoord;
|
|
|
|
int y = te.yCoord;
|
|
|
|
int z = te.zCoord;
|
|
|
|
|
|
|
|
ForgeDirection e = bch.getWorldX();
|
|
|
|
ForgeDirection u = bch.getWorldY();
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
minX = 0;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
maxX = 16;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
minY = 0;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
maxY = 16;
|
|
|
|
|
|
|
|
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
|
|
|
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int cableConnectionRenderTo()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-02-18 06:51:31 +01:00
|
|
|
@Override
|
|
|
|
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
|
|
|
{
|
|
|
|
if ( proxy.isActive() )
|
|
|
|
{
|
|
|
|
List<IMEInventoryHandler> Handler = new ArrayList( 1 );
|
|
|
|
Handler.add( myHandler );
|
|
|
|
return Handler;
|
|
|
|
}
|
|
|
|
return new ArrayList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
|
|
|
{
|
|
|
|
updateHandler();
|
|
|
|
host.markForSave();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPriority(int newValue)
|
|
|
|
{
|
|
|
|
priority = newValue;
|
|
|
|
host.markForSave();
|
|
|
|
updateHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
|
|
|
|
|
|
|
if ( inv == Config )
|
|
|
|
updateHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateHandler()
|
|
|
|
{
|
|
|
|
myHandler.myAccess = AccessRestriction.WRITE;
|
|
|
|
myHandler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
|
|
|
|
myHandler.myPriority = priority;
|
|
|
|
|
2014-02-21 21:36:40 +01:00
|
|
|
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
2014-02-18 06:51:31 +01:00
|
|
|
|
|
|
|
int slotsToUse = 18 + getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
|
|
|
for (int x = 0; x < Config.getSizeInventory() && x < slotsToUse; x++)
|
|
|
|
{
|
|
|
|
IAEItemStack is = Config.getAEStackInSlot( x );
|
|
|
|
if ( is != null )
|
|
|
|
priorityList.add( is );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
|
|
|
myHandler.myPartitionList = new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) );
|
|
|
|
else
|
|
|
|
myHandler.myPartitionList = new PrecisePriorityList( priorityList );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.writeToNBT( data );
|
|
|
|
Config.writeToNBT( data, "config" );
|
|
|
|
data.setInteger( "priority", priority );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void readFromNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.readFromNBT( data );
|
|
|
|
Config.readFromNBT( data, "config" );
|
|
|
|
priority = data.getInteger( "priority" );
|
|
|
|
updateHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 int getPriority()
|
|
|
|
{
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void blinkCell(int slot)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNeighborChanged()
|
|
|
|
{
|
|
|
|
TileEntity te = host.getTile();
|
|
|
|
World w = te.getWorldObj();
|
|
|
|
ForgeDirection side = this.side;
|
|
|
|
|
|
|
|
int x = te.xCoord + side.offsetX;
|
|
|
|
int y = te.yCoord + side.offsetY;
|
|
|
|
int z = te.zCoord + side.offsetZ;
|
|
|
|
|
2014-02-23 07:55:46 +01:00
|
|
|
blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
2014-02-18 06:51:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
|
|
|
|
{
|
|
|
|
if ( blocked || input == null || input.getStackSize() <= 0 )
|
|
|
|
return input;
|
|
|
|
|
|
|
|
ItemStack is = input.getItemStack();
|
|
|
|
Item i = is.getItem();
|
|
|
|
|
|
|
|
long maxStorage = Math.min( input.getStackSize(), is.getMaxStackSize() );
|
|
|
|
boolean worked = false;
|
|
|
|
|
|
|
|
TileEntity te = host.getTile();
|
|
|
|
World w = te.getWorldObj();
|
|
|
|
ForgeDirection side = this.side;
|
|
|
|
|
|
|
|
int x = te.xCoord + side.offsetX;
|
|
|
|
int y = te.yCoord + side.offsetY;
|
|
|
|
int z = te.zCoord + side.offsetZ;
|
|
|
|
|
2014-02-23 07:55:46 +01:00
|
|
|
if ( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) )
|
2014-02-18 06:51:31 +01:00
|
|
|
{
|
|
|
|
if ( i instanceof ItemBlock || i instanceof IPlantable )
|
|
|
|
{
|
|
|
|
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
2014-02-19 06:26:43 +01:00
|
|
|
|
|
|
|
float pitch = 0.0f, yaw = 0.0f;
|
|
|
|
player.yOffset = 1.8f;
|
|
|
|
|
|
|
|
switch (side)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
pitch = 90.0f;
|
|
|
|
player.yOffset = -1.8f;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
yaw = -90.0f;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
yaw = 180.0f;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
yaw = 0.0f;
|
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
pitch = 90.0f;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
yaw = 90.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
player.posX = (float) tile.xCoord + 0.5;
|
|
|
|
player.posY = (float) tile.yCoord + 0.5;
|
|
|
|
player.posZ = (float) tile.zCoord + 0.5;
|
|
|
|
|
|
|
|
player.rotationPitch = player.prevCameraPitch = player.cameraPitch = pitch;
|
|
|
|
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
|
|
|
|
|
2014-02-18 06:51:31 +01:00
|
|
|
maxStorage = is.stackSize;
|
|
|
|
worked = true;
|
|
|
|
if ( type == Actionable.MODULATE )
|
|
|
|
{
|
|
|
|
i.onItemUse( is, player, w, x, y, z, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
|
|
|
maxStorage = maxStorage - is.stackSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
maxStorage = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
worked = true;
|
|
|
|
Chunk c = w.getChunkFromBlockCoords( x, z );
|
|
|
|
int sum = 0;
|
|
|
|
for (List Z : c.entityLists)
|
|
|
|
sum += Z.size();
|
|
|
|
|
|
|
|
if ( sum < 32 )
|
|
|
|
{
|
|
|
|
if ( type == Actionable.MODULATE )
|
|
|
|
{
|
|
|
|
is.stackSize = (int) maxStorage;
|
|
|
|
if ( type == Actionable.MODULATE )
|
2014-02-23 07:55:46 +01:00
|
|
|
{
|
|
|
|
EntityItem ei = new EntityItem( w, // w
|
|
|
|
((side.offsetX != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetX * -0.3 + (double) x, // spawn
|
|
|
|
((side.offsetY != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetY * -0.3 + (double) y, // spawn
|
|
|
|
((side.offsetZ != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetZ * -0.3 + (double) z, // spawn
|
|
|
|
is.copy() );
|
|
|
|
ei.motionX = side.offsetX * 0.2;
|
|
|
|
ei.motionY = side.offsetY * 0.2;
|
|
|
|
ei.motionZ = side.offsetZ * 0.2;
|
|
|
|
w.spawnEntityInWorld( ei );
|
|
|
|
}
|
2014-02-18 06:51:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-23 07:55:46 +01:00
|
|
|
blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
2014-02-18 06:51:31 +01:00
|
|
|
|
|
|
|
if ( worked )
|
|
|
|
{
|
|
|
|
IAEItemStack out = input.copy();
|
|
|
|
out.decStackSize( maxStorage );
|
2014-02-19 06:26:43 +01:00
|
|
|
if ( out.getStackSize() == 0 )
|
|
|
|
return null;
|
2014-02-18 06:51:31 +01:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
return input;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|