Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23aa8fd72d | |||
| 106003ebf9 | |||
| 8271597394 | |||
| 9210069d9b | |||
| f364359905 | |||
| fb618b939f | |||
| 43a47f8971 | |||
| e85acf2bee | |||
| bbde2443e1 | |||
| ad2f63ba0d | |||
| ee977720ca | |||
| ca953f4596 | |||
| 2adc055536 | |||
| 399934ac2b | |||
| 9451106c81 | |||
| 8e75de8fb9 | |||
| eca598516e | |||
| 2c5a54c210 | |||
| 1ac2ab0c10 | |||
| 199b17b9c6 | |||
| f582c8081b | |||
| 77d66b1817 | |||
| df370396b1 | |||
| ceeb84a439 | |||
| 9af6b50347 | |||
| d151313253 | |||
| 6d935cc8ae | |||
| 1396dbf600 | |||
| 8087a43df5 | |||
| c2cd395ca1 | |||
| a6e2975677 | |||
| 3783ae8619 | |||
| be17616836 | |||
| 36c72d641f | |||
| f878a7598d | |||
| 071ae6d680 | |||
| cc29230ce5 | |||
| b282e5d968 | |||
| 3410db7b45 | |||
| 800c30e91c | |||
| 817163dbf6 | |||
| d164e279ef | |||
| 4f9b8db6fc | |||
| b58c92ebb6 |
@@ -112,5 +112,6 @@ processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
expand 'version': project.version, 'mcversion': config.minecraft_version
|
||||
include 'pack.mcmeta'
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ package appeng.api.config;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public enum Settings
|
||||
@@ -55,16 +56,19 @@ public enum Settings
|
||||
|
||||
STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ), PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) );
|
||||
|
||||
private final EnumSet values;
|
||||
private final EnumSet<? extends Enum<?>> values;
|
||||
|
||||
Settings( EnumSet set )
|
||||
Settings( @Nonnull EnumSet<? extends Enum<?>> possibleOptions )
|
||||
{
|
||||
if( set == null || set.isEmpty() )
|
||||
throw new RuntimeException( "Invalid configuration." );
|
||||
this.values = set;
|
||||
if ( possibleOptions.isEmpty() )
|
||||
{
|
||||
throw new IllegalArgumentException( "Tried to instantiate an empty setting." );
|
||||
}
|
||||
|
||||
this.values = possibleOptions;
|
||||
}
|
||||
|
||||
public EnumSet getPossibleValues()
|
||||
public EnumSet<? extends Enum<?>> getPossibleValues()
|
||||
{
|
||||
return this.values;
|
||||
}
|
||||
|
||||
@@ -59,9 +59,21 @@ public interface IStorageCell extends ICellWorkbenchItem
|
||||
* @param cellItem item
|
||||
*
|
||||
* @return number of bytes
|
||||
*
|
||||
* @deprecated use {@link IStorageCell#getBytesPerType(ItemStack)}
|
||||
*/
|
||||
@Deprecated
|
||||
int BytePerType( ItemStack cellItem );
|
||||
|
||||
/**
|
||||
* Determines the number of bytes used for any type included on the cell.
|
||||
*
|
||||
* @param cellItem item
|
||||
*
|
||||
* @return number of bytes
|
||||
*/
|
||||
int getBytesPerType( ItemStack cellItem );
|
||||
|
||||
/**
|
||||
* Must be between 1 and 63, indicates how many types you want to store on
|
||||
* the item.
|
||||
|
||||
@@ -94,4 +94,4 @@ public interface IGrid
|
||||
* @return the node considered the pivot point of the grid.
|
||||
*/
|
||||
IGridNode getPivot();
|
||||
}
|
||||
}
|
||||
@@ -156,11 +156,18 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
|
||||
try
|
||||
{
|
||||
return this.renderInfo = new BlockRenderInfo( this.getRenderer().newInstance() );
|
||||
final BaseBlockRender renderer = this.getRenderer().newInstance();
|
||||
this.renderInfo = new BlockRenderInfo( renderer );
|
||||
|
||||
return this.renderInfo;
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch ( InstantiationException e )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.getRenderer(), e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( "Failed to create a new instance of " + this.getRenderer() + " because of permissions.", e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,13 +804,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
}
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.tileEntityType , e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( "Failed to create a new instance of " + this.tileEntityType + ", because lack of permissions", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z )
|
||||
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
|
||||
SelectedPart sp = this.cb( world, x, y, z ).selectPart( v3 );
|
||||
@@ -450,10 +450,10 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
|
||||
|
||||
public void setupTile()
|
||||
{
|
||||
this.setTileEntity( noTesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBus.class.getName() ) );
|
||||
this.setTileEntity( noTesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBus.class.getName() ) );
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
tesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBusTESR.class.getName() );
|
||||
tesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBusTESR.class.getName() );
|
||||
GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" );
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( tesrTile, this );
|
||||
}
|
||||
|
||||
@@ -364,9 +364,6 @@ public class ClientHelper extends ServerHelper
|
||||
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
|
||||
if( player == null )
|
||||
return;
|
||||
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
|
||||
@@ -79,7 +79,6 @@ import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.INEI;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public abstract class AEBaseGui extends GuiContainer
|
||||
@@ -744,8 +743,6 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
catch( Exception err )
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
if( Platform.isDrawing( Tessellator.instance ) )
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
this.setItemRender( pIR );
|
||||
return;
|
||||
@@ -794,8 +791,6 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
}
|
||||
catch( Exception err )
|
||||
{
|
||||
if( Platform.isDrawing( tessellator ) )
|
||||
tessellator.draw();
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
@@ -876,15 +871,10 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
{
|
||||
try
|
||||
{
|
||||
// drawSlotInventory
|
||||
// super.func_146977_a( s );r
|
||||
GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
|
||||
}
|
||||
catch( Exception err )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if( Platform.isDrawing( tessellator ) )
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,21 @@ import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.ISlimReadableNumberConverter;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class AppEngRenderItem extends RenderItem
|
||||
{
|
||||
private static final ReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
|
||||
public IAEItemStack aeStack;
|
||||
|
||||
@@ -125,11 +134,11 @@ public class AppEngRenderItem extends RenderItem
|
||||
{
|
||||
if( AEConfig.instance.useTerminalUseLargeFont() )
|
||||
{
|
||||
return NUMBER_CONVERTER.toShortHumanReadableForm( originalSize );
|
||||
return SLIM_CONVERTER.toSlimReadableForm( originalSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
return NUMBER_CONVERTER.toHumanReadableForm( originalSize );
|
||||
return WIDE_CONVERTER.toWideReadableForm( originalSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,9 +325,6 @@ public class BaseBlockRender
|
||||
|
||||
public void renderInvBlock( EnumSet<ForgeDirection> sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer )
|
||||
{
|
||||
if( Platform.isDrawing( tess ) )
|
||||
tess.draw();
|
||||
|
||||
int meta = 0;
|
||||
if( block != null && block.hasSubtypes() && item != null )
|
||||
meta = item.getItemDamage();
|
||||
|
||||
@@ -472,7 +472,7 @@ public final class BusRenderHelper implements IPartRenderHelper
|
||||
return block;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access the multi part block." );
|
||||
throw new MissingDefinition( "Tried to access the multi part block without it being defined." );
|
||||
}
|
||||
|
||||
public void prepareBounds( RenderBlocks renderer )
|
||||
|
||||
@@ -33,7 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -65,9 +64,6 @@ public class TESRWrapper extends TileEntitySpecialRenderer
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
if( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
@@ -76,9 +72,6 @@ public class TESRWrapper extends TileEntitySpecialRenderer
|
||||
this.renderBlocksInstance.blockAccess = te.getWorldObj();
|
||||
this.blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, this.renderBlocksInstance );
|
||||
|
||||
if( Platform.isDrawing( tess ) )
|
||||
throw new RuntimeException( "Error during rendering." );
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
@@ -87,7 +80,7 @@ public class TESRWrapper extends TileEntitySpecialRenderer
|
||||
AELog.severe( "Hi, Looks like there was a crash while rendering something..." );
|
||||
t.printStackTrace();
|
||||
AELog.severe( "MC will now crash ( probably )!" );
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,20 @@ import appeng.client.ClientHelper;
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv1
|
||||
*/
|
||||
public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU
|
||||
{
|
||||
private static final ReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
|
||||
public RenderBlockCraftingCPUMonitor()
|
||||
{
|
||||
@@ -53,9 +60,6 @@ public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU
|
||||
@Override
|
||||
public void renderTile( AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer )
|
||||
{
|
||||
if( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
||||
if( tile instanceof TileCraftingMonitorTile )
|
||||
{
|
||||
TileCraftingMonitorTile cmt = (TileCraftingMonitorTile) tile;
|
||||
@@ -177,7 +181,7 @@ public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU
|
||||
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
|
||||
|
||||
final long stackSize = ais.getStackSize();
|
||||
final String renderedStackSize = NUMBER_CONVERTER.toHumanReadableForm( stackSize );
|
||||
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize );
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( renderedStackSize );
|
||||
|
||||
@@ -31,9 +31,8 @@ public class FlippableIcon implements IIcon
|
||||
|
||||
public FlippableIcon( IIcon o )
|
||||
{
|
||||
|
||||
if( o == null )
|
||||
throw new RuntimeException( "Cannot create a wrapper icon with a null icon." );
|
||||
throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." );
|
||||
|
||||
this.original = o;
|
||||
this.flip_u = false;
|
||||
|
||||
@@ -32,9 +32,8 @@ public class FullIcon implements IIcon
|
||||
|
||||
public FullIcon( IIcon o )
|
||||
{
|
||||
|
||||
if( o == null )
|
||||
throw new RuntimeException( "Cannot create a wrapper icon with a null icon." );
|
||||
throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." );
|
||||
|
||||
this.p = o;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,8 @@ public class OffsetIcon implements IIcon
|
||||
|
||||
public OffsetIcon( IIcon o, float x, float y )
|
||||
{
|
||||
|
||||
if( o == null )
|
||||
throw new RuntimeException( "Cannot create a wrapper icon with a null icon." );
|
||||
throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." );
|
||||
|
||||
this.p = o;
|
||||
this.offsetX = x;
|
||||
|
||||
@@ -30,28 +30,27 @@ public class TaughtIcon implements IIcon
|
||||
|
||||
final float tightness;
|
||||
|
||||
private final IIcon p;
|
||||
private final IIcon icon;
|
||||
|
||||
public TaughtIcon( IIcon o, float tightness )
|
||||
public TaughtIcon( IIcon icon, float tightness )
|
||||
{
|
||||
if( icon == null )
|
||||
throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." );
|
||||
|
||||
if( o == null )
|
||||
throw new RuntimeException( "Cannot create a wrapper icon with a null icon." );
|
||||
|
||||
this.p = o;
|
||||
this.icon = icon;
|
||||
this.tightness = tightness * 0.4f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth()
|
||||
{
|
||||
return this.p.getIconWidth();
|
||||
return this.icon.getIconWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight()
|
||||
{
|
||||
return this.p.getIconHeight();
|
||||
return this.icon.getIconHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +99,7 @@ public class TaughtIcon implements IIcon
|
||||
@SideOnly( Side.CLIENT )
|
||||
public String getIconName()
|
||||
{
|
||||
return this.p.getIconName();
|
||||
return this.icon.getIconName();
|
||||
}
|
||||
|
||||
private float v( double d )
|
||||
@@ -109,7 +108,7 @@ public class TaughtIcon implements IIcon
|
||||
d -= this.tightness;
|
||||
if( d > 8 )
|
||||
d += this.tightness;
|
||||
return this.p.getInterpolatedV( Math.min( 16.0, Math.max( 0.0, d ) ) );
|
||||
return this.icon.getInterpolatedV( Math.min( 16.0, Math.max( 0.0, d ) ) );
|
||||
}
|
||||
|
||||
private float u( double d )
|
||||
@@ -118,6 +117,6 @@ public class TaughtIcon implements IIcon
|
||||
d -= this.tightness;
|
||||
if( d > 8 )
|
||||
d += this.tightness;
|
||||
return this.p.getInterpolatedU( Math.min( 16.0, Math.max( 0.0, d ) ) );
|
||||
return this.icon.getInterpolatedU( Math.min( 16.0, Math.max( 0.0, d ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public abstract class AEBaseContainer extends Container
|
||||
this.obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null;
|
||||
|
||||
if( this.tileEntity == null && this.part == null && this.obj == null )
|
||||
throw new RuntimeException( "Must have a valid anchor" );
|
||||
throw new IllegalArgumentException( "Must have a valid anchor, instead " + anchor + " in " + ip );
|
||||
|
||||
this.mySrc = new PlayerSource( ip.player, this.getActionHost() );
|
||||
|
||||
@@ -380,7 +380,7 @@ public abstract class AEBaseContainer extends Container
|
||||
return super.addSlotToContainer( newSlot );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Invalid Slot for AE Container." );
|
||||
throw new IllegalArgumentException( "Invalid Slot [" + newSlot + "]for AE Container instead of AppEngSlot." );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,15 +49,13 @@ import appeng.util.iterators.NullIterator;
|
||||
|
||||
public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
final TileCellWorkbench workBench;
|
||||
final AppEngNullInventory ni = new AppEngNullInventory();
|
||||
private final TileCellWorkbench workBench;
|
||||
private final AppEngNullInventory nullInventory = new AppEngNullInventory();
|
||||
@GuiSync( 2 )
|
||||
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
|
||||
IInventory UpgradeInventoryWrapper;
|
||||
ItemStack prevStack = null;
|
||||
int lastUpgrades = 0;
|
||||
ItemStack LastCell;
|
||||
private ItemStack prevStack = null;
|
||||
private int lastUpgrades = 0;
|
||||
private ItemStack LastCell;
|
||||
|
||||
public ContainerCellWorkbench( InventoryPlayer ip, TileCellWorkbench te )
|
||||
{
|
||||
@@ -99,7 +97,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.invPlayer ) );
|
||||
|
||||
IInventory inv = this.upgradeable.getInventoryByName( "config" );
|
||||
this.UpgradeInventoryWrapper = new Upgrades();// Platform.isServer() ? new Upgrades() : new AppEngInternalInventory(
|
||||
IInventory upgradeInventory = new Upgrades();
|
||||
// null, 3 * 8 );
|
||||
|
||||
for( int w = 0; w < 7; w++ )
|
||||
@@ -113,7 +111,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
for( int z = 0; z < 8; z++ )
|
||||
{
|
||||
int iSLot = zz * 8 + z;
|
||||
this.addSlotToContainer( new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.UpgradeInventoryWrapper, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this.invPlayer ) );
|
||||
this.addSlotToContainer( new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this.invPlayer ) );
|
||||
}
|
||||
/*
|
||||
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new
|
||||
@@ -134,7 +132,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
if( this.prevStack != is )
|
||||
{
|
||||
this.prevStack = is;
|
||||
return this.lastUpgrades = this.getCellUpgradeInventory().getSizeInventory();
|
||||
this.lastUpgrades = this.getCellUpgradeInventory().getSizeInventory();
|
||||
}
|
||||
return this.lastUpgrades;
|
||||
}
|
||||
@@ -180,8 +178,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
|
||||
public IInventory getCellUpgradeInventory()
|
||||
{
|
||||
IInventory ri = this.workBench.getCellUpgradeInventory();
|
||||
return ri == null ? this.ni : ri;
|
||||
final IInventory upgradeInventory = this.workBench.getCellUpgradeInventory();
|
||||
|
||||
return upgradeInventory == null ? this.nullInventory : upgradeInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +236,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
class Upgrades implements IInventory
|
||||
private class Upgrades implements IInventory
|
||||
{
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,7 +49,7 @@ import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEConfig extends Configuration implements IConfigurableObject, IConfigManagerHost
|
||||
public final class AEConfig extends Configuration implements IConfigurableObject, IConfigManagerHost
|
||||
{
|
||||
|
||||
public static final double TUNNEL_POWER_LOSS = 0.05;
|
||||
|
||||
@@ -31,7 +31,6 @@ import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.networking.IGridBlock;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.core.api.ApiPart;
|
||||
import appeng.core.api.ApiStorage;
|
||||
@@ -81,7 +80,7 @@ public final class Api implements IAppEngApi
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartHelper partHelper()
|
||||
public ApiPart partHelper()
|
||||
{
|
||||
return this.partHelper;
|
||||
}
|
||||
@@ -119,8 +118,9 @@ public final class Api implements IAppEngApi
|
||||
@Override
|
||||
public IGridNode createGridNode( IGridBlock blk )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
throw new RuntimeException( "Grid Features are Server Side Only." );
|
||||
if ( Platform.isClient() )
|
||||
throw new IllegalStateException( "Grid features for " + blk + " are server side only." );
|
||||
|
||||
return new GridNode( blk );
|
||||
}
|
||||
|
||||
@@ -129,9 +129,4 @@ public final class Api implements IAppEngApi
|
||||
{
|
||||
return new GridConnection( a, b, ForgeDirection.UNKNOWN );
|
||||
}
|
||||
|
||||
public ApiPart getPartHelper()
|
||||
{
|
||||
return this.partHelper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ import appeng.util.Platform;
|
||||
|
||||
|
||||
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.7.10]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory" )
|
||||
public class AppEng
|
||||
public final class AppEng
|
||||
{
|
||||
public static final String MOD_ID = "appliedenergistics2";
|
||||
public static final String MOD_NAME = "Applied Energistics 2";
|
||||
|
||||
@@ -85,7 +85,7 @@ public class IMCHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException( "Invalid IMC Called: " + key );
|
||||
throw new IllegalStateException( "Invalid IMC Called: " + key );
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.core;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
@@ -189,7 +188,7 @@ public final class Registration
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
throw new IllegalStateException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
this.storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
@@ -562,10 +561,16 @@ public final class Registration
|
||||
registration.registerAchievements();
|
||||
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting ) )
|
||||
CraftingManager.getInstance().getRecipeList().add( new DisassembleRecipe() );
|
||||
{
|
||||
GameRegistry.addRecipe( new DisassembleRecipe() );
|
||||
RecipeSorter.register( "appliedenergistics2:disassemble", DisassembleRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless" );
|
||||
}
|
||||
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) )
|
||||
CraftingManager.getInstance().getRecipeList().add( new FacadeRecipe() );
|
||||
{
|
||||
GameRegistry.addRecipe( new FacadeRecipe() );
|
||||
RecipeSorter.register( "appliedenergistics2:facade", FacadeRecipe.class, Category.SHAPED, "after:minecraft:shaped" );
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit( FMLPostInitializationEvent event )
|
||||
@@ -586,7 +591,7 @@ public final class Registration
|
||||
PlayerMessages.values();
|
||||
GuiText.values();
|
||||
|
||||
Api.INSTANCE.getPartHelper().initFMPSupport();
|
||||
Api.INSTANCE.partHelper().initFMPSupport();
|
||||
for( Block block : blocks.multiPart().maybeBlock().asSet() )
|
||||
{
|
||||
( (BlockCableBus) block ).setupTile();
|
||||
|
||||
@@ -105,19 +105,19 @@ public class WorldSettings extends Configuration
|
||||
|
||||
if( !aeBaseFolder.isDirectory() && !aeBaseFolder.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
||||
throw new IllegalStateException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File compass = new File( aeBaseFolder, COMPASS_FOLDER );
|
||||
if( !compass.isDirectory() && !compass.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() );
|
||||
throw new IllegalStateException( "Failed to create " + compass.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File spawnData = new File( aeBaseFolder, SPAWNDATA_FOLDER );
|
||||
if( !spawnData.isDirectory() && !spawnData.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() );
|
||||
throw new IllegalStateException( "Failed to create " + spawnData.getAbsolutePath() );
|
||||
}
|
||||
|
||||
instance = new WorldSettings( aeBaseFolder );
|
||||
@@ -158,7 +158,7 @@ public class WorldSettings extends Configuration
|
||||
NBTTagCompound loadSpawnData( int dim, int chunkX, int chunkZ )
|
||||
{
|
||||
if( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
throw new IllegalStateException( "Invalid Request" );
|
||||
|
||||
NBTTagCompound data = null;
|
||||
File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" );
|
||||
@@ -225,7 +225,7 @@ public class WorldSettings extends Configuration
|
||||
void writeSpawnData( int dim, int chunkX, int chunkZ, NBTTagCompound data )
|
||||
{
|
||||
if( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
throw new IllegalStateException( "Invalid Request" );
|
||||
|
||||
File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" );
|
||||
FileOutputStream fileOutputStream = null;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
@@ -85,9 +86,9 @@ public class ApiPart implements IPartHelper
|
||||
{
|
||||
return Class.forName( base );
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +96,7 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
if( this.tileImplementations.get( description ) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.tileImplementations.get( description );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
return this.tileImplementations.get( description );
|
||||
}
|
||||
|
||||
String f = base;// TileCableBus.class.getName();
|
||||
@@ -121,9 +115,9 @@ public class ApiPart implements IPartHelper
|
||||
{
|
||||
myCLass = Class.forName( f );
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
|
||||
String path = f;
|
||||
@@ -147,14 +141,7 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
this.tileImplementations.put( description, myCLass );
|
||||
|
||||
try
|
||||
{
|
||||
return myCLass;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
return myCLass;
|
||||
}
|
||||
|
||||
public Class getClassByDesc( String Addendum, String fullPath, String root, String next )
|
||||
@@ -247,19 +234,21 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
public ClassNode getReader( String name )
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = '/' + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = this.getClass().getResourceAsStream( path );
|
||||
try
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = '/' + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = this.getClass().getResourceAsStream( path );
|
||||
cr = new ClassReader( is );
|
||||
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept( cn, ClassReader.EXPAND_FRAMES );
|
||||
|
||||
return cn;
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Error loading " + name, t );
|
||||
throw new IllegalStateException( "Error loading " + name, e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +295,7 @@ public class ApiPart implements IPartHelper
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
throw new RuntimeException( "Unable to manage part API.", e );
|
||||
throw new IllegalStateException( "Unable to manage part API.", e );
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package appeng.core.api.definitions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
@@ -40,7 +38,7 @@ public class DefinitionConstructor
|
||||
return ( (ITileDefinition) definition );
|
||||
}
|
||||
|
||||
throw new RuntimeException( "No tile definition" );
|
||||
throw new IllegalStateException( "No tile definition for " + feature );
|
||||
}
|
||||
|
||||
public final IBlockDefinition registerBlockDefinition( IAEFeature feature )
|
||||
@@ -52,7 +50,7 @@ public class DefinitionConstructor
|
||||
return ( (IBlockDefinition) definition );
|
||||
}
|
||||
|
||||
throw new RuntimeException( "No block definition" );
|
||||
throw new IllegalStateException( "No block definition for " + feature );
|
||||
}
|
||||
|
||||
public final IItemDefinition registerItemDefinition( IAEFeature feature )
|
||||
@@ -91,13 +89,9 @@ public class DefinitionConstructor
|
||||
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
ItemStackSrc multiPartSource = target.createPart( type, color );
|
||||
final Optional<ItemStackSrc> maybeSource = Optional.fromNullable( multiPartSource );
|
||||
final ItemStackSrc multiPartSource = target.createPart( type, color );
|
||||
|
||||
if( maybeSource.isPresent() )
|
||||
{
|
||||
definition.add( color, multiPartSource );
|
||||
}
|
||||
definition.add( color, multiPartSource );
|
||||
}
|
||||
|
||||
return definition;
|
||||
|
||||
@@ -77,10 +77,10 @@ public class IMCGrinder implements IIMCProcessor
|
||||
int turns = msg.getInteger( "turns" );
|
||||
|
||||
if( in == null )
|
||||
throw new RuntimeException( "invalid input" );
|
||||
throw new IllegalStateException( "invalid input" );
|
||||
|
||||
if( out == null )
|
||||
throw new RuntimeException( "invalid output" );
|
||||
throw new IllegalStateException( "invalid output" );
|
||||
|
||||
if( msg.hasKey( "optional" ) )
|
||||
{
|
||||
@@ -88,7 +88,7 @@ public class IMCGrinder implements IIMCProcessor
|
||||
ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
|
||||
|
||||
if( optional == null )
|
||||
throw new RuntimeException( "invalid optional" );
|
||||
throw new IllegalStateException( "invalid optional" );
|
||||
|
||||
float chance = msg.getFloat( "chance" );
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class IMCMatterCannon implements IIMCProcessor
|
||||
double weight = msg.getDouble( "weight" );
|
||||
|
||||
if( ammo == null )
|
||||
throw new RuntimeException( "invalid item" );
|
||||
throw new IllegalStateException( "invalid item in message " + m );
|
||||
|
||||
AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight );
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item",
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
@@ -55,9 +57,9 @@ public class IMCP2PAttunement implements IIMCProcessor
|
||||
if( is != null )
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
|
||||
else
|
||||
throw new RuntimeException( "invalid item" );
|
||||
throw new IllegalStateException( "invalid item in message " + m );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "invalid type" );
|
||||
throw new IllegalStateException( "invalid type in message " + m + " is not contained in " + Arrays.toString( TunnelType.values() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public enum AEFeature
|
||||
|
||||
DenseEnergyCells( "HigherCapacity" ), DenseCables( "HigherCapacity" ),
|
||||
|
||||
P2PTunnelRF( "P2PTunnels" ), P2PTunnelME( "P2PTunnels" ), P2PTunnelItems( "P2PTunnels" ), P2PTunnelRedstone( "P2PTunnels" ), P2PTunnelEU( "P2PTunnels" ), P2PTunnelMJ( "P2PTunnels" ), P2PTunnelLiquids( "P2PTunnels" ), P2PTunnelLight( "P2PTunnels" ),
|
||||
P2PTunnelRF( "P2PTunnels" ), P2PTunnelME( "P2PTunnels" ), P2PTunnelItems( "P2PTunnels" ), P2PTunnelRedstone( "P2PTunnels" ), P2PTunnelEU( "P2PTunnels" ), P2PTunnelLiquids( "P2PTunnels" ), P2PTunnelLight( "P2PTunnels" ),
|
||||
|
||||
MassCannonBlockDamage( "BlockFeatures" ), TinyTNTBlockDamage( "BlockFeatures" ), Facades( "Facades" ),
|
||||
|
||||
@@ -79,9 +79,7 @@ public enum AEFeature
|
||||
|
||||
AEFeature( String cat )
|
||||
{
|
||||
this.category = cat;
|
||||
this.isVisible = !this.name().equals( "Core" );
|
||||
this.defaultValue = true;
|
||||
this(cat, true);
|
||||
}
|
||||
|
||||
AEFeature( String cat, boolean defaultValue )
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Set;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
|
||||
public class FeaturedActiveChecker
|
||||
public final class FeaturedActiveChecker
|
||||
{
|
||||
private final Set<AEFeature> features;
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridCache;
|
||||
@@ -28,10 +30,9 @@ import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
public class GridCacheRegistry implements IGridCacheRegistry
|
||||
public final class GridCacheRegistry implements IGridCacheRegistry
|
||||
{
|
||||
|
||||
private final HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>>();
|
||||
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>>();
|
||||
|
||||
@Override
|
||||
public void registerGridCache( Class<? extends IGridCache> iface, Class<? extends IGridCache> implementation )
|
||||
@@ -39,7 +40,7 @@ public class GridCacheRegistry implements IGridCacheRegistry
|
||||
if( iface.isAssignableFrom( implementation ) )
|
||||
this.caches.put( iface, implementation );
|
||||
else
|
||||
throw new RuntimeException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements" );
|
||||
throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,15 +50,31 @@ public class GridCacheRegistry implements IGridCacheRegistry
|
||||
|
||||
for( Class<? extends IGridCache> iface : this.caches.keySet() )
|
||||
{
|
||||
Constructor<? extends IGridCache> c;
|
||||
try
|
||||
{
|
||||
Constructor<? extends IGridCache> c = this.caches.get( iface ).getConstructor( IGrid.class );
|
||||
c = this.caches.get( iface ).getConstructor( IGrid.class );
|
||||
map.put( iface, c.newInstance( g ) );
|
||||
}
|
||||
catch( Throwable e )
|
||||
catch( NoSuchMethodException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,9 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
@Override
|
||||
public void whiteListTileEntity( Class<? extends TileEntity> c )
|
||||
{
|
||||
|
||||
if( c.getName().equals( TileEntity.class.getName() ) )
|
||||
{
|
||||
throw new RuntimeException( new AppEngException( "Someone tried to make all tiles movable, this is a clear violation of the purpose of the white list." ) );
|
||||
throw new IllegalArgumentException( new AppEngException( "Someone tried to make all tiles movable with " + c + ", this is a clear violation of the purpose of the white list." ) );
|
||||
}
|
||||
|
||||
this.test.add( c );
|
||||
|
||||
@@ -44,7 +44,7 @@ public enum GuiText
|
||||
|
||||
CraftingTerminal, FormationPlane, Inscriber, QuartzCuttingKnife,
|
||||
|
||||
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel,
|
||||
METunnel, ItemTunnel, RedstoneTunnel, EUTunnel, FluidTunnel,
|
||||
|
||||
StoredSize, CopyMode, CopyModeDesc, PatternTerminal, CraftingPattern,
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ public enum TickRates
|
||||
|
||||
AnnihilationPlane( 2, 120 ),
|
||||
|
||||
MJTunnel( 1, 20 ),
|
||||
|
||||
METunnel( 5, 20 ),
|
||||
|
||||
Inscriber( 1, 1 ),
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class AppEngPacket
|
||||
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
|
||||
public final int getPacketID()
|
||||
@@ -50,7 +50,7 @@ public abstract class AppEngPacket
|
||||
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
|
||||
protected void configureWrite( ByteBuf data )
|
||||
|
||||
@@ -130,7 +130,7 @@ public class AppEngPacketHandlerBase
|
||||
REVERSE_LOOKUP.put( this.packetClass, this );
|
||||
|
||||
if( this.packetConstructor == null )
|
||||
throw new RuntimeException( "Invalid Packet Class, must be constructable on DataInputStream" );
|
||||
throw new IllegalStateException( "Invalid Packet Class " + c + ", must be constructable on DataInputStream" );
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket( int id )
|
||||
|
||||
@@ -228,10 +228,10 @@ public enum GuiBridge implements IGuiHandler
|
||||
String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" );
|
||||
|
||||
if( start.equals( guiClass ) )
|
||||
throw new RuntimeException( "Unable to find gui class" );
|
||||
throw new IllegalStateException( "Unable to find gui class" );
|
||||
this.Gui = ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass );
|
||||
if( this.Gui == null )
|
||||
throw new RuntimeException( "Cannot Load class: " + guiClass );
|
||||
throw new IllegalStateException( "Cannot Load class: " + guiClass );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ public enum GuiBridge implements IGuiHandler
|
||||
public boolean CorrectTileOrPart( Object tE )
|
||||
{
|
||||
if( this.Tile == null )
|
||||
throw new RuntimeException( "This Gui Cannot use the standard Handler." );
|
||||
throw new IllegalArgumentException( "This Gui Cannot use the standard Handler." );
|
||||
|
||||
return this.Tile.isInstance( tE );
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
throw new IllegalStateException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
Object o = target.newInstance( inventory, tE );
|
||||
@@ -364,7 +364,7 @@ public enum GuiBridge implements IGuiHandler
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,14 +462,14 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
throw new IllegalStateException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
return target.newInstance( inventory, tE );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,16 +31,17 @@ import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketConfigButton extends AppEngPacket
|
||||
public final class PacketConfigButton extends AppEngPacket
|
||||
{
|
||||
|
||||
public final Settings option;
|
||||
public final boolean rotationDirection;
|
||||
private final Settings option;
|
||||
private final boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
@Reflected
|
||||
public PacketConfigButton( ByteBuf stream )
|
||||
{
|
||||
this.option = Settings.values()[stream.readInt()];
|
||||
@@ -66,12 +67,15 @@ public class PacketConfigButton extends AppEngPacket
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||
if ( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
|
||||
Enum newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||
cm.putSetting( this.option, newState );
|
||||
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
|
||||
Enum<?> newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||
cm.putSetting( this.option, newState );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
{
|
||||
|
||||
if( Platform.isClient() )
|
||||
throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
|
||||
@@ -37,8 +37,11 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -53,6 +56,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
@@ -152,14 +156,14 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
|
||||
for( int x = 0; x < craftMatrix.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack PatternItem = testInv.getStackInSlot( x );
|
||||
ItemStack patternItem = testInv.getStackInSlot( x );
|
||||
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
if( currentItem != null )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, currentItem );
|
||||
ItemStack newItemStack = r.matches( testInv, pmp.worldObj ) ? r.getCraftingResult( testInv ) : null;
|
||||
testInv.setInventorySlotContents( x, PatternItem );
|
||||
testInv.setInventorySlotContents( x, patternItem );
|
||||
|
||||
if( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
|
||||
{
|
||||
@@ -178,10 +182,10 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
}
|
||||
|
||||
// True if we need to fetch an item for the recipe
|
||||
if( PatternItem != null && currentItem == null )
|
||||
if( patternItem != null && currentItem == null )
|
||||
{
|
||||
// Grab from network by recipe
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), storage, player.worldObj, r, is, testInv, PatternItem, x, all, realForFake, filter );
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), storage, player.worldObj, r, is, testInv, patternItem, x, all, realForFake, filter );
|
||||
|
||||
// If that doesn't get it, grab exact items from network (?)
|
||||
// TODO see if this code is necessary
|
||||
@@ -209,28 +213,7 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
// If that doesn't work, grab from the player's inventory
|
||||
if( whichItem == null && playerInventory != null )
|
||||
{
|
||||
for( int y = 0; y < this.recipe[x].length; y++ )
|
||||
{
|
||||
ItemStack playerItemStack = null;
|
||||
for( int i = 0; i < playerInventory.getSizeInventory(); i++ )
|
||||
{
|
||||
// check if the item in slot y matches the required item.
|
||||
playerItemStack = playerInventory.getStackInSlot( i );
|
||||
if( playerItemStack != null && this.recipe[x][y] != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
|
||||
{
|
||||
if( realForFake == Actionable.SIMULATE )
|
||||
{
|
||||
whichItem = playerInventory.getStackInSlot( i ).copy();
|
||||
whichItem.stackSize = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
whichItem = playerInventory.decrStackSize( i, 1 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
whichItem = extractItemFromPlayerInventory( player, realForFake, patternItem );
|
||||
}
|
||||
|
||||
craftMatrix.setInventorySlotContents( x, whichItem );
|
||||
@@ -243,4 +226,43 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to extract an item from the player inventory. Does account for fuzzy items.
|
||||
*
|
||||
* @param player the {@link EntityPlayer} to extract from
|
||||
* @param mode the {@link Actionable} to simulate or modulate the operation
|
||||
* @param patternItem which {@link ItemStack} to extract
|
||||
* @return null or a found {@link ItemStack}
|
||||
*/
|
||||
private ItemStack extractItemFromPlayerInventory( EntityPlayer player, Actionable mode, ItemStack patternItem )
|
||||
{
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
|
||||
final AEItemStack request = AEItemStack.create( patternItem );
|
||||
final boolean isSimulated = mode == Actionable.SIMULATE;
|
||||
final boolean checkFuzzy = request.isOre() || patternItem.getItemDamage() == OreDictionary.WILDCARD_VALUE || patternItem.hasTagCompound() || patternItem.isItemStackDamageable();
|
||||
|
||||
if( !checkFuzzy )
|
||||
{
|
||||
if( isSimulated )
|
||||
{
|
||||
return ia.simulateRemove( 1, patternItem, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ia.removeItems( 1, patternItem, null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isSimulated )
|
||||
{
|
||||
return ia.simulateSimilarRemove( 1, patternItem, FuzzyMode.IGNORE_ALL, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ia.removeSimilarItems( 1, patternItem, FuzzyMode.IGNORE_ALL, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
catch( Throwable t )
|
||||
{
|
||||
this.finish();
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
|
||||
this.finish();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class CraftingLink implements ICraftingLink
|
||||
this.standalone = data.getBoolean( "standalone" );
|
||||
|
||||
if( !data.hasKey( "req" ) || !data.getBoolean( "req" ) )
|
||||
throw new RuntimeException( "Invalid Crafting Link for Object" );
|
||||
throw new IllegalStateException( "Invalid Crafting Link for Object" );
|
||||
|
||||
this.req = req;
|
||||
this.cpu = null;
|
||||
@@ -61,7 +61,7 @@ public class CraftingLink implements ICraftingLink
|
||||
this.standalone = data.getBoolean( "standalone" );
|
||||
|
||||
if( !data.hasKey( "req" ) || data.getBoolean( "req" ) )
|
||||
throw new RuntimeException( "Invalid Crafting Link for Object" );
|
||||
throw new IllegalStateException( "Invalid Crafting Link for Object" );
|
||||
|
||||
this.cpu = cpu;
|
||||
this.req = null;
|
||||
|
||||
@@ -264,7 +264,7 @@ public class CraftingTreeProcess
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException( "Crafting Tree construction failed." );
|
||||
throw new IllegalStateException( "Crafting Tree construction failed." );
|
||||
}
|
||||
|
||||
public void setSimulate()
|
||||
|
||||
@@ -44,6 +44,6 @@ public final class EntityIds
|
||||
if( droppedEntity == EntityGrowingCrystal.class )
|
||||
return GROWING_CRYSTAL;
|
||||
|
||||
throw new RuntimeException( "Missing entity id: " + droppedEntity.getName() );
|
||||
throw new IllegalStateException( "Missing entity id: " + droppedEntity.getName() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class FacadePart implements IFacadePart, IBoxProvider
|
||||
public FacadePart( ItemStack facade, ForgeDirection side )
|
||||
{
|
||||
if( facade == null )
|
||||
throw new RuntimeException( "Facade Part constructed on null item." );
|
||||
throw new IllegalArgumentException( "Facade Part constructed on null item." );
|
||||
this.facade = facade.copy();
|
||||
this.facade.stackSize = 1;
|
||||
this.side = side;
|
||||
|
||||
@@ -54,7 +54,8 @@ public enum PartRegistry
|
||||
return pr.name;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException( "Invalid PartName" );
|
||||
|
||||
throw new IllegalStateException( "Invalid PartName" );
|
||||
}
|
||||
|
||||
public static TMultiPart getPartByBlock( Block block, int meta )
|
||||
@@ -74,13 +75,13 @@ public enum PartRegistry
|
||||
try
|
||||
{
|
||||
if( this == CableBusPart )
|
||||
return (TMultiPart) Api.INSTANCE.getPartHelper().getCombinedInstance( this.part.getName() ).newInstance();
|
||||
return (TMultiPart) Api.INSTANCE.partHelper().getCombinedInstance( this.part.getName() ).newInstance();
|
||||
else
|
||||
return this.part.getConstructor( int.class ).newInstance( meta );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
@@ -100,13 +101,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
|
||||
static final Set<Block> badBlocks = new HashSet<Block>();
|
||||
private static boolean interfaceRequest = false;
|
||||
final int[] sides = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
final IAEItemStack[] requireWork = new IAEItemStack[] { null, null, null, null, null, null, null, null };
|
||||
final MultiCraftingTracker craftingTracker;
|
||||
final AENetworkProxy gridProxy;
|
||||
final IInterfaceHost iHost;
|
||||
final BaseActionSource mySrc;
|
||||
final BaseActionSource mySource;
|
||||
final BaseActionSource interfaceRequestSource;
|
||||
final ConfigManager cm = new ConfigManager( this );
|
||||
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 8 );
|
||||
final AppEngInternalInventory storage = new AppEngInternalInventory( this, 8 );
|
||||
@@ -133,7 +134,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
this.iHost = ih;
|
||||
this.craftingTracker = new MultiCraftingTracker( this.iHost, 9 );
|
||||
this.mySrc = this.fluids.changeSource = this.items.changeSource = new MachineSource( this.iHost );
|
||||
this.mySource = this.fluids.changeSource = this.items.changeSource = new MachineSource( this.iHost );
|
||||
this.interfaceRequestSource = new InterfaceRequestSource( this.iHost );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -371,7 +373,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // Stored != null; dispose!
|
||||
else
|
||||
// Stored != null; dispose!
|
||||
{
|
||||
IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
|
||||
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
|
||||
@@ -507,7 +510,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return TickRateModulation.SLEEP;
|
||||
|
||||
if( this.hasItemsToSend() )
|
||||
this.pushItemsOut( EnumSet.allOf( ForgeDirection.class ) );
|
||||
this.pushItemsOut( this.iHost.getTargets() );
|
||||
|
||||
boolean couldDoWork = this.updateStorage();
|
||||
return this.hasWorkToDo() ? ( couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER ) : TickRateModulation.SLEEP;
|
||||
@@ -574,7 +577,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
boolean changed = false;
|
||||
InventoryAdaptor adaptor = this.getAdaptor( x );
|
||||
interfaceRequest = this.isWorking = true;
|
||||
this.isWorking = true;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -592,13 +595,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
throw new GridAccessException();
|
||||
}
|
||||
|
||||
IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.mySrc );
|
||||
IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.interfaceRequestSource );
|
||||
if( acquired != null )
|
||||
{
|
||||
changed = true;
|
||||
ItemStack issue = adaptor.addItems( acquired.getItemStack() );
|
||||
if( issue != null )
|
||||
throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" );
|
||||
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
|
||||
}
|
||||
else
|
||||
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
|
||||
@@ -618,7 +621,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
throw new GridAccessException();
|
||||
}
|
||||
|
||||
toStore = Platform.poweredInsert( src, this.destination, toStore, this.mySrc );
|
||||
toStore = Platform.poweredInsert( src, this.destination, toStore, this.interfaceRequestSource );
|
||||
|
||||
if( toStore != null )
|
||||
diff -= toStore.getStackSize();
|
||||
@@ -629,9 +632,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
changed = true;
|
||||
ItemStack removed = adaptor.removeItems( (int) diff, null, null );
|
||||
if( removed == null )
|
||||
throw new RuntimeException( "bad attempt at managing inventory. ( removeItems )" );
|
||||
throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" );
|
||||
else if( removed.stackSize != diff )
|
||||
throw new RuntimeException( "bad attempt at managing inventory. ( removeItems )" );
|
||||
throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" );
|
||||
}
|
||||
}
|
||||
// else wtf?
|
||||
@@ -644,7 +647,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
if( changed )
|
||||
this.updatePlan( x );
|
||||
|
||||
interfaceRequest = this.isWorking = false;
|
||||
this.isWorking = false;
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -659,7 +662,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null )
|
||||
{
|
||||
return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorldObj(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySrc );
|
||||
return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorldObj(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
@@ -734,7 +737,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
this.cancelCrafting();
|
||||
|
||||
this.markDirty();
|
||||
} @Override
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||
{
|
||||
if( this.hasConfig() )
|
||||
@@ -825,7 +830,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
ItemStack is = table.getStackInSlot( x );
|
||||
if( is != null )
|
||||
{
|
||||
this.addToSendList( ad.addItems( is ) );
|
||||
final ItemStack added = ad.addItems( is );
|
||||
this.addToSendList( added );
|
||||
}
|
||||
}
|
||||
this.pushItemsOut( possibleDirections );
|
||||
@@ -1095,8 +1101,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
}
|
||||
|
||||
private class InterfaceRequestSource extends MachineSource
|
||||
{
|
||||
|
||||
class InterfaceInventory extends MEMonitorIInventory
|
||||
public InterfaceRequestSource( IActionHost v )
|
||||
{
|
||||
super( v );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class InterfaceInventory extends MEMonitorIInventory
|
||||
{
|
||||
|
||||
public InterfaceInventory( DualityInterface tileInterface )
|
||||
@@ -1108,7 +1123,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
@Override
|
||||
public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src )
|
||||
{
|
||||
if( interfaceRequest )
|
||||
if( src instanceof InterfaceRequestSource )
|
||||
return input;
|
||||
|
||||
return super.injectItems( input, type, src );
|
||||
@@ -1117,12 +1132,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
@Override
|
||||
public IAEItemStack extractItems( IAEItemStack request, Actionable type, BaseActionSource src )
|
||||
{
|
||||
if( interfaceRequest )
|
||||
if( src instanceof InterfaceRequestSource )
|
||||
return null;
|
||||
|
||||
return super.extractItems( request, type, src );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +68,6 @@ public class MetaRotation implements IOrientable
|
||||
if( this.w instanceof World )
|
||||
( (World) this.w ).setBlockMetadataWithNotify( this.x, this.y, this.z, Up.ordinal(), 1 + 2 );
|
||||
else
|
||||
throw new RuntimeException( this.w.getClass().getName() + " received, expected World" );
|
||||
throw new IllegalStateException( this.w.getClass().getName() + " received, expected World" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
NBTTagCompound encodedValue = is.getTagCompound();
|
||||
|
||||
if( encodedValue == null )
|
||||
throw new RuntimeException( "No pattern here!" );
|
||||
throw new IllegalArgumentException( "No pattern here!" );
|
||||
|
||||
NBTTagList inTag = encodedValue.getTagList( "in", 10 );
|
||||
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
|
||||
@@ -99,7 +99,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
out.add( AEApi.instance().storage().createItemStack( this.correctOutput ) );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "No pattern here!" );
|
||||
throw new IllegalStateException( "No pattern here!" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,7 +144,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
}
|
||||
|
||||
if( tmpOutputs.isEmpty() || tmpInputs.isEmpty() )
|
||||
throw new RuntimeException( "No pattern here!" );
|
||||
throw new IllegalStateException( "No pattern here!" );
|
||||
|
||||
int offset = 0;
|
||||
this.condensedInputs = new IAEItemStack[tmpInputs.size()];
|
||||
@@ -182,7 +182,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
{
|
||||
if( !this.isCrafting )
|
||||
{
|
||||
throw new RuntimeException( "Only crafting recipes supported." );
|
||||
throw new IllegalStateException( "Only crafting recipes supported." );
|
||||
}
|
||||
|
||||
TestStatus result = this.getStatus( slotIndex, i );
|
||||
@@ -270,7 +270,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
public ItemStack getOutput( InventoryCrafting craftingInv, World w )
|
||||
{
|
||||
if( !this.isCrafting )
|
||||
throw new RuntimeException( "Only crafting recipes supported." );
|
||||
throw new IllegalStateException( "Only crafting recipes supported." );
|
||||
|
||||
for( int x = 0; x < craftingInv.getSizeInventory(); x++ )
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
||||
* Marker interface to help identify invocation of reflection
|
||||
*/
|
||||
@Retention( RetentionPolicy.SOURCE )
|
||||
@Target( { ElementType.CONSTRUCTOR, ElementType.FIELD } )
|
||||
@Target( { ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE } )
|
||||
public @interface Reflected
|
||||
{
|
||||
|
||||
|
||||
@@ -22,13 +22,14 @@ package appeng.integration;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
|
||||
import appeng.api.exceptions.ModNotInstalled;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
public class IntegrationNode
|
||||
public final class IntegrationNode
|
||||
{
|
||||
|
||||
final String displayName;
|
||||
@@ -59,12 +60,12 @@ public class IntegrationNode
|
||||
public boolean isActive()
|
||||
{
|
||||
if( this.state == IntegrationStage.PRE_INIT )
|
||||
this.Call( IntegrationStage.PRE_INIT );
|
||||
this.call( IntegrationStage.PRE_INIT );
|
||||
|
||||
return this.state != IntegrationStage.FAILED;
|
||||
}
|
||||
|
||||
void Call( IntegrationStage stage )
|
||||
void call( IntegrationStage stage )
|
||||
{
|
||||
if( this.state != IntegrationStage.FAILED )
|
||||
{
|
||||
@@ -76,15 +77,15 @@ public class IntegrationNode
|
||||
switch( stage )
|
||||
{
|
||||
case PRE_INIT:
|
||||
|
||||
boolean enabled = this.modID == null || Loader.isModLoaded( this.modID );
|
||||
final ModAPIManager apiManager = ModAPIManager.INSTANCE;
|
||||
boolean enabled = this.modID == null || Loader.isModLoaded( this.modID ) || apiManager.hasAPI( this.modID );
|
||||
|
||||
AEConfig.instance.addCustomCategoryComment( "ModIntegration", "Valid Values are 'AUTO', 'ON', or 'OFF' - defaults to 'AUTO' ; Suggested that you leave this alone unless your experiencing an issue, or wish to disable the integration for a reason." );
|
||||
String Mode = AEConfig.instance.get( "ModIntegration", this.displayName.replace( " ", "" ), "AUTO" ).getString();
|
||||
String mode = AEConfig.instance.get( "ModIntegration", this.displayName.replace( " ", "" ), "AUTO" ).getString();
|
||||
|
||||
if( Mode.toUpperCase().equals( "ON" ) )
|
||||
if( mode.toUpperCase().equals( "ON" ) )
|
||||
enabled = true;
|
||||
if( Mode.toUpperCase().equals( "OFF" ) )
|
||||
if( mode.toUpperCase().equals( "OFF" ) )
|
||||
enabled = false;
|
||||
|
||||
if( enabled )
|
||||
|
||||
@@ -46,16 +46,16 @@ public enum IntegrationRegistry
|
||||
public void init()
|
||||
{
|
||||
for( IntegrationNode node : this.modules )
|
||||
node.Call( IntegrationStage.PRE_INIT );
|
||||
node.call( IntegrationStage.PRE_INIT );
|
||||
|
||||
for( IntegrationNode node : this.modules )
|
||||
node.Call( IntegrationStage.INIT );
|
||||
node.call( IntegrationStage.INIT );
|
||||
}
|
||||
|
||||
public void postInit()
|
||||
{
|
||||
for( IntegrationNode node : this.modules )
|
||||
node.Call( IntegrationStage.POST_INIT );
|
||||
node.call( IntegrationStage.POST_INIT );
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
@@ -95,7 +95,8 @@ public enum IntegrationRegistry
|
||||
return node.instance;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException( "integration with " + name.name() + " is disabled." );
|
||||
|
||||
throw new IllegalStateException( "integration with " + name.name() + " is disabled." );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,13 +29,9 @@ public enum IntegrationType
|
||||
|
||||
BC( IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon" ),
|
||||
|
||||
MJ6( IntegrationSide.BOTH, "BuildCraft6 Power", null ),
|
||||
RF( IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", "CoFHAPI" ),
|
||||
|
||||
MJ5( IntegrationSide.BOTH, "BuildCraft5 Power", null ),
|
||||
|
||||
RF( IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", null ),
|
||||
|
||||
RFItem( IntegrationSide.BOTH, "RedstoneFlux Power - Items", null ),
|
||||
RFItem( IntegrationSide.BOTH, "RedstoneFlux Power - Items", "CoFHAPI" ),
|
||||
|
||||
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded" ),
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class InvTweaks extends BaseModule implements IInvTweaks
|
||||
public void postInit()
|
||||
{
|
||||
if( api == null )
|
||||
throw new RuntimeException( "InvTweaks API Instance Failed." );
|
||||
throw new IllegalStateException( "InvTweaks API Instance Failed." );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,7 +146,7 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( "Invalid version of NEI, please update", t );
|
||||
throw new IllegalStateException( "Invalid version of NEI, please update", t );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,8 +147,8 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
|
||||
if( cachedRecipe.hasOptional )
|
||||
{
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( cachedRecipe.Chance );
|
||||
fr.drawString( cachedRecipe.Chance, ( 168 - width ) / 2, 5, 0 );
|
||||
int width = fr.getStringWidth( cachedRecipe.displayChance );
|
||||
fr.drawString( cachedRecipe.displayChance, ( 168 - width ) / 2, 5, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,10 +186,9 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
|
||||
|
||||
public class CachedGrindStoneRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public final ArrayList<PositionedStack> ingredients;
|
||||
public final List<PositionedStack> ingredients;
|
||||
public final PositionedStack result;
|
||||
public String Chance;
|
||||
public String displayChance;
|
||||
boolean hasOptional = false;
|
||||
|
||||
public CachedGrindStoneRecipe( IGrinderEntry recipe )
|
||||
@@ -199,8 +198,10 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
|
||||
|
||||
if( recipe.getOptionalOutput() != null )
|
||||
{
|
||||
final int chancePercent = (int) (recipe.getOptionalChance() * 100);
|
||||
|
||||
this.hasOptional = true;
|
||||
this.Chance = ( (int) ( recipe.getOptionalChance() * 100 ) ) + GuiText.OfSecondOutput.getLocal();
|
||||
this.displayChance = String.format( GuiText.OfSecondOutput.getLocal(), chancePercent );
|
||||
this.ingredients.add( new PositionedStack( recipe.getOptionalOutput(), -30 + 107 + 18, 47 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -187,9 +187,13 @@ public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler
|
||||
{
|
||||
return this.getClass().newInstance();
|
||||
}
|
||||
catch( Exception e )
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ public abstract class AEBaseItem extends Item implements IAEFeature
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation )
|
||||
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayMoreInfo )
|
||||
{
|
||||
this.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
this.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,8 +89,8 @@ public abstract class AEBaseItem extends Item implements IAEFeature
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
super.addInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addInformation( stack, player, lines, displayMoreInfo );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
|
||||
MaterialType mt = this.getTypeByStack( stack );
|
||||
if( mt == null )
|
||||
@@ -179,7 +179,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
if( this.dmgToMaterial.get( newMaterialNum ) == null )
|
||||
this.dmgToMaterial.put( newMaterialNum, mat );
|
||||
else
|
||||
throw new RuntimeException( "Meta Overlap detected." );
|
||||
throw new IllegalStateException( "Meta Overlap detected." );
|
||||
|
||||
return mat.stackSrc;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
return mat.stackSrc;
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Cannot create the same material twice..." );
|
||||
throw new IllegalStateException( "Cannot create the same material twice..." );
|
||||
}
|
||||
|
||||
public void makeUnique()
|
||||
@@ -359,7 +359,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
|
||||
eqi.motionX = location.motionX;
|
||||
|
||||
@@ -162,13 +162,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
lines.add( ButtonToolTips.DoesntDespawn.getLocal() );
|
||||
int progress = this.getProgress( stack ) % SINGLE_OFFSET;
|
||||
lines.add( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" );
|
||||
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
ICraftingPatternDetails details = this.getPatternForItem( stack, player.worldObj );
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -28,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -41,6 +43,8 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.parts.IPart;
|
||||
@@ -48,119 +52,104 @@ import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.core.features.NameResolver;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
|
||||
public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
{
|
||||
public static ItemMultiPart instance;
|
||||
private final NameResolver nameResolver;
|
||||
private final Map<Integer, PartTypeIst> dmgToPart = new HashMap<Integer, PartTypeIst>();
|
||||
private final Map<Integer, PartTypeWithVariant> registered;
|
||||
private final Map<Integer, PartTypeWithVariant> unregistered;
|
||||
|
||||
public ItemMultiPart( IPartHelper partHelper )
|
||||
{
|
||||
Preconditions.checkNotNull( partHelper );
|
||||
|
||||
this.registered = new HashMap<Integer, PartTypeWithVariant>();
|
||||
this.unregistered = new HashMap<Integer, PartTypeWithVariant>();
|
||||
|
||||
this.nameResolver = new NameResolver( this.getClass() );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
partHelper.setItemBusRenderer( this );
|
||||
this.setHasSubtypes( true );
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final ItemStackSrc createPart( PartType mat )
|
||||
{
|
||||
int varID = 0;
|
||||
Preconditions.checkNotNull( mat );
|
||||
|
||||
return this.createPart( mat, 0 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStackSrc createPart( PartType mat, AEColor color )
|
||||
{
|
||||
Preconditions.checkNotNull( mat );
|
||||
Preconditions.checkNotNull( color );
|
||||
|
||||
final int varID = color.ordinal();
|
||||
|
||||
return this.createPart( mat, varID );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ItemStackSrc createPart( PartType mat, int varID )
|
||||
{
|
||||
assert mat != null;
|
||||
assert varID >= 0;
|
||||
|
||||
// verify
|
||||
for( PartTypeIst p : this.dmgToPart.values() )
|
||||
for( PartTypeWithVariant p : this.registered.values() )
|
||||
{
|
||||
if( p.part == mat && p.variant == varID )
|
||||
throw new RuntimeException( "Cannot create the same material twice..." );
|
||||
throw new IllegalStateException( "Cannot create the same material twice..." );
|
||||
}
|
||||
|
||||
boolean enabled = true;
|
||||
for( AEFeature f : mat.getFeature() )
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
int newPartNum = mat.baseDamage + varID;
|
||||
ItemStackSrc output = new ItemStackSrc( this, newPartNum );
|
||||
for( IntegrationType integrationType : mat.getIntegrations() )
|
||||
enabled &= IntegrationRegistry.INSTANCE.isEnabled( integrationType );
|
||||
|
||||
if( enabled )
|
||||
{
|
||||
PartTypeIst pti = new PartTypeIst();
|
||||
pti.part = mat;
|
||||
pti.variant = varID;
|
||||
final int partDamage = mat.baseDamage + varID;
|
||||
final ItemStackSrc output = new ItemStackSrc( this, partDamage );
|
||||
|
||||
if( this.dmgToPart.get( newPartNum ) == null )
|
||||
{
|
||||
this.dmgToPart.put( newPartNum, pti );
|
||||
return output;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException( "Meta Overlap detected." );
|
||||
}
|
||||
}
|
||||
final PartTypeWithVariant pti = new PartTypeWithVariant( mat, varID );
|
||||
|
||||
this.processMetaOverlap( enabled, partDamage, mat, pti );
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public ItemStackSrc createPart( PartType mat, Enum variant )
|
||||
private void processMetaOverlap( boolean enabled, int partDamage, PartType mat, PartTypeWithVariant pti )
|
||||
{
|
||||
try
|
||||
{
|
||||
// I think this still works?
|
||||
ItemStack is = new ItemStack( this );
|
||||
mat.getPart().getConstructor( ItemStack.class ).newInstance( is );
|
||||
}
|
||||
catch( Throwable e )
|
||||
{
|
||||
AELog.integration( e );
|
||||
e.printStackTrace();
|
||||
return null; // part not supported..
|
||||
}
|
||||
assert partDamage >= 0;
|
||||
assert mat != null;
|
||||
assert pti != null;
|
||||
|
||||
int varID = variant == null ? 0 : variant.ordinal();
|
||||
final Map<Integer, PartTypeWithVariant> reference = ( enabled ) ? this.registered : this.unregistered;
|
||||
if( reference.containsKey( partDamage ) )
|
||||
throw new IllegalStateException( "Meta Overlap detected with type " + mat + " and damage " + partDamage + ". Found " + reference.get( partDamage ) + " there already." );
|
||||
|
||||
// verify
|
||||
for( PartTypeIst p : this.dmgToPart.values() )
|
||||
{
|
||||
if( p.part == mat && p.variant == varID )
|
||||
throw new RuntimeException( "Cannot create the same material twice..." );
|
||||
}
|
||||
|
||||
boolean enabled = true;
|
||||
for( AEFeature f : mat.getFeature() )
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
if( enabled )
|
||||
{
|
||||
int newPartNum = mat.baseDamage + varID;
|
||||
ItemStackSrc output = new ItemStackSrc( this, newPartNum );
|
||||
|
||||
PartTypeIst pti = new PartTypeIst();
|
||||
pti.part = mat;
|
||||
pti.variant = varID;
|
||||
|
||||
if( this.dmgToPart.get( newPartNum ) == null )
|
||||
{
|
||||
this.dmgToPart.put( newPartNum, pti );
|
||||
return output;
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Meta Overlap detected." );
|
||||
}
|
||||
|
||||
return null;
|
||||
reference.put( partDamage, pti );
|
||||
}
|
||||
|
||||
public int getDamageByType( PartType t )
|
||||
{
|
||||
for( Entry<Integer, PartTypeIst> pt : this.dmgToPart.entrySet() )
|
||||
Preconditions.checkNotNull( t );
|
||||
|
||||
for( Entry<Integer, PartTypeWithVariant> pt : this.registered.entrySet() )
|
||||
{
|
||||
if( pt.getValue().part == t )
|
||||
return pt.getKey();
|
||||
@@ -178,7 +167,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
@Override
|
||||
public IIcon getIconFromDamage( int dmg )
|
||||
{
|
||||
return this.dmgToPart.get( dmg ).ico;
|
||||
return this.registered.get( dmg ).ico;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,36 +182,16 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
return "item.appliedenergistics2." + this.getName( is );
|
||||
}
|
||||
|
||||
public String getName( ItemStack is )
|
||||
{
|
||||
return this.nameResolver.getName( this.getTypeByStack( is ).name() );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PartType getTypeByStack( ItemStack is )
|
||||
{
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
PartTypeIst pt = this.dmgToPart.get( is.getItemDamage() );
|
||||
if( pt != null )
|
||||
return pt.part;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName( ItemStack is )
|
||||
{
|
||||
PartType pt = this.getTypeByStack( is );
|
||||
if( pt == null )
|
||||
return "Unnamed";
|
||||
final PartType pt = this.getTypeByStack( is );
|
||||
|
||||
if( pt.isCable() )
|
||||
{
|
||||
final AEColor[] variants = AEColor.values();
|
||||
|
||||
return super.getItemStackDisplayName( is ) + " - " + variants[this.dmgToPart.get( is.getItemDamage() ).variant].toString();
|
||||
return super.getItemStackDisplayName( is ) + " - " + variants[this.registered.get( is.getItemDamage() ).variant].toString();
|
||||
}
|
||||
|
||||
if( pt.getExtraName() != null )
|
||||
@@ -234,59 +203,96 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
@Override
|
||||
public void getSubItems( Item number, CreativeTabs tab, List cList )
|
||||
{
|
||||
List<Entry<Integer, PartTypeIst>> types = new ArrayList<Entry<Integer, PartTypeIst>>( this.dmgToPart.entrySet() );
|
||||
Collections.sort( types, new Comparator<Entry<Integer, PartTypeIst>>()
|
||||
List<Entry<Integer, PartTypeWithVariant>> types = new ArrayList<Entry<Integer, PartTypeWithVariant>>( this.registered.entrySet() );
|
||||
Collections.sort( types, new Comparator<Entry<Integer, PartTypeWithVariant>>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare( Entry<Integer, PartTypeIst> o1, Entry<Integer, PartTypeIst> o2 )
|
||||
public int compare( Entry<Integer, PartTypeWithVariant> o1, Entry<Integer, PartTypeWithVariant> o2 )
|
||||
{
|
||||
return o1.getValue().part.name().compareTo( o2.getValue().part.name() );
|
||||
}
|
||||
} );
|
||||
|
||||
for( Entry<Integer, PartTypeIst> part : types )
|
||||
for( Entry<Integer, PartTypeWithVariant> part : types )
|
||||
cList.add( new ItemStack( this, 1, part.getKey() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons( IIconRegister par1IconRegister )
|
||||
{
|
||||
for( Entry<Integer, PartTypeIst> part : this.dmgToPart.entrySet() )
|
||||
for( Entry<Integer, PartTypeWithVariant> part : this.registered.entrySet() )
|
||||
{
|
||||
String tex = "appliedenergistics2:" + this.getName( new ItemStack( this, 1, part.getKey() ) );
|
||||
part.getValue().ico = par1IconRegister.registerIcon( tex );
|
||||
}
|
||||
}
|
||||
|
||||
public String getName( ItemStack is )
|
||||
{
|
||||
Preconditions.checkNotNull( is );
|
||||
|
||||
final PartType stackType = this.getTypeByStack( is );
|
||||
final String typeName = stackType.name();
|
||||
|
||||
return this.nameResolver.getName( typeName );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public PartType getTypeByStack( ItemStack is )
|
||||
{
|
||||
Preconditions.checkNotNull( is );
|
||||
|
||||
final PartTypeWithVariant pt = this.registered.get( is.getItemDamage() );
|
||||
if( pt != null )
|
||||
return pt.part;
|
||||
final PartTypeWithVariant unregisteredPartType = this.unregistered.get( is.getItemDamage() );
|
||||
if( unregisteredPartType != null )
|
||||
return unregisteredPartType.part;
|
||||
|
||||
throw new IllegalStateException( "ItemStack " + is + " has to be either registered or unregistered, but was not found in either." );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IPart createPartFromItemStack( ItemStack is )
|
||||
{
|
||||
final PartType type = this.getTypeByStack( is );
|
||||
final Class<? extends IPart> part = type.getPart();
|
||||
|
||||
try
|
||||
{
|
||||
PartType t = this.getTypeByStack( is );
|
||||
if( t != null )
|
||||
{
|
||||
if( t.constructor == null )
|
||||
t.constructor = t.getPart().getConstructor( ItemStack.class );
|
||||
if( type.constructor == null )
|
||||
type.constructor = part.getConstructor( ItemStack.class );
|
||||
|
||||
return t.constructor.newInstance( is );
|
||||
}
|
||||
return type.constructor.newInstance( is );
|
||||
}
|
||||
catch( Throwable e )
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
throw new RuntimeException( "Unable to construct IBusPart from IBusItem : " + this.getTypeByStack( is ).getPart().getName() + " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
throw new IllegalStateException( "Unable to construct IBusPart from IBusItem : " + part.getName() + " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to construct IBusPart from IBusItem : " + part.getName() + " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to construct IBusPart from IBusItem : " + part.getName() + " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
}
|
||||
catch( NoSuchMethodException e )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to construct IBusPart from IBusItem : " + part.getName() + " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int variantOf( int itemDamage )
|
||||
{
|
||||
if( this.dmgToPart.containsKey( itemDamage ) )
|
||||
return this.dmgToPart.get( itemDamage ).variant;
|
||||
if( this.registered.containsKey( itemDamage ) )
|
||||
return this.registered.get( itemDamage ).variant;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
@@ -301,22 +307,19 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
if( stack.getItem() == this )
|
||||
{
|
||||
PartType pt = this.getTypeByStack( stack );
|
||||
if ( pt != null )
|
||||
switch( pt )
|
||||
{
|
||||
switch( pt )
|
||||
{
|
||||
case ImportBus:
|
||||
importBus = true;
|
||||
if( u == pt )
|
||||
group = true;
|
||||
break;
|
||||
case ExportBus:
|
||||
exportBus = true;
|
||||
if( u == pt )
|
||||
group = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
case ImportBus:
|
||||
importBus = true;
|
||||
if( u == pt )
|
||||
group = true;
|
||||
break;
|
||||
case ExportBus:
|
||||
exportBus = true;
|
||||
if( u == pt )
|
||||
group = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,17 +330,21 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getStackFromTypeAndVariant( PartType mt, int variant )
|
||||
private static final class PartTypeWithVariant
|
||||
{
|
||||
return new ItemStack( this, 1, mt.baseDamage + variant );
|
||||
}
|
||||
|
||||
private static class PartTypeIst
|
||||
{
|
||||
private PartType part;
|
||||
private int variant;
|
||||
private final PartType part;
|
||||
private final int variant;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IIcon ico;
|
||||
|
||||
private PartTypeWithVariant( PartType part, int variant )
|
||||
{
|
||||
assert part != null;
|
||||
assert variant >= 0;
|
||||
|
||||
this.part = part;
|
||||
this.variant = variant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@ package appeng.items.parts;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.parts.automation.PartAnnihilationPlane;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
@@ -60,9 +63,9 @@ import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public enum PartType
|
||||
{
|
||||
InvalidType( -1, EnumSet.of( AEFeature.Core ), null ),
|
||||
InvalidType( -1, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), null ),
|
||||
|
||||
CableGlass( 0, EnumSet.of( AEFeature.Core ), PartCableGlass.class )
|
||||
CableGlass( 0, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartCableGlass.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
@@ -71,7 +74,7 @@ public enum PartType
|
||||
}
|
||||
},
|
||||
|
||||
CableCovered( 20, EnumSet.of( AEFeature.Core ), PartCableCovered.class )
|
||||
CableCovered( 20, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartCableCovered.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
@@ -80,7 +83,7 @@ public enum PartType
|
||||
}
|
||||
},
|
||||
|
||||
CableSmart( 40, EnumSet.of( AEFeature.Channels ), PartCableSmart.class )
|
||||
CableSmart( 40, EnumSet.of( AEFeature.Channels ), EnumSet.noneOf( IntegrationType.class ), PartCableSmart.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
@@ -89,7 +92,7 @@ public enum PartType
|
||||
}
|
||||
},
|
||||
|
||||
CableDense( 60, EnumSet.of( AEFeature.Channels ), PartDenseCable.class )
|
||||
CableDense( 60, EnumSet.of( AEFeature.Channels ), EnumSet.noneOf( IntegrationType.class ), PartDenseCable.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
@@ -98,74 +101,76 @@ public enum PartType
|
||||
}
|
||||
},
|
||||
|
||||
ToggleBus( 80, EnumSet.of( AEFeature.Core ), PartToggleBus.class ),
|
||||
ToggleBus( 80, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartToggleBus.class ),
|
||||
|
||||
InvertedToggleBus( 100, EnumSet.of( AEFeature.Core ), PartInvertedToggleBus.class ),
|
||||
InvertedToggleBus( 100, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartInvertedToggleBus.class ),
|
||||
|
||||
CableAnchor( 120, EnumSet.of( AEFeature.Core ), PartCableAnchor.class ),
|
||||
CableAnchor( 120, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartCableAnchor.class ),
|
||||
|
||||
QuartzFiber( 140, EnumSet.of( AEFeature.Core ), PartQuartzFiber.class ),
|
||||
QuartzFiber( 140, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartQuartzFiber.class ),
|
||||
|
||||
Monitor( 160, EnumSet.of( AEFeature.Core ), PartMonitor.class ),
|
||||
Monitor( 160, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartMonitor.class ),
|
||||
|
||||
SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), PartSemiDarkMonitor.class ),
|
||||
SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartSemiDarkMonitor.class ),
|
||||
|
||||
DarkMonitor( 200, EnumSet.of( AEFeature.Core ), PartDarkMonitor.class ),
|
||||
DarkMonitor( 200, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartDarkMonitor.class ),
|
||||
|
||||
StorageBus( 220, EnumSet.of( AEFeature.StorageBus ), PartStorageBus.class ),
|
||||
StorageBus( 220, EnumSet.of( AEFeature.StorageBus ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ),
|
||||
|
||||
ImportBus( 240, EnumSet.of( AEFeature.ImportBus ), PartImportBus.class ),
|
||||
ImportBus( 240, EnumSet.of( AEFeature.ImportBus ), EnumSet.noneOf( IntegrationType.class ), PartImportBus.class ),
|
||||
|
||||
ExportBus( 260, EnumSet.of( AEFeature.ExportBus ), PartExportBus.class ),
|
||||
ExportBus( 260, EnumSet.of( AEFeature.ExportBus ), EnumSet.noneOf( IntegrationType.class ), PartExportBus.class ),
|
||||
|
||||
LevelEmitter( 280, EnumSet.of( AEFeature.LevelEmitter ), PartLevelEmitter.class ),
|
||||
LevelEmitter( 280, EnumSet.of( AEFeature.LevelEmitter ), EnumSet.noneOf( IntegrationType.class ), PartLevelEmitter.class ),
|
||||
|
||||
AnnihilationPlane( 300, EnumSet.of( AEFeature.AnnihilationPlane ), PartAnnihilationPlane.class ),
|
||||
AnnihilationPlane( 300, EnumSet.of( AEFeature.AnnihilationPlane ), EnumSet.noneOf( IntegrationType.class ), PartAnnihilationPlane.class ),
|
||||
|
||||
FormationPlane( 320, EnumSet.of( AEFeature.FormationPlane ), PartFormationPlane.class ),
|
||||
FormationPlane( 320, EnumSet.of( AEFeature.FormationPlane ), EnumSet.noneOf( IntegrationType.class ), PartFormationPlane.class ),
|
||||
|
||||
PatternTerminal( 340, EnumSet.of( AEFeature.Patterns ), PartPatternTerminal.class ),
|
||||
PatternTerminal( 340, EnumSet.of( AEFeature.Patterns ), EnumSet.noneOf( IntegrationType.class ), PartPatternTerminal.class ),
|
||||
|
||||
CraftingTerminal( 360, EnumSet.of( AEFeature.CraftingTerminal ), PartCraftingTerminal.class ),
|
||||
CraftingTerminal( 360, EnumSet.of( AEFeature.CraftingTerminal ), EnumSet.noneOf( IntegrationType.class ), PartCraftingTerminal.class ),
|
||||
|
||||
Terminal( 380, EnumSet.of( AEFeature.Core ), PartTerminal.class ),
|
||||
Terminal( 380, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartTerminal.class ),
|
||||
|
||||
StorageMonitor( 400, EnumSet.of( AEFeature.StorageMonitor ), PartStorageMonitor.class ),
|
||||
StorageMonitor( 400, EnumSet.of( AEFeature.StorageMonitor ), EnumSet.noneOf( IntegrationType.class ), PartStorageMonitor.class ),
|
||||
|
||||
ConversionMonitor( 420, EnumSet.of( AEFeature.PartConversionMonitor ), PartConversionMonitor.class ),
|
||||
ConversionMonitor( 420, EnumSet.of( AEFeature.PartConversionMonitor ), EnumSet.noneOf( IntegrationType.class ), PartConversionMonitor.class ),
|
||||
|
||||
Interface( 440, EnumSet.of( AEFeature.Core ), PartInterface.class ),
|
||||
Interface( 440, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartInterface.class ),
|
||||
|
||||
P2PTunnelME( 460, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelME ), PartP2PTunnelME.class, GuiText.METunnel ),
|
||||
P2PTunnelME( 460, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelME ), EnumSet.noneOf( IntegrationType.class ), PartP2PTunnelME.class, GuiText.METunnel ),
|
||||
|
||||
P2PTunnelRedstone( 461, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRedstone ), PartP2PRedstone.class, GuiText.RedstoneTunnel ),
|
||||
P2PTunnelRedstone( 461, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRedstone ), EnumSet.noneOf( IntegrationType.class ), PartP2PRedstone.class, GuiText.RedstoneTunnel ),
|
||||
|
||||
P2PTunnelItems( 462, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelItems ), PartP2PItems.class, GuiText.ItemTunnel ),
|
||||
P2PTunnelItems( 462, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelItems ), EnumSet.noneOf( IntegrationType.class ), PartP2PItems.class, GuiText.ItemTunnel ),
|
||||
|
||||
P2PTunnelLiquids( 463, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLiquids ), PartP2PLiquids.class, GuiText.FluidTunnel ),
|
||||
P2PTunnelLiquids( 463, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLiquids ), EnumSet.noneOf( IntegrationType.class ), PartP2PLiquids.class, GuiText.FluidTunnel ),
|
||||
|
||||
P2PTunnelEU( 465, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelEU ), PartP2PIC2Power.class, GuiText.EUTunnel ),
|
||||
P2PTunnelEU( 465, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelEU ), EnumSet.of( IntegrationType.IC2 ), PartP2PIC2Power.class, GuiText.EUTunnel ),
|
||||
|
||||
P2PTunnelRF( 466, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRF ), PartP2PRFPower.class, GuiText.RFTunnel ),
|
||||
P2PTunnelRF( 466, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRF ), EnumSet.of( IntegrationType.RF ), PartP2PRFPower.class, GuiText.RFTunnel ),
|
||||
|
||||
P2PTunnelLight( 467, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLight ), PartP2PLight.class, GuiText.LightTunnel ),
|
||||
P2PTunnelLight( 467, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLight ), EnumSet.noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel ),
|
||||
|
||||
InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), PartInterfaceTerminal.class );
|
||||
InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), EnumSet.noneOf( IntegrationType.class ), PartInterfaceTerminal.class );
|
||||
|
||||
public final int baseDamage;
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final Set<AEFeature> features;
|
||||
private final Set<IntegrationType> integrations;
|
||||
private final Class<? extends IPart> myPart;
|
||||
private final GuiText extraName;
|
||||
public Constructor<? extends IPart> constructor;
|
||||
|
||||
PartType( int baseMetaValue, EnumSet<AEFeature> features, Class<? extends IPart> c )
|
||||
PartType( int baseMetaValue, Set<AEFeature> features, Set<IntegrationType> integrations, Class<? extends IPart> c )
|
||||
{
|
||||
this( baseMetaValue, features, c, null );
|
||||
this( baseMetaValue, features, integrations, c, null );
|
||||
}
|
||||
|
||||
PartType( int baseMetaValue, EnumSet<AEFeature> features, Class<? extends IPart> c, GuiText en )
|
||||
PartType( int baseMetaValue, Set<AEFeature> features, Set<IntegrationType> integrations, Class<? extends IPart> c, GuiText en )
|
||||
{
|
||||
this.features = features;
|
||||
this.features = Collections.unmodifiableSet( features ) ;
|
||||
this.integrations = Collections.unmodifiableSet( integrations );
|
||||
this.myPart = c;
|
||||
this.extraName = en;
|
||||
this.baseDamage = baseMetaValue;
|
||||
@@ -176,11 +181,16 @@ public enum PartType
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeature()
|
||||
public Set<AEFeature> getFeature()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
public Set<IntegrationType> getIntegrations()
|
||||
{
|
||||
return this.integrations;
|
||||
}
|
||||
|
||||
public Class<? extends IPart> getPart()
|
||||
{
|
||||
return this.myPart;
|
||||
|
||||
@@ -38,6 +38,7 @@ import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
@@ -55,12 +56,12 @@ import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
|
||||
public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
|
||||
{
|
||||
final MaterialType component;
|
||||
final int totalBytes;
|
||||
final int perType;
|
||||
final double idleDrain;
|
||||
private final MaterialType component;
|
||||
private final int totalBytes;
|
||||
private final int perType;
|
||||
private final double idleDrain;
|
||||
|
||||
public ItemBasicStorageCell( MaterialType whichCell, int kilobytes )
|
||||
{
|
||||
@@ -96,9 +97,9 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
IMEInventoryHandler inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
if( inventory instanceof ICellInventoryHandler )
|
||||
{
|
||||
@@ -113,12 +114,12 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
|
||||
if( handler.isPreformatted() )
|
||||
{
|
||||
String List = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal();
|
||||
String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal();
|
||||
|
||||
if( handler.isFuzzy() )
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + ' ' + GuiText.Fuzzy.getLocal() );
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Fuzzy.getLocal() );
|
||||
else
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + ' ' + GuiText.Precise.getLocal() );
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,6 +137,12 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
return this.perType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( ItemStack cellItem )
|
||||
{
|
||||
return this.perType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( ItemStack cellItem )
|
||||
{
|
||||
@@ -234,10 +241,24 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
{
|
||||
playerInventory.setInventorySlotContents( playerInventory.currentItem, null );
|
||||
|
||||
// drop core
|
||||
ItemStack extraB = ia.addItems( this.component.stack( 1 ) );
|
||||
if( extraB != null )
|
||||
player.dropPlayerItemWithRandomChoice( extraB, false );
|
||||
|
||||
// drop upgrades
|
||||
final IInventory upgradesInventory = this.getUpgradesInventory( stack );
|
||||
for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++ )
|
||||
{
|
||||
final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex );
|
||||
final ItemStack leftStack = ia.addItems( upgradeStack );
|
||||
if( leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice( upgradeStack, false );
|
||||
}
|
||||
}
|
||||
|
||||
// drop empty storage cell case
|
||||
for( ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
final ItemStack extraA = ia.addItems( storageCellStack );
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
WorldCoord wc = this.getStoredSize( stack );
|
||||
if( wc.x > 0 )
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = this.getPermissions( stack );
|
||||
if( perms.isEmpty() )
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) );
|
||||
|
||||
|
||||
@@ -388,9 +388,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
@@ -417,6 +417,12 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( ItemStack cellItem )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( ItemStack cellItem )
|
||||
{
|
||||
|
||||
@@ -95,9 +95,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
@@ -481,6 +481,12 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( ItemStack cellItem )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( ItemStack cellItem )
|
||||
{
|
||||
|
||||
@@ -80,9 +80,9 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
|
||||
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
|
||||
|
||||
@@ -109,6 +109,12 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( ItemStack cellItem )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( ItemStack cellItem )
|
||||
{
|
||||
|
||||
@@ -73,9 +73,9 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
|
||||
|
||||
if( stack.hasTagCompound() )
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPow
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
double internalCurrentPower = 0;
|
||||
|
||||
@@ -305,7 +305,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
this.setGridStorage( WorldSettings.getInstance().getGridStorage( node.getLong( "g" ) ) );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Loading data after part of a grid, this is invalid." );
|
||||
throw new IllegalStateException( "Loading data after part of a grid, this is invalid." );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,16 +71,16 @@ public class NetworkEventBus
|
||||
classEvents.put( listAs, thisEvent );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Invalid ME Network Event Subscriber, " + m.getName() + "s Parameter must extend MENetworkEvent." );
|
||||
throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + "s Parameter must extend MENetworkEvent." );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Invalid ME Network Event Subscriber, " + m.getName() + " must have exactly 1 parameter." );
|
||||
throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + " must have exactly 1 parameter." );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( "Error while adding " + c.getName() + " to event bus", t );
|
||||
throw new IllegalStateException( "Error while adding " + c.getName() + " to event bus", t );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public class NetworkEventBus
|
||||
AELog.severe( "Offending Class: " + obj.getClass().getName() );
|
||||
AELog.severe( "Offending Object: " + obj.toString() );
|
||||
AELog.error( e1 );
|
||||
throw new RuntimeException( e1 );
|
||||
throw new IllegalStateException( e1 );
|
||||
}
|
||||
|
||||
if( e.isCanceled() )
|
||||
|
||||
+1
-1
@@ -501,7 +501,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
{
|
||||
if( world == null || grid == null || actionSrc == null || slotItem == null )
|
||||
{
|
||||
throw new RuntimeException( "Invalid Crafting Job Request" );
|
||||
throw new IllegalArgumentException( "Invalid Crafting Job Request" );
|
||||
}
|
||||
|
||||
CraftingJob job = new CraftingJob( world, grid, actionSrc, slotItem, cb );
|
||||
|
||||
+1
-1
@@ -140,6 +140,6 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
final NetworkMonitor<?> last = DEPTH.pop();
|
||||
if( last != this )
|
||||
throw new RuntimeException( "Invalid Access to Networked Storage API detected." );
|
||||
throw new IllegalStateException( "Invalid Access to Networked Storage API detected." );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public IAEItemStack getItemStack( IAEItemStack what, CraftingItemList storage2 )
|
||||
{
|
||||
IAEItemStack is = null;
|
||||
IAEItemStack is;
|
||||
switch( storage2 )
|
||||
{
|
||||
case STORAGE:
|
||||
@@ -960,7 +960,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
break;
|
||||
default:
|
||||
case ALL:
|
||||
throw new RuntimeException( "Invalid Operation" );
|
||||
throw new IllegalStateException( "Invalid Operation" );
|
||||
}
|
||||
|
||||
if( is != null )
|
||||
|
||||
@@ -168,7 +168,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
private void surface( NetworkInventoryHandler<T> networkInventoryHandler, Actionable type )
|
||||
{
|
||||
if( this.getDepth( type ).pop() != this )
|
||||
throw new RuntimeException( "Invalid Access to Networked Storage API detected." );
|
||||
throw new IllegalStateException( "Invalid Access to Networked Storage API detected." );
|
||||
}
|
||||
|
||||
private LinkedList getDepth( Actionable type )
|
||||
|
||||
@@ -348,7 +348,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
throw new RuntimeException( "Now that is silly!" );
|
||||
throw new UnsupportedOperationException( "Now that is silly!" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -887,7 +887,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
p.readFromStream( data );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Invalid Stream For CableBus Container." );
|
||||
throw new IllegalStateException( "Invalid Stream For CableBus Container." );
|
||||
}
|
||||
}
|
||||
else if( this.getPart( side ) != null )
|
||||
@@ -936,7 +936,8 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
return side;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException( "Uhh Bad Part on Side." );
|
||||
|
||||
throw new IllegalStateException( "Uhh Bad Part (" + part + ") on Side." );
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
if( requestTotal <= 0 )
|
||||
{
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
if( !doFill )
|
||||
{
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
|
||||
return Math.min( resource.amount, requestTotal );
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import appeng.util.Platform;
|
||||
|
||||
|
||||
@InterfaceList( value = { @Interface( iface = "cofh.api.energy.IEnergyReceiver", iname = "RF" ) } )
|
||||
public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEnergyReceiver
|
||||
public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEnergyReceiver
|
||||
{
|
||||
private static final ThreadLocal<Stack<PartP2PRFPower>> THREAD_STACK = new ThreadLocal<Stack<PartP2PRFPower>>();
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
|
||||
return total;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
|
||||
return total;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -59,14 +59,21 @@ import appeng.core.AELog;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost
|
||||
{
|
||||
private static final ReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
IAEItemStack configuredItem;
|
||||
boolean isLocked;
|
||||
IStackWatcher myWatcher;
|
||||
@@ -229,8 +236,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
||||
this.dspList = GLAllocation.generateDisplayLists( 1 );
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
if( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
||||
if( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) )
|
||||
return;
|
||||
@@ -341,7 +346,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
||||
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
|
||||
|
||||
final long stackSize = ais.getStackSize();
|
||||
final String renderedStackSize = NUMBER_CONVERTER.toHumanReadableForm( stackSize );
|
||||
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize );
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( renderedStackSize );
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
@@ -324,7 +323,7 @@ public class RecipeHandler implements IRecipeHandler
|
||||
{
|
||||
AELog.error( e );
|
||||
if( this.data.crash )
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +331,7 @@ public class RecipeHandler implements IRecipeHandler
|
||||
public void injectRecipes()
|
||||
{
|
||||
if( cpw.mods.fml.common.Loader.instance().hasReachedState( LoaderState.POSTINITIALIZATION ) )
|
||||
throw new RuntimeException( "Recipes must now be loaded in Init." );
|
||||
throw new IllegalStateException( "Recipes must now be loaded in Init." );
|
||||
|
||||
HashMap<Class, Integer> processed = new HashMap<Class, Integer>();
|
||||
try
|
||||
@@ -376,7 +375,7 @@ public class RecipeHandler implements IRecipeHandler
|
||||
if( this.data.exceptions )
|
||||
AELog.error( e );
|
||||
if( this.data.crash )
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
|
||||
for( Entry<Class, Integer> e : processed.entrySet() )
|
||||
|
||||
@@ -21,12 +21,17 @@ package appeng.recipes.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
@@ -39,109 +44,116 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
|
||||
public class DisassembleRecipe implements IRecipe
|
||||
public final class DisassembleRecipe implements IRecipe
|
||||
{
|
||||
private static final ItemStack MISMATCHED_STACK = null;
|
||||
|
||||
private final IMaterials mats;
|
||||
private final IItems items;
|
||||
private final IBlocks blocks;
|
||||
private final Map<IItemDefinition, IItemDefinition> cellMappings;
|
||||
private final Map<IItemDefinition, IItemDefinition> nonCellMappings;
|
||||
|
||||
public DisassembleRecipe()
|
||||
{
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IItems items = definitions.items();
|
||||
final IMaterials mats = definitions.materials();
|
||||
|
||||
this.blocks = definitions.blocks();
|
||||
this.items = definitions.items();
|
||||
this.mats = definitions.materials();
|
||||
this.cellMappings = new HashMap<IItemDefinition, IItemDefinition>( 4 );
|
||||
this.nonCellMappings = new HashMap<IItemDefinition, IItemDefinition>( 5 );
|
||||
|
||||
this.cellMappings.put( this.items.cell1k(), this.mats.cell1kPart() );
|
||||
this.cellMappings.put( this.items.cell4k(), this.mats.cell4kPart() );
|
||||
this.cellMappings.put( this.items.cell16k(), this.mats.cell16kPart() );
|
||||
this.cellMappings.put( this.items.cell64k(), this.mats.cell64kPart() );
|
||||
this.cellMappings.put( items.cell1k(), mats.cell1kPart() );
|
||||
this.cellMappings.put( items.cell4k(), mats.cell4kPart() );
|
||||
this.cellMappings.put( items.cell16k(), mats.cell16kPart() );
|
||||
this.cellMappings.put( items.cell64k(), mats.cell64kPart() );
|
||||
|
||||
this.nonCellMappings.put( this.items.encodedPattern(), this.mats.blankPattern() );
|
||||
this.nonCellMappings.put( this.blocks.craftingStorage1k(), this.mats.cell1kPart() );
|
||||
this.nonCellMappings.put( this.blocks.craftingStorage4k(), this.mats.cell4kPart() );
|
||||
this.nonCellMappings.put( this.blocks.craftingStorage16k(), this.mats.cell16kPart() );
|
||||
this.nonCellMappings.put( this.blocks.craftingStorage64k(), this.mats.cell64kPart() );
|
||||
this.nonCellMappings.put( items.encodedPattern(), mats.blankPattern() );
|
||||
this.nonCellMappings.put( blocks.craftingStorage1k(), mats.cell1kPart() );
|
||||
this.nonCellMappings.put( blocks.craftingStorage4k(), mats.cell4kPart() );
|
||||
this.nonCellMappings.put( blocks.craftingStorage16k(), mats.cell16kPart() );
|
||||
this.nonCellMappings.put( blocks.craftingStorage64k(), mats.cell64kPart() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( InventoryCrafting inv, World w )
|
||||
{
|
||||
return this.getOutput( inv, false ) != null;
|
||||
return this.getOutput( inv ) != null;
|
||||
}
|
||||
|
||||
private ItemStack getOutput( InventoryCrafting inv, boolean createFacade )
|
||||
@Nullable
|
||||
private ItemStack getOutput( IInventory inventory )
|
||||
{
|
||||
ItemStack hasCell = null;
|
||||
int itemCount = 0;
|
||||
ItemStack output = MISMATCHED_STACK;
|
||||
|
||||
for( int x = 0; x < inv.getSizeInventory(); x++ )
|
||||
for( int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++ )
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( x );
|
||||
if( is != null )
|
||||
ItemStack stackInSlot = inventory.getStackInSlot( slotIndex );
|
||||
if( stackInSlot != null )
|
||||
{
|
||||
if( hasCell != null )
|
||||
return null;
|
||||
// needs a single input in the recipe
|
||||
itemCount++;
|
||||
if ( itemCount > 1 )
|
||||
return MISMATCHED_STACK;
|
||||
|
||||
hasCell = this.getCellOutput( is );
|
||||
|
||||
// make sure the storage cell is empty...
|
||||
if( hasCell != null )
|
||||
// handle storage cells
|
||||
for( ItemStack storageCellStack : this.getCellOutput( stackInSlot ).asSet() )
|
||||
{
|
||||
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
// make sure the storage cell stackInSlot empty...
|
||||
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory( stackInSlot, null, StorageChannel.ITEMS );
|
||||
if( cellInv != null )
|
||||
{
|
||||
IItemList<IAEItemStack> list = cellInv.getAvailableItems( StorageChannel.ITEMS.createList() );
|
||||
if( !list.isEmpty() )
|
||||
return null;
|
||||
}
|
||||
|
||||
output = storageCellStack;
|
||||
}
|
||||
|
||||
hasCell = this.getNonCellOutput( is );
|
||||
|
||||
if( hasCell == null )
|
||||
return null;
|
||||
// handle crafting storage blocks
|
||||
for( ItemStack craftingStorageStack : this.getNonCellOutput( stackInSlot ).asSet() )
|
||||
{
|
||||
output = craftingStorageStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasCell;
|
||||
return output;
|
||||
}
|
||||
|
||||
private ItemStack getCellOutput( ItemStack compared )
|
||||
@Nonnull
|
||||
private Optional<ItemStack> getCellOutput( ItemStack compared )
|
||||
{
|
||||
for( Map.Entry<IItemDefinition, IItemDefinition> entry : this.cellMappings.entrySet() )
|
||||
{
|
||||
if( entry.getKey().isSameAs( compared ) )
|
||||
{
|
||||
return entry.getValue().maybeStack( 1 ).get();
|
||||
return entry.getValue().maybeStack( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
private ItemStack getNonCellOutput( ItemStack compared )
|
||||
@Nonnull
|
||||
private Optional<ItemStack> getNonCellOutput( ItemStack compared )
|
||||
{
|
||||
for( Map.Entry<IItemDefinition, IItemDefinition> entry : this.nonCellMappings.entrySet() )
|
||||
{
|
||||
if( entry.getKey().isSameAs( compared ) )
|
||||
{
|
||||
return entry.getValue().maybeStack( 1 ).get();
|
||||
return entry.getValue().maybeStack( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack getCraftingResult( InventoryCrafting inv )
|
||||
{
|
||||
return this.getOutput( inv, true );
|
||||
return this.getOutput( inv );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,6 +162,7 @@ public class DisassembleRecipe implements IRecipe
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() // no default output..
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||
ret.append( tmp ).append( ", " );
|
||||
}
|
||||
ret.append( this.output );
|
||||
throw new RuntimeException( ret.toString() );
|
||||
throw new IllegalStateException( ret.toString() );
|
||||
}
|
||||
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
@@ -122,7 +122,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||
ret.append( tmp ).append( ", " );
|
||||
}
|
||||
ret.append( this.output );
|
||||
throw new RuntimeException( ret.toString() );
|
||||
throw new IllegalStateException( ret.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
|
||||
ret.append( tmp ).append( ", " );
|
||||
}
|
||||
ret.append( this.output );
|
||||
throw new RuntimeException( ret.toString() );
|
||||
throw new IllegalArgumentException( ret.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class MekCrusher implements ICraftHandler, IWebsiteSerializer
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RecipeError( "MekCrusher must have a single input, and single output." );
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,9 @@ import net.minecraft.server.MinecraftServer;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
|
||||
public class AECommand extends CommandBase
|
||||
public final class AECommand extends CommandBase
|
||||
{
|
||||
|
||||
final MinecraftServer srv;
|
||||
private final MinecraftServer srv;
|
||||
|
||||
public AECommand( MinecraftServer server )
|
||||
{
|
||||
|
||||
@@ -58,13 +58,13 @@ public class ServerHelper extends CommonHelper
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
throw new RuntimeException( "This is a server..." );
|
||||
throw new UnsupportedOperationException( "This is a server..." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTileEntitySpecialRenderer( Class tile, AEBaseBlock blk )
|
||||
{
|
||||
throw new RuntimeException( "This is a server..." );
|
||||
throw new UnsupportedOperationException( "This is a server..." );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,6 +179,6 @@ public class ServerHelper extends CommonHelper
|
||||
@Override
|
||||
public void missingCoreMod()
|
||||
{
|
||||
throw new RuntimeException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." );
|
||||
throw new IllegalStateException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package appeng.services.version;
|
||||
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -111,7 +110,7 @@ public final class VersionParser
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidParameterException( "Raw channel did not contain any of the pre-programmed types." );
|
||||
throw new IllegalArgumentException( "Raw channel " + rawChannel + " did not contain any of the pre-programmed types." );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -269,7 +269,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
Collections.shuffle( places );
|
||||
|
||||
if( places.isEmpty() )
|
||||
throw new RuntimeException( "No air or even the tile hat was destroyed?!?!" );
|
||||
throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." );
|
||||
|
||||
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
|
||||
{
|
||||
|
||||
@@ -51,15 +51,15 @@ public class AETileEventHandler
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,15 +72,15 @@ public class AETileEventHandler
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,15 +93,15 @@ public class AETileEventHandler
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,15 +114,15 @@ public class AETileEventHandler
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,15 +144,15 @@ public class AETileEventHandler
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
final AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 );
|
||||
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
|
||||
final ConfigManager cm = new ConfigManager( this );
|
||||
final ConfigManager manager = new ConfigManager( this );
|
||||
|
||||
IInventory cacheUpgrades = null;
|
||||
IInventory cacheConfig = null;
|
||||
@@ -56,7 +56,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
public TileCellWorkbench()
|
||||
{
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.manager.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
{
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.cm.writeToNBT( data );
|
||||
this.manager.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
@@ -105,7 +105,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
{
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.cm.readFromNBT( data );
|
||||
this.manager.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,13 +136,13 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
this.cacheUpgrades = null;
|
||||
this.cacheConfig = null;
|
||||
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if( c != null )
|
||||
IInventory configInventory = this.getCellConfigInventory();
|
||||
if( configInventory != null )
|
||||
{
|
||||
boolean cellHasConfig = false;
|
||||
for( int x = 0; x < c.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < configInventory.getSizeInventory(); x++ )
|
||||
{
|
||||
if( c.getStackInSlot( x ) != null )
|
||||
if( configInventory.getStackInSlot( x ) != null )
|
||||
{
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
@@ -152,17 +152,17 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
if( cellHasConfig )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, c.getStackInSlot( x ) );
|
||||
this.config.setInventorySlotContents( x, configInventory.getStackInSlot( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
configInventory.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
configInventory.markDirty();
|
||||
}
|
||||
}
|
||||
else if( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
else if( this.manager.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, null );
|
||||
@@ -185,7 +185,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
private IInventory getCellConfigInventory()
|
||||
{
|
||||
if( this.cacheConfig == null )
|
||||
{
|
||||
@@ -201,7 +201,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.cm;
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -785,7 +785,6 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
|
||||
private static class ChestNoHandler extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 7995805326136526631L;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.transformer;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
@@ -36,25 +37,21 @@ import appeng.core.AEConfig;
|
||||
|
||||
|
||||
@MCVersion( "1.7.10" )
|
||||
public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
public final class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
{
|
||||
|
||||
public final AppEngCore instance;
|
||||
|
||||
protected final ModMetadata md = new ModMetadata();
|
||||
private final ModMetadata metadata = new ModMetadata();
|
||||
|
||||
public AppEngCore()
|
||||
{
|
||||
this.instance = this;
|
||||
FMLRelaunchLog.info( "[AppEng] Core Init" );
|
||||
this.md.autogenerated = false;
|
||||
this.md.authorList.add( "AlgorithmX2" );
|
||||
this.md.credits = "AlgorithmX2";
|
||||
this.md.modId = this.getModId();
|
||||
this.md.version = this.getVersion();
|
||||
this.md.name = this.getName();
|
||||
this.md.url = "http://ae2.ae-mod.info";
|
||||
this.md.description = "Embedded Coremod for Applied Energistics 2";
|
||||
this.metadata.autogenerated = false;
|
||||
this.metadata.authorList.add( "AlgorithmX2" );
|
||||
this.metadata.credits = "AlgorithmX2";
|
||||
this.metadata.modId = this.getModId();
|
||||
this.metadata.version = this.getVersion();
|
||||
this.metadata.name = this.getName();
|
||||
this.metadata.url = "http://ae2.ae-mod.info";
|
||||
this.metadata.description = "Embedded Coremod for Applied Energistics 2";
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -74,6 +71,7 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
return "appeng.transformer.AppEngCore";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSetupClass()
|
||||
{
|
||||
@@ -95,7 +93,7 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
return this.md;
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,18 +23,24 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
|
||||
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
public class MissingCoreMod extends CustomModLoadingErrorDisplayException
|
||||
@SideOnly( Side.CLIENT )
|
||||
public final class MissingCoreMod extends CustomModLoadingErrorDisplayException
|
||||
{
|
||||
|
||||
private static final int SHADOW_WHITE = 0xeeeeee;
|
||||
private static final int COLOR_WHITE = 0xffffff;
|
||||
private static final long serialVersionUID = -966774766922821652L;
|
||||
private static final int SCREEN_OFFSET = 15;
|
||||
|
||||
private boolean deobf = false;
|
||||
|
||||
@Override
|
||||
public void initGui( GuiErrorScreen errorScreen, FontRenderer fontRenderer )
|
||||
{
|
||||
Class clz = errorScreen.getClass();
|
||||
Class<?> clz = errorScreen.getClass();
|
||||
try
|
||||
{
|
||||
clz.getField( "mc" );
|
||||
@@ -50,35 +56,46 @@ public class MissingCoreMod extends CustomModLoadingErrorDisplayException
|
||||
public void drawScreen( GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime )
|
||||
{
|
||||
int offset = 10;
|
||||
this.drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 Properly.", errorScreen.width / 2, offset += 15, 0xffffff );
|
||||
this.drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset += 15, 0xeeeeee );
|
||||
this.drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 properly.", errorScreen.width / 2, offset, COLOR_WHITE );
|
||||
|
||||
offset += 15;
|
||||
offset += SCREEN_OFFSET;
|
||||
this.drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset, SHADOW_WHITE );
|
||||
|
||||
offset += 2 * SCREEN_OFFSET;
|
||||
|
||||
if( this.deobf )
|
||||
{
|
||||
offset += 15;
|
||||
this.drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset += 15, 0xffffff );
|
||||
this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.transformer.AppEngCore", errorScreen.width / 2, offset += 15, 0xeeeeee );
|
||||
offset += SCREEN_OFFSET;
|
||||
this.drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset, COLOR_WHITE );
|
||||
|
||||
offset += SCREEN_OFFSET;
|
||||
this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.transformer.AppEngCore", errorScreen.width / 2, offset, SHADOW_WHITE );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawCenteredString( fontRenderer, "You're launcher may refer to this by different names,", errorScreen.width / 2, offset += 15, 0xffffff );
|
||||
this.drawCenteredString( fontRenderer, "You're launcher may refer to this by different names,", errorScreen.width / 2, offset, COLOR_WHITE );
|
||||
|
||||
offset += 5;
|
||||
offset += SCREEN_OFFSET + 5;
|
||||
|
||||
this.drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee );
|
||||
this.drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee );
|
||||
this.drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee );
|
||||
this.drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
|
||||
|
||||
offset += 15;
|
||||
offset += SCREEN_OFFSET;
|
||||
this.drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
|
||||
|
||||
this.drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset += 15, 0xffffff );
|
||||
offset += SCREEN_OFFSET;
|
||||
this.drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
|
||||
|
||||
offset += 2 * SCREEN_OFFSET;
|
||||
this.drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset, COLOR_WHITE );
|
||||
}
|
||||
}
|
||||
|
||||
public void drawCenteredString( FontRenderer fontRenderer, String string, int x, int y, int colour )
|
||||
private void drawCenteredString( FontRenderer fontRenderer, String string, int x, int y, int colour )
|
||||
{
|
||||
fontRenderer.drawStringWithShadow( string, x - fontRenderer.getStringWidth( string.replaceAll( "\\P{InBasic_Latin}", "" ) ) / 2, y, colour );
|
||||
final String reEncoded = string.replaceAll( "\\P{InBasic_Latin}", "" );
|
||||
final int reEndcodedWidth = fontRenderer.getStringWidth( reEncoded );
|
||||
final int centeredX = x - reEndcodedWidth / 2;
|
||||
|
||||
fontRenderer.drawStringWithShadow( string, centeredX, y, colour );
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package appeng.transformer.asm;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -34,13 +34,16 @@ import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.transformer.annotations.Integration;
|
||||
|
||||
|
||||
public class ASMIntegration implements IClassTransformer
|
||||
@Reflected
|
||||
public final class ASMIntegration implements IClassTransformer
|
||||
{
|
||||
@Reflected
|
||||
public ASMIntegration()
|
||||
{
|
||||
|
||||
@@ -64,6 +67,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public byte[] transform( String name, String transformedName, byte[] basicClass )
|
||||
{
|
||||
@@ -72,8 +76,6 @@ public class ASMIntegration implements IClassTransformer
|
||||
|
||||
if( transformedName.startsWith( "appeng." ) )
|
||||
{
|
||||
// log( "Found " + transformedName );
|
||||
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader( basicClass );
|
||||
classReader.accept( classNode, 0 );
|
||||
@@ -112,7 +114,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
}
|
||||
else if( this.hasAnnotation( an, Integration.InterfaceList.class ) )
|
||||
{
|
||||
for( Object o : ( (List) an.values.get( 1 ) ) )
|
||||
for( Object o : ( (Iterable) an.values.get( 1 ) ) )
|
||||
{
|
||||
if( this.stripInterface( classNode, Integration.InterfaceList.class, (AnnotationNode) o ) )
|
||||
changed = true;
|
||||
@@ -145,15 +147,15 @@ public class ASMIntegration implements IClassTransformer
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean hasAnnotation( AnnotationNode ann, Class annotation )
|
||||
private boolean hasAnnotation( AnnotationNode ann, Class<?> annotation )
|
||||
{
|
||||
return ann.desc.equals( Type.getDescriptor( annotation ) );
|
||||
}
|
||||
|
||||
private boolean stripInterface( ClassNode classNode, Class class1, AnnotationNode an )
|
||||
private boolean stripInterface( ClassNode classNode, Class<?> class1, AnnotationNode an )
|
||||
{
|
||||
if( an.values.size() != 4 )
|
||||
throw new RuntimeException( "Unable to handle Interface annotation on " + classNode.name );
|
||||
throw new IllegalArgumentException( "Unable to handle Interface annotation on " + classNode.name );
|
||||
|
||||
String iFace = null;
|
||||
String iName = null;
|
||||
@@ -168,10 +170,9 @@ public class ASMIntegration implements IClassTransformer
|
||||
else if( an.values.get( 2 ).equals( "iname" ) )
|
||||
iName = (String) an.values.get( 3 );
|
||||
|
||||
IntegrationType type = IntegrationType.valueOf( iName );
|
||||
|
||||
if( iName != null && iFace != null )
|
||||
{
|
||||
final IntegrationType type = IntegrationType.valueOf( iName );
|
||||
if( !IntegrationRegistry.INSTANCE.isEnabled( type ) )
|
||||
{
|
||||
this.log( "Removing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is disabled." );
|
||||
@@ -182,7 +183,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
this.log( "Allowing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is enabled." );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name );
|
||||
throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name );
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -190,7 +191,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
private boolean stripMethod( ClassNode classNode, MethodNode mn, Iterator<MethodNode> i, Class class1, AnnotationNode an )
|
||||
{
|
||||
if( an.values.size() != 2 )
|
||||
throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name );
|
||||
throw new IllegalArgumentException( "Unable to handle Method annotation on " + classNode.name );
|
||||
|
||||
String iName = null;
|
||||
|
||||
@@ -210,7 +211,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
this.log( "Allowing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is enabled." );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name );
|
||||
throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.transformer.asm;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -39,26 +40,31 @@ import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
|
||||
public class ASMTweaker implements IClassTransformer
|
||||
|
||||
@Reflected
|
||||
public final class ASMTweaker implements IClassTransformer
|
||||
{
|
||||
private static final String[] EXCEPTIONS = new String[0];
|
||||
private final Multimap<String, PublicLine> privateToPublicMethods = HashMultimap.create();
|
||||
|
||||
final Multimap<String, publicLine> privateToPublicMethods = HashMultimap.create();
|
||||
|
||||
@Reflected
|
||||
public ASMTweaker()
|
||||
{
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new publicLine( "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new publicLine( "a", "(Lzk;)V" ) );
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "a", "(Lzk;)V" ) );
|
||||
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "writeToNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "func_145841_b", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "b", "(Ldh;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "writeToNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "func_145841_b", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "b", "(Ldh;)V" ) );
|
||||
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "readFromNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "func_145839_a", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "a", "(Ldh;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "readFromNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "func_145839_a", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "a", "(Ldh;)V" ) );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public byte[] transform( String name, String transformedName, byte[] basicClass )
|
||||
{
|
||||
@@ -73,9 +79,9 @@ public class ASMTweaker implements IClassTransformer
|
||||
ClassReader classReader = new ClassReader( basicClass );
|
||||
classReader.accept( classNode, 0 );
|
||||
|
||||
for( publicLine Set : this.privateToPublicMethods.get( transformedName ) )
|
||||
for( PublicLine set : this.privateToPublicMethods.get( transformedName ) )
|
||||
{
|
||||
this.makePublic( classNode, Set );
|
||||
this.makePublic( classNode, set );
|
||||
}
|
||||
|
||||
// CALL VIRTUAL!
|
||||
@@ -85,7 +91,7 @@ public class ASMTweaker implements IClassTransformer
|
||||
{
|
||||
if( mn.name.equals( "func_146977_a" ) || ( mn.name.equals( "a" ) && mn.desc.equals( "(Lzk;)V" ) ) )
|
||||
{
|
||||
MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, new String[0] );
|
||||
MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, EXCEPTIONS );
|
||||
newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 0 ) );
|
||||
newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 1 ) );
|
||||
newNode.instructions.add( new MethodInsnNode( Opcodes.INVOKESPECIAL, classNode.name, mn.name, mn.desc, false ) );
|
||||
@@ -132,7 +138,7 @@ public class ASMTweaker implements IClassTransformer
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private void makePublic( ClassNode classNode, publicLine set )
|
||||
private void makePublic( ClassNode classNode, PublicLine set )
|
||||
{
|
||||
for( MethodNode mn : classNode.methods )
|
||||
{
|
||||
@@ -149,13 +155,12 @@ public class ASMTweaker implements IClassTransformer
|
||||
FMLRelaunchLog.log( "AE2-CORE", Level.INFO, string );
|
||||
}
|
||||
|
||||
class publicLine
|
||||
private static final class PublicLine
|
||||
{
|
||||
private final String name;
|
||||
private final String desc;
|
||||
|
||||
final String name;
|
||||
final String desc;
|
||||
|
||||
public publicLine( String name, String desc )
|
||||
public PublicLine( String name, String desc )
|
||||
{
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user