From 444e020ae0509f5d8874640f4984e97e083b0072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Fri, 17 Jun 2016 14:34:02 +0200 Subject: [PATCH] Source clean-up --- src/java/mmm/deco/DExtraSlabDouble.java | 3 +++ src/java/mmm/deco/DExtraSlabHalf.java | 3 +++ src/java/mmm/deco/E_DWoodType.java | 3 +++ src/java/mmm/food/FMilkBucket.java | 2 +- src/java/mmm/food/FMilkType.java | 11 ++++++----- src/java/mmm/food/FMilkingHandler.java | 16 ++++++++-------- src/java/mmm/materials/E_MMetalItemType.java | 2 +- src/java/mmm/materials/MMetal.java | 4 ++-- src/java/mmm/materials/MMetalBlock.java | 2 +- src/java/mmm/materials/MOre.java | 4 ++-- src/java/mmm/materials/Materials.java | 8 ++++---- src/java/mmm/materials/ore/MOCopper.java | 2 +- src/java/mmm/proxy/PClient.java | 3 +++ src/java/mmm/proxy/PServer.java | 1 + src/java/mmm/tech/tools/TTAxe.java | 2 +- src/java/mmm/utils/I_UItemModelProvider.java | 5 ++++- src/java/mmm/utils/UAccessors.java | 20 ++++++++++---------- src/java/mmm/utils/USeat.java | 12 +++++++----- 18 files changed, 61 insertions(+), 42 deletions(-) diff --git a/src/java/mmm/deco/DExtraSlabDouble.java b/src/java/mmm/deco/DExtraSlabDouble.java index 79c8939..210ad85 100644 --- a/src/java/mmm/deco/DExtraSlabDouble.java +++ b/src/java/mmm/deco/DExtraSlabDouble.java @@ -1,5 +1,6 @@ package mmm.deco; + import java.util.Random; import javax.annotation.Nullable; @@ -10,6 +11,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + + public class DExtraSlabDouble extends DExtraSlabBlock { diff --git a/src/java/mmm/deco/DExtraSlabHalf.java b/src/java/mmm/deco/DExtraSlabHalf.java index 6c7e717..2ea1ab9 100644 --- a/src/java/mmm/deco/DExtraSlabHalf.java +++ b/src/java/mmm/deco/DExtraSlabHalf.java @@ -1,7 +1,10 @@ package mmm.deco; + import net.minecraft.block.state.IBlockState; + + public class DExtraSlabHalf extends DExtraSlabBlock { diff --git a/src/java/mmm/deco/E_DWoodType.java b/src/java/mmm/deco/E_DWoodType.java index 3b36f2e..8c48ea7 100644 --- a/src/java/mmm/deco/E_DWoodType.java +++ b/src/java/mmm/deco/E_DWoodType.java @@ -1,10 +1,13 @@ package mmm.deco; + import net.minecraft.block.Block; import net.minecraft.block.BlockPlanks; import net.minecraft.block.material.MapColor; import net.minecraft.init.Blocks; + + public enum E_DWoodType { OAK( "oak" , BlockPlanks.EnumType.OAK ) , // BIRCH( "birch" , BlockPlanks.EnumType.BIRCH ) , // diff --git a/src/java/mmm/food/FMilkBucket.java b/src/java/mmm/food/FMilkBucket.java index afa174e..3f8343e 100644 --- a/src/java/mmm/food/FMilkBucket.java +++ b/src/java/mmm/food/FMilkBucket.java @@ -18,7 +18,7 @@ public class FMilkBucket public final FMilkType milkType; - public FMilkBucket( FMilkType milkType ) + public FMilkBucket( final FMilkType milkType ) { super( ); this.milkType = milkType; diff --git a/src/java/mmm/food/FMilkType.java b/src/java/mmm/food/FMilkType.java index cd1a144..d562c58 100644 --- a/src/java/mmm/food/FMilkType.java +++ b/src/java/mmm/food/FMilkType.java @@ -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 ); } - 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.isVanilla = isVanilla; @@ -74,18 +75,18 @@ public class FMilkType URegistry.addItem( 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; return this; } - public boolean check( EntityAnimal animal ) + public boolean check( final EntityAnimal animal ) { return this.extraCheck == null || this.extraCheck.test( animal ); } diff --git a/src/java/mmm/food/FMilkingHandler.java b/src/java/mmm/food/FMilkingHandler.java index 8c778ba..2373d3b 100644 --- a/src/java/mmm/food/FMilkingHandler.java +++ b/src/java/mmm/food/FMilkingHandler.java @@ -18,18 +18,18 @@ public class FMilkingHandler { @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 ) { return; } - Entity target = event.getTarget( ); + final Entity target = event.getTarget( ); if ( ! ( target instanceof EntityAnimal ) ) { return; } - EntityAnimal animal = (EntityAnimal) target; + final EntityAnimal animal = (EntityAnimal) target; if ( animal.isChild( ) ) { return; } @@ -38,9 +38,9 @@ public class FMilkingHandler return; } - Set< FMilkType > milkTypes = FMilkType.MILK_TYPES.get( animal.getClass( ) ); + final Set< FMilkType > milkTypes = FMilkType.MILK_TYPES.get( animal.getClass( ) ); FMilkType milkType = null; - for ( FMilkType type : milkTypes ) { + for ( final FMilkType type : milkTypes ) { if ( type.check( animal ) ) { milkType = type; break; @@ -50,9 +50,9 @@ public class FMilkingHandler return; } - EntityPlayer player = event.getEntityPlayer( ); + final EntityPlayer player = event.getEntityPlayer( ); if ( !milkType.isVanilla || player.capabilities.isCreativeMode ) { - ItemStack bucket = new ItemStack( milkType.bucket ); + final ItemStack bucket = new ItemStack( milkType.bucket ); if ( --heldStack.stackSize == 0 ) { player.setHeldItem( event.getHand( ) , bucket ); } else if ( !player.inventory.addItemStackToInventory( bucket ) ) { diff --git a/src/java/mmm/materials/E_MMetalItemType.java b/src/java/mmm/materials/E_MMetalItemType.java index 5be0a17..adcda70 100644 --- a/src/java/mmm/materials/E_MMetalItemType.java +++ b/src/java/mmm/materials/E_MMetalItemType.java @@ -8,7 +8,7 @@ public enum E_MMetalItemType { public final String name; - private E_MMetalItemType( String name ) + private E_MMetalItemType( final String name ) { this.name = name; } diff --git a/src/java/mmm/materials/MMetal.java b/src/java/mmm/materials/MMetal.java index f57accc..8eb644c 100644 --- a/src/java/mmm/materials/MMetal.java +++ b/src/java/mmm/materials/MMetal.java @@ -21,8 +21,8 @@ public class MMetal public final Item NUGGET; - public MMetal( final String name , final float baseSmeltingXP , float hardness , int harvestLevel , - MapColor mapColor ) + public MMetal( final String name , final float baseSmeltingXP , final float hardness , final int harvestLevel , + final MapColor mapColor ) { this( baseSmeltingXP , new MMetalBlock( name , hardness , harvestLevel , mapColor ) , // new MMetalItem( E_MMetalItemType.INGOT , name ) , // diff --git a/src/java/mmm/materials/MMetalBlock.java b/src/java/mmm/materials/MMetalBlock.java index 281df23..f03be61 100644 --- a/src/java/mmm/materials/MMetalBlock.java +++ b/src/java/mmm/materials/MMetalBlock.java @@ -14,7 +14,7 @@ public class MMetalBlock 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 ); this.setHardness( hardness ); diff --git a/src/java/mmm/materials/MOre.java b/src/java/mmm/materials/MOre.java index d827176..87a0bab 100644 --- a/src/java/mmm/materials/MOre.java +++ b/src/java/mmm/materials/MOre.java @@ -181,8 +181,8 @@ public class MOre public void registerRecipes( ) { if ( this.metal != null ) { - ItemStack output = new ItemStack( this.metal.INGOT , this.genIngots ); - float xp = this.metal.SMELTING_XP * this.genIngots; + final ItemStack output = new ItemStack( this.metal.INGOT , this.genIngots ); + final float xp = this.metal.SMELTING_XP * this.genIngots; if ( this.dropItems == null ) { GameRegistry.addSmelting( this , output , xp ); } else { diff --git a/src/java/mmm/materials/Materials.java b/src/java/mmm/materials/Materials.java index 0f7aa22..dc4ec59 100644 --- a/src/java/mmm/materials/Materials.java +++ b/src/java/mmm/materials/Materials.java @@ -37,8 +37,8 @@ public class Materials COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT ); // Stones extracted from ores - URegistry.addItem( STONE_MALACHITE = makeStone( "malachite" ) ); - URegistry.addItem( STONE_CUPRITE = makeStone( "cuprite" ) ); + URegistry.addItem( STONE_MALACHITE = Materials.makeStone( "malachite" ) ); + URegistry.addItem( STONE_CUPRITE = Materials.makeStone( "cuprite" ) ); // Actual ores 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 ); stone.setCreativeTab( CreativeTabs.MATERIALS ); return stone; diff --git a/src/java/mmm/materials/ore/MOCopper.java b/src/java/mmm/materials/ore/MOCopper.java index fbca57c..936fd26 100644 --- a/src/java/mmm/materials/ore/MOCopper.java +++ b/src/java/mmm/materials/ore/MOCopper.java @@ -25,7 +25,7 @@ public class MOCopper @Override - public void addConditions( List< WOreGenerationCondition > conditions ) + public void addConditions( final List< WOreGenerationCondition > conditions ) { conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) , new WOreGenerationParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) ); diff --git a/src/java/mmm/proxy/PClient.java b/src/java/mmm/proxy/PClient.java index 23c5a16..3b13bc2 100644 --- a/src/java/mmm/proxy/PClient.java +++ b/src/java/mmm/proxy/PClient.java @@ -1,8 +1,11 @@ package mmm.proxy; + import mmm.utils.URegistry; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + + public class PClient extends PCommon { diff --git a/src/java/mmm/proxy/PServer.java b/src/java/mmm/proxy/PServer.java index 814e471..8b041e8 100644 --- a/src/java/mmm/proxy/PServer.java +++ b/src/java/mmm/proxy/PServer.java @@ -1,5 +1,6 @@ package mmm.proxy; + public class PServer extends PCommon { diff --git a/src/java/mmm/tech/tools/TTAxe.java b/src/java/mmm/tech/tools/TTAxe.java index 259de55..b0391dd 100644 --- a/src/java/mmm/tech/tools/TTAxe.java +++ b/src/java/mmm/tech/tools/TTAxe.java @@ -15,7 +15,7 @@ public class TTAxe 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 ); URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "axe" ); diff --git a/src/java/mmm/utils/I_UItemModelProvider.java b/src/java/mmm/utils/I_UItemModelProvider.java index 3512e16..9a13403 100644 --- a/src/java/mmm/utils/I_UItemModelProvider.java +++ b/src/java/mmm/utils/I_UItemModelProvider.java @@ -1,10 +1,13 @@ package mmm.utils; + import net.minecraft.client.renderer.block.model.ModelResourceLocation; + + public interface I_UItemModelProvider { - + public ModelResourceLocation getModelResourceLocation( ); } diff --git a/src/java/mmm/utils/UAccessors.java b/src/java/mmm/utils/UAccessors.java index afcde72..4bc8278 100644 --- a/src/java/mmm/utils/UAccessors.java +++ b/src/java/mmm/utils/UAccessors.java @@ -16,20 +16,20 @@ public class UAccessors 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; try { f = cls.getDeclaredField( fn ); - } catch ( NoSuchFieldException e ) { + } catch ( final NoSuchFieldException e ) { throw new RuntimeException( "could not find field " + fnForge + " / " + fnSearge // + " in class " + cls.getCanonicalName( ) , e ); } f.setAccessible( true ); try { return MethodHandles.lookup( ).unreflectGetter( f ); - } catch ( IllegalAccessException e ) { + } catch ( final IllegalAccessException e ) { throw new RuntimeException( "error while creating getter for " + fnForge + " / " + fnSearge // + " in class " + cls.getCanonicalName( ) , e ); } @@ -40,8 +40,8 @@ public class UAccessors static { isDeobfuscated = (Boolean) Launch.blackboard.get( "fml.deobfuscatedEnvironment" ); - fg_Block_blockHardness = createGetter( Block.class , "blockHardness" , "field_149782_v" ); - fg_Block_blockResistance = createGetter( Block.class , "blockResistance" , "field_149781_w" ); + fg_Block_blockHardness = UAccessors.createGetter( Block.class , "blockHardness" , "field_149782_v" ); + 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 { - 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 { - return (float) fg_Block_blockResistance.invokeExact( block ); + return (float) UAccessors.fg_Block_blockResistance.invokeExact( block ); } } diff --git a/src/java/mmm/utils/USeat.java b/src/java/mmm/utils/USeat.java index b97b080..6a74625 100644 --- a/src/java/mmm/utils/USeat.java +++ b/src/java/mmm/utils/USeat.java @@ -19,21 +19,23 @@ public class USeat 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 ); } - 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 ) { 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; - for ( USeat existingSeat : seats ) { + for ( final USeat existingSeat : seats ) { if ( !existingSeat.pos.equals( pos ) ) { continue; } @@ -146,7 +148,7 @@ public class USeat return; } - Block block = this.worldObj.getBlockState( this.pos ).getBlock( ); + final Block block = this.worldObj.getBlockState( this.pos ).getBlock( ); if ( ! ( block instanceof I_UBlockSeat ) ) { this.setDead( ); return;