From a43b2730d37d11fde32f1b8d4469cc74d8dfd3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Wed, 15 Jun 2016 21:36:57 +0200 Subject: [PATCH] Some refactoring. Also, copper. --- src/java/mmm/materials/E_MMetalItemType.java | 14 +++++ src/java/mmm/materials/MMetal.java | 58 ++++++++++++++++++ .../materials/{MItem.java => MMetalItem.java} | 7 +-- .../mmm/materials/{DOre.java => MOre.java} | 51 ++++++++++++--- src/java/mmm/materials/Materials.java | 27 +++----- .../mmm/blockstates/materials/ore/copper.json | 5 ++ .../blockstates/materials/ores/copper.json | 5 -- src/resources/assets/mmm/lang/en_US.lang | 6 +- .../block/materials/{ores => ore}/copper.json | 2 +- .../models/item/materials/ingot/copper.json | 6 ++ .../models/item/materials/nugget/copper.json | 6 ++ .../{iron_nugget.json => nugget/iron.json} | 2 +- .../mmm/models/item/materials/ore/copper.json | 3 + .../models/item/materials/ores/copper.json | 3 - .../blocks/materials/{ores => ore}/copper.png | Bin .../items/materials/ingots/copper.png | Bin 0 -> 204 bytes .../items/materials/nuggets/copper.png | Bin 0 -> 137 bytes .../{iron_nugget.png => nuggets/iron.png} | Bin 18 files changed, 150 insertions(+), 45 deletions(-) create mode 100644 src/java/mmm/materials/E_MMetalItemType.java create mode 100644 src/java/mmm/materials/MMetal.java rename src/java/mmm/materials/{MItem.java => MMetalItem.java} (57%) rename src/java/mmm/materials/{DOre.java => MOre.java} (71%) create mode 100644 src/resources/assets/mmm/blockstates/materials/ore/copper.json delete mode 100644 src/resources/assets/mmm/blockstates/materials/ores/copper.json rename src/resources/assets/mmm/models/block/materials/{ores => ore}/copper.json (57%) create mode 100644 src/resources/assets/mmm/models/item/materials/ingot/copper.json create mode 100644 src/resources/assets/mmm/models/item/materials/nugget/copper.json rename src/resources/assets/mmm/models/item/materials/{iron_nugget.json => nugget/iron.json} (55%) create mode 100644 src/resources/assets/mmm/models/item/materials/ore/copper.json delete mode 100644 src/resources/assets/mmm/models/item/materials/ores/copper.json rename src/resources/assets/mmm/textures/blocks/materials/{ores => ore}/copper.png (100%) create mode 100644 src/resources/assets/mmm/textures/items/materials/ingots/copper.png create mode 100644 src/resources/assets/mmm/textures/items/materials/nuggets/copper.png rename src/resources/assets/mmm/textures/items/materials/{iron_nugget.png => nuggets/iron.png} (100%) diff --git a/src/java/mmm/materials/E_MMetalItemType.java b/src/java/mmm/materials/E_MMetalItemType.java new file mode 100644 index 0000000..137251f --- /dev/null +++ b/src/java/mmm/materials/E_MMetalItemType.java @@ -0,0 +1,14 @@ +package mmm.materials; + +public enum E_MMetalItemType { + INGOT( "ingot" ) , + NUGGET( "nugget" ); + + public final String name; + + + private E_MMetalItemType( String name ) + { + this.name = name; + } +} \ No newline at end of file diff --git a/src/java/mmm/materials/MMetal.java b/src/java/mmm/materials/MMetal.java new file mode 100644 index 0000000..ab960df --- /dev/null +++ b/src/java/mmm/materials/MMetal.java @@ -0,0 +1,58 @@ +package mmm.materials; + + +import mmm.utils.I_URecipeRegistrar; +import mmm.utils.URegistry; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + + + +public class MMetal + implements I_URecipeRegistrar +{ + + public final Item INGOT; + public final Item NUGGET; + + + public MMetal( final String name ) + { + this.INGOT = new MMetalItem( E_MMetalItemType.INGOT , name ); + this.NUGGET = new MMetalItem( E_MMetalItemType.NUGGET , name ); + } + + + public MMetal( final Item ingot , final Item nugget ) + { + this.INGOT = ingot; + this.NUGGET = nugget; + } + + + public MMetal register( ) + { + if ( this.INGOT instanceof MMetalItem ) { + URegistry.addItem( this.INGOT ); + } + if ( this.NUGGET instanceof MMetalItem ) { + URegistry.addItem( this.NUGGET ); + } + if ( this.INGOT instanceof MMetalItem || this.NUGGET instanceof MMetalItem ) { + this.registerRecipes( ); + } + return this; + } + + + @Override + public void registerRecipes( ) + { + GameRegistry.addShapelessRecipe( new ItemStack( this.NUGGET , 9 ) , this.INGOT ); + GameRegistry.addRecipe( new ItemStack( this.INGOT ) , // + "NNN" , "NNN" , "NNN" , // + 'N' , this.NUGGET ); + } + +} diff --git a/src/java/mmm/materials/MItem.java b/src/java/mmm/materials/MMetalItem.java similarity index 57% rename from src/java/mmm/materials/MItem.java rename to src/java/mmm/materials/MMetalItem.java index d92af12..59b830a 100644 --- a/src/java/mmm/materials/MItem.java +++ b/src/java/mmm/materials/MMetalItem.java @@ -7,15 +7,14 @@ import net.minecraft.item.Item; -public class MItem +public class MMetalItem extends Item { - - public MItem( String name ) + public MMetalItem( final E_MMetalItemType type , final String name ) { super( ); this.setCreativeTab( CreativeTabs.MATERIALS ); - URegistry.setIdentifiers( this , "materials" , name ); + URegistry.setIdentifiers( this , "materials" , type.name , name ); } } diff --git a/src/java/mmm/materials/DOre.java b/src/java/mmm/materials/MOre.java similarity index 71% rename from src/java/mmm/materials/DOre.java rename to src/java/mmm/materials/MOre.java index e934f85..45b3a0d 100644 --- a/src/java/mmm/materials/DOre.java +++ b/src/java/mmm/materials/MOre.java @@ -5,6 +5,7 @@ import java.util.Random; import javax.annotation.Nullable; +import mmm.utils.I_URecipeRegistrar; import mmm.utils.URegistry; import net.minecraft.block.Block; import net.minecraft.block.SoundType; @@ -18,11 +19,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameRegistry; -public class DOre +public class MOre extends Block + implements I_URecipeRegistrar { private int dropMin , dropMax; private Item dropItems; @@ -30,14 +33,17 @@ public class DOre private int expMin , expMax; + private MMetal metal; + private float smeltingXP; - public DOre( final String name , final int harvestLevel ) + + public MOre( final String name , final int harvestLevel ) { this( name , harvestLevel , Material.ROCK.getMaterialMapColor( ) ); } - public DOre( final String name , final int harvestLevel , final MapColor color ) + public MOre( final String name , final int harvestLevel , final MapColor color ) { super( Material.ROCK , color ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); @@ -45,31 +51,33 @@ public class DOre this.setHardness( 3.0f ); this.setResistance( 5.0f ); this.setHarvestLevel( "pickaxe" , harvestLevel ); - URegistry.setIdentifiers( this , "materials" , "ores" , name ); + URegistry.setIdentifiers( this , "materials" , "ore" , name ); this.dropMin = this.dropMax = 1; this.expMin = this.expMax = 0; + this.metal = null; + this.smeltingXP = 0; } - public DOre setDrops( final Item item ) + public MOre setDrops( final Item item ) { return this.setDrops( item , 0 , 1 , 1 ); } - public DOre setDrops( final Item item , final int meta ) + public MOre setDrops( final Item item , final int meta ) { return this.setDrops( item , meta , 1 , 1 ); } - public DOre setDrops( final Item item , final int dropMin , final int dropMax ) + public MOre setDrops( final Item item , final int dropMin , final int dropMax ) { return this.setDrops( item , 0 , dropMin , dropMax ); } - public DOre setDrops( final Item item , final int meta , final int dropMin , final int dropMax ) + public MOre setDrops( final Item item , final int meta , final int dropMin , final int dropMax ) { assert dropMin <= dropMax; assert dropMin > 0; @@ -81,13 +89,13 @@ public class DOre } - public DOre setExperience( final int value ) + public MOre setExperience( final int value ) { return this.setExperience( value , value ); } - public DOre setExperience( final int min , final int max ) + public MOre setExperience( final int min , final int max ) { assert min <= max; assert min >= 0; @@ -97,6 +105,14 @@ public class DOre } + public MOre setMetal( final MMetal metal , final float smeltingXP ) + { + this.metal = metal; + this.smeltingXP = smeltingXP; + return this; + } + + @Override @Nullable public Item getItemDropped( final IBlockState state , final Random rand , final int fortune ) @@ -152,4 +168,19 @@ public class DOre { return new ItemStack( this ); } + + + @Override + public void registerRecipes( ) + { + if ( this.metal != null ) { + if ( this.dropItems == null ) { + GameRegistry.addSmelting( this , new ItemStack( this.metal.INGOT ) , this.smeltingXP ); + } else { + GameRegistry.addSmelting( this.dropItems , new ItemStack( this.metal.INGOT ) , this.smeltingXP ); + } + this.metal = null; + } + } + } diff --git a/src/java/mmm/materials/Materials.java b/src/java/mmm/materials/Materials.java index 4144ee4..3f98463 100644 --- a/src/java/mmm/materials/Materials.java +++ b/src/java/mmm/materials/Materials.java @@ -1,27 +1,25 @@ package mmm.materials; -import mmm.utils.I_URecipeRegistrar; import mmm.utils.URegistry; import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; public class Materials - implements I_URecipeRegistrar { - public static final DOre ORE_COPPER; + public static final MMetal GOLD; + public static final MMetal IRON; + public static final MMetal COPPER; - public static final MItem NUGGET_IRON; + public static final MOre ORE_COPPER; static { - URegistry.addBlock( ORE_COPPER = new DOre( "copper" , 1 ) ); + GOLD = new MMetal( Items.GOLD_INGOT , Items.GOLD_NUGGET ).register( ); + IRON = new MMetal( Items.IRON_INGOT , new MMetalItem( E_MMetalItemType.NUGGET , "iron" ) ).register( ); + COPPER = new MMetal( "copper" ).register( ); - URegistry.addItem( NUGGET_IRON = new MItem( "iron_nugget" ) ); - - URegistry.addRecipeRegistrar( new Materials( ) ); + URegistry.addBlock( ORE_COPPER = new MOre( "copper" , 1 ).setMetal( COPPER , 0.4f ) ); } @@ -36,13 +34,4 @@ public class Materials // EMPTY } - - @Override - public void registerRecipes( ) - { - GameRegistry.addShapelessRecipe( new ItemStack( Materials.NUGGET_IRON , 9 ) , Items.IRON_INGOT ); - GameRegistry.addRecipe( new ItemStack( Items.IRON_INGOT ) , // - "NNN" , "NNN" , "NNN" , // - 'N' , Materials.NUGGET_IRON ); - } } diff --git a/src/resources/assets/mmm/blockstates/materials/ore/copper.json b/src/resources/assets/mmm/blockstates/materials/ore/copper.json new file mode 100644 index 0000000..807093a --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/ore/copper.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "mmm:materials/ore/copper" } + } +} diff --git a/src/resources/assets/mmm/blockstates/materials/ores/copper.json b/src/resources/assets/mmm/blockstates/materials/ores/copper.json deleted file mode 100644 index 18f3ab5..0000000 --- a/src/resources/assets/mmm/blockstates/materials/ores/copper.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "normal": { "model": "mmm:materials/ores/copper" } - } -} diff --git a/src/resources/assets/mmm/lang/en_US.lang b/src/resources/assets/mmm/lang/en_US.lang index 6fb65dc..bc811de 100644 --- a/src/resources/assets/mmm/lang/en_US.lang +++ b/src/resources/assets/mmm/lang/en_US.lang @@ -21,6 +21,8 @@ tile.mmm.deco.chair.jungle.name=Jungle Wood Chair tile.mmm.deco.chair.dark_oak.name=Dark Oak Chair -tile.mmm.materials.ores.copper.name=Native Copper +item.mmm.materials.nugget.iron.name=Iron Nugget -item.mmm.materials.iron_nugget.name=Iron Nugget \ No newline at end of file +item.mmm.materials.ingot.copper.name=Copper Ingot +item.mmm.materials.nugget.copper.name=Copper Nugget +tile.mmm.materials.ore.copper.name=Native Copper diff --git a/src/resources/assets/mmm/models/block/materials/ores/copper.json b/src/resources/assets/mmm/models/block/materials/ore/copper.json similarity index 57% rename from src/resources/assets/mmm/models/block/materials/ores/copper.json rename to src/resources/assets/mmm/models/block/materials/ore/copper.json index d1067f1..ec97ae3 100644 --- a/src/resources/assets/mmm/models/block/materials/ores/copper.json +++ b/src/resources/assets/mmm/models/block/materials/ore/copper.json @@ -1,6 +1,6 @@ { "parent": "minecraft:block/cube_all", "textures": { - "all": "mmm:blocks/materials/ores/copper" + "all": "mmm:blocks/materials/ore/copper" } } \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/ingot/copper.json b/src/resources/assets/mmm/models/item/materials/ingot/copper.json new file mode 100644 index 0000000..449a280 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/ingot/copper.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "mmm:items/materials/ingots/copper" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/nugget/copper.json b/src/resources/assets/mmm/models/item/materials/nugget/copper.json new file mode 100644 index 0000000..4c03073 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/nugget/copper.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "mmm:items/materials/nuggets/copper" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/iron_nugget.json b/src/resources/assets/mmm/models/item/materials/nugget/iron.json similarity index 55% rename from src/resources/assets/mmm/models/item/materials/iron_nugget.json rename to src/resources/assets/mmm/models/item/materials/nugget/iron.json index 4be20b6..78b4100 100644 --- a/src/resources/assets/mmm/models/item/materials/iron_nugget.json +++ b/src/resources/assets/mmm/models/item/materials/nugget/iron.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "mmm:items/materials/iron_nugget" + "layer0": "mmm:items/materials/nuggets/iron" } } \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/ore/copper.json b/src/resources/assets/mmm/models/item/materials/ore/copper.json new file mode 100644 index 0000000..b716f5d --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/ore/copper.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/materials/ore/copper" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/ores/copper.json b/src/resources/assets/mmm/models/item/materials/ores/copper.json deleted file mode 100644 index ff8efd6..0000000 --- a/src/resources/assets/mmm/models/item/materials/ores/copper.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "mmm:block/materials/ores/copper" -} \ No newline at end of file diff --git a/src/resources/assets/mmm/textures/blocks/materials/ores/copper.png b/src/resources/assets/mmm/textures/blocks/materials/ore/copper.png similarity index 100% rename from src/resources/assets/mmm/textures/blocks/materials/ores/copper.png rename to src/resources/assets/mmm/textures/blocks/materials/ore/copper.png diff --git a/src/resources/assets/mmm/textures/items/materials/ingots/copper.png b/src/resources/assets/mmm/textures/items/materials/ingots/copper.png new file mode 100644 index 0000000000000000000000000000000000000000..de341bbca620f74ca964070f414cd7ff93f94d97 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`lRaG=Lo7}wCrB7QC~3M_FQDcv z%wd1uh`)zZs%hQJ`}g<%x4*xW<#+_|!DXDW%6`rcJ?-AR9?bfXxhG1#wW-|w#b0)5 zhD$6)EfdrxNTu{7F?blB5vZBv@WZWIOX4uE!?)XSJ6$VG6_a-`mM@#qWN5}b!Sui% z-oqLj8H`y{7|doHm?U=Br!aS1YB?(~$&}ZEf#Ljy7M@D?P!pi@7(8A5T-G@yGywok C!AL*= literal 0 HcmV?d00001 diff --git a/src/resources/assets/mmm/textures/items/materials/nuggets/copper.png b/src/resources/assets/mmm/textures/items/materials/nuggets/copper.png new file mode 100644 index 0000000000000000000000000000000000000000..724b7b74e758766071f9df8ab39574f8c1267a2b GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`0iG_7Ar_~T6C_wI4*tw(|8L+k z?U}gs^nd@qe}Dh~e7WA=`@$>#&re}am^D8?_QU^&kN7U}IGR65D;KL=r*OI~h1p@& m$xU;$*beY0Mt|mDVwit2;ogtmd7FV|GkCiCxvXmL literal 0 HcmV?d00001 diff --git a/src/resources/assets/mmm/textures/items/materials/iron_nugget.png b/src/resources/assets/mmm/textures/items/materials/nuggets/iron.png similarity index 100% rename from src/resources/assets/mmm/textures/items/materials/iron_nugget.png rename to src/resources/assets/mmm/textures/items/materials/nuggets/iron.png