Source clean-up

This commit is contained in:
Emmanuel BENOîT 2016-06-17 14:34:02 +02:00
parent f404da6034
commit 444e020ae0
18 changed files with 61 additions and 42 deletions

View file

@ -1,5 +1,6 @@
package mmm.deco; package mmm.deco;
import java.util.Random; import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -10,6 +11,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
public class DExtraSlabDouble public class DExtraSlabDouble
extends DExtraSlabBlock extends DExtraSlabBlock
{ {

View file

@ -1,7 +1,10 @@
package mmm.deco; package mmm.deco;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
public class DExtraSlabHalf public class DExtraSlabHalf
extends DExtraSlabBlock extends DExtraSlabBlock
{ {

View file

@ -1,10 +1,13 @@
package mmm.deco; package mmm.deco;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
public enum E_DWoodType { public enum E_DWoodType {
OAK( "oak" , BlockPlanks.EnumType.OAK ) , // OAK( "oak" , BlockPlanks.EnumType.OAK ) , //
BIRCH( "birch" , BlockPlanks.EnumType.BIRCH ) , // BIRCH( "birch" , BlockPlanks.EnumType.BIRCH ) , //

View file

@ -18,7 +18,7 @@ public class FMilkBucket
public final FMilkType milkType; public final FMilkType milkType;
public FMilkBucket( FMilkType milkType ) public FMilkBucket( final FMilkType milkType )
{ {
super( ); super( );
this.milkType = milkType; this.milkType = milkType;

View file

@ -58,13 +58,14 @@ public class FMilkType
} }
public FMilkType( String name , Class< ? extends EntityAnimal > animal ) public FMilkType( final String name , final Class< ? extends EntityAnimal > animal )
{ {
this( name , false , animal , null ); this( name , false , animal , null );
} }
private FMilkType( String name , boolean isVanilla , Class< ? extends EntityAnimal > animal , Item bucket ) private FMilkType( final String name , final boolean isVanilla , final Class< ? extends EntityAnimal > animal ,
Item bucket )
{ {
this.name = name; this.name = name;
this.isVanilla = isVanilla; this.isVanilla = isVanilla;
@ -74,18 +75,18 @@ public class FMilkType
URegistry.addItem( bucket ); URegistry.addItem( bucket );
} }
this.bucket = bucket; this.bucket = bucket;
MILK_TYPES.put( animal , this ); FMilkType.MILK_TYPES.put( animal , this );
} }
public FMilkType setExtraCheck( Predicate< EntityAnimal > extraCheck ) public FMilkType setExtraCheck( final Predicate< EntityAnimal > extraCheck )
{ {
this.extraCheck = extraCheck; this.extraCheck = extraCheck;
return this; return this;
} }
public boolean check( EntityAnimal animal ) public boolean check( final EntityAnimal animal )
{ {
return this.extraCheck == null || this.extraCheck.test( animal ); return this.extraCheck == null || this.extraCheck.test( animal );
} }

View file

@ -18,18 +18,18 @@ public class FMilkingHandler
{ {
@SubscribeEvent @SubscribeEvent
public void handleMilking( PlayerInteractEvent.EntityInteract event ) public void handleMilking( final PlayerInteractEvent.EntityInteract event )
{ {
ItemStack heldStack = event.getItemStack( ); final ItemStack heldStack = event.getItemStack( );
if ( heldStack == null || heldStack.getItem( ) != Items.BUCKET ) { if ( heldStack == null || heldStack.getItem( ) != Items.BUCKET ) {
return; return;
} }
Entity target = event.getTarget( ); final Entity target = event.getTarget( );
if ( ! ( target instanceof EntityAnimal ) ) { if ( ! ( target instanceof EntityAnimal ) ) {
return; return;
} }
EntityAnimal animal = (EntityAnimal) target; final EntityAnimal animal = (EntityAnimal) target;
if ( animal.isChild( ) ) { if ( animal.isChild( ) ) {
return; return;
} }
@ -38,9 +38,9 @@ public class FMilkingHandler
return; return;
} }
Set< FMilkType > milkTypes = FMilkType.MILK_TYPES.get( animal.getClass( ) ); final Set< FMilkType > milkTypes = FMilkType.MILK_TYPES.get( animal.getClass( ) );
FMilkType milkType = null; FMilkType milkType = null;
for ( FMilkType type : milkTypes ) { for ( final FMilkType type : milkTypes ) {
if ( type.check( animal ) ) { if ( type.check( animal ) ) {
milkType = type; milkType = type;
break; break;
@ -50,9 +50,9 @@ public class FMilkingHandler
return; return;
} }
EntityPlayer player = event.getEntityPlayer( ); final EntityPlayer player = event.getEntityPlayer( );
if ( !milkType.isVanilla || player.capabilities.isCreativeMode ) { if ( !milkType.isVanilla || player.capabilities.isCreativeMode ) {
ItemStack bucket = new ItemStack( milkType.bucket ); final ItemStack bucket = new ItemStack( milkType.bucket );
if ( --heldStack.stackSize == 0 ) { if ( --heldStack.stackSize == 0 ) {
player.setHeldItem( event.getHand( ) , bucket ); player.setHeldItem( event.getHand( ) , bucket );
} else if ( !player.inventory.addItemStackToInventory( bucket ) ) { } else if ( !player.inventory.addItemStackToInventory( bucket ) ) {

View file

@ -8,7 +8,7 @@ public enum E_MMetalItemType {
public final String name; public final String name;
private E_MMetalItemType( String name ) private E_MMetalItemType( final String name )
{ {
this.name = name; this.name = name;
} }

View file

@ -21,8 +21,8 @@ public class MMetal
public final Item NUGGET; public final Item NUGGET;
public MMetal( final String name , final float baseSmeltingXP , float hardness , int harvestLevel , public MMetal( final String name , final float baseSmeltingXP , final float hardness , final int harvestLevel ,
MapColor mapColor ) final MapColor mapColor )
{ {
this( baseSmeltingXP , new MMetalBlock( name , hardness , harvestLevel , mapColor ) , // this( baseSmeltingXP , new MMetalBlock( name , hardness , harvestLevel , mapColor ) , //
new MMetalItem( E_MMetalItemType.INGOT , name ) , // new MMetalItem( E_MMetalItemType.INGOT , name ) , //

View file

@ -14,7 +14,7 @@ public class MMetalBlock
extends Block extends Block
{ {
public MMetalBlock( String name , float hardness , int harvestLevel , MapColor mapColor ) public MMetalBlock( final String name , final float hardness , final int harvestLevel , final MapColor mapColor )
{ {
super( Material.IRON , mapColor ); super( Material.IRON , mapColor );
this.setHardness( hardness ); this.setHardness( hardness );

View file

@ -181,8 +181,8 @@ public class MOre
public void registerRecipes( ) public void registerRecipes( )
{ {
if ( this.metal != null ) { if ( this.metal != null ) {
ItemStack output = new ItemStack( this.metal.INGOT , this.genIngots ); final ItemStack output = new ItemStack( this.metal.INGOT , this.genIngots );
float xp = this.metal.SMELTING_XP * this.genIngots; final float xp = this.metal.SMELTING_XP * this.genIngots;
if ( this.dropItems == null ) { if ( this.dropItems == null ) {
GameRegistry.addSmelting( this , output , xp ); GameRegistry.addSmelting( this , output , xp );
} else { } else {

View file

@ -37,8 +37,8 @@ public class Materials
COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT ); COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT );
// Stones extracted from ores // Stones extracted from ores
URegistry.addItem( STONE_MALACHITE = makeStone( "malachite" ) ); URegistry.addItem( STONE_MALACHITE = Materials.makeStone( "malachite" ) );
URegistry.addItem( STONE_CUPRITE = makeStone( "cuprite" ) ); URegistry.addItem( STONE_CUPRITE = Materials.makeStone( "cuprite" ) );
// Actual ores // Actual ores
URegistry.addBlock( ORE_COPPER = new MOCopper( ) ); URegistry.addBlock( ORE_COPPER = new MOCopper( ) );
@ -47,9 +47,9 @@ public class Materials
} }
public static Item makeStone( String name ) public static Item makeStone( final String name )
{ {
Item stone = new Item( ); final Item stone = new Item( );
URegistry.setIdentifiers( stone , "materials" , "stone" , name ); URegistry.setIdentifiers( stone , "materials" , "stone" , name );
stone.setCreativeTab( CreativeTabs.MATERIALS ); stone.setCreativeTab( CreativeTabs.MATERIALS );
return stone; return stone;

View file

@ -25,7 +25,7 @@ public class MOCopper
@Override @Override
public void addConditions( List< WOreGenerationCondition > conditions ) public void addConditions( final List< WOreGenerationCondition > conditions )
{ {
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) , conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) ); new WOreGenerationParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) );

View file

@ -1,8 +1,11 @@
package mmm.proxy; package mmm.proxy;
import mmm.utils.URegistry; import mmm.utils.URegistry;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class PClient public class PClient
extends PCommon extends PCommon
{ {

View file

@ -1,5 +1,6 @@
package mmm.proxy; package mmm.proxy;
public class PServer public class PServer
extends PCommon extends PCommon
{ {

View file

@ -15,7 +15,7 @@ public class TTAxe
implements I_URecipeRegistrar implements I_URecipeRegistrar
{ {
public TTAxe( final ToolMaterial material , float damage , float attackSpeed ) public TTAxe( final ToolMaterial material , final float damage , final float attackSpeed )
{ {
super( material , damage , attackSpeed ); super( material , damage , attackSpeed );
URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "axe" ); URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "axe" );

View file

@ -1,10 +1,13 @@
package mmm.utils; package mmm.utils;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
public interface I_UItemModelProvider public interface I_UItemModelProvider
{ {
public ModelResourceLocation getModelResourceLocation( ); public ModelResourceLocation getModelResourceLocation( );
} }

View file

@ -16,20 +16,20 @@ public class UAccessors
private static final boolean isDeobfuscated; private static final boolean isDeobfuscated;
private static MethodHandle createGetter( Class< ? > cls , String fnForge , String fnSearge ) private static MethodHandle createGetter( final Class< ? > cls , final String fnForge , final String fnSearge )
{ {
String fn = isDeobfuscated ? fnForge : fnSearge; final String fn = UAccessors.isDeobfuscated ? fnForge : fnSearge;
Field f; Field f;
try { try {
f = cls.getDeclaredField( fn ); f = cls.getDeclaredField( fn );
} catch ( NoSuchFieldException e ) { } catch ( final NoSuchFieldException e ) {
throw new RuntimeException( "could not find field " + fnForge + " / " + fnSearge // throw new RuntimeException( "could not find field " + fnForge + " / " + fnSearge //
+ " in class " + cls.getCanonicalName( ) , e ); + " in class " + cls.getCanonicalName( ) , e );
} }
f.setAccessible( true ); f.setAccessible( true );
try { try {
return MethodHandles.lookup( ).unreflectGetter( f ); return MethodHandles.lookup( ).unreflectGetter( f );
} catch ( IllegalAccessException e ) { } catch ( final IllegalAccessException e ) {
throw new RuntimeException( "error while creating getter for " + fnForge + " / " + fnSearge // throw new RuntimeException( "error while creating getter for " + fnForge + " / " + fnSearge //
+ " in class " + cls.getCanonicalName( ) , e ); + " in class " + cls.getCanonicalName( ) , e );
} }
@ -40,8 +40,8 @@ public class UAccessors
static { static {
isDeobfuscated = (Boolean) Launch.blackboard.get( "fml.deobfuscatedEnvironment" ); isDeobfuscated = (Boolean) Launch.blackboard.get( "fml.deobfuscatedEnvironment" );
fg_Block_blockHardness = createGetter( Block.class , "blockHardness" , "field_149782_v" ); fg_Block_blockHardness = UAccessors.createGetter( Block.class , "blockHardness" , "field_149782_v" );
fg_Block_blockResistance = createGetter( Block.class , "blockResistance" , "field_149781_w" ); fg_Block_blockResistance = UAccessors.createGetter( Block.class , "blockResistance" , "field_149781_w" );
} }
@ -51,16 +51,16 @@ public class UAccessors
} }
public static float getBlockHardness( Block block ) public static float getBlockHardness( final Block block )
throws Throwable throws Throwable
{ {
return (float) fg_Block_blockHardness.invokeExact( block ); return (float) UAccessors.fg_Block_blockHardness.invokeExact( block );
} }
public static float getBlockResistance( Block block ) public static float getBlockResistance( final Block block )
throws Throwable throws Throwable
{ {
return (float) fg_Block_blockResistance.invokeExact( block ); return (float) UAccessors.fg_Block_blockResistance.invokeExact( block );
} }
} }

View file

@ -19,21 +19,23 @@ public class USeat
extends Entity extends Entity
{ {
public static void register( Mmm mmm ) public static void register( final Mmm mmm )
{ {
EntityRegistry.registerModEntity( USeat.class , "Seat" , 0 , mmm , 80 , 1 , false ); EntityRegistry.registerModEntity( USeat.class , "Seat" , 0 , mmm , 80 , 1 , false );
} }
public static boolean sit( World world , BlockPos pos , EntityPlayer player , double yOffset ) public static boolean sit( final World world , final BlockPos pos , final EntityPlayer player ,
final double yOffset )
{ {
if ( world.isRemote ) { if ( world.isRemote ) {
return true; return true;
} }
List< USeat > seats = world.getEntitiesWithinAABB( USeat.class , new AxisAlignedBB( pos ).expand( 1 , 1 , 1 ) ); final List< USeat > seats = world.getEntitiesWithinAABB( USeat.class ,
new AxisAlignedBB( pos ).expand( 1 , 1 , 1 ) );
USeat seat = null; USeat seat = null;
for ( USeat existingSeat : seats ) { for ( final USeat existingSeat : seats ) {
if ( !existingSeat.pos.equals( pos ) ) { if ( !existingSeat.pos.equals( pos ) ) {
continue; continue;
} }
@ -146,7 +148,7 @@ public class USeat
return; return;
} }
Block block = this.worldObj.getBlockState( this.pos ).getBlock( ); final Block block = this.worldObj.getBlockState( this.pos ).getBlock( );
if ( ! ( block instanceof I_UBlockSeat ) ) { if ( ! ( block instanceof I_UBlockSeat ) ) {
this.setDead( ); this.setDead( );
return; return;