Source formatting

Imported my usual settings and applied them
This commit is contained in:
Emmanuel BENOîT 2016-06-13 17:14:55 +02:00
parent 4e3a03d04a
commit 830693a060
6 changed files with 293 additions and 204 deletions

View file

@ -1,5 +1,6 @@
package mmm;
import mmm.deco.DecorativeBlocks;
import mmm.utils.URegistration;
import net.minecraftforge.fml.common.Mod;
@ -8,51 +9,67 @@ import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod( modid = Mmm.ID , name = Mmm.NAME , version = Mmm.VERSION )
public class Mmm {
public class Mmm
{
public static final String ID = "mmm";
public static final String NAME = "MMM!";
public static final String VERSION = "0.1-1.9.4";
public static final String PREFIX = ID + ".";
public static final String PREFIX = Mmm.ID + ".";
@SidedProxy
public static CommonProxy proxy = null;
public static abstract class CommonProxy {
public static abstract class CommonProxy
{
public void preInit(FMLPreInitializationEvent event) {
public void preInit( final FMLPreInitializationEvent event )
{
DecorativeBlocks.preInit( );
URegistration.registerRecipes( );
}
public void init(FMLInitializationEvent event) {
public void init( final FMLInitializationEvent event )
{
// EMPTY
}
}
public static class ServerProxy extends CommonProxy {
public static class ServerProxy
extends CommonProxy
{
// EMPTY
}
public static class ClientProxy extends CommonProxy {
public static class ClientProxy
extends CommonProxy
{
@Override
public void preInit(FMLPreInitializationEvent event) {
public void preInit( final FMLPreInitializationEvent event )
{
super.preInit( event );
URegistration.setupItemModels( );
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
}
@EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
public void preInit( final FMLPreInitializationEvent event )
{
Mmm.proxy.preInit( event );
}
@EventHandler
public void init( final FMLInitializationEvent event )
{
Mmm.proxy.init( event );
}
}

View file

@ -1,5 +1,6 @@
package mmm.deco;
import java.util.List;
import mmm.Mmm;
@ -31,10 +32,15 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class DBlockTable extends Block implements I_URecipeRegistrar {
public class DBlockTable
extends Block
implements I_URecipeRegistrar
{
public final static String ID = "deco_table_";
public final static String NAME = Mmm.PREFIX + ID;
public final static String NAME = Mmm.PREFIX + DBlockTable.ID;
public static enum E_WoodType {
OAK( "oak" , BlockPlanks.EnumType.OAK ) , //
@ -49,7 +55,9 @@ public class DBlockTable extends Block implements I_URecipeRegistrar {
public final MapColor mapColor;
public final Block block;
private E_WoodType(String suffix, BlockPlanks.EnumType planks) {
private E_WoodType( final String suffix , final BlockPlanks.EnumType planks )
{
this.suffix = suffix;
this.metaData = planks.getMetadata( );
this.mapColor = planks.getMapColor( );
@ -74,28 +82,31 @@ public class DBlockTable extends Block implements I_URecipeRegistrar {
public static final PropertyBool SW = PropertyBool.create( "sw" );
public static final PropertyBool SE = PropertyBool.create( "se" );
private static final PropertyBool[] DIRECTIONS = { //
NORTH, NE, EAST, SE, SOUTH, SW, WEST, NW//
DBlockTable.NORTH , DBlockTable.NE , DBlockTable.EAST , DBlockTable.SE , DBlockTable.SOUTH ,
DBlockTable.SW , DBlockTable.WEST , DBlockTable.NW//
};
public final E_WoodType type;
public DBlockTable(E_WoodType type) {
public DBlockTable( final E_WoodType type )
{
super( Material.WOOD , type.mapColor );
this.type = type;
this.setDefaultState( this.blockState.getBaseState( )//
.withProperty(NORTH, Boolean.valueOf(false))//
.withProperty(EAST, Boolean.valueOf(false))//
.withProperty(SOUTH, Boolean.valueOf(false))//
.withProperty(WEST, Boolean.valueOf(false))//
.withProperty(NW, Boolean.valueOf(false))//
.withProperty(NE, Boolean.valueOf(false))//
.withProperty(SW, Boolean.valueOf(false))//
.withProperty(SE, Boolean.valueOf(false)));
.withProperty( DBlockTable.NORTH , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.EAST , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.SOUTH , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.WEST , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.NW , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.NE , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.SW , Boolean.valueOf( false ) )//
.withProperty( DBlockTable.SE , Boolean.valueOf( false ) ) );
this.setCreativeTab( CreativeTabs.DECORATIONS );
this.setRegistryName(ID + type.suffix);
this.setUnlocalizedName(NAME + type.suffix);
this.setRegistryName( DBlockTable.ID + type.suffix );
this.setUnlocalizedName( DBlockTable.NAME + type.suffix );
this.lightOpacity = 0;
this.translucent = false;
@ -110,8 +121,10 @@ public class DBlockTable extends Block implements I_URecipeRegistrar {
URegistration.addBlock( this );
}
@Override
public void registerRecipe() {
public void registerRecipe( )
{
GameRegistry.addShapedRecipe( new ItemStack( this ) , //
"BBB" , //
"S S" , //
@ -120,140 +133,166 @@ public class DBlockTable extends Block implements I_URecipeRegistrar {
);
}
@Override
public boolean isOpaqueCube(IBlockState state) {
public boolean isOpaqueCube( final IBlockState state )
{
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
public boolean isFullCube( final IBlockState state )
{
return false;
}
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) {
public boolean canConnectTo( final IBlockAccess worldIn , final BlockPos pos )
{
return worldIn.getBlockState( pos ).getBlock( ) == this;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] { NORTH, EAST, WEST, SOUTH, NE, NW, SE, SW });
}
@Override
public int getMetaFromState(IBlockState state) {
protected BlockStateContainer createBlockState( )
{
return new BlockStateContainer( this , new IProperty[] {
DBlockTable.NORTH , DBlockTable.EAST , DBlockTable.WEST , DBlockTable.SOUTH , DBlockTable.NE ,
DBlockTable.NW , DBlockTable.SE , DBlockTable.SW
} );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return 0;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
BlockPos n = pos.north();
BlockPos s = pos.south();
BlockPos w = pos.west();
BlockPos e = pos.east();
return state.withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, n)))//
.withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, e)))//
.withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, s)))//
.withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, w)))//
.withProperty(NW, Boolean.valueOf(this.canConnectTo(worldIn, n.west())))//
.withProperty(NE, Boolean.valueOf(this.canConnectTo(worldIn, n.east())))//
.withProperty(SW, Boolean.valueOf(this.canConnectTo(worldIn, s.west())))//
.withProperty(SE, Boolean.valueOf(this.canConnectTo(worldIn, s.east())))//
public IBlockState getActualState( final IBlockState state , final IBlockAccess worldIn , final BlockPos pos )
{
final BlockPos n = pos.north( );
final BlockPos s = pos.south( );
final BlockPos w = pos.west( );
final BlockPos e = pos.east( );
return state.withProperty( DBlockTable.NORTH , Boolean.valueOf( this.canConnectTo( worldIn , n ) ) )//
.withProperty( DBlockTable.EAST , Boolean.valueOf( this.canConnectTo( worldIn , e ) ) )//
.withProperty( DBlockTable.SOUTH , Boolean.valueOf( this.canConnectTo( worldIn , s ) ) )//
.withProperty( DBlockTable.WEST , Boolean.valueOf( this.canConnectTo( worldIn , w ) ) )//
.withProperty( DBlockTable.NW , Boolean.valueOf( this.canConnectTo( worldIn , n.west( ) ) ) )//
.withProperty( DBlockTable.NE , Boolean.valueOf( this.canConnectTo( worldIn , n.east( ) ) ) )//
.withProperty( DBlockTable.SW , Boolean.valueOf( this.canConnectTo( worldIn , s.west( ) ) ) )//
.withProperty( DBlockTable.SE , Boolean.valueOf( this.canConnectTo( worldIn , s.east( ) ) ) )//
;
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot) {
public IBlockState withRotation( final IBlockState state , final Rotation rot )
{
switch ( rot ) {
case CLOCKWISE_180:
return state.withProperty(NORTH, state.getValue(SOUTH))//
.withProperty(EAST, state.getValue(WEST))//
.withProperty(SOUTH, state.getValue(NORTH))//
.withProperty(WEST, state.getValue(EAST))//
.withProperty(NW, state.getValue(SE))//
.withProperty(NE, state.getValue(SW))//
.withProperty(SE, state.getValue(NW))//
.withProperty(SW, state.getValue(NE))//
return state.withProperty( DBlockTable.NORTH , state.getValue( DBlockTable.SOUTH ) )//
.withProperty( DBlockTable.EAST , state.getValue( DBlockTable.WEST ) )//
.withProperty( DBlockTable.SOUTH , state.getValue( DBlockTable.NORTH ) )//
.withProperty( DBlockTable.WEST , state.getValue( DBlockTable.EAST ) )//
.withProperty( DBlockTable.NW , state.getValue( DBlockTable.SE ) )//
.withProperty( DBlockTable.NE , state.getValue( DBlockTable.SW ) )//
.withProperty( DBlockTable.SE , state.getValue( DBlockTable.NW ) )//
.withProperty( DBlockTable.SW , state.getValue( DBlockTable.NE ) )//
;
case COUNTERCLOCKWISE_90:
return state.withProperty(NORTH, state.getValue(EAST))//
.withProperty(EAST, state.getValue(SOUTH))//
.withProperty(SOUTH, state.getValue(WEST))//
.withProperty(WEST, state.getValue(NORTH))//
.withProperty(NW, state.getValue(NE))//
.withProperty(NE, state.getValue(SE))//
.withProperty(SE, state.getValue(SW))//
.withProperty(SW, state.getValue(NW))//
return state.withProperty( DBlockTable.NORTH , state.getValue( DBlockTable.EAST ) )//
.withProperty( DBlockTable.EAST , state.getValue( DBlockTable.SOUTH ) )//
.withProperty( DBlockTable.SOUTH , state.getValue( DBlockTable.WEST ) )//
.withProperty( DBlockTable.WEST , state.getValue( DBlockTable.NORTH ) )//
.withProperty( DBlockTable.NW , state.getValue( DBlockTable.NE ) )//
.withProperty( DBlockTable.NE , state.getValue( DBlockTable.SE ) )//
.withProperty( DBlockTable.SE , state.getValue( DBlockTable.SW ) )//
.withProperty( DBlockTable.SW , state.getValue( DBlockTable.NW ) )//
;
case CLOCKWISE_90:
return state.withProperty(NORTH, state.getValue(WEST))//
.withProperty(EAST, state.getValue(NORTH))//
.withProperty(SOUTH, state.getValue(EAST))//
.withProperty(WEST, state.getValue(SOUTH))//
.withProperty(NW, state.getValue(SW))//
.withProperty(NE, state.getValue(NW))//
.withProperty(SE, state.getValue(NE))//
.withProperty(SW, state.getValue(SE))//
return state.withProperty( DBlockTable.NORTH , state.getValue( DBlockTable.WEST ) )//
.withProperty( DBlockTable.EAST , state.getValue( DBlockTable.NORTH ) )//
.withProperty( DBlockTable.SOUTH , state.getValue( DBlockTable.EAST ) )//
.withProperty( DBlockTable.WEST , state.getValue( DBlockTable.SOUTH ) )//
.withProperty( DBlockTable.NW , state.getValue( DBlockTable.SW ) )//
.withProperty( DBlockTable.NE , state.getValue( DBlockTable.NW ) )//
.withProperty( DBlockTable.SE , state.getValue( DBlockTable.NE ) )//
.withProperty( DBlockTable.SW , state.getValue( DBlockTable.SE ) )//
;
default:
return state;
}
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirrorIn) {
public IBlockState withMirror( final IBlockState state , final Mirror mirrorIn )
{
switch ( mirrorIn ) {
case LEFT_RIGHT:
return state.withProperty(NORTH, state.getValue(SOUTH))//
.withProperty(SOUTH, state.getValue(NORTH))//
.withProperty(NW, state.getValue(SW))//
.withProperty(NE, state.getValue(SE))//
.withProperty(SW, state.getValue(NW))//
.withProperty(SE, state.getValue(NE))//
return state.withProperty( DBlockTable.NORTH , state.getValue( DBlockTable.SOUTH ) )//
.withProperty( DBlockTable.SOUTH , state.getValue( DBlockTable.NORTH ) )//
.withProperty( DBlockTable.NW , state.getValue( DBlockTable.SW ) )//
.withProperty( DBlockTable.NE , state.getValue( DBlockTable.SE ) )//
.withProperty( DBlockTable.SW , state.getValue( DBlockTable.NW ) )//
.withProperty( DBlockTable.SE , state.getValue( DBlockTable.NE ) )//
;
case FRONT_BACK:
return state.withProperty(EAST, state.getValue(WEST))//
.withProperty(WEST, state.getValue(EAST))//
.withProperty(NW, state.getValue(NE))//
.withProperty(NE, state.getValue(NW))//
.withProperty(SW, state.getValue(SE))//
.withProperty(SE, state.getValue(SW))//
return state.withProperty( DBlockTable.EAST , state.getValue( DBlockTable.WEST ) )//
.withProperty( DBlockTable.WEST , state.getValue( DBlockTable.EAST ) )//
.withProperty( DBlockTable.NW , state.getValue( DBlockTable.NE ) )//
.withProperty( DBlockTable.NE , state.getValue( DBlockTable.NW ) )//
.withProperty( DBlockTable.SW , state.getValue( DBlockTable.SE ) )//
.withProperty( DBlockTable.SE , state.getValue( DBlockTable.SW ) )//
;
default:
return state;
}
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
IBlockState actual = this.getActualState(state, source, pos);
for (int i = 0, dir = 0; i < 4; i++, dir += 2) {
boolean c0 = actual.getValue(DIRECTIONS[dir]);
boolean c1 = actual.getValue(DIRECTIONS[(dir + 6) % 8]);
boolean c10 = actual.getValue(DIRECTIONS[(dir + 7) % 8]);
if (!(c0 || c1) || (c0 && c1 && !c10)) {
return FULL_BLOCK_AABB;
}
}
return COLLISION_TOP;
}
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB container,
List<AxisAlignedBB> output, Entity entity) {
IBlockState actual = this.getActualState(state, worldIn, pos);
addCollisionBoxToList(pos, container, output, COLLISION_TOP);
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
{
final IBlockState actual = this.getActualState( state , source , pos );
for ( int i = 0 , dir = 0 ; i < 4 ; i++ , dir += 2 ) {
boolean c0 = actual.getValue(DIRECTIONS[dir]);
boolean c1 = actual.getValue(DIRECTIONS[(dir + 6) % 8]);
boolean c10 = actual.getValue(DIRECTIONS[(dir + 7) % 8]);
if (!(c0 || c1) || (c0 && c1 && !c10)) {
addCollisionBoxToList(pos, container, output, COLLISION_LEGS[i]);
final boolean c0 = actual.getValue( DBlockTable.DIRECTIONS[ dir ] );
final boolean c1 = actual.getValue( DBlockTable.DIRECTIONS[ ( dir + 6 ) % 8 ] );
final boolean c10 = actual.getValue( DBlockTable.DIRECTIONS[ ( dir + 7 ) % 8 ] );
if ( ! ( c0 || c1 ) || c0 && c1 && !c10 ) {
return Block.FULL_BLOCK_AABB;
}
}
return DBlockTable.COLLISION_TOP;
}
@Override
public void addCollisionBoxToList( final IBlockState state , final World worldIn , final BlockPos pos ,
final AxisAlignedBB container , final List< AxisAlignedBB > output , final Entity entity )
{
final IBlockState actual = this.getActualState( state , worldIn , pos );
Block.addCollisionBoxToList( pos , container , output , DBlockTable.COLLISION_TOP );
for ( int i = 0 , dir = 0 ; i < 4 ; i++ , dir += 2 ) {
final boolean c0 = actual.getValue( DBlockTable.DIRECTIONS[ dir ] );
final boolean c1 = actual.getValue( DBlockTable.DIRECTIONS[ ( dir + 6 ) % 8 ] );
final boolean c10 = actual.getValue( DBlockTable.DIRECTIONS[ ( dir + 7 ) % 8 ] );
if ( ! ( c0 || c1 ) || c0 && c1 && !c10 ) {
Block.addCollisionBoxToList( pos , container , output , DBlockTable.COLLISION_LEGS[ i ] );
}
}
}
@Override
@SideOnly( Side.CLIENT )
public BlockRenderLayer getBlockLayer() {
public BlockRenderLayer getBlockLayer( )
{
return BlockRenderLayer.CUTOUT;
}
}

View file

@ -1,6 +1,8 @@
package mmm.deco;
public class DecorativeBlocks {
public class DecorativeBlocks
{
public static final DBlockTable TABLE_OAK;
public static final DBlockTable TABLE_BIRCH;
@ -18,7 +20,9 @@ public class DecorativeBlocks {
TABLE_ACACIA = new DBlockTable( DBlockTable.E_WoodType.ACACIA );
}
public static void preInit() {
public static void preInit( )
{
// EMPTY
}

View file

@ -1,6 +1,8 @@
package mmm.utils;
public interface I_URecipeRegistrar {
public interface I_URecipeRegistrar
{
public void registerRecipe( );

View file

@ -1,10 +1,16 @@
package mmm.utils;
import net.minecraft.util.math.AxisAlignedBB;
public class UMaths {
public static AxisAlignedBB makeBlockAABB(int x1, int y1, int z1, int x2, int y2, int z2) {
public class UMaths
{
public static AxisAlignedBB makeBlockAABB( final int x1 , final int y1 , final int z1 , final int x2 ,
final int y2 , final int z2 )
{
return new AxisAlignedBB( x1 * .0625 , y1 * .0625 , z1 * .0625 , x2 * .0625 , y2 * .0625 , z2 * .0625 );
}

View file

@ -1,5 +1,6 @@
package mmm.utils;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@ -11,60 +12,80 @@ import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class URegistration {
public class URegistration
{
private static final HashMap< Item , Boolean > ITEMS = new HashMap< Item , Boolean >( );
private static final HashSet< Block > BLOCKS = new HashSet< Block >( );
public static void addItem(Item item) {
addItem(item, true);
public static void addItem( final Item item )
{
URegistration.addItem( item , true );
}
public static void addItem(Item item, boolean registerModel) {
public static void addItem( final Item item , final boolean registerModel )
{
GameRegistry.register( item );
ITEMS.put(item, registerModel);
URegistration.ITEMS.put( item , registerModel );
}
public static void addBlock(Block block) {
addBlock(block, true);
public static void addBlock( final Block block )
{
URegistration.addBlock( block , true );
}
public static void addBlock(Block block, Item blockItem) {
addBlock(block, blockItem, true);
public static void addBlock( final Block block , final Item blockItem )
{
URegistration.addBlock( block , blockItem , true );
}
public static void addBlock(Block block, boolean registerItemModel) {
addBlock(block, new ItemBlock(block).setRegistryName(block.getRegistryName()), registerItemModel);
public static void addBlock( final Block block , final boolean registerItemModel )
{
URegistration.addBlock( block , new ItemBlock( block ).setRegistryName( block.getRegistryName( ) ) ,
registerItemModel );
}
public static void addBlock(Block block, Item blockItem, boolean registerItemModel) {
public static void addBlock( final Block block , final Item blockItem , final boolean registerItemModel )
{
GameRegistry.register( block );
BLOCKS.add(block);
URegistration.BLOCKS.add( block );
if ( blockItem != null ) {
addItem(blockItem, registerItemModel);
URegistration.addItem( blockItem , registerItemModel );
}
}
public static void registerRecipes() {
for (Block block : BLOCKS) {
public static void registerRecipes( )
{
for ( final Block block : URegistration.BLOCKS ) {
if ( block instanceof I_URecipeRegistrar ) {
( (I_URecipeRegistrar) block ).registerRecipe( );
}
}
for (Item item : ITEMS.keySet()) {
for ( final Item item : URegistration.ITEMS.keySet( ) ) {
if ( item instanceof I_URecipeRegistrar ) {
( (I_URecipeRegistrar) item ).registerRecipe( );
}
}
}
public static void setupItemModels() {
for (Map.Entry<Item, Boolean> entry : ITEMS.entrySet()) {
public static void setupItemModels( )
{
for ( final Map.Entry< Item , Boolean > entry : URegistration.ITEMS.entrySet( ) ) {
if ( !entry.getValue( ) ) {
continue;
}
Item item = entry.getKey();
final Item item = entry.getKey( );
ModelLoader.setCustomModelResourceLocation( item , 0 ,
new ModelResourceLocation( item.getRegistryName( ) , "inventory" ) );
}