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 0000000..de341bb Binary files /dev/null and b/src/resources/assets/mmm/textures/items/materials/ingots/copper.png differ 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 0000000..724b7b7 Binary files /dev/null and b/src/resources/assets/mmm/textures/items/materials/nuggets/copper.png differ 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