Some refactoring. Also, copper.
This commit is contained in:
parent
c9c0a6e31e
commit
a43b2730d3
18 changed files with 150 additions and 45 deletions
14
src/java/mmm/materials/E_MMetalItemType.java
Normal file
14
src/java/mmm/materials/E_MMetalItemType.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
58
src/java/mmm/materials/MMetal.java
Normal file
58
src/java/mmm/materials/MMetal.java
Normal file
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": { "model": "mmm:materials/ore/copper" }
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": { "model": "mmm:materials/ores/copper" }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
item.mmm.materials.ingot.copper.name=Copper Ingot
|
||||
item.mmm.materials.nugget.copper.name=Copper Nugget
|
||||
tile.mmm.materials.ore.copper.name=Native Copper
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "mmm:blocks/materials/ores/copper"
|
||||
"all": "mmm:blocks/materials/ore/copper"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "mmm:items/materials/ingots/copper"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "mmm:items/materials/nuggets/copper"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "mmm:items/materials/iron_nugget"
|
||||
"layer0": "mmm:items/materials/nuggets/iron"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "mmm:block/materials/ore/copper"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"parent": "mmm:block/materials/ores/copper"
|
||||
}
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
Binary file not shown.
After Width: | Height: | Size: 204 B |
Binary file not shown.
After Width: | Height: | Size: 137 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 134 B |
Reference in a new issue