Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import codechicken.multipart.TMultiPart;
|
||||
@@ -27,46 +28,28 @@ import appeng.block.misc.BlockQuartzTorch;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.Api;
|
||||
|
||||
|
||||
public enum PartRegistry
|
||||
{
|
||||
QuartzTorchPart("ae2_torch", BlockQuartzTorch.class, QuartzTorchPart.class), CableBusPart("ae2_cablebus", BlockCableBus.class, CableBusPart.class);
|
||||
QuartzTorchPart( "ae2_torch", BlockQuartzTorch.class, QuartzTorchPart.class ), CableBusPart( "ae2_cablebus", BlockCableBus.class, CableBusPart.class );
|
||||
|
||||
final private String name;
|
||||
final private Class<? extends AEBaseBlock> blk;
|
||||
final private Class<? extends TMultiPart> part;
|
||||
|
||||
public String getName()
|
||||
PartRegistry( String name, Class<? extends AEBaseBlock> blk, Class<? extends TMultiPart> part )
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
PartRegistry( String name, Class<? extends AEBaseBlock> blk, Class<? extends TMultiPart> part ) {
|
||||
this.name = name;
|
||||
this.blk = blk;
|
||||
this.part = part;
|
||||
}
|
||||
|
||||
public TMultiPart construct(int meta)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this == CableBusPart )
|
||||
return (TMultiPart) Api.INSTANCE.getPartHelper().getCombinedInstance( this.part.getName() ).newInstance();
|
||||
else
|
||||
return this.part.getConstructor( int.class ).newInstance( meta );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPartName(TMultiPart part)
|
||||
public static String getPartName( TMultiPart part )
|
||||
{
|
||||
Class c = part.getClass();
|
||||
for (PartRegistry pr : values())
|
||||
for( PartRegistry pr : values() )
|
||||
{
|
||||
if ( pr.equals( c ) )
|
||||
if( pr.equals( c ) )
|
||||
{
|
||||
return pr.name;
|
||||
}
|
||||
@@ -74,11 +57,11 @@ public enum PartRegistry
|
||||
throw new RuntimeException( "Invalid PartName" );
|
||||
}
|
||||
|
||||
public static TMultiPart getPartByBlock(Block block, int meta)
|
||||
public static TMultiPart getPartByBlock( Block block, int meta )
|
||||
{
|
||||
for (PartRegistry pr : values())
|
||||
for( PartRegistry pr : values() )
|
||||
{
|
||||
if ( pr.blk.isInstance( block ) )
|
||||
if( pr.blk.isInstance( block ) )
|
||||
{
|
||||
return pr.construct( meta );
|
||||
}
|
||||
@@ -86,15 +69,35 @@ public enum PartRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPart(Block block)
|
||||
public TMultiPart construct( int meta )
|
||||
{
|
||||
for (PartRegistry pr : values())
|
||||
try
|
||||
{
|
||||
if ( pr.blk.isInstance( block ) )
|
||||
if( this == CableBusPart )
|
||||
return (TMultiPart) Api.INSTANCE.getPartHelper().getCombinedInstance( this.part.getName() ).newInstance();
|
||||
else
|
||||
return this.part.getConstructor( int.class ).newInstance( meta );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPart( Block block )
|
||||
{
|
||||
for( PartRegistry pr : values() )
|
||||
{
|
||||
if( pr.blk.isInstance( block ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user