Added coke
+ Fuel registration stuff
This commit is contained in:
parent
9284a31149
commit
f6b6a10b66
7 changed files with 117 additions and 38 deletions
|
@ -20,8 +20,9 @@ public class Materials
|
|||
public static final MMetal IRON;
|
||||
public static final MMetal COPPER;
|
||||
|
||||
public static final Item STONE_MALACHITE;
|
||||
public static final Item STONE_CUPRITE;
|
||||
public static final Item ITEM_MALACHITE;
|
||||
public static final Item ITEM_CUPRITE;
|
||||
public static final Item ITEM_COKE;
|
||||
|
||||
public static final MOre ORE_COPPER;
|
||||
public static final MOre ORE_MALACHITE;
|
||||
|
@ -36,9 +37,10 @@ public class Materials
|
|||
// Custom metals
|
||||
COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT );
|
||||
|
||||
// Stones extracted from ores
|
||||
URegistry.addItem( STONE_MALACHITE = Materials.makeStone( "malachite" ) );
|
||||
URegistry.addItem( STONE_CUPRITE = Materials.makeStone( "cuprite" ) );
|
||||
// Items that do not correspond to metals or ores
|
||||
URegistry.addItem( ITEM_MALACHITE = Materials.makeItem( "malachite" ) );
|
||||
URegistry.addItem( ITEM_CUPRITE = Materials.makeItem( "cuprite" ) );
|
||||
URegistry.addItem( ITEM_COKE = Materials.makeFuel( "coke" , 4800 ) );
|
||||
|
||||
// Actual ores
|
||||
URegistry.addBlock( ORE_COPPER = new MOCopper( ) );
|
||||
|
@ -47,7 +49,15 @@ public class Materials
|
|||
}
|
||||
|
||||
|
||||
public static Item makeStone( final String name )
|
||||
public static Item makeFuel( String name , int burnTime )
|
||||
{
|
||||
Item fuel = makeItem( name );
|
||||
URegistry.setFuel( fuel , burnTime );
|
||||
return fuel;
|
||||
}
|
||||
|
||||
|
||||
public static Item makeItem( final String name )
|
||||
{
|
||||
final Item stone = new Item( );
|
||||
URegistry.setIdentifiers( stone , "materials" , "stone" , name );
|
||||
|
|
|
@ -21,7 +21,7 @@ public class MOCuprite
|
|||
{
|
||||
super( "cuprite" , 1 );
|
||||
this.setMetal( Materials.COPPER , 2 );
|
||||
this.setDrops( Materials.STONE_CUPRITE );
|
||||
this.setDrops( Materials.ITEM_CUPRITE );
|
||||
this.setExperience( 2 , 5 );
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class MOMalachite
|
|||
{
|
||||
super( "malachite" , 1 );
|
||||
this.setMetal( Materials.COPPER );
|
||||
this.setDrops( Materials.STONE_MALACHITE );
|
||||
this.setDrops( Materials.ITEM_MALACHITE );
|
||||
this.setExperience( 1 , 3 );
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class MOMalachite
|
|||
{
|
||||
super.registerRecipes( );
|
||||
GameRegistry.addShapelessRecipe( new ItemStack( Items.DYE , 1 , 2 ) ,
|
||||
new ItemStack( Materials.STONE_MALACHITE ) );
|
||||
new ItemStack( Materials.ITEM_MALACHITE ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,20 +13,44 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.IForgeRegistryEntry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import scala.actors.threadpool.Arrays;
|
||||
|
||||
|
||||
|
||||
public class URegistry
|
||||
{
|
||||
|
||||
private static class FuelHandler
|
||||
implements IFuelHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getBurnTime( final ItemStack fuel )
|
||||
{
|
||||
final Item item = fuel.getItem( );
|
||||
final Object fuelInfo = URegistry.FUELS.get( item );
|
||||
if ( fuelInfo != null ) {
|
||||
if ( item.getHasSubtypes( ) ) {
|
||||
return ( (int[]) fuelInfo )[ fuel.getItemDamage( ) ];
|
||||
}
|
||||
return ( (Integer) fuelInfo ).intValue( );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final SimpleNetworkWrapper network = new SimpleNetworkWrapper( Mmm.ID );
|
||||
private static int nextPacketDiscriminator = 0;
|
||||
|
||||
|
@ -35,6 +59,13 @@ public class URegistry
|
|||
private static final HashMap< Item , Boolean > ITEMS = new HashMap< Item , Boolean >( );
|
||||
private static final HashSet< Block > BLOCKS = new HashSet< Block >( );
|
||||
|
||||
private static final HashMap< Item , Object > FUELS = new HashMap<>( );
|
||||
private static final FuelHandler FUEL_HANDLER = new FuelHandler( );
|
||||
|
||||
static {
|
||||
GameRegistry.registerFuelHandler( URegistry.FUEL_HANDLER );
|
||||
}
|
||||
|
||||
|
||||
public static void setIdentifiers( final IForgeRegistryEntry< ? > thing , final String... strings )
|
||||
{
|
||||
|
@ -113,6 +144,36 @@ public class URegistry
|
|||
}
|
||||
|
||||
|
||||
public static void setFuel( final Item item , final int value )
|
||||
{
|
||||
Object obj;
|
||||
if ( item.getHasSubtypes( ) ) {
|
||||
final int values[] = new int[ 16 ];
|
||||
Arrays.fill( values , value );
|
||||
obj = values;
|
||||
} else {
|
||||
obj = Integer.valueOf( value );
|
||||
}
|
||||
URegistry.FUELS.put( item , obj );
|
||||
}
|
||||
|
||||
|
||||
public static void setFuel( final Item item , final int meta , final int value )
|
||||
{
|
||||
if ( !item.getHasSubtypes( ) ) {
|
||||
throw new IllegalArgumentException( "item " + item + " has no subtypes" );
|
||||
}
|
||||
|
||||
Object obj = URegistry.FUELS.get( item );
|
||||
if ( obj == null ) {
|
||||
obj = new int[ 16 ];
|
||||
URegistry.FUELS.put( item , obj );
|
||||
}
|
||||
|
||||
( (int[]) obj )[ meta ] = value;
|
||||
}
|
||||
|
||||
|
||||
public static void addRecipeRegistrar( final Object object )
|
||||
{
|
||||
if ( object instanceof I_URecipeRegistrar ) {
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
item.mmm.materials.stone.coke.name=Coke
|
||||
item.mmm.materials.nugget.iron.name=Iron Nugget
|
||||
|
||||
item.mmm.materials.ingot.copper.name=Copper Ingot
|
||||
item.mmm.materials.nugget.copper.name=Copper Nugget
|
||||
tile.mmm.materials.block.copper.name=Copper Block
|
||||
tile.mmm.materials.ore.copper.name=Native Copper
|
||||
item.mmm.materials.stone.malachite.name=Malachite
|
||||
tile.mmm.materials.ore.malachite.name=Malachite Ore
|
||||
item.mmm.materials.stone.cuprite.name=Cuprite
|
||||
tile.mmm.materials.ore.cuprite.name=Cuprite Ore
|
||||
|
||||
|
||||
item.mmm.tech.tools.copper.shovel.name=Copper Shovel
|
||||
item.mmm.tech.tools.copper.axe.name=Copper Axe
|
||||
item.mmm.tech.tools.copper.pickaxe.name=Copper Pickaxe
|
||||
item.mmm.tech.tools.copper.hoe.name=Copper Hoe
|
||||
item.mmm.tech.tools.copper.sword.name=Copper Sword
|
||||
item.mmm.tech.tools.copper.armor.feet.name=Copper Boots
|
||||
item.mmm.tech.tools.copper.armor.legs.name=Copper Leggings
|
||||
item.mmm.tech.tools.copper.armor.chest.name=Copper Chestplate
|
||||
item.mmm.tech.tools.copper.armor.head.name=Copper Helmet
|
||||
|
||||
|
||||
item.milk.name=Cow milk
|
||||
item.mmm.food.milk.sheep.name=Sheep milk
|
||||
item.mmm.food.milk.pig.name=Pig milk
|
||||
item.mmm.food.milk.horse.name=Horse milk
|
||||
item.mmm.food.milk.donkey.name=Donkey milk
|
||||
|
||||
|
||||
tile.mmm.deco.stairs.granite.name=Granite Stairs
|
||||
tile.mmm.deco.stairs.diorite.name=Diorite Stairs
|
||||
tile.mmm.deco.stairs.andesite.name=Andesite Stairs
|
||||
|
@ -19,32 +50,3 @@ tile.mmm.deco.chair.spruce.name=Spruce Chair
|
|||
tile.mmm.deco.chair.acacia.name=Acacia Chair
|
||||
tile.mmm.deco.chair.jungle.name=Jungle Wood Chair
|
||||
tile.mmm.deco.chair.dark_oak.name=Dark Oak Chair
|
||||
|
||||
|
||||
item.mmm.materials.nugget.iron.name=Iron Nugget
|
||||
|
||||
item.mmm.materials.ingot.copper.name=Copper Ingot
|
||||
item.mmm.materials.nugget.copper.name=Copper Nugget
|
||||
tile.mmm.materials.block.copper.name=Copper Block
|
||||
tile.mmm.materials.ore.copper.name=Native Copper
|
||||
item.mmm.materials.stone.malachite.name=Malachite
|
||||
tile.mmm.materials.ore.malachite.name=Malachite Ore
|
||||
item.mmm.materials.stone.cuprite.name=Cuprite
|
||||
tile.mmm.materials.ore.cuprite.name=Cuprite Ore
|
||||
|
||||
item.mmm.tech.tools.copper.shovel.name=Copper Shovel
|
||||
item.mmm.tech.tools.copper.axe.name=Copper Axe
|
||||
item.mmm.tech.tools.copper.pickaxe.name=Copper Pickaxe
|
||||
item.mmm.tech.tools.copper.hoe.name=Copper Hoe
|
||||
item.mmm.tech.tools.copper.sword.name=Copper Sword
|
||||
item.mmm.tech.tools.copper.armor.feet.name=Copper Boots
|
||||
item.mmm.tech.tools.copper.armor.legs.name=Copper Leggings
|
||||
item.mmm.tech.tools.copper.armor.chest.name=Copper Chestplate
|
||||
item.mmm.tech.tools.copper.armor.head.name=Copper Helmet
|
||||
|
||||
|
||||
item.milk.name=Cow milk
|
||||
item.mmm.food.milk.sheep.name=Sheep milk
|
||||
item.mmm.food.milk.pig.name=Pig milk
|
||||
item.mmm.food.milk.horse.name=Horse milk
|
||||
item.mmm.food.milk.donkey.name=Donkey milk
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "mmm:items/materials/stone/coke"
|
||||
}
|
||||
}
|
BIN
src/resources/assets/mmm/textures/items/materials/stone/coke.png
Normal file
BIN
src/resources/assets/mmm/textures/items/materials/stone/coke.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 280 B |
Reference in a new issue