1.8.8 + deleted all integration can be recovered later or something.

This commit is contained in:
AlgorithmX2
2015-12-31 17:19:44 -06:00
parent 2e51ea5f78
commit 71afa9bf53
142 changed files with 386 additions and 7919 deletions
@@ -1,175 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.BCHelpers;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import buildcraft.api.blueprints.IBuilderContext;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.LayerFlags;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.ForgeDirection;
import appeng.parts.CableBusContainer;
public class AECableSchematicTile extends AEGenericSchematicTile implements IPartHost
{
@Override
public void rotateLeft( IBuilderContext context )
{
CableBusContainer cbc = new CableBusContainer( this );
cbc.readFromNBT( this.tileNBT );
cbc.rotateLeft();
this.tileNBT = new NBTTagCompound();
cbc.writeToNBT( this.tileNBT );
}
@Override
public IFacadeContainer getFacadeContainer()
{
return null;
}
@Override
public boolean canAddPart( ItemStack part, ForgeDirection side )
{
return false;
}
@Override
public ForgeDirection addPart( ItemStack is, ForgeDirection side, EntityPlayer owner )
{
return null;
}
@Override
public IPart getPart( ForgeDirection side )
{
return null;
}
@Override
public void removePart( ForgeDirection side, boolean suppressUpdate )
{
}
@Override
public void markForUpdate()
{
}
@Override
public DimensionalCoord getLocation()
{
return null;
}
@Override
public TileEntity getTile()
{
return null;
}
@Override
public AEColor getColor()
{
return null;
}
@Override
public void clearContainer()
{
}
@Override
public boolean isBlocked( ForgeDirection side )
{
return false;
}
@Override
public SelectedPart selectPart( Vec3 pos )
{
return null;
}
@Override
public void markForSave()
{
}
@Override
public void partChanged()
{
}
@Override
public boolean hasRedstone( ForgeDirection side )
{
return false;
}
@Override
public boolean isEmpty()
{
return false;
}
@Override
public Set<LayerFlags> getLayerFlags()
{
return null;
}
@Override
public void cleanup()
{
}
@Override
public void notifyNeighbors()
{
}
@Override
public boolean isInWorld()
{
return false;
}
}
@@ -1,79 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.BCHelpers;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile;
import appeng.api.util.ForgeDirection;
import appeng.api.util.ICommonTile;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class AEGenericSchematicTile extends SchematicTile
{
@Override
public void storeRequirements( IBuilderContext context, int x, int y, int z )
{
TileEntity tile = context.world().getTileEntity( x, y, z );
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
if( tile instanceof AEBaseTile )
{
ICommonTile tcb = (ICommonTile) tile;
tcb.getDrops( tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, list );
}
this.storedRequirements = list.toArray( new ItemStack[list.size()] );
}
@Override
public void rotateLeft( IBuilderContext context )
{
if( this.tileNBT.hasKey( "orientation_forward" ) && this.tileNBT.hasKey( "orientation_up" ) )
{
String forward = this.tileNBT.getString( "orientation_forward" );
String up = this.tileNBT.getString( "orientation_up" );
if( forward != null && up != null )
{
try
{
ForgeDirection fdForward = ForgeDirection.valueOf( forward );
ForgeDirection fdUp = ForgeDirection.valueOf( up );
fdForward = Platform.rotateAround( fdForward, ForgeDirection.DOWN );
fdUp = Platform.rotateAround( fdUp, ForgeDirection.DOWN );
this.tileNBT.setString( "orientation_forward", fdForward.name() );
this.tileNBT.setString( "orientation_up", fdUp.name() );
}
catch( Throwable ignored )
{
}
}
}
}
}
@@ -1,40 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.BCHelpers;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicBlock;
import appeng.api.util.ForgeDirection;
import appeng.util.Platform;
public class AERotatableBlockSchematic extends SchematicBlock
{
@Override
public void rotateLeft( IBuilderContext context )
{
if( this.meta < 6 )
{
ForgeDirection d = Platform.rotateAround( ForgeDirection.values()[this.meta], ForgeDirection.DOWN );
this.meta = d.ordinal();
}
}
}
@@ -1,58 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.BCHelpers;
import net.minecraft.tileentity.TileEntity;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.api.util.ForgeDirection;
import appeng.integration.abstraction.IBuildCraftTransport;
public class BCPipeHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc )
{
if ( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.BuildCraftTransport ) )
{
final IBuildCraftTransport bc = (IBuildCraftTransport) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.BuildCraftTransport );
return chan == StorageChannel.ITEMS && bc.isPipe( te, d );
}
return false;
}
@Override
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src )
{
if( chan == StorageChannel.ITEMS )
{
return new BCPipeInventory( te, d );
}
return null;
}
}
@@ -1,89 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.BCHelpers;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.ForgeDirection;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IBuildCraftTransport;
public class BCPipeInventory implements IMEInventory<IAEItemStack>
{
private final TileEntity te;
private final ForgeDirection direction;
public BCPipeInventory( TileEntity te, ForgeDirection direction )
{
this.te = te;
this.direction = direction;
}
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.BuildCraftTransport ) )
{
final IBuildCraftTransport registry = (IBuildCraftTransport) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.BuildCraftTransport );
if( mode == Actionable.SIMULATE )
{
if( registry.canAddItemsToPipe( this.te, input.getItemStack(), this.direction ) )
{
return null;
}
return input;
}
if( registry.addItemsToPipe( this.te, input.getItemStack(), this.direction ) )
{
return null;
}
}
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;
}
}
@@ -1,70 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import appeng.api.AEApi;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IBetterStorage;
import appeng.integration.modules.helpers.BSCrateHandler;
import appeng.integration.modules.helpers.BSCrateStorageAdaptor;
import appeng.util.InventoryAdaptor;
public class BetterStorage implements IIntegrationModule, IBetterStorage
{
@Reflected
public static BetterStorage instance;
@Reflected
public BetterStorage()
{
IntegrationHelper.testClassExistence( this, net.mcft.copy.betterstorage.api.crate.ICrateStorage.class );
}
@Override
public boolean isStorageCrate( Object te )
{
return te instanceof ICrateStorage;
}
@Override
public InventoryAdaptor getAdaptor( Object te, ForgeDirection d )
{
if( te instanceof ICrateStorage )
{
return new BSCrateStorageAdaptor( te );
}
return null;
}
@Override
public void init()
{
}
@Override
public void postInit()
{
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BSCrateHandler() );
}
}
@@ -1,130 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BuilderAPI;
import buildcraft.api.blueprints.ISchematicRegistry;
import appeng.api.AEApi;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.ITileDefinition;
import appeng.api.util.IOrientableBlock;
import appeng.core.AELog;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.modules.BCHelpers.AECableSchematicTile;
import appeng.integration.modules.BCHelpers.AEGenericSchematicTile;
import appeng.integration.modules.BCHelpers.AERotatableBlockSchematic;
/**
* The builder has no interface, because it provides no functionality
*
* @author thatsIch
* @version rv3 - 12.06.2015
* @since rv3 12.06.2015
*/
@Reflected
public class BuildCraftBuilder implements IIntegrationModule
{
@Reflected
public static BuildCraftBuilder instance;
@Reflected
public BuildCraftBuilder()
{
IntegrationHelper.testClassExistence( this, buildcraft.api.blueprints.BuilderAPI.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.blueprints.IBuilderContext.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.blueprints.ISchematicRegistry.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.blueprints.SchematicTile.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.blueprints.SchematicBlock.class );
}
@Override
public void init() throws Throwable
{
try
{
this.initBuilderSupport();
}
catch( Exception builderSupport )
{
// not supported?
}
}
@Override
public void postInit()
{
}
private void initBuilderSupport()
{
final ISchematicRegistry schematicRegistry = BuilderAPI.schematicRegistry;
final IBlocks blocks = AEApi.instance().definitions().blocks();
final IBlockDefinition maybeMultiPart = blocks.multiPart();
for( Method blockDefinition : blocks.getClass().getMethods() )
{
try
{
final IBlockDefinition def = (IBlockDefinition) blockDefinition.invoke( blocks );
final Optional<Block> maybeBlock = def.maybeBlock();
if( !maybeBlock.isPresent() )
{
continue;
}
final Block block = maybeBlock.get();
if( block instanceof IOrientableBlock && ( (IOrientableBlock) block ).usesMetadata() && !( def instanceof ITileDefinition ) )
{
schematicRegistry.registerSchematicBlock( block, AERotatableBlockSchematic.class );
}
else if( maybeMultiPart.isSameAs( new ItemStack( block ) ) )
{
schematicRegistry.registerSchematicBlock( block, AECableSchematicTile.class );
}
else if( def instanceof ITileDefinition )
{
schematicRegistry.registerSchematicBlock( block, AEGenericSchematicTile.class );
}
}
catch( InvocationTargetException ignore )
{
AELog.warning( "Encountered problems while initializing the BuildCraft Builder support. Can not invoke the method %s", blockDefinition );
}
catch( IllegalAccessException ignore )
{
AELog.warning( "Encountered problems while initializing the BuildCraft Builder support. Can not access the method %s", blockDefinition );
}
}
}
}
@@ -1,90 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.tools.IToolWrench;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IBuildCraftCore;
@Reflected
public final class BuildCraftCore implements IBuildCraftCore, IIntegrationModule
{
@Reflected
public static BuildCraftCore instance;
@Reflected
public BuildCraftCore()
{
IntegrationHelper.testClassExistence( this, buildcraft.BuildCraftCore.class );
IntegrationHelper.testClassExistence( this, buildcraft.BuildCraftTransport.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.tools.IToolWrench.class );
}
@Override
public boolean isWrench( Item eq )
{
return eq instanceof IToolWrench;
}
@Override
public boolean canWrench( @Nonnull Item wrench, EntityPlayer wrencher, int x, int y, int z )
{
return ( (IToolWrench) wrench ).canWrench( wrencher, x, y, z );
}
@Override
public void wrenchUsed( @Nonnull Item wrench, EntityPlayer wrencher, int x, int y, int z )
{
( (IToolWrench) wrench ).wrenchUsed( wrencher, x, y, z );
}
@Override
public void init()
{
}
@Override
public void postInit()
{
this.registerPowerP2P();
}
private void registerPowerP2P()
{
final IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftCore.engineBlock, 1, 0 ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftCore.engineBlock, 1, 1 ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftCore.engineBlock, 1, 2 ), TunnelType.RF_POWER );
}
}
@@ -1,302 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.event.FMLInterModComms;
import buildcraft.api.facades.IFacadeItem;
import buildcraft.api.transport.IInjectable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.transport.ItemFacade;
import buildcraft.transport.PipeIconProvider;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.TunnelType;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IItemDefinition;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IFacadePart;
import appeng.facade.FacadePart;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IBuildCraftTransport;
import appeng.integration.modules.BCHelpers.BCPipeHandler;
/**
* @author thatsIch
* @version rv3 - 12.06.2015
* @since rv3 12.06.2015
*/
@Reflected
public class BuildCraftTransport implements IBuildCraftTransport, IIntegrationModule
{
@Reflected
public static BuildCraftTransport instance;
@Reflected
public BuildCraftTransport()
{
IntegrationHelper.testClassExistence( this, buildcraft.BuildCraftTransport.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.facades.IFacadeItem.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.transport.IInjectable.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.transport.IPipeConnection.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.transport.IPipeTile.class );
IntegrationHelper.testClassExistence( this, buildcraft.api.transport.IPipeTile.PipeType.class );
IntegrationHelper.testClassExistence( this, buildcraft.transport.ItemFacade.class );
IntegrationHelper.testClassExistence( this, buildcraft.transport.PipeIconProvider.class );
}
@Override
public boolean isFacade( ItemStack is )
{
if( is == null )
{
return false;
}
return is.getItem() instanceof IFacadeItem;
}
@Nullable
@Override
public IFacadePart createFacadePart( Block blk, int meta, @Nonnull ForgeDirection side )
{
try
{
final ItemFacade.FacadeState state = ItemFacade.FacadeState.create( blk, meta );
final ItemStack facade = ItemFacade.getFacade( state );
return new FacadePart( facade, side );
}
catch( Exception ignored )
{
}
return null;
}
@Override
public IFacadePart createFacadePart( @Nonnull ItemStack fs, @Nonnull ForgeDirection side )
{
return new FacadePart( fs, side );
}
@Nullable
@Override
public ItemStack getTextureForFacade( @Nonnull ItemStack facade )
{
final Item maybeFacadeItem = facade.getItem();
if( maybeFacadeItem instanceof IFacadeItem )
{
final IFacadeItem facadeItem = (IFacadeItem) maybeFacadeItem;
final Block[] blocks = facadeItem.getBlocksForFacade( facade );
final int[] metas = facadeItem.getMetaValuesForFacade( facade );
if( blocks.length > 0 && metas.length > 0 )
{
return new ItemStack( blocks[0], 1, metas[0] );
}
}
return null;
}
@Nullable
@Override
public IIcon getCobbleStructurePipeTexture()
{
try
{
return buildcraft.BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal() ); // Structure
}
catch( Exception ignored )
{
}
return null;
// Pipe
}
@Override
public boolean isPipe( TileEntity te, @Nonnull ForgeDirection dir )
{
if( te instanceof IPipeTile )
{
final IPipeTile pipeTile = (IPipeTile) te;
return !pipeTile.hasPipePluggable( dir.getOpposite() );
}
return false;
}
@Override
public boolean canAddItemsToPipe( TileEntity te, ItemStack is, ForgeDirection dir )
{
if( is != null && te != null && te instanceof IInjectable )
{
IInjectable pt = (IInjectable) te;
if( pt.canInjectItems( dir ) )
{
int amt = pt.injectItem( is, false, dir, null );
if( amt == is.stackSize )
{
return true;
}
}
}
return false;
}
@Override
public boolean addItemsToPipe( @Nullable TileEntity te, @Nullable ItemStack is, @Nonnull ForgeDirection dir )
{
if( is != null && te != null && te instanceof IInjectable )
{
IInjectable pt = (IInjectable) te;
if( pt.canInjectItems( dir ) )
{
int amt = pt.injectItem( is, false, dir, null );
if( amt == is.stackSize )
{
pt.injectItem( is, true, dir, null );
return true;
}
}
}
return false;
}
private void addFacade( ItemStack item )
{
if( item != null )
{
FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item );
}
}
private void registerPowerP2P()
{
final IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipePowerCobblestone ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipePowerDiamond ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipePowerGold ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipePowerQuartz ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipePowerStone ), TunnelType.RF_POWER );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipePowerWood ), TunnelType.RF_POWER );
}
private void registerItemP2P()
{
final IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsWood ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsVoid ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsSandstone ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsQuartz ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsObsidian ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsIron ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsGold ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsEmerald ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsDiamond ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsStone ), TunnelType.ITEM );
registry.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeItemsCobblestone ), TunnelType.ITEM );
}
private void registerLiquidsP2P()
{
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsCobblestone ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsEmerald ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsGold ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsIron ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsSandstone ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsStone ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsVoid ), TunnelType.FLUID );
reg.addNewAttunement( new ItemStack( buildcraft.BuildCraftTransport.pipeFluidsWood ), TunnelType.FLUID );
}
@Override
public void init() throws Throwable
{
this.initPipeConnection();
this.initFacades();
}
@Override
public void postInit()
{
this.registerPowerP2P();
this.registerItemP2P();
this.registerLiquidsP2P();
}
private void initPipeConnection()
{
final IAppEngApi api = AEApi.instance();
api.partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" );
api.registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() );
}
private void initFacades()
{
final IAppEngApi api = AEApi.instance();
final IBlocks blocks = api.definitions().blocks();
this.addFacadeStack( blocks.fluix() );
this.addFacadeStack( blocks.quartz() );
this.addFacadeStack( blocks.quartzChiseled() );
this.addFacadeStack( blocks.quartzPillar() );
for( Block skyStoneBlock : blocks.skyStone().maybeBlock().asSet() )
{
this.addFacade( new ItemStack( skyStoneBlock, 1, 0 ) );
this.addFacade( new ItemStack( skyStoneBlock, 1, 1 ) );
this.addFacade( new ItemStack( skyStoneBlock, 1, 2 ) );
this.addFacade( new ItemStack( skyStoneBlock, 1, 3 ) );
}
}
private void addFacadeStack( IItemDefinition definition )
{
for( ItemStack facadeStack : definition.maybeStack( 1 ).asSet() )
{
this.addFacade( facadeStack );
}
}
}
@@ -1,62 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import appeng.api.util.AEColor;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.ICLApi;
public class CLApi implements ICLApi, IIntegrationModule
{
@Reflected
public static CLApi instance;
@Reflected
public CLApi()
{
IntegrationHelper.testClassExistence( this, coloredlightscore.src.api.CLApi.class );
}
@Override
public void init() throws Throwable
{
}
@Override
public void postInit()
{
// :P
}
@Override
public int colorLight( AEColor color, int light )
{
int mv = color.mediumVariant;
float r = ( mv >> 16 ) & 0xff;
float g = ( mv >> 8 ) & 0xff;
float b = ( mv ) & 0xff;
return coloredlightscore.src.api.CLApi.makeRGBLightValue( r / 255.0f, g / 255.0f, b / 255.0f, light / 15.0f );
}
}
@@ -1,459 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Optional;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import cpw.mods.fml.relauncher.ReflectionHelper;
import uristqwerty.CraftGuide.CraftGuideLog;
import uristqwerty.CraftGuide.DefaultRecipeTemplate;
import uristqwerty.CraftGuide.RecipeGeneratorImplementation;
import uristqwerty.CraftGuide.api.ChanceSlot;
import uristqwerty.CraftGuide.api.CraftGuideAPIObject;
import uristqwerty.CraftGuide.api.ItemSlot;
import uristqwerty.CraftGuide.api.RecipeGenerator;
import uristqwerty.CraftGuide.api.RecipeProvider;
import uristqwerty.CraftGuide.api.RecipeTemplate;
import uristqwerty.CraftGuide.api.Slot;
import uristqwerty.CraftGuide.api.SlotType;
import uristqwerty.gui_craftguide.texture.DynamicTexture;
import uristqwerty.gui_craftguide.texture.TextureClip;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.definitions.IBlocks;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IInscriberRecipe;
import appeng.api.recipes.IIngredient;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
public final class CraftGuide extends CraftGuideAPIObject implements IIntegrationModule, RecipeProvider
{
private static final int SLOT_SIZE = 16;
private static final int TEXTURE_WIDTH = 79;
private static final int TEXTURE_HEIGHT = 58;
private static final int GRINDER_RATIO = 10000;
private static final Slot[] GRINDER_SLOTS = {
new ItemSlot( 3, 21, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 41, 21, SLOT_SIZE, SLOT_SIZE, true ).drawOwnBackground().setSlotType( SlotType.OUTPUT_SLOT ),
new ChanceSlot( 59, 12, SLOT_SIZE, SLOT_SIZE, true ).setRatio( GRINDER_RATIO ).setFormatString( " (%1$.2f%% chance)" ).drawOwnBackground().setSlotType( SlotType.OUTPUT_SLOT ),
new ChanceSlot( 59, 30, SLOT_SIZE, SLOT_SIZE, true ).setRatio( GRINDER_RATIO ).setFormatString( " (%1$.2f%% chance)" ).drawOwnBackground().setSlotType( SlotType.OUTPUT_SLOT ),
new ItemSlot( 22, 12, SLOT_SIZE, SLOT_SIZE ).setSlotType( SlotType.MACHINE_SLOT ),
new ItemSlot( 22, 30, SLOT_SIZE, SLOT_SIZE ).setSlotType( SlotType.MACHINE_SLOT )
};
private static final Slot[] INSCRIBER_SLOTS = {
new ItemSlot( 12, 21, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 21, 3, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 21, 39, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 50, 21, SLOT_SIZE, SLOT_SIZE, true ).drawOwnBackground().setSlotType( SlotType.OUTPUT_SLOT ),
new ItemSlot( 31, 21, SLOT_SIZE, SLOT_SIZE ).setSlotType( SlotType.MACHINE_SLOT )
};
private static final Slot[] SHAPELESS_CRAFTING_SLOTS = {
new ItemSlot( 3, 3, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 21, 3, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 39, 3, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 3, 21, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 21, 21, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 39, 21, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 3, 39, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 21, 39, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 39, 39, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 59, 21, SLOT_SIZE, SLOT_SIZE, true ).setSlotType( SlotType.OUTPUT_SLOT ),
};
private static final Slot[] CRAFTING_SLOTS_OWN_BG = {
new ItemSlot( 3, 3, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 21, 3, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 39, 3, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 3, 21, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 21, 21, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 39, 21, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 3, 39, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 21, 39, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 39, 39, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 59, 21, SLOT_SIZE, SLOT_SIZE, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(),
};
private static final Slot[] SMALL_CRAFTING_SLOTS_OWN_BG = {
new ItemSlot( 12, 12, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 30, 12, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 12, 30, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 30, 30, SLOT_SIZE, SLOT_SIZE ).drawOwnBackground(),
new ItemSlot( 59, 21, SLOT_SIZE, SLOT_SIZE, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(),
};
private static final Slot[] CRTAFTING_SLOTS = {
new ItemSlot( 3, 3, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 21, 3, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 39, 3, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 3, 21, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 21, 21, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 39, 21, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 3, 39, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 21, 39, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 39, 39, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 59, 21, SLOT_SIZE, SLOT_SIZE, true ).setSlotType( SlotType.OUTPUT_SLOT ),
};
private static final Slot[] SMALL_CRAFTING_SLOTS = {
new ItemSlot( 12, 12, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 30, 12, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 12, 30, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 30, 30, SLOT_SIZE, SLOT_SIZE ),
new ItemSlot( 59, 21, SLOT_SIZE, SLOT_SIZE, true ).setSlotType( SlotType.OUTPUT_SLOT ),
};
@Reflected
public static CraftGuide instance;
public CraftGuide()
{
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.CraftGuideLog.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.DefaultRecipeTemplate.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.RecipeGeneratorImplementation.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.ChanceSlot.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.CraftGuideAPIObject.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.ItemSlot.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.RecipeGenerator.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.RecipeProvider.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.RecipeTemplate.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.Slot.class );
IntegrationHelper.testClassExistence( this, uristqwerty.CraftGuide.api.SlotType.class );
IntegrationHelper.testClassExistence( this, uristqwerty.gui_craftguide.texture.DynamicTexture.class );
IntegrationHelper.testClassExistence( this, uristqwerty.gui_craftguide.texture.TextureClip.class );
}
@Override
public void init() throws Throwable
{
}
@Override
public void postInit()
{
}
@Override
public void generateRecipes( RecipeGenerator generator )
{
final RecipeTemplate craftingTemplate;
final RecipeTemplate smallTemplate;
if( uristqwerty.CraftGuide.CraftGuide.newerBackgroundStyle )
{
craftingTemplate = generator.createRecipeTemplate( CRAFTING_SLOTS_OWN_BG, null );
smallTemplate = generator.createRecipeTemplate( SMALL_CRAFTING_SLOTS_OWN_BG, null );
}
else
{
final TextureClip craftingBG = new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 1, TEXTURE_WIDTH, TEXTURE_HEIGHT );
final TextureClip craftingSelected = new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 1, TEXTURE_WIDTH, TEXTURE_HEIGHT );
craftingTemplate = new DefaultRecipeTemplate( CRTAFTING_SLOTS, RecipeGeneratorImplementation.workbench, craftingBG, craftingSelected );
final TextureClip smallBG = new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 61, TEXTURE_WIDTH, TEXTURE_HEIGHT );
final TextureClip smallSelected = new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 61, TEXTURE_WIDTH, TEXTURE_HEIGHT );
smallTemplate = new DefaultRecipeTemplate( SMALL_CRAFTING_SLOTS, RecipeGeneratorImplementation.workbench, smallBG, smallSelected );
}
final TextureClip shapelessBG = new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 1, 121, TEXTURE_WIDTH, TEXTURE_HEIGHT );
final TextureClip shapelessSelected = new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 121, TEXTURE_WIDTH, TEXTURE_HEIGHT );
final RecipeTemplate shapelessTemplate = new DefaultRecipeTemplate( SHAPELESS_CRAFTING_SLOTS, RecipeGeneratorImplementation.workbench, shapelessBG, shapelessSelected );
this.addCraftingRecipes( craftingTemplate, smallTemplate, shapelessTemplate, generator );
final IAppEngApi api = AEApi.instance();
final IBlocks aeBlocks = api.definitions().blocks();
final Optional<ItemStack> grindstone = aeBlocks.grindStone().maybeStack( 1 );
final Optional<ItemStack> inscriber = aeBlocks.inscriber().maybeStack( 1 );
if( grindstone.isPresent() )
{
this.addGrinderRecipes( api, grindstone.get(), generator );
}
if( inscriber.isPresent() )
{
this.addInscriberRecipes( api, inscriber.get(), generator );
}
}
@SuppressWarnings( "unchecked" )
private List<IRecipe> getUncheckedRecipes()
{
return (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
}
private void addCraftingRecipes( RecipeTemplate template, RecipeTemplate templateSmall, RecipeTemplate templateShapeless, RecipeGenerator generator )
{
final List<IRecipe> recipes = this.getUncheckedRecipes();
int errCount = 0;
for( IRecipe recipe : recipes )
{
try
{
final Object[] items = this.getCraftingRecipe( recipe, true );
if( items == null )
{
continue;
}
if( items.length == 5 )
{
generator.addRecipe( templateSmall, items );
}
else if( recipe instanceof ShapelessRecipe )
{
generator.addRecipe( templateShapeless, items );
}
else
{
generator.addRecipe( template, items );
}
}
catch( Exception e )
{
if( errCount >= 5 )
{
CraftGuideLog.log( "AppEng CraftGuide integration: Stack trace limit reached, further stack traces from this invocation will not be logged to the console. They will still be logged to (.minecraft)/config/CraftGuide/CraftGuide.log", true );
}
else
{
e.printStackTrace();
}
errCount++;
CraftGuideLog.log( e );
}
}
}
private void addGrinderRecipes( IAppEngApi api, ItemStack grindstone, RecipeGenerator generator )
{
final ItemStack handle = api.definitions().blocks().crankHandle().maybeStack( 1 ).orNull();
final RecipeTemplate grinderTemplate = generator.createRecipeTemplate( GRINDER_SLOTS, grindstone );
for( IGrinderEntry recipe : api.registries().grinder().getRecipes() )
{
generator.addRecipe( grinderTemplate, new Object[] {
recipe.getInput(),
recipe.getOutput(),
new Object[] {
recipe.getOptionalOutput(),
(int) ( recipe.getOptionalChance() * GRINDER_RATIO )
},
new Object[] {
recipe.getSecondOptionalOutput(),
(int) ( recipe.getOptionalChance() * GRINDER_RATIO )
},
handle,
grindstone
} );
}
}
private void addInscriberRecipes( IAppEngApi api, ItemStack inscriber, RecipeGenerator generator )
{
final RecipeTemplate inscriberTemplate = generator.createRecipeTemplate( INSCRIBER_SLOTS, inscriber );
for( IInscriberRecipe recipe : api.registries().inscriber().getRecipes() )
{
generator.addRecipe( inscriberTemplate, new Object[] {
recipe.getInputs(),
recipe.getTopOptional().orNull(),
recipe.getBottomOptional().orNull(),
recipe.getOutput(),
inscriber
} );
}
}
private Object[] getCraftingShapelessRecipe( List<?> items, ItemStack recipeOutput )
{
final Object[] output = new Object[10];
for( int i = 0; i < items.size(); i++ )
{
output[i] = items.get( i );
if( output[i] instanceof ItemStack[] )
{
output[i] = Arrays.asList( (ItemStack[]) output[i] );
}
if( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ( (IIngredient) output[i] ).getItemStackSet() );
}
catch( RegistrationError ignored )
{
}
catch( MissingIngredientError ignored )
{
}
}
}
output[9] = recipeOutput;
return output;
}
private Object[] getSmallShapedRecipe( int width, int height, Object[] items, ItemStack recipeOutput )
{
final Object[] output = new Object[5];
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
final int i = y * 2 + x;
output[i] = items[y * width + x];
if( output[i] instanceof ItemStack[] )
{
output[i] = Arrays.asList( (ItemStack[]) output[i] );
}
if( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ( (IIngredient) output[i] ).getItemStackSet() );
}
catch( RegistrationError ignored )
{
}
catch( MissingIngredientError ignored )
{
}
}
}
}
output[4] = recipeOutput;
return output;
}
private Object[] getCraftingShapedRecipe( int width, int height, Object[] items, ItemStack recipeOutput )
{
final Object[] output = new Object[10];
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
final int i = y * 3 + x;
output[i] = items[y * width + x];
if( output[i] instanceof ItemStack[] )
{
output[i] = Arrays.asList( (ItemStack[]) output[i] );
}
if( output[i] instanceof IIngredient )
{
try
{
output[i] = this.toCG( ( (IIngredient) output[i] ).getItemStackSet() );
}
catch( RegistrationError ignored )
{
}
catch( MissingIngredientError ignored )
{
}
}
}
}
output[9] = recipeOutput;
return output;
}
private Object toCG( ItemStack[] itemStackSet )
{
final List<ItemStack> list = Arrays.asList( itemStackSet );
for( int x = 0; x < list.size(); x++ )
{
list.set( x, list.get( x ).copy() );
if( list.get( x ).stackSize == 0 )
{
list.get( x ).stackSize = 1;
}
}
return list;
}
@Nullable
private Object[] getCraftingRecipe( IRecipe recipe, boolean allowSmallGrid )
{
if( recipe instanceof ShapelessRecipe )
{
final List<Object> items = ReflectionHelper.getPrivateValue( ShapelessRecipe.class, (ShapelessRecipe) recipe, "input" );
return this.getCraftingShapelessRecipe( items, recipe.getRecipeOutput() );
}
else if( recipe instanceof ShapedRecipe )
{
final int width = ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "width" );
final int height = ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "height" );
final Object[] items = ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "input" );
if( allowSmallGrid && width < 3 && height < 3 )
{
return this.getSmallShapedRecipe( width, height, items, recipe.getRecipeOutput() );
}
else
{
return this.getCraftingShapedRecipe( width, height, items, recipe.getRecipeOutput() );
}
}
return null;
}
}
@@ -1,69 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.tileentity.TileEntity;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventory;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IDSU;
import appeng.integration.modules.helpers.MFRDSUHandler;
import appeng.integration.modules.helpers.MinefactoryReloadedDeepStorageUnit;
public class DSU implements IDSU, IIntegrationModule
{
@Reflected
public static DSU instance;
@Reflected
public DSU()
{
IntegrationHelper.testClassExistence( this, powercrystals.minefactoryreloaded.api.IDeepStorageUnit.class );
}
@Override
public IMEInventory getDSU( TileEntity te )
{
return new MinefactoryReloadedDeepStorageUnit( te );
}
@Override
public boolean isDSU( TileEntity te )
{
return te instanceof IDeepStorageUnit;
}
@Override
public void init()
{
}
@Override
public void postInit()
{
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new MFRDSUHandler() );
}
}
@@ -1,221 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Event;
import codechicken.lib.vec.BlockCoord;
import codechicken.microblock.BlockMicroMaterial;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartConverter;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import appeng.api.AEApi;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.parts.IPartHost;
import appeng.core.AELog;
import appeng.fmp.CableBusPart;
import appeng.fmp.FMPEvent;
import appeng.fmp.FMPPlacementHelper;
import appeng.fmp.PartRegistry;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.IFMP;
import appeng.integration.modules.helpers.FMPPacketEvent;
import appeng.parts.CableBusContainer;
public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IFMP
{
@Reflected
public static FMP instance;
@Override
public TMultiPart createPart( String name, boolean client )
{
for( PartRegistry pr : PartRegistry.values() )
{
if( pr.getName().equals( name ) )
{
return pr.construct( 0 );
}
}
return null;
}
@Override
public TMultiPart convert( World world, BlockCoord pos )
{
Block blk = world.getBlock( pos.x, pos.y, pos.z );
int meta = world.getBlockMetadata( pos.x, pos.y, pos.z );
TMultiPart part = PartRegistry.getPartByBlock( blk, meta );
if( part instanceof CableBusPart )
{
CableBusPart cbp = (CableBusPart) part;
cbp.convertFromTile( world.getTileEntity( pos.x, pos.y, pos.z ) );
}
return part;
}
@Override
public Iterable<Block> blockTypes()
{
final IBlocks blocks = AEApi.instance().definitions().blocks();
final List<Block> blockTypes = Lists.newArrayListWithCapacity( 2 );
this.addBlockTypes( blockTypes, blocks.multiPart() );
this.addBlockTypes( blockTypes, blocks.quartzTorch() );
return blockTypes;
}
private void addBlockTypes( Collection<Block> blockTypes, IBlockDefinition definition )
{
for( Block block : definition.maybeBlock().asSet() )
{
blockTypes.add( block );
}
}
@Override
public void init() throws Throwable
{
final IBlocks blocks = AEApi.instance().definitions().blocks();
this.createAndRegister( blocks.quartz(), 0 );
this.createAndRegister( blocks.quartzPillar(), 0 );
this.createAndRegister( blocks.quartzChiseled(), 0 );
this.createAndRegister( blocks.skyStone(), 0 );
this.createAndRegister( blocks.skyStone(), 1 );
this.createAndRegister( blocks.skyStone(), 2 );
this.createAndRegister( blocks.skyStone(), 3 );
PartRegistry[] reg = PartRegistry.values();
String[] data = new String[reg.length];
for( int x = 0; x < data.length; x++ )
{
data[x] = reg[x].getName();
}
MultiPartRegistry.registerConverter( this );
MultiPartRegistry.registerParts( this, data );
MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" );
}
private void createAndRegister( IBlockDefinition definition, int i )
{
for( Block block : definition.maybeBlock().asSet() )
{
BlockMicroMaterial.createAndRegister( block, i );
}
}
@Override
public void postInit()
{
MinecraftForge.EVENT_BUS.register( new FMPEvent() );
}
@Override
public IPartHost getOrCreateHost( TileEntity tile )
{
try
{
BlockCoord loc = new BlockCoord( tile.xCoord, tile.yCoord, tile.zCoord );
TileMultipart mp = TileMultipart.getOrConvertTile( tile.getWorldObj(), loc );
if( mp != null )
{
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
while( i.hasNext() )
{
TMultiPart p = i.next();
if( p instanceof CableBusPart )
{
return (IPartHost) p;
}
}
return new FMPPlacementHelper( mp );
}
}
catch( Throwable t )
{
AELog.error( t );
}
return null;
}
@Override
public CableBusContainer getCableContainer( TileEntity te )
{
if( te instanceof TileMultipart )
{
TileMultipart mp = (TileMultipart) te;
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
while( i.hasNext() )
{
TMultiPart p = i.next();
if( p instanceof CableBusPart )
{
return ( (CableBusPart) p ).getCableBus();
}
}
}
return null;
}
@Override
public void registerPassThrough( Class<?> layerInterface )
{
try
{
MultipartGenerator.registerPassThroughInterface( layerInterface.getName() );
}
catch( Throwable t )
{
AELog.severe( "Failed to register " + layerInterface.getName() + " with FMP, some features may not work with MultiParts." );
AELog.error( t );
}
}
@Override
public Event newFMPPacketEvent( EntityPlayerMP sender )
{
return new FMPPacketEvent( sender );
}
}
@@ -1,214 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventory;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.IFZ;
import appeng.integration.modules.helpers.FactorizationBarrel;
import appeng.integration.modules.helpers.FactorizationHandler;
import appeng.util.Platform;
/**
* 100% Hacks.
*/
public class FZ implements IFZ, IIntegrationModule
{
@Reflected
public static FZ instance;
private static Class<?> day_BarrelClass;
private static Method day_getItemCount;
private static Method day_setItemCount;
private static Method day_getMaxSize;
private static Field day_item;
@Override
public ItemStack barrelGetItem( TileEntity te )
{
try
{
ItemStack i = null;
if( day_BarrelClass.isInstance( te ) )
{
i = (ItemStack) day_item.get( te );
}
if( i != null )
{
i = Platform.cloneItemStack( i );
}
return i;
}
catch( IllegalArgumentException ignored )
{
}
catch( IllegalAccessException ignored )
{
}
return null;
}
@Override
public int barrelGetMaxItemCount( TileEntity te )
{
try
{
if( day_BarrelClass.isInstance( te ) )
{
return (Integer) day_getMaxSize.invoke( te );
}
}
catch( IllegalAccessException ignored )
{
}
catch( IllegalArgumentException ignored )
{
}
catch( InvocationTargetException ignored )
{
}
return 0;
}
@Override
public int barrelGetItemCount( TileEntity te )
{
try
{
if( day_BarrelClass.isInstance( te ) )
{
return (Integer) day_getItemCount.invoke( te );
}
}
catch( IllegalAccessException ignored )
{
}
catch( IllegalArgumentException ignored )
{
}
catch( InvocationTargetException ignored )
{
}
return 0;
}
@Override
public void setItemType( TileEntity te, ItemStack input )
{
try
{
if( day_BarrelClass.isInstance( te ) )
{
day_item.set( te, input == null ? null : input.copy() );
}
}
catch( IllegalArgumentException ignored )
{
}
catch( IllegalAccessException ignored )
{
}
}
@Override
public void barrelSetCount( TileEntity te, int max )
{
try
{
if( day_BarrelClass.isInstance( te ) )
{
day_setItemCount.invoke( te, max );
}
te.markDirty();
}
catch( IllegalAccessException ignored )
{
}
catch( IllegalArgumentException ignored )
{
}
catch( InvocationTargetException ignored )
{
}
}
@Override
public IMEInventory getFactorizationBarrel( TileEntity te )
{
return new FactorizationBarrel( this, te );
}
@Override
public boolean isBarrel( TileEntity te )
{
return day_BarrelClass.isAssignableFrom( te.getClass() );
}
@Override
public void grinderRecipe( ItemStack in, ItemStack out )
{
try
{
Class<?> c = Class.forName( "factorization.oreprocessing.TileEntityGrinder" );
Method m = c.getMethod( "addRecipe", Object.class, ItemStack.class, float.class );
float amt = out.stackSize;
out.stackSize = 1;
m.invoke( c, in, out, amt );
}
catch( Throwable t )
{
// AELog.info( "" );
// throw new RuntimeException( t );
}
}
@Override
public void init() throws Throwable
{
day_BarrelClass = Class.forName( "factorization.weird.TileEntityDayBarrel" );
day_getItemCount = day_BarrelClass.getDeclaredMethod( "getItemCount" );
day_setItemCount = day_BarrelClass.getDeclaredMethod( "setItemCount", int.class );
day_getMaxSize = day_BarrelClass.getDeclaredMethod( "getMaxSize" );
day_item = day_BarrelClass.getDeclaredField( "item" );
}
@Override
public void postInit()
{
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new FactorizationHandler() );
}
}
@@ -1,110 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.recipe.RecipeInputItemStack;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.TunnelType;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IPartHelper;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IIC2;
public class IC2 implements IIC2, IIntegrationModule
{
@Reflected
public static IC2 instance;
@Reflected
public IC2()
{
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyTile.class );
IntegrationHelper.testClassExistence( this, ic2.api.recipe.RecipeInputItemStack.class );
}
@Override
public void init()
{
final IAppEngApi api = AEApi.instance();
final IPartHelper partHelper = api.partHelper();
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.IC2 ) )
{
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySink", "ic2.api.energy.tile.IEnergySink" );
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
}
}
@Override
public void postInit()
{
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
reg.addNewAttunement( this.getItem( "copperCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedCopperCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "goldCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedGoldCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "ironCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedIronCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedTinCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "glassFiberCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "tinCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "detectorCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "splitterCableItem" ), TunnelType.IC2_POWER );
// this is gone?
// AEApi.INSTANCE().registries().matterCannon().registerAmmo( getItem( "uraniumDrop" ), 238.0289 );
}
@Override
public void addToEnergyNet( TileEntity appEngTile )
{
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergyTile) appEngTile ) );
}
@Override
public void removeFromEnergyNet( TileEntity appEngTile )
{
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergyTile) appEngTile ) );
}
@Override
public ItemStack getItem( String name )
{
return ic2.api.item.IC2Items.getItem( name );
}
@Override
public void maceratorRecipe( ItemStack in, ItemStack out )
{
ic2.api.recipe.Recipes.macerator.addRecipe( new RecipeInputItemStack( in, in.stackSize ), null, out );
}
}
@@ -1,145 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import java.lang.reflect.Method;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mods.immibis.core.api.multipart.ICoverSystem;
import mods.immibis.core.api.multipart.IMultipartTile;
import appeng.api.AEApi;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartItem;
import appeng.core.AELog;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IImmibisMicroblocks;
public class ImmibisMicroblocks implements IImmibisMicroblocks, IIntegrationModule
{
@Reflected
public static ImmibisMicroblocks instance;
private boolean canConvertTiles = false;
private Class<?> MicroblockAPIUtils;
private Method mergeIntoMicroblockContainer;
@Reflected
public ImmibisMicroblocks()
{
IntegrationHelper.testClassExistence( this, mods.immibis.core.api.multipart.IMultipartTile.class );
IntegrationHelper.testClassExistence( this, mods.immibis.core.api.multipart.ICoverSystem.class );
IntegrationHelper.testClassExistence( this, mods.immibis.core.api.multipart.IPartContainer.class );
}
@Override
public void init() throws Throwable
{
try
{
this.MicroblockAPIUtils = Class.forName( "mods.immibis.microblocks.api.MicroblockAPIUtils" );
this.mergeIntoMicroblockContainer = this.MicroblockAPIUtils.getMethod( "mergeIntoMicroblockContainer", ItemStack.class, EntityPlayer.class, World.class, int.class, int.class, int.class, int.class, Block.class, int.class );
this.canConvertTiles = true;
}
catch( Throwable t )
{
AELog.error( t );
}
}
@Override
public void postInit()
{
}
@Override
public IPartHost getOrCreateHost( EntityPlayer player, int side, TileEntity te )
{
final World w = te.getWorldObj();
final int x = te.xCoord;
final int y = te.yCoord;
final int z = te.zCoord;
final boolean isPartItem = player != null && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IPartItem;
if( te instanceof IMultipartTile && this.canConvertTiles && isPartItem )
{
final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart();
final Optional<Block> maybeMultiPartBlock = multiPart.maybeBlock();
final Optional<ItemStack> maybeMultiPartStack = multiPart.maybeStack( 1 );
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent();
if( multiPartPresent )
{
final Block multiPartBlock = maybeMultiPartBlock.get();
final ItemStack multiPartStack = maybeMultiPartStack.get();
try
{
// ItemStack.class, EntityPlayer.class, World.class,
// int.class, int.class, int.class, int.class, Block.class, int.class );
this.mergeIntoMicroblockContainer.invoke( null, multiPartStack, player, w, x, y, z, side, multiPartBlock, 0 );
}
catch( Throwable e )
{
this.canConvertTiles = false;
return null;
}
}
}
final TileEntity tx = w.getTileEntity( x, y, z );
if( tx instanceof IPartHost )
{
return (IPartHost) tx;
}
return null;
}
@Override
public boolean leaveParts( TileEntity te )
{
if( te instanceof IMultipartTile )
{
ICoverSystem ci = ( (IMultipartTile) te ).getCoverSystem();
if( ci != null )
{
ci.convertToContainerBlock();
}
return true;
}
return false;
}
}
@@ -1,65 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import invtweaks.api.InvTweaksAPI;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IInvTweaks;
public class InvTweaks implements IInvTweaks, IIntegrationModule
{
@Reflected
public static InvTweaks instance;
static InvTweaksAPI api;
@Reflected
public InvTweaks()
{
IntegrationHelper.testClassExistence( this, invtweaks.api.InvTweaksAPI.class );
}
@Override
public void init()
{
api = (InvTweaksAPI) Loader.instance().getIndexedModList().get( "inventorytweaks" ).getMod();
}
@Override
public void postInit()
{
if( api == null )
{
throw new IllegalStateException( "InvTweaks API Instance Failed." );
}
}
@Override
public int compareItems( ItemStack i, ItemStack j )
{
return api.compareItems( i, j );
}
}
@@ -1,47 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
public class MFR implements IIntegrationModule
{
@Reflected
public static MFR instance;
@Reflected
public MFR()
{
IntegrationHelper.testClassExistence( this, powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection.class );
}
@Override
public void init() throws Throwable
{
}
@Override
public void postInit()
{
}
}
@@ -1,84 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.event.FMLInterModComms;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IMekanism;
public final class Mekanism implements IMekanism, IIntegrationModule
{
@Reflected
public static Mekanism instance;
@Reflected
public Mekanism()
{
IntegrationHelper.testClassExistence( this, mekanism.api.energy.IStrictEnergyAcceptor.class );
}
@Override
public void init() throws Throwable
{
}
@Override
public void postInit()
{
}
@Override
public void addCrusherRecipe( ItemStack in, ItemStack out )
{
final NBTTagCompound sendTag = this.convertToSimpleRecipe( in, out );
FMLInterModComms.sendMessage( "mekanism", "CrusherRecipe", sendTag );
}
@Override
public void addEnrichmentChamberRecipe( ItemStack in, ItemStack out )
{
final NBTTagCompound sendTag = this.convertToSimpleRecipe( in, out );
FMLInterModComms.sendMessage( "mekanism", "EnrichmentChamberRecipe", sendTag );
}
private NBTTagCompound convertToSimpleRecipe( ItemStack in, ItemStack out )
{
final NBTTagCompound sendTag = new NBTTagCompound();
final NBTTagCompound inputTagDummy = new NBTTagCompound();
final NBTTagCompound outputTagDummy = new NBTTagCompound();
final NBTTagCompound inputTag = in.writeToNBT( inputTagDummy );
final NBTTagCompound outputTag = out.writeToNBT( outputTagDummy );
sendTag.setTag( "input", inputTag );
sendTag.setTag( "output", outputTag );
return sendTag;
}
}
@@ -1,188 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerTooltipHandler;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.implementations.GuiCraftingTerm;
import appeng.client.gui.implementations.GuiPatternTerm;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.INEI;
import appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEICraftingHandler;
import appeng.integration.modules.NEIHelpers.NEIFacadeRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler;
import appeng.integration.modules.NEIHelpers.TerminalCraftingSlotFinder;
public class NEI implements INEI, IContainerTooltipHandler, IIntegrationModule
{
@Reflected
public static NEI instance;
private final Class<?> apiClass;
// recipe handler...
private Method registerRecipeHandler;
private Method registerUsageHandler;
@Reflected
public NEI() throws ClassNotFoundException
{
IntegrationHelper.testClassExistence( this, codechicken.nei.api.API.class );
IntegrationHelper.testClassExistence( this, codechicken.nei.api.IStackPositioner.class );
IntegrationHelper.testClassExistence( this, codechicken.nei.guihook.GuiContainerManager.class );
IntegrationHelper.testClassExistence( this, codechicken.nei.guihook.IContainerTooltipHandler.class );
IntegrationHelper.testClassExistence( this, codechicken.nei.recipe.ICraftingHandler.class );
IntegrationHelper.testClassExistence( this, codechicken.nei.recipe.IUsageHandler.class );
this.apiClass = Class.forName( "codechicken.nei.api.API" );
}
@Override
public void init() throws Throwable
{
this.registerRecipeHandler = this.apiClass.getDeclaredMethod( "registerRecipeHandler", codechicken.nei.recipe.ICraftingHandler.class );
this.registerUsageHandler = this.apiClass.getDeclaredMethod( "registerUsageHandler", codechicken.nei.recipe.IUsageHandler.class );
this.registerRecipeHandler( new NEIAEShapedRecipeHandler() );
this.registerRecipeHandler( new NEIAEShapelessRecipeHandler() );
this.registerRecipeHandler( new NEIInscriberRecipeHandler() );
this.registerRecipeHandler( new NEIWorldCraftingHandler() );
this.registerRecipeHandler( new NEIGrinderRecipeHandler() );
if( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) && AEConfig.instance.isFeatureEnabled( AEFeature.EnableFacadeCrafting ) )
{
this.registerRecipeHandler( new NEIFacadeRecipeHandler() );
}
// large stack tooltips
GuiContainerManager.addTooltipHandler( this );
// crafting terminal...
Method registerGuiOverlay = this.apiClass.getDeclaredMethod( "registerGuiOverlay", Class.class, String.class, IStackPositioner.class );
Class overlayHandler = Class.forName( "codechicken.nei.api.IOverlayHandler" );
Class<NEICraftingHandler> defaultHandler = NEICraftingHandler.class;
Method registrar = this.apiClass.getDeclaredMethod( "registerGuiOverlayHandler", Class.class, overlayHandler, String.class );
registerGuiOverlay.invoke( this.apiClass, GuiCraftingTerm.class, "crafting", new TerminalCraftingSlotFinder() );
registerGuiOverlay.invoke( this.apiClass, GuiPatternTerm.class, "crafting", new TerminalCraftingSlotFinder() );
Constructor defaultConstructor = defaultHandler.getConstructor( int.class, int.class );
registrar.invoke( this.apiClass, GuiCraftingTerm.class, defaultConstructor.newInstance( 6, 75 ), "crafting" );
registrar.invoke( this.apiClass, GuiPatternTerm.class, defaultConstructor.newInstance( 6, 75 ), "crafting" );
}
public void registerRecipeHandler( Object o ) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{
this.registerRecipeHandler.invoke( this.apiClass, o );
this.registerUsageHandler.invoke( this.apiClass, o );
}
@Override
public void postInit()
{
}
@Override
public void drawSlot( Slot s )
{
if( s == null )
{
return;
}
ItemStack stack = s.getStack();
if( stack == null )
{
return;
}
Minecraft mc = Minecraft.getMinecraft();
FontRenderer fontRenderer = mc.fontRenderer;
int x = s.xDisplayPosition;
int y = s.yDisplayPosition;
GuiContainerManager.drawItems.renderItemAndEffectIntoGUI( fontRenderer, mc.getTextureManager(), stack, x, y );
GuiContainerManager.drawItems.renderItemOverlayIntoGUI( fontRenderer, mc.getTextureManager(), stack, x, y, String.valueOf( stack.stackSize ) );
}
@Override
public RenderItem setItemRender( RenderItem renderItem )
{
try
{
RenderItem ri = GuiContainerManager.drawItems;
GuiContainerManager.drawItems = renderItem;
return ri;
}
catch( Throwable t )
{
throw new IllegalStateException( "Invalid version of NEI, please update", t );
}
}
@Override
public List<String> handleTooltip( GuiContainer arg0, int arg1, int arg2, List<String> current )
{
return current;
}
@Override
public List<String> handleItemDisplayName( GuiContainer arg0, ItemStack arg1, List<String> current )
{
return current;
}
@Override
public List<String> handleItemTooltip( GuiContainer guiScreen, ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip )
{
if( guiScreen instanceof AEBaseMEGui )
{
return ( (AEBaseMEGui) guiScreen ).handleItemTooltip( stack, mouseX, mouseY, currentToolTip );
}
return currentToolTip;
}
}
@@ -1,263 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.DefaultOverlayRenderer;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.IIngredient;
import appeng.core.AEConfig;
import appeng.recipes.game.ShapedRecipe;
import appeng.util.Platform;
public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
{
@Override
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting" ) );
}
@Override
public void loadCraftingRecipes( String outputId, Object... results )
{
if( ( outputId.equals( "crafting" ) ) && ( this.getClass() == NEIAEShapedRecipeHandler.class ) )
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for( IRecipe recipe : recipes )
{
if( ( recipe instanceof ShapedRecipe ) )
{
if( ( (ShapedRecipe) recipe ).isEnabled() )
{
CachedShapedRecipe cachedRecipe = new CachedShapedRecipe( (ShapedRecipe) recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
@Override
public void loadCraftingRecipes( ItemStack result )
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for( IRecipe recipe : recipes )
{
if( ( recipe instanceof ShapedRecipe ) )
{
if( ( (ShapedRecipe) recipe ).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( recipe.getRecipeOutput(), result ) )
{
CachedShapedRecipe cachedRecipe = new CachedShapedRecipe( (ShapedRecipe) recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
}
}
@Override
public void loadUsageRecipes( ItemStack ingredient )
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for( IRecipe recipe : recipes )
{
if( ( recipe instanceof ShapedRecipe ) )
{
CachedShapedRecipe cachedRecipe = new CachedShapedRecipe( (ShapedRecipe) recipe );
if( ( (ShapedRecipe) recipe ).isEnabled() && cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() ) )
{
cachedRecipe.computeVisuals();
if( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
{
cachedRecipe.setIngredientPermutation( cachedRecipe.ingredients, ingredient );
this.arecipes.add( cachedRecipe );
}
}
}
}
}
@Override
public String getGuiTexture()
{
return "textures/gui/container/crafting_table.png";
}
@Override
public String getOverlayIdentifier()
{
return "crafting";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiCrafting.class;
}
@Override
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return ( super.hasOverlay( gui, container, recipe ) ) || ( ( this.isRecipe2x2( recipe ) ) && ( RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ) ) );
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if( renderer != null )
{
return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if( positioner == null )
{
return null;
}
return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner );
}
@Override
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if( handler != null )
{
return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
private boolean isRecipe2x2( final int recipe )
{
for( PositionedStack stack : this.getIngredientStacks( recipe ) )
{
if( ( stack.relx > 43 ) || ( stack.rely > 24 ) )
{
return false;
}
}
return true;
}
@Override
public String getRecipeName()
{
return NEIClientUtils.translate( "recipe.shaped" );
}
private class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
{
private final List<PositionedStack> ingredients;
private final PositionedStack result;
public CachedShapedRecipe( ShapedRecipe recipe )
{
this.result = new PositionedStack( recipe.getRecipeOutput(), 119, 24 );
this.ingredients = new ArrayList<PositionedStack>();
this.setIngredients( recipe.getWidth(), recipe.getHeight(), recipe.getIngredients() );
}
private void setIngredients( final int width, final int height, final Object[] items )
{
boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
for( int x = 0; x < width; x++ )
{
for( int y = 0; y < height; y++ )
{
if( items[( y * width + x )] != null )
{
IIngredient ing = (IIngredient) items[( y * width + x )];
try
{
ItemStack[] is = ing.getItemStackSet();
PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPreferred( is ) : is, 25 + x * 18, 6 + y * 18, false );
stack.setMaxSize( 1 );
this.ingredients.add( stack );
}
catch( RegistrationError ignored )
{
}
catch( MissingIngredientError ignored )
{
}
}
}
}
}
@Override
public PositionedStack getResult()
{
return this.result;
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIAEShapedRecipeHandler.this.cycleticks / 20, this.ingredients );
}
private void computeVisuals()
{
for( PositionedStack p : this.ingredients )
{
p.generatePermutations();
}
this.result.generatePermutations();
}
}
}
@@ -1,272 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.DefaultOverlayRenderer;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.IIngredient;
import appeng.core.AEConfig;
import appeng.recipes.game.ShapelessRecipe;
import appeng.util.Platform;
public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
{
@Override
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting" ) );
}
@Override
public void loadCraftingRecipes( String outputId, Object... results )
{
if( ( outputId.equals( "crafting" ) ) && ( this.getClass() == NEIAEShapelessRecipeHandler.class ) )
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for( IRecipe recipe : recipes )
{
if( ( recipe instanceof ShapelessRecipe ) )
{
if( ( (ShapelessRecipe) recipe ).isEnabled() )
{
CachedShapelessRecipe cachedRecipe = new CachedShapelessRecipe( (ShapelessRecipe) recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
@Override
public void loadCraftingRecipes( ItemStack result )
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for( IRecipe recipe : recipes )
{
if( ( recipe instanceof ShapelessRecipe ) )
{
if( ( (ShapelessRecipe) recipe ).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( recipe.getRecipeOutput(), result ) )
{
CachedShapelessRecipe cachedRecipe = new CachedShapelessRecipe( (ShapelessRecipe) recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
}
}
@Override
public void loadUsageRecipes( ItemStack ingredient )
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for( IRecipe recipe : recipes )
{
if( ( recipe instanceof ShapelessRecipe ) )
{
CachedShapelessRecipe cachedRecipe = new CachedShapelessRecipe( (ShapelessRecipe) recipe );
if( ( (ShapelessRecipe) recipe ).isEnabled() && cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() ) )
{
cachedRecipe.computeVisuals();
if( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
{
cachedRecipe.setIngredientPermutation( cachedRecipe.ingredients, ingredient );
this.arecipes.add( cachedRecipe );
}
}
}
}
}
@Override
public String getGuiTexture()
{
return "textures/gui/container/crafting_table.png";
}
@Override
public String getOverlayIdentifier()
{
return "crafting";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiCrafting.class;
}
@Override
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return ( super.hasOverlay( gui, container, recipe ) ) || ( ( this.isRecipe2x2( recipe ) ) && ( RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ) ) );
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if( renderer != null )
{
return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if( positioner == null )
{
return null;
}
return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner );
}
@Override
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if( handler != null )
{
return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
<<<<<<< HEAD
public boolean isRecipe2x2( int recipe )
=======
private boolean isRecipe2x2( final int recipe )
>>>>>>> 500fc47... Reduces visibility of internal fields/methods
{
for( PositionedStack stack : this.getIngredientStacks( recipe ) )
{
if( ( stack.relx > 43 ) || ( stack.rely > 24 ) )
{
return false;
}
}
return true;
}
@Override
public String getRecipeName()
{
return NEIClientUtils.translate( "recipe.shapeless" );
}
private class CachedShapelessRecipe extends TemplateRecipeHandler.CachedRecipe
{
private final List<PositionedStack> ingredients;
private final PositionedStack result;
public CachedShapelessRecipe( ShapelessRecipe recipe )
{
this.result = new PositionedStack( recipe.getRecipeOutput(), 119, 24 );
this.ingredients = new ArrayList<PositionedStack>();
this.setIngredients( recipe.getInput().toArray() );
}
@Override
public PositionedStack getResult()
{
return this.result;
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIAEShapelessRecipeHandler.this.cycleticks / 20, this.ingredients );
}
<<<<<<< HEAD
public void setIngredients( Object[] items )
=======
private void setIngredients( final Object[] items )
>>>>>>> 500fc47... Reduces visibility of internal fields/methods
{
boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
for( int x = 0; x < 3; x++ )
{
for( int y = 0; y < 3; y++ )
{
if( items.length > ( y * 3 + x ) )
{
IIngredient ing = (IIngredient) items[( y * 3 + x )];
try
{
ItemStack[] is = ing.getItemStackSet();
PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPreferred( is ) : ing.getItemStackSet(), 25 + x * 18, 6 + y * 18, false );
stack.setMaxSize( 1 );
this.ingredients.add( stack );
}
catch( RegistrationError ignored )
{
}
catch( MissingIngredientError ignored )
{
}
}
}
}
}
private void computeVisuals()
{
for( PositionedStack p : this.ingredients )
{
p.generatePermutations();
}
this.result.generatePermutations();
}
}
}
@@ -1,131 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.recipe.IRecipeHandler;
import appeng.client.gui.implementations.GuiCraftingTerm;
import appeng.client.gui.implementations.GuiPatternTerm;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIRecipe;
import appeng.util.Platform;
public class NEICraftingHandler implements IOverlayHandler
{
private final int offsetX;
private final int offsetY;
public NEICraftingHandler( final int x, final int y )
{
}
@Override
public void overlayRecipe( GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift )
{
try
{
List ingredients = recipe.getIngredientStacks( recipeIndex );
this.overlayRecipe( gui, ingredients, shift );
}
catch( Exception ignored )
{
}
catch( Error ignored )
{
}
}
private void overlayRecipe( GuiContainer gui, List<PositionedStack> ingredients, boolean shift )
{
try
{
NBTTagCompound recipe = new NBTTagCompound();
if( gui instanceof GuiCraftingTerm || gui instanceof GuiPatternTerm )
{
for( PositionedStack positionedStack : ingredients )
{
int col = ( positionedStack.relx - 25 ) / 18;
int row = ( positionedStack.rely - 6 ) / 18;
if( positionedStack.items != null && positionedStack.items.length > 0 )
{
for( Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots )
{
if( slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix )
{
if( slot.getSlotIndex() == col + row * 3 )
{
NBTTagList tags = new NBTTagList();
List<ItemStack> list = new LinkedList<ItemStack>();
// prefer pure crystals.
for( int x = 0; x < positionedStack.items.length; x++ )
{
if( Platform.isRecipePrioritized( positionedStack.items[x] ) )
{
list.add( 0, positionedStack.items[x] );
}
else
{
list.add( positionedStack.items[x] );
}
}
for( ItemStack is : list )
{
NBTTagCompound tag = new NBTTagCompound();
is.writeToNBT( tag );
tags.appendTag( tag );
}
recipe.setTag( "#" + slot.getSlotIndex(), tags );
break;
}
}
}
}
}
NetworkHandler.instance.sendToServer( new PacketNEIRecipe( recipe ) );
}
}
catch( Exception ignored )
{
}
catch( Error ignored )
{
}
}
}
@@ -1,249 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.DefaultOverlayRenderer;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.core.localization.GuiText;
import appeng.facade.IFacadeItem;
import appeng.items.parts.ItemFacade;
public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
{
private final ItemFacade facade;
private final IItemDefinition anchorDefinition;
public NEIFacadeRecipeHandler()
{
final IDefinitions definitions = AEApi.instance().definitions();
this.facade = (ItemFacade) definitions.items().facade().maybeItem().get();
this.anchorDefinition = definitions.parts().cableAnchor();
}
@Override
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting" ) );
}
@Override
public void loadCraftingRecipes( String outputId, Object... results )
{
if( ( outputId.equals( "crafting" ) ) && ( this.getClass() == NEIFacadeRecipeHandler.class ) )
{
final List<ItemStack> facades = this.facade.getFacades();
for( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() )
{
for( ItemStack is : facades )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, is );
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
@Override
public void loadCraftingRecipes( ItemStack result )
{
if( result.getItem() == this.facade )
{
for( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, result );
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
@Override
public void loadUsageRecipes( ItemStack ingredient )
{
List<ItemStack> facades = this.facade.getFacades();
for( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() )
{
for( ItemStack is : facades )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, is );
if( recipe.contains( recipe.ingredients, ingredient.getItem() ) )
{
recipe.computeVisuals();
if( recipe.contains( recipe.ingredients, ingredient ) )
{
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
this.arecipes.add( recipe );
}
}
}
}
}
@Override
public String getGuiTexture()
{
return "textures/gui/container/crafting_table.png";
}
@Override
public String getOverlayIdentifier()
{
return "crafting";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiCrafting.class;
}
@Override
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return ( super.hasOverlay( gui, container, recipe ) ) || ( ( this.isRecipe2x2( recipe ) ) && ( RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ) ) );
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if( renderer != null )
{
return renderer;
}
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
if( positioner == null )
{
return null;
}
return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner );
}
@Override
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if( handler != null )
{
return handler;
}
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
private boolean isRecipe2x2( final int recipe )
{
for( PositionedStack stack : this.getIngredientStacks( recipe ) )
{
if( ( stack.relx > 43 ) || ( stack.rely > 24 ) )
{
return false;
}
}
return true;
}
@Override
public String getRecipeName()
{
return GuiText.FacadeCrafting.getLocal();
}
private final class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
{
public final List<PositionedStack> ingredients;
public final PositionedStack result;
public CachedShapedRecipe( IFacadeItem facade, ItemStack anchor, ItemStack output )
{
output.stackSize = 4;
this.result = new PositionedStack( output, 119, 24 );
this.ingredients = new ArrayList<PositionedStack>();
ItemStack in = facade.getTextureItem( output );
this.setIngredients( 3, 3, new Object[] { null, anchor, null, anchor, in, anchor, null, anchor, null } );
}
public void setIngredients( int width, int height, Object[] items )
{
for( int x = 0; x < width; x++ )
{
for( int y = 0; y < height; y++ )
{
if( items[( y * width + x )] != null )
{
ItemStack is = (ItemStack) items[( y * width + x )];
PositionedStack stack = new PositionedStack( is, 25 + x * 18, 6 + y * 18, false );
stack.setMaxSize( 1 );
this.ingredients.add( stack );
}
}
}
}
@Override
public PositionedStack getResult()
{
return this.result;
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIFacadeRecipeHandler.this.cycleticks / 20, this.ingredients );
}
public void computeVisuals()
{
for( PositionedStack p : this.ingredients )
{
p.generatePermutations();
}
this.result.generatePermutations();
}
}
}
@@ -1,243 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.recipe.TemplateRecipeHandler;
import appeng.api.AEApi;
import appeng.api.features.IGrinderEntry;
import appeng.client.gui.implementations.GuiGrinder;
import appeng.core.localization.GuiText;
public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
{
@Override
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "grindstone" ) );
}
@Override
public void loadCraftingRecipes( String outputId, Object... results )
{
if( ( outputId.equals( "grindstone" ) ) && ( this.getClass() == NEIGrinderRecipeHandler.class ) )
{
for( IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes() )
{
CachedGrindStoneRecipe cachedRecipe = new CachedGrindStoneRecipe( recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
@Override
public void loadCraftingRecipes( ItemStack result )
{
for( IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes() )
{
if( NEIServerUtils.areStacksSameTypeCrafting( recipe.getOutput(), result ) )
{
CachedGrindStoneRecipe cachedRecipe = new CachedGrindStoneRecipe( recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
}
@Override
public void loadUsageRecipes( ItemStack ingredient )
{
for( IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes() )
{
CachedGrindStoneRecipe cachedRecipe = new CachedGrindStoneRecipe( recipe );
if( ( cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() ) ) )
{
cachedRecipe.computeVisuals();
if( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
{
cachedRecipe.setIngredientPermutation( cachedRecipe.ingredients, ingredient );
this.arecipes.add( cachedRecipe );
}
}
}
}
@Override
public String getGuiTexture()
{
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/guis/grinder.png" );
return loc.toString();
}
@Override
public String getOverlayIdentifier()
{
return "grindstone";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiGrinder.class;
}
@Override
public void drawBackground( int recipe )
{
GL11.glColor4f( 1, 1, 1, 1 );
GuiDraw.changeTexture( this.getGuiTexture() );
GuiDraw.drawTexturedModalRect( 40, 10, 75, 16 + 10, 90, 66 );
}
@Override
public void drawForeground( int recipe )
{
super.drawForeground( recipe );
if( this.arecipes.size() > recipe )
{
CachedRecipe cr = this.arecipes.get( recipe );
if( cr instanceof CachedGrindStoneRecipe )
{
CachedGrindStoneRecipe cachedRecipe = (CachedGrindStoneRecipe) cr;
if( cachedRecipe.hasOptional )
{
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
int width = fr.getStringWidth( cachedRecipe.displayChance );
fr.drawString( cachedRecipe.displayChance, ( 168 - width ) / 2, 5, 0 );
}
else
{
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
int width = fr.getStringWidth( GuiText.NoSecondOutput.getLocal() );
fr.drawString( GuiText.NoSecondOutput.getLocal(), ( 168 - width ) / 2, 5, 0 );
}
}
}
}
@Override
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return false;
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
return null;
}
@Override
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
return null;
}
@Override
public String getRecipeName()
{
return GuiText.GrindStone.getLocal();
}
private class CachedGrindStoneRecipe extends TemplateRecipeHandler.CachedRecipe
{
private final List<PositionedStack> ingredients;
private final PositionedStack result;
private String displayChance;
private boolean hasOptional = false;
public CachedGrindStoneRecipe( IGrinderEntry recipe )
{
this.result = new PositionedStack( recipe.getOutput(), -30 + 107, 47 );
this.ingredients = new ArrayList<PositionedStack>();
final ItemStack optionalOutput = recipe.getOptionalOutput();
final int optionalChancePercent = (int) ( recipe.getOptionalChance() * 100 );
if( optionalOutput != null )
{
this.hasOptional = true;
this.displayChance = String.format( GuiText.OfSecondOutput.getLocal(), optionalChancePercent );
this.ingredients.add( new PositionedStack( optionalOutput, -30 + 107 + 18, 47 ) );
}
final ItemStack secondOptionalOutput = recipe.getSecondOptionalOutput();
final int secondOptionalChancePercent = (int) ( recipe.getSecondOptionalChance() * 100 );
if( secondOptionalOutput != null )
{
this.hasOptional = true;
this.displayChance = String.format( GuiText.MultipleOutputs.getLocal(), optionalChancePercent, secondOptionalChancePercent );
this.ingredients.add( new PositionedStack( secondOptionalOutput, -30 + 107 + 18 + 18, 47 ) );
}
if( recipe.getInput() != null )
{
this.ingredients.add( new PositionedStack( recipe.getInput(), 45, 24 ) );
}
}
@Override
public PositionedStack getResult()
{
return this.result;
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIGrinderRecipeHandler.this.cycleticks / 20, this.ingredients );
}
private void computeVisuals()
{
for( PositionedStack p : this.ingredients )
{
p.generatePermutations();
}
this.result.generatePermutations();
}
}
}
@@ -1,208 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.recipe.TemplateRecipeHandler;
import appeng.api.AEApi;
import appeng.api.features.IInscriberRecipe;
import appeng.client.gui.implementations.GuiInscriber;
import appeng.core.localization.GuiText;
/**
* @author AlgorithmX2
* @author thatsIch
* @version rv2
* @since rv0
*/
public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
{
@Override
public void loadTransferRects()
{
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "inscriber" ) );
}
@Override
public void loadCraftingRecipes( String outputId, Object... results )
{
if( ( outputId.equals( "inscriber" ) ) && ( this.getClass() == NEIInscriberRecipeHandler.class ) )
{
for( IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
CachedInscriberRecipe cachedRecipe = new CachedInscriberRecipe( recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
else
{
super.loadCraftingRecipes( outputId, results );
}
}
@Override
public void loadCraftingRecipes( ItemStack result )
{
for( IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
if( NEIServerUtils.areStacksSameTypeCrafting( recipe.getOutput(), result ) )
{
CachedInscriberRecipe cachedRecipe = new CachedInscriberRecipe( recipe );
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
}
@Override
public void loadUsageRecipes( ItemStack ingredient )
{
for( IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
CachedInscriberRecipe cachedRecipe = new CachedInscriberRecipe( recipe );
if( ( cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() ) ) )
{
cachedRecipe.computeVisuals();
if( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
{
cachedRecipe.setIngredientPermutation( cachedRecipe.ingredients, ingredient );
this.arecipes.add( cachedRecipe );
}
}
}
}
@Override
public String getGuiTexture()
{
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/guis/inscriber.png" );
return loc.toString();
}
@Override
public String getOverlayIdentifier()
{
return "inscriber";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiInscriber.class;
}
@Override
public void drawBackground( int recipe )
{
GL11.glColor4f( 1, 1, 1, 1 );
GuiDraw.changeTexture( this.getGuiTexture() );
GuiDraw.drawTexturedModalRect( 0, 0, 5, 11, 166, 75 );
}
@Override
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return false;
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
return null;
}
@Override
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
return null;
}
@Override
public String getRecipeName()
{
return GuiText.Inscriber.getLocal();
}
private class CachedInscriberRecipe extends TemplateRecipeHandler.CachedRecipe
{
private final List<PositionedStack> ingredients;
private final PositionedStack result;
public CachedInscriberRecipe( IInscriberRecipe recipe )
{
this.result = new PositionedStack( recipe.getOutput(), 108, 29 );
this.ingredients = new ArrayList<PositionedStack>();
for( ItemStack top : recipe.getTopOptional().asSet() )
{
this.ingredients.add( new PositionedStack( top, 40, 5 ) );
}
this.ingredients.add( new PositionedStack( recipe.getInputs(), 40 + 18, 28 ) );
for( ItemStack bot : recipe.getBottomOptional().asSet() )
{
this.ingredients.add( new PositionedStack( bot, 40, 51 ) );
}
}
@Override
public PositionedStack getResult()
{
return this.result;
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIInscriberRecipeHandler.this.cycleticks / 20, this.ingredients );
}
private void computeVisuals()
{
for( PositionedStack p : this.ingredients )
{
p.generatePermutations();
}
this.result.generatePermutations();
}
}
}
@@ -1,254 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.ICraftingHandler;
import codechicken.nei.recipe.IUsageHandler;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IMaterials;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler
{
private final Map<IItemDefinition, String> details = new HashMap<IItemDefinition, String>();
private final List<IItemDefinition> offsets = new LinkedList<IItemDefinition>();
private final List<PositionedStack> outputs = new LinkedList<PositionedStack>();
private ItemStack target;
@Override
public String getRecipeName()
{
return GuiText.InWorldCrafting.getLocal();
}
@Override
public int numRecipes()
{
return this.offsets.size();
}
@Override
public void drawBackground( int recipe )
{
GL11.glColor4f( 1, 1, 1, 1 );// nothing.
}
@Override
public void drawForeground( int recipe )
{
if( this.outputs.size() > recipe )
{
// PositionedStack cr = this.outputs.get( recipe );
String details = this.details.get( this.offsets.get( recipe ) );
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
fr.drawSplitString( details, 10, 25, 150, 0 );
}
}
@Override
public List<PositionedStack> getIngredientStacks( int recipeIndex )
{
return new ArrayList<PositionedStack>();
}
@Override
public List<PositionedStack> getOtherStacks( int recipeIndex )
{
return new ArrayList<PositionedStack>();
}
@Override
public PositionedStack getResultStack( int recipe )
{
return this.outputs.get( recipe );
}
@Override
public void onUpdate()
{
}
@Override
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return false;
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
return null;
}
@Override
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
return null;
}
@Override
public int recipiesPerPage()
{
return 1;
}
@Override
public List<String> handleTooltip( GuiRecipe gui, List<String> currentToolTip, int recipe )
{
return currentToolTip;
}
@Override
public List<String> handleItemTooltip( GuiRecipe gui, ItemStack stack, List<String> currentToolTip, int recipe )
{
return currentToolTip;
}
@Override
public boolean keyTyped( GuiRecipe gui, char keyChar, int keyCode, int recipe )
{
return false;
}
@Override
public boolean mouseClicked( GuiRecipe gui, int button, int recipe )
{
return false;
}
@Override
public IUsageHandler getUsageHandler( String inputId, Object... ingredients )
{
return this;
}
@Override
public ICraftingHandler getRecipeHandler( String outputId, Object... results )
{
NEIWorldCraftingHandler g = this.newInstance();
if( results.length > 0 && results[0] instanceof ItemStack )
{
g.target = (ItemStack) results[0];
g.addRecipes();
return g;
}
return this;
}
private NEIWorldCraftingHandler newInstance()
{
try
{
return this.getClass().newInstance();
}
catch( InstantiationException e )
{
throw new IllegalStateException( e );
}
catch( IllegalAccessException e )
{
throw new IllegalStateException( e );
}
}
private void addRecipes()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IMaterials materials = definitions.materials();
final String message;
if( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) )
{
message = GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal();
}
else
{
message = GuiText.ChargedQuartzFind.getLocal();
}
this.addRecipe( materials.certusQuartzCrystalCharged(), message );
if( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
{
this.addRecipe( materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
}
if( AEConfig.instance.isFeatureEnabled( AEFeature.InWorldFluix ) )
{
this.addRecipe( materials.fluixCrystal(), GuiText.inWorldFluix.getLocal() );
}
if( AEConfig.instance.isFeatureEnabled( AEFeature.InWorldSingularity ) )
{
this.addRecipe( materials.qESingularity(), GuiText.inWorldSingularity.getLocal() );
}
if( AEConfig.instance.isFeatureEnabled( AEFeature.InWorldPurification ) )
{
this.addRecipe( materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getLocal() );
this.addRecipe( materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getLocal() );
this.addRecipe( materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getLocal() );
}
}
private void addRecipe( IItemDefinition def, String msg )
{
for( ItemStack definitionStack : def.maybeStack( 1 ).asSet() )
{
if( NEIServerUtils.areStacksSameTypeCrafting( definitionStack, this.target ) )
{
this.offsets.add( def );
this.outputs.add( new PositionedStack( definitionStack, 75, 4 ) );
this.details.put( def, msg );
}
}
}
}
@@ -1,46 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.NEIHelpers;
import java.util.ArrayList;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IStackPositioner;
import appeng.client.gui.implementations.GuiMEMonitorable;
public class TerminalCraftingSlotFinder implements IStackPositioner
{
@Override
public ArrayList<PositionedStack> positionStacks( ArrayList<PositionedStack> a )
{
for( PositionedStack ps : a )
{
if( ps != null )
{
ps.relx += GuiMEMonitorable.craftingGridOffsetX;
ps.rely += GuiMEMonitorable.craftingGridOffsetY;
}
}
return a;
}
}
@@ -1,77 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import li.cil.oc.api.Items;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.TunnelType;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IPartHelper;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
public class OpenComputers implements IIntegrationModule
{
@Reflected
public static OpenComputers instance;
@Reflected
public OpenComputers()
{
IntegrationHelper.testClassExistence( this, li.cil.oc.api.Items.class );
IntegrationHelper.testClassExistence( this, li.cil.oc.api.Network.class );
IntegrationHelper.testClassExistence( this, li.cil.oc.api.network.Environment.class );
IntegrationHelper.testClassExistence( this, li.cil.oc.api.network.SidedEnvironment.class );
IntegrationHelper.testClassExistence( this, li.cil.oc.api.network.Node.class );
IntegrationHelper.testClassExistence( this, li.cil.oc.api.network.Message.class );
}
@Override
public void init()
{
final IAppEngApi api = AEApi.instance();
final IPartHelper partHelper = api.partHelper();
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.OpenComputers ) )
{
partHelper.registerNewLayer( "appeng.parts.layers.LayerSidedEnvironment", "li.cil.oc.api.network.SidedEnvironment" );
}
}
@Override
public void postInit()
{
final IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
registry.addNewAttunement( Items.get( "cable" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "adapter" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "switch" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "accessPoint" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "lanCard" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "linkedCard" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "wlanCard" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
registry.addNewAttunement( Items.get( "analyzer" ).createItemStack( 1 ), TunnelType.COMPUTER_MESSAGE );
}
}
@@ -1,85 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.GameRegistry;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.TunnelType;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IPartHelper;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
public class PneumaticCraft implements IIntegrationModule
{
@Reflected
public static PneumaticCraft instance;
private static final String PNEUMATIC_CRAFT_MOD_ID = "PneumaticCraft";
@Reflected
public PneumaticCraft()
{
IntegrationHelper.testClassExistence( this, pneumaticCraft.api.block.BlockSupplier.class );
IntegrationHelper.testClassExistence( this, pneumaticCraft.api.tileentity.ISidedPneumaticMachine.class );
IntegrationHelper.testClassExistence( this, pneumaticCraft.api.tileentity.AirHandlerSupplier.class );
IntegrationHelper.testClassExistence( this, pneumaticCraft.api.tileentity.IAirHandler.class );
}
@Override
public void init()
{
final IAppEngApi api = AEApi.instance();
final IPartHelper partHelper = api.partHelper();
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.PneumaticCraft ) )
{
partHelper.registerNewLayer( appeng.parts.layers.LayerPressure.class.getName(), pneumaticCraft.api.tileentity.ISidedPneumaticMachine.class.getName() );
}
}
@Override
public void postInit()
{
this.registerPressureAttunement( "pressureTube" );
this.registerPressureAttunement( "advancedPressureTube" );
}
private void registerPressureAttunement( String itemID )
{
final IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
final ItemStack modItem = GameRegistry.findItemStack( PNEUMATIC_CRAFT_MOD_ID, itemID, 1 );
if( modItem != null )
{
modItem.setItemDamage( OreDictionary.WILDCARD_VALUE );
registry.addNewAttunement( modItem, TunnelType.PRESSURE );
}
}
}
@@ -1,61 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.item.ItemStack;
import mods.railcraft.api.crafting.IRockCrusherRecipe;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IRC;
public class RC implements IRC, IIntegrationModule
{
@Reflected
public static RC instance;
@Reflected
public RC()
{
IntegrationHelper.testClassExistence( this, mods.railcraft.api.crafting.RailcraftCraftingManager.class );
IntegrationHelper.testClassExistence( this, mods.railcraft.api.crafting.IRockCrusherRecipe.class );
}
@Override
public void rockCrusher( ItemStack input, ItemStack output )
{
IRockCrusherRecipe re = RailcraftCraftingManager.rockCrusher.createNewRecipe( input, true, true );
re.addOutput( output, 1.0f );
}
@Override
public void init()
{
}
@Override
public void postInit()
{
}
}
@@ -1,96 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.TunnelType;
import appeng.api.parts.IPartHelper;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
public final class RF implements IIntegrationModule
{
@Reflected
public static RF instance;
@Reflected
public RF()
{
IntegrationHelper.testClassExistence( this, cofh.api.energy.IEnergyReceiver.class );
IntegrationHelper.testClassExistence( this, cofh.api.energy.IEnergyProvider.class );
IntegrationHelper.testClassExistence( this, cofh.api.energy.IEnergyHandler.class );
IntegrationHelper.testClassExistence( this, cofh.api.energy.IEnergyConnection.class );
}
@Override
public void init()
{
final IAppEngApi api = AEApi.instance();
final IPartHelper partHelper = api.partHelper();
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.RF ) )
{
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyReceiver" );
}
}
@Override
public void postInit()
{
this.registerRFAttunement( "ExtraUtilities", "extractor_base", 12 );
this.registerRFAttunement( "ExtraUtilities", "pipes", 11 );
this.registerRFAttunement( "ExtraUtilities", "pipes", 14 );
this.registerRFAttunement( "ExtraUtilities", "generator", OreDictionary.WILDCARD_VALUE );
this.registerRFAttunement( "ThermalExpansion", "Cell", OreDictionary.WILDCARD_VALUE );
this.registerRFAttunement( "ThermalExpansion", "Dynamo", OreDictionary.WILDCARD_VALUE );
// Fluxduct
this.registerRFAttunement( "ThermalDynamics", "ThermalDynamics_0", 0 );
this.registerRFAttunement( "EnderIO", "itemPowerConduit", OreDictionary.WILDCARD_VALUE );
this.registerRFAttunement( "EnderIO", "blockCapacitorBank", 0 );
this.registerRFAttunement( "EnderIO", "blockPowerMonitor", 0 );
}
private void registerRFAttunement( String mod, String name, int dmg )
{
assert mod != null;
assert !mod.isEmpty();
assert name != null;
assert !name.isEmpty();
assert dmg >= 0;
final ItemStack modItem = GameRegistry.findItemStack( mod, name, 1 );
if( modItem != null )
{
modItem.setItemDamage( dmg );
AEApi.instance().registries().p2pTunnel().addNewAttunement( modItem, TunnelType.RF_POWER );
}
}
}
@@ -1,47 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
public class RFItem implements IIntegrationModule
{
@Reflected
public static RFItem instance;
@Reflected
public RFItem()
{
IntegrationHelper.testClassExistence( this, cofh.api.energy.IEnergyContainerItem.class );
}
@Override
public void init()
{
}
@Override
public void postInit()
{
}
}
@@ -1,48 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
public class RotaryCraft implements IIntegrationModule
{
@Reflected
public static RotaryCraft instance;
@Reflected
public RotaryCraft()
{
IntegrationHelper.testClassExistence( this, Reika.RotaryCraft.API.Power.AdvancedShaftPowerReceiver.class );
IntegrationHelper.testClassExistence( this, Reika.RotaryCraft.API.Interfaces.Transducerable.class );
}
@Override
public void init() throws Throwable
{
}
@Override
public void postInit()
{
}
}
@@ -1,73 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.modules.waila.PartWailaDataProvider;
import appeng.integration.modules.waila.TileWailaDataProvider;
import appeng.tile.AEBaseTile;
public class Waila implements IIntegrationModule
{
@Reflected
public static Waila instance;
@Reflected
public Waila()
{
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaDataProvider.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaRegistrar.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaConfigHandler.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaDataAccessor.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.ITaggedList.class );
}
public static void register( IWailaRegistrar registrar )
{
final IWailaDataProvider partHost = new PartWailaDataProvider();
registrar.registerStackProvider( partHost, AEBaseTile.class );
registrar.registerBodyProvider( partHost, AEBaseTile.class );
registrar.registerNBTProvider( partHost, AEBaseTile.class );
final IWailaDataProvider tile = new TileWailaDataProvider();
registrar.registerBodyProvider( tile, AEBaseTile.class );
registrar.registerNBTProvider( tile, AEBaseTile.class );
}
@Override
public void init() throws Throwable
{
FMLInterModComms.sendMessage( "Waila", "register", this.getClass().getName() + ".register" );
}
@Override
public void postInit()
{
}
}
@@ -1,92 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.item.ItemStack;
<<<<<<< HEAD
=======
>>>>>>> 500fc47... Reduces visibility of internal fields/methods
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.ForgeDirection;
import appeng.util.item.AEItemStack;
public class BSCrate implements IMEInventory<IAEItemStack>
{
private final ICrateStorage crateStorage;
public BSCrate( final Object object )
{
this.crateStorage = (ICrateStorage) object;
}
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( mode == Actionable.SIMULATE )
{
return null;
}
ItemStack failed = this.crateStorage.insertItems( input.getItemStack() );
if( failed == null )
{
return null;
}
input.setStackSize( failed.stackSize );
return input;
}
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if( mode == Actionable.SIMULATE )
{
int howMany = this.crateStorage.getItemCount( request.getItemStack() );
return howMany > request.getStackSize() ? request : request.copy().setStackSize( howMany );
}
ItemStack obtained = this.crateStorage.extractItems( request.getItemStack(), (int) request.getStackSize() );
return AEItemStack.create( obtained );
}
@Override
public IItemList getAvailableItems( IItemList out )
{
for( ItemStack is : this.crateStorage.getContents() )
{
out.add( AEItemStack.create( is ) );
}
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
}
@@ -1,49 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.tileentity.TileEntity;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.util.ForgeDirection;
public class BSCrateHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc )
{
return channel == StorageChannel.ITEMS && te instanceof ICrateStorage;
}
@Override
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src )
{
if( channel == StorageChannel.ITEMS )
{
return new BSCrate( te );
}
return null;
}
}
@@ -1,217 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import java.util.Iterator;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.item.ItemStack;
<<<<<<< HEAD
=======
>>>>>>> 500fc47... Reduces visibility of internal fields/methods
import appeng.api.config.FuzzyMode;
import appeng.api.util.ForgeDirection;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
import appeng.util.iterators.StackToSlotIterator;
public class BSCrateStorageAdaptor extends InventoryAdaptor
{
private final ICrateStorage cs;
public BSCrateStorageAdaptor( final Object te )
{
this.cs = (ICrateStorage) te;
}
@Override
public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack target = null;
for( ItemStack is : this.cs.getContents() )
{
if( is != null )
{
if( is.stackSize > 0 && ( filter == null || Platform.isSameItem( filter, is ) ) )
{
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
}
}
}
}
if( target != null )
{
ItemStack f = Platform.cloneItemStack( target );
f.stackSize = amount;
return this.cs.extractItems( f, amount );
}
return null;
}
@Override
public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack target = null;
for( ItemStack is : this.cs.getContents() )
{
if( is != null )
{
if( is.stackSize > 0 && ( filter == null || Platform.isSameItem( filter, is ) ) )
{
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
}
}
}
}
if( target != null )
{
int cnt = this.cs.getItemCount( target );
if( cnt == 0 )
{
return null;
}
if( cnt > amount )
{
cnt = amount;
}
ItemStack c = target.copy();
c.stackSize = cnt;
return c;
}
return null;
}
@Override
public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack target = null;
for( ItemStack is : this.cs.getContents() )
{
if( is != null )
{
if( is.stackSize > 0 && ( filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode ) ) )
{
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
}
}
}
}
if( target != null )
{
ItemStack f = Platform.cloneItemStack( target );
f.stackSize = amount;
return this.cs.extractItems( f, amount );
}
return null;
}
@Override
public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack target = null;
for( ItemStack is : this.cs.getContents() )
{
if( is != null )
{
if( is.stackSize > 0 && ( filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode ) ) )
{
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
}
}
}
}
if( target != null )
{
int cnt = this.cs.getItemCount( target );
if( cnt == 0 )
{
return null;
}
if( cnt > amount )
{
cnt = amount;
}
ItemStack c = target.copy();
c.stackSize = cnt;
return c;
}
return null;
}
@Override
public ItemStack addItems( ItemStack toBeAdded )
{
return this.cs.insertItems( toBeAdded );
}
@Override
public ItemStack simulateAdd( ItemStack toBeSimulated )
{
int items = this.cs.getSpaceForItem( toBeSimulated );
ItemStack cloned = Platform.cloneItemStack( toBeSimulated );
if( toBeSimulated.stackSize <= items )
{
return null;
}
cloned.stackSize -= items;
return cloned;
}
@Override
public boolean containsItems()
{
return this.cs.getUniqueItems() > 0;
}
@Override
public Iterator<ItemSlot> iterator()
{
return new StackToSlotIterator( this.cs.getContents().iterator() );
}
}
@@ -1,40 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.eventhandler.Event;
public class FMPPacketEvent extends Event
{
private final EntityPlayerMP sender;
public FMPPacketEvent( EntityPlayerMP sender )
{
this.sender = sender;
}
public EntityPlayerMP getSender()
{
return this.sender;
}
}
@@ -1,176 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.integration.abstraction.IFZ;
import appeng.util.item.AEItemStack;
public class FactorizationBarrel implements IMEInventory<IAEItemStack>
{
private final IFZ fProxy;
private final TileEntity te;
public FactorizationBarrel( IFZ proxy, TileEntity tile )
{
this.te = tile;
this.fProxy = proxy;
}
public long remainingItemCount()
{
return this.fProxy.barrelGetMaxItemCount( this.te ) - this.fProxy.barrelGetItemCount( this.te );
}
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( input == null )
{
return null;
}
if( input.getStackSize() == 0 )
{
return null;
}
ItemStack shared = input.getItemStack();
if( shared.isItemDamaged() )
{
return input;
}
if( this.remainingItemTypes() > 0 )
{
if( mode == Actionable.MODULATE )
{
this.fProxy.setItemType( this.te, input.getItemStack() );
}
}
if( this.containsItemType( input, mode == Actionable.SIMULATE ) )
{
int max = this.fProxy.barrelGetMaxItemCount( this.te );
int newTotal = (int) this.storedItemCount() + (int) input.getStackSize();
if( newTotal > max )
{
if( mode == Actionable.MODULATE )
{
this.fProxy.barrelSetCount( this.te, max );
}
IAEItemStack result = input.copy();
result.setStackSize( newTotal - max );
return result;
}
else
{
if( mode == Actionable.MODULATE )
{
this.fProxy.barrelSetCount( this.te, newTotal );
}
return null;
}
}
return input;
}
private long remainingItemTypes()
{
return this.fProxy.barrelGetItem( this.te ) == null ? 1 : 0;
}
private boolean containsItemType( final IAEItemStack i, final boolean acceptEmpty )
{
ItemStack currentItem = this.fProxy.barrelGetItem( this.te );
// empty barrels want your love too!
if( acceptEmpty && currentItem == null )
{
return true;
}
return i.equals( currentItem );
}
private long storedItemCount()
{
return this.fProxy.barrelGetItemCount( this.te );
}
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if( this.containsItemType( request, false ) )
{
int howMany = (int) this.storedItemCount();
if( request.getStackSize() >= howMany )
{
if( mode == Actionable.MODULATE )
{
this.fProxy.setItemType( this.te, null );
this.fProxy.barrelSetCount( this.te, 0 );
}
IAEItemStack r = request.copy();
r.setStackSize( howMany );
return r;
}
else
{
if( mode == Actionable.MODULATE )
{
this.fProxy.barrelSetCount( this.te, (int) ( howMany - request.getStackSize() ) );
}
return request.copy();
}
}
return null;
}
@Override
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
ItemStack i = this.fProxy.barrelGetItem( this.te );
if( i != null )
{
i.stackSize = this.fProxy.barrelGetItemCount( this.te );
out.addStorage( AEItemStack.create( i ) );
}
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
}
@@ -1,51 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.util.ForgeDirection;
import appeng.integration.modules.FZ;
import appeng.me.storage.MEMonitorIInventory;
import appeng.util.inv.IMEAdaptor;
public class FactorizationHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc )
{
return chan == StorageChannel.ITEMS && FZ.instance.isBarrel( te );
}
@Override
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src )
{
if( chan == StorageChannel.ITEMS )
{
return new MEMonitorIInventory( new IMEAdaptor( FZ.instance.getFactorizationBarrel( te ), src ) );
}
return null;
}
}
@@ -1,52 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.util.ForgeDirection;
import appeng.integration.modules.DSU;
import appeng.me.storage.MEMonitorIInventory;
import appeng.util.inv.IMEAdaptor;
public class MFRDSUHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc )
{
return chan == StorageChannel.ITEMS && DSU.instance.isDSU( te );
}
@Override
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src )
{
if( chan == StorageChannel.ITEMS )
{
return new MEMonitorIInventory( new IMEAdaptor( DSU.instance.getDSU( te ), src ) );
}
return null;
}
}
@@ -1,140 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.util.item.AEItemStack;
public class MinefactoryReloadedDeepStorageUnit implements IMEInventory<IAEItemStack>
{
private final IDeepStorageUnit dsu;
public MinefactoryReloadedDeepStorageUnit( TileEntity ta )
{
this.dsu = (IDeepStorageUnit) ta;
}
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
ItemStack is = this.dsu.getStoredItemType();
if( is != null )
{
if( input.equals( is ) )
{
long max = this.dsu.getMaxStoredCount();
long storedItems = is.stackSize;
if( max == storedItems )
{
return input;
}
storedItems += input.getStackSize();
if( storedItems > max )
{
IAEItemStack overflow = AEItemStack.create( is );
overflow.setStackSize( (int) ( storedItems - max ) );
if( mode == Actionable.MODULATE )
{
this.dsu.setStoredItemCount( (int) max );
}
return overflow;
}
else
{
if( mode == Actionable.MODULATE )
{
this.dsu.setStoredItemCount( is.stackSize + (int) input.getStackSize() );
}
return null;
}
}
}
else
{
if( input.getTagCompound() != null )
{
return input;
}
if( mode == Actionable.MODULATE )
{
this.dsu.setStoredItemType( input.getItemStack(), (int) input.getStackSize() );
}
return null;
}
return input;
}
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
ItemStack is = this.dsu.getStoredItemType();
if( request.equals( is ) )
{
if( request.getStackSize() >= is.stackSize )
{
is = is.copy();
if( mode == Actionable.MODULATE )
{
this.dsu.setStoredItemCount( 0 );
}
return AEItemStack.create( is );
}
else
{
if( mode == Actionable.MODULATE )
{
this.dsu.setStoredItemCount( is.stackSize - (int) request.getStackSize() );
}
return request.copy();
}
}
return null;
}
@Override
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
{
ItemStack is = this.dsu.getStoredItemType();
if( is != null )
{
out.add( AEItemStack.create( is ) );
}
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
}
@@ -1,52 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.helpers;
import appeng.api.util.ForgeDirection;
import cofh.api.energy.IEnergyReceiver;
public class NullRFHandler implements IEnergyReceiver
{
@Override
public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
{
return 0;
}
@Override
public int getEnergyStored( ForgeDirection from )
{
return 0;
}
@Override
public int getMaxEnergyStored( ForgeDirection from )
{
return 0;
}
@Override
public boolean canConnectEnergy( ForgeDirection from )
{
return true;
}
}
@@ -1,73 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
/**
* Base implementation for {@link mcp.mobius.waila.api.IWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public abstract class BaseWailaDataProvider implements IWailaDataProvider
{
@Override
public ItemStack getWailaStack( IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return null;
}
@Override
public List<String> getWailaHead( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaTail( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
{
return tag;
}
}
@@ -1,194 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import appeng.api.parts.IPart;
import appeng.integration.modules.waila.part.ChannelWailaDataProvider;
import appeng.integration.modules.waila.part.IPartWailaDataProvider;
import appeng.integration.modules.waila.part.PartAccessor;
import appeng.integration.modules.waila.part.PartStackWailaDataProvider;
import appeng.integration.modules.waila.part.PowerStateWailaDataProvider;
import appeng.integration.modules.waila.part.StorageMonitorWailaDataProvider;
import appeng.integration.modules.waila.part.Tracer;
/**
* Delegation provider for parts through {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PartWailaDataProvider implements IWailaDataProvider
{
/**
* Contains all providers
*/
private final List<IPartWailaDataProvider> providers;
/**
* Can access parts through view-hits
*/
private final PartAccessor accessor = new PartAccessor();
/**
* Traces views hit on blocks
*/
private final Tracer tracer = new Tracer();
/**
* Initializes the provider list with all wanted providers
*/
public PartWailaDataProvider()
{
final IPartWailaDataProvider channel = new ChannelWailaDataProvider();
final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider();
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
this.providers = Lists.newArrayList( channel, storageMonitor, powerState, partStack );
}
@Override
public ItemStack getWailaStack( IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final MovingObjectPosition mop = accessor.getPosition();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
ItemStack wailaStack = null;
for( IPartWailaDataProvider provider : this.providers )
{
wailaStack = provider.getWailaStack( part, config, wailaStack );
}
return wailaStack;
}
return null;
}
@Override
public List<String> getWailaHead( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final MovingObjectPosition mop = accessor.getPosition();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( IPartWailaDataProvider provider : this.providers )
{
provider.getWailaHead( part, currentToolTip, accessor, config );
}
}
return currentToolTip;
}
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final MovingObjectPosition mop = accessor.getPosition();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( IPartWailaDataProvider provider : this.providers )
{
provider.getWailaBody( part, currentToolTip, accessor, config );
}
}
return currentToolTip;
}
@Override
public List<String> getWailaTail( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final MovingObjectPosition mop = accessor.getPosition();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( IPartWailaDataProvider provider : this.providers )
{
provider.getWailaTail( part, currentToolTip, accessor, config );
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
{
final MovingObjectPosition mop = this.tracer.retraceBlock( world, player, x, y, z );
if( mop != null )
{
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( IPartWailaDataProvider provider : this.providers )
{
provider.getNBTData( player, part, te, tag, world, x, y, z );
}
}
}
return tag;
}
}
@@ -1,118 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import appeng.integration.modules.waila.tile.ChargerWailaDataProvider;
import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider;
import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider;
import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider;
/**
* Delegation provider for tiles through {@link mcp.mobius.waila.api.IWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class TileWailaDataProvider implements IWailaDataProvider
{
/**
* Contains all providers
*/
private final List<IWailaDataProvider> providers;
/**
* Initializes the provider list with all wanted providers
*/
public TileWailaDataProvider()
{
final IWailaDataProvider charger = new ChargerWailaDataProvider();
final IWailaDataProvider energyCell = new PowerStorageWailaDataProvider();
final IWailaDataProvider craftingBlock = new PowerStateWailaDataProvider();
final IWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider();
this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor );
}
@Override
public ItemStack getWailaStack( IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return null;
}
@Override
public List<String> getWailaHead( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
for( IWailaDataProvider provider : this.providers )
{
provider.getWailaHead( itemStack, currentToolTip, accessor, config );
}
return currentToolTip;
}
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
for( IWailaDataProvider provider : this.providers )
{
provider.getWailaBody( itemStack, currentToolTip, accessor, config );
}
return currentToolTip;
}
@Override
public List<String> getWailaTail( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
for( IWailaDataProvider provider : this.providers )
{
provider.getWailaTail( itemStack, currentToolTip, accessor, config );
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
{
for( IWailaDataProvider provider : this.providers )
{
provider.getNBTData( player, te, tag, world, x, y, z );
}
return tag;
}
}
@@ -1,74 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.parts.IPart;
/**
* Default implementation of {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider
{
@Override
public ItemStack getWailaStack( IPart part, IWailaConfigHandler config, ItemStack partStack )
{
return null;
}
@Override
public List<String> getWailaHead( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaTail( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
{
return tag;
}
}
@@ -1,162 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import gnu.trove.map.TObjectByteMap;
import gnu.trove.map.hash.TObjectByteHashMap;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
/**
* Channel-information provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
{
/**
* Channel key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
*/
private static final String ID_USED_CHANNELS = "usedChannels";
/**
* Used cache for channels if the channel was not transmitted through the server.
* <p/>
* This is useful, when a player just started to look at a tile
* and thus just requested the new information from the server.
* <p/>
* The cache will be updated from the server.
*/
private final TObjectByteMap<IPart> cache = new TObjectByteHashMap<IPart>();
/**
* Adds the used and max channel to the tool tip
*
* @param part being looked at part
* @param currentToolTip current tool tip
* @param accessor wrapper for various world information
* @param config config to react to various settings
*
* @return modified tool tip
*/
@Override
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
if( part instanceof PartCableSmart || part instanceof PartDenseCable )
{
final NBTTagCompound tag = accessor.getNBTData();
final byte usedChannels = this.getUsedChannels( part, tag, this.cache );
final byte maxChannels = (byte) ( ( part instanceof PartDenseCable ) ? 32 : 8 );
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
currentToolTip.add( formattedToolTip );
}
return currentToolTip;
}
/**
* Determines the source of the channel.
* <p/>
* If the client received information of the channels on the server, they are used,
* else if the cache contains a previous stored value, this will be used.
* Default value is 0.
*
* @param part part to be looked at
* @param tag tag maybe containing the channel information
* @param cache cache with previous knowledge
*
* @return used channels on the cable
*/
private byte getUsedChannels( IPart part, NBTTagCompound tag, TObjectByteMap<IPart> cache )
{
final byte usedChannels;
if( tag.hasKey( ID_USED_CHANNELS ) )
{
usedChannels = tag.getByte( ID_USED_CHANNELS );
this.cache.put( part, usedChannels );
}
else if( this.cache.containsKey( part ) )
{
usedChannels = this.cache.get( part );
}
else
{
usedChannels = 0;
}
return usedChannels;
}
/**
* Called on server to transfer information from server to client.
* <p/>
* If the part is a cable,
* it writes the channel information in the {@code #tag}
* using the {@code ID_USED_CHANNELS} key.
*
* @param player player looking at the part
* @param part part being looked at
* @param te host of the part
* @param tag transferred tag which is send to the client
* @param world world of the part
* @param x x pos of the part
* @param y y pos of the part
* @param z z pos of the part
*
* @return tag send to the client
*/
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
{
if( part instanceof PartCableSmart || part instanceof PartDenseCable )
{
final NBTTagCompound tempTag = new NBTTagCompound();
part.writeToNBT( tempTag );
if( tempTag.hasKey( ID_USED_CHANNELS ) )
{
final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS );
tag.setByte( ID_USED_CHANNELS, usedChannels );
}
}
return tag;
}
}
@@ -1,54 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.parts.IPart;
/**
* An abstraction layer of the {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for {@link appeng.api.parts.IPart}.
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public interface IPartWailaDataProvider
{
ItemStack getWailaStack( IPart part, IWailaConfigHandler config, ItemStack partStack );
List<String> getWailaHead( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
List<String> getWailaTail( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z );
}
@@ -1,69 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import com.google.common.base.Optional;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
/**
* Accessor to access specific parts for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PartAccessor
{
/**
* Hits a {@link appeng.api.parts.IPartHost} with {@link net.minecraft.util.MovingObjectPosition}.
* <p/>
* You can derive the looked at {@link appeng.api.parts.IPart} by doing that.
* If a facade is being looked at, it is defined as being absent.
*
* @param te being looked at {@link net.minecraft.tileentity.TileEntity}
* @param mop type of ray-trace
*
* @return maybe the looked at {@link appeng.api.parts.IPart}
*/
public Optional<IPart> getMaybePart( TileEntity te, MovingObjectPosition mop )
{
if( te instanceof IPartHost )
{
final Vec3 position = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
final IPartHost host = (IPartHost) te;
final SelectedPart sp = host.selectPart( position );
if( sp.part != null )
{
return Optional.of( sp.part );
}
}
return Optional.absent();
}
}
@@ -1,44 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import appeng.api.parts.IPart;
import appeng.api.parts.PartItemStack;
/**
* Part ItemStack provider for WAILA
*
* @author TheJulianJES
* @version rv2
* @since rv2
*/
public class PartStackWailaDataProvider extends BasePartWailaDataProvider {
@Override
public ItemStack getWailaStack( IPart part, IWailaConfigHandler config, ItemStack partStack )
{
partStack = part.getItemStack( PartItemStack.Pick );
return partStack;
}
}
@@ -1,91 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
/**
* Power state provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider
{
/**
* Adds state to the tooltip
*
* @param part part with state
* @param currentToolTip to be added to tooltip
* @param accessor wrapper for various information
* @param config config settings
*
* @return modified tooltip
*/
@Override
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
if( part instanceof IPowerChannelState )
{
final IPowerChannelState state = (IPowerChannelState) part;
currentToolTip.add( this.getToolTip( state.isActive(), state.isPowered() ) );
}
return currentToolTip;
}
/**
* Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered}
*
* @param isActive if part is active
* @param isPowered if part is powered
*
* @return tooltip of the state
*/
private String getToolTip( boolean isActive, boolean isPowered )
{
final String result;
if( isActive && isPowered )
{
result = WailaText.DeviceOnline.getLocal();
}
else if( isPowered )
{
result = WailaText.DeviceMissingChannel.getLocal();
}
else
{
result = WailaText.DeviceOffline.getLocal();
}
return result;
}
}
@@ -1,81 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.core.localization.WailaText;
/**
* Storage monitor provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider
{
/**
* Displays the stack if present and if the monitor is locked.
* Can handle fluids and items.
*
* @param part maybe storage monitor
* @param currentToolTip to be written to tooltip
* @param accessor information wrapper
* @param config config option
*
* @return modified tooltip
*/
@Override
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
if( part instanceof IPartStorageMonitor )
{
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
final IAEStack<?> displayed = monitor.getDisplayed();
final boolean isLocked = monitor.isLocked();
if( displayed instanceof IAEItemStack )
{
IAEItemStack ais = (IAEItemStack) displayed;
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().getDisplayName() );
}
else if( displayed instanceof IAEFluidStack )
{
IAEFluidStack ais = (IAEFluidStack) displayed;
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
}
currentToolTip.add( ( isLocked ) ? WailaText.Locked.getLocal() : WailaText.Unlocked.getLocal() );
}
return currentToolTip;
}
}
@@ -1,98 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.part;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
/**
* Tracer for players hitting blocks
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class Tracer
{
/**
* Trace view of players to blocks.
* Ignore all which are out of reach.
*
* @param world word of block
* @param player player viewing block
* @param x x pos of block
* @param y y pos of block
* @param z z pos of block
*
* @return trace movement. Can be null
*/
public MovingObjectPosition retraceBlock( World world, EntityPlayerMP player, int x, int y, int z )
{
Block block = world.getBlock( x, y, z );
Vec3 headVec = this.getCorrectedHeadVec( player );
Vec3 lookVec = player.getLook( 1.0F );
double reach = this.getBlockReachDistance_server( player );
Vec3 endVec = headVec.addVector( lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach );
return block.collisionRayTrace( world, x, y, z, headVec, endVec );
}
/**
* Gets the view point of a player
*
* @param player player with head
*
* @return view point of player
*/
private Vec3 getCorrectedHeadVec( EntityPlayer player )
{
Vec3 v = Vec3.createVectorHelper( player.posX, player.posY, player.posZ );
if( player.worldObj.isRemote )
{
//compatibility with eye height changing mods
v.yCoord += player.getEyeHeight() - player.getDefaultEyeHeight();
}
else
{
v.yCoord += player.getEyeHeight();
if( player instanceof EntityPlayerMP && player.isSneaking() )
{
v.yCoord -= 0.08;
}
}
return v;
}
/**
* @param player multi-player player
*
* @return block reach distance of player
*/
private double getBlockReachDistance_server( EntityPlayerMP player )
{
return player.theItemInWorldManager.getBlockReachDistance();
}
}
@@ -1,78 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import appeng.tile.misc.TileCharger;
/**
* Charger provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class ChargerWailaDataProvider extends BaseWailaDataProvider
{
/**
* Displays the holding item and its tooltip
*
* @param itemStack stack of charger
* @param currentToolTip unmodified tooltip
* @param accessor wrapper information
* @param config config option
*
* @return modified tooltip
*/
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
if( te instanceof TileCharger )
{
final TileCharger charger = (TileCharger) te;
final IInventory chargerInventory = charger.getInternalInventory();
final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 );
if( chargingItem != null )
{
final String currentInventory = chargingItem.getDisplayName();
final EntityPlayer player = accessor.getPlayer();
currentToolTip.add( WailaText.Contains + ": " + currentInventory );
chargingItem.getItem().addInformation( chargingItem, player, currentToolTip, true );
}
}
return currentToolTip;
}
}
@@ -1,74 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import appeng.tile.crafting.TileCraftingMonitorTile;
/**
* Crafting-monitor provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider
{
/**
* Displays the item currently crafted by the CPU cluster
*
* @param itemStack stack of crafting monitor
* @param currentToolTip unmodified tooltip
* @param accessor information wrapper
* @param config config option
*
* @return modified tooltip
*/
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
if( te instanceof TileCraftingMonitorTile )
{
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) te;
final IAEItemStack displayStack = monitor.getJobProgress();
if( displayStack != null )
{
final String currentCrafting = displayStack.getItemStack().getDisplayName();
currentToolTip.add( WailaText.Crafting.getLocal() + ": " + currentCrafting );
}
}
return currentToolTip;
}
}
@@ -1,82 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.implementations.IPowerChannelState;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
/**
* Power state provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PowerStateWailaDataProvider extends BaseWailaDataProvider
{
/**
* Adds state to the tooltip
*
* @param itemStack stack of power state
* @param currentToolTip to be added to tooltip
* @param accessor wrapper for various information
* @param config config settings
*
* @return modified tooltip
*/
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
if( te instanceof IPowerChannelState )
{
final IPowerChannelState state = (IPowerChannelState) te;
final boolean isActive = state.isActive();
final boolean isPowered = state.isPowered();
if( isActive && isPowered )
{
currentToolTip.add( WailaText.DeviceOnline.getLocal() );
}
else if( isPowered )
{
currentToolTip.add( WailaText.DeviceMissingChannel.getLocal() );
}
else
{
currentToolTip.add( WailaText.DeviceOffline.getLocal() );
}
}
return currentToolTip;
}
}
@@ -1,173 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.waila.tile;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import gnu.trove.map.TObjectLongMap;
import gnu.trove.map.hash.TObjectLongHashMap;
import mcp.mobius.waila.api.ITaggedList;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.networking.energy.IAEPowerStorage;
import appeng.core.localization.WailaText;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import appeng.util.Platform;
/**
* Power storage provider for WAILA
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider
{
/**
* Power key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
*/
private static final String ID_CURRENT_POWER = "currentPower";
/**
* Used cache for power if the power was not transmitted through the server.
* <p/>
* This is useful, when a player just started to look at a tile
* and thus just requested the new information from the server.
* <p/>
* The cache will be updated from the server.
*/
private final TObjectLongMap<TileEntity> cache = new TObjectLongHashMap<TileEntity>();
/**
* Adds the current and max power to the tool tip
* Will ignore if the tile has an energy buffer ( &gt; 0 )
*
* @param itemStack stack of power storage
* @param currentToolTip current tool tip
* @param accessor wrapper for various world information
* @param config config to react to various settings
*
* @return modified tool tip
*/
@Override
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
{
//Removes RF tooltip on WAILA 1.5.9+
((ITaggedList<String, String>) currentToolTip).removeEntries("RFEnergyStorage");
final TileEntity te = accessor.getTileEntity();
if( te instanceof IAEPowerStorage )
{
final IAEPowerStorage storage = (IAEPowerStorage) te;
final double maxPower = storage.getAEMaxPower();
if( maxPower > 0 )
{
final NBTTagCompound tag = accessor.getNBTData();
final long internalCurrentPower = this.getInternalCurrentPower( tag, te );
final long internalMaxPower = (long) ( 100 * maxPower );
final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false );
final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false );
currentToolTip.add( WailaText.Contains.getLocal() + ": " + formatCurrentPower + " / " + formatMaxPower );
}
}
return currentToolTip;
}
/**
* Called on server to transfer information from server to client.
* <p/>
* If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage},
* it writes the power information to the {@code #tag}
* using the {@code #ID_CURRENT_POWER} key.
*
* @param player player looking at the power storage
* @param te power storage
* @param tag transferred tag which is send to the client
* @param world world of the power storage
* @param x x pos of the power storage
* @param y y pos of the power storage
* @param z z pos of the power storage
*
* @return tag send to the client
*/
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
{
if( te instanceof IAEPowerStorage )
{
final IAEPowerStorage storage = (IAEPowerStorage) te;
if( storage.getAEMaxPower() > 0 )
{
final long internalCurrentPower = (long) ( 100 * storage.getAECurrentPower() );
tag.setLong( ID_CURRENT_POWER, internalCurrentPower );
}
}
return tag;
}
/**
* Determines the current power.
* <p/>
* If the client received power information on the server, they are used,
* else if the cache contains a previous stored value, this will be used.
* Default value is 0.
*
* @param te te to be looked at
* @param tag tag maybe containing the channel information
*
* @return used channels on the cable
*/
private long getInternalCurrentPower( NBTTagCompound tag, TileEntity te )
{
final long internalCurrentPower;
if( tag.hasKey( ID_CURRENT_POWER ) )
{
internalCurrentPower = tag.getLong( ID_CURRENT_POWER );
this.cache.put( te, internalCurrentPower );
}
else if( this.cache.containsKey( te ) )
{
internalCurrentPower = this.cache.get( te );
}
else
{
internalCurrentPower = 0;
}
return internalCurrentPower;
}
}