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;
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
{

View file

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

View file

@ -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 ) , //

View file

@ -18,7 +18,7 @@ public class FMilkBucket
public final FMilkType milkType;
public FMilkBucket( FMilkType milkType )
public FMilkBucket( final FMilkType milkType )
{
super( );
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 );
}
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 );
}

View file

@ -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 ) ) {

View file

@ -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;
}

View file

@ -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 ) , //

View file

@ -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 );

View file

@ -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 {

View file

@ -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;

View file

@ -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 ) ) );

View file

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

View file

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

View file

@ -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" );

View file

@ -1,7 +1,10 @@
package mmm.utils;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
public interface I_UItemModelProvider
{

View file

@ -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 );
}
}

View file

@ -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;