diff --git a/src/java/mmm/deco/DThrone.java b/src/java/mmm/deco/DThrone.java index aa84df6..b549a02 100644 --- a/src/java/mmm/deco/DThrone.java +++ b/src/java/mmm/deco/DThrone.java @@ -1,9 +1,9 @@ package mmm.deco; +import mmm.utils.UBlockItemWithVariants; import mmm.utils.URegistry; import net.minecraft.item.Item; -import net.minecraft.item.ItemCloth; @@ -19,9 +19,9 @@ public class DThrone { URegistry.addBlock( this.BOTTOM = new DThroneBlock( this , woodType , false ) , null ); URegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null ); - this.ITEM = new ItemCloth( this.BOTTOM ); - URegistry.setIdentifiers( this.ITEM , "deco" , "throne" , woodType.suffix ); - URegistry.addItem( this.ITEM ); + this.ITEM = new UBlockItemWithVariants( this.BOTTOM , "deco" , "throne" , woodType.suffix ) // + .useColorVariants( ) // + .register( ); } } diff --git a/src/java/mmm/deco/DThroneBlock.java b/src/java/mmm/deco/DThroneBlock.java index 8dbdfd4..dc54e1a 100644 --- a/src/java/mmm/deco/DThroneBlock.java +++ b/src/java/mmm/deco/DThroneBlock.java @@ -367,6 +367,9 @@ public class DThroneBlock @Override public void registerRecipes( ) { + if ( this.isTop ) { + return; + } for ( final EnumDyeColor dyeColor : EnumDyeColor.values( ) ) { GameRegistry.addShapedRecipe( new ItemStack( this , 1 , dyeColor.getMetadata( ) ) , // " E " , // diff --git a/src/java/mmm/utils/UBlockItemWithVariants.java b/src/java/mmm/utils/UBlockItemWithVariants.java new file mode 100644 index 0000000..e9756d3 --- /dev/null +++ b/src/java/mmm/utils/UBlockItemWithVariants.java @@ -0,0 +1,97 @@ +package mmm.utils; + + +import mmm.Mmm; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.ModelLoader; + + + +public class UBlockItemWithVariants + extends ItemBlock +{ + private final String[] baseName; + private String[] variants; + + + public UBlockItemWithVariants( final Block block , final String... baseName ) + { + super( block ); + + final StringBuilder sbName = new StringBuilder( Mmm.ID ); + this.baseName = new String[ baseName.length ]; + for ( int i = 0 ; i < baseName.length ; i++ ) { + this.baseName[ i ] = baseName[ i ]; + sbName.append( '.' ).append( baseName[ i ] ); + } + this.setUnlocalizedName( sbName.toString( ) ); + + this.setMaxDamage( 0 ); + this.setHasSubtypes( true ); + } + + + public UBlockItemWithVariants setVariants( final String... variantNames ) + { + this.variants = new String[ variantNames.length ]; + for ( int i = 0 ; i < variantNames.length ; i++ ) { + this.variants[ i ] = variantNames[ i ]; + } + return this; + } + + + public UBlockItemWithVariants useColorVariants( ) + { + this.variants = new String[ 16 ]; + for ( int i = 0 ; i < 16 ; i++ ) { + this.variants[ i ] = EnumDyeColor.byMetadata( i ).getUnlocalizedName( ); + } + return this; + } + + + public UBlockItemWithVariants register( ) + { + final StringBuilder sbRegPath = new StringBuilder( ); + for ( int i = 0 ; i < this.baseName.length ; i++ ) { + if ( i != 0 ) { + sbRegPath.append( '/' ); + } + sbRegPath.append( this.baseName[ i ] ); + } + this.setRegistryName( Mmm.ID , sbRegPath.toString( ) ); + URegistry.addItem( this , false ); + + final int len = sbRegPath.length( ); + final int nVariants = this.variants.length; + for ( int i = 0 ; i < nVariants ; i++ ) { + sbRegPath.setLength( len ); + sbRegPath.append( '/' ).append( this.variants[ i ] ); + ModelLoader.setCustomModelResourceLocation( this , i , new ModelResourceLocation( // + new ResourceLocation( Mmm.ID , sbRegPath.toString( ) ) , "inventory" ) ); + } + return this; + } + + + @Override + public int getMetadata( final int damage ) + { + return damage; + } + + + @Override + public String getUnlocalizedName( final ItemStack stack ) + { + return super.getUnlocalizedName( ) + "." + + EnumDyeColor.byMetadata( stack.getMetadata( ) ).getUnlocalizedName( ); + } + +} diff --git a/src/resources/assets/mmm/models/item/deco/throne.json b/src/resources/assets/mmm/models/item/deco/throne.json new file mode 100644 index 0000000..1bc690f --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne.json @@ -0,0 +1,239 @@ +{ + "textures" : { + "particle" : "#wood" , + "wood" : "#wood" , + "frontbottom" : "#frontbottom" , + "fronttop" : "#fronttop" , + "wool" : "#wool" , + "top": "#top" + }, + + "display": { + "thirdperson_righthand": { + "rotation": [ 90, 180, 0 ], + "translation": [ 0, 1.5, -1.75 ], + "scale": [ 0.5 , 0.5 , 0.5 ] + }, + "firstperson_righthand": { + "rotation": [ 10, -45, 10 ], + "translation": [ 0, 1.5, -1.75 ], + "scale": [ 0.75 , 0.75 , 0.75 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0 ], + "scale": [ 0.5 , 0.5 , 0.5 ] + }, + "gui": { + "rotation": [ 20, 30, 0 ], + "translation": [ 2.5, -1, 0 ], + "scale": [ 0.85, 0.85, 0.85 ] + } + } , + + "elements": + [ + { + "from": [ 4, 2.5, 0 ] , + "to": [ 12 , 8, 1 ] , + "faces": { + "north": { "texture": "#wood" , "uv": [ 0 , 0 , 16 , 11 ] } , + "south": { "texture": "#frontbottom" , "uv": [ 0 , 0 , 16 , 11 ] } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + + { + "from": [ 4, 4.5, 1 ] , + "to": [ 5.5 , 5.5, 8 ] , + "faces": { + "south": { "texture": "#frontbottom" , "uv": [ 0 , 5 , 3 , 7 ] } , + "down": { "texture": "#wood" } , + "up": { "texture": "#top" , "uv": [ 0 , 2 , 3 , 16 ] } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 10.5, 4.5, 1 ] , + "to": [ 12 , 5.5, 8 ] , + "faces": { + "south": { "texture": "#frontbottom" , "uv": [ 13 , 5 , 16 , 7 ] } , + "down": { "texture": "#wood" } , + "up": { "texture": "#top" , "uv": [ 13 , 2 , 16 , 16 ] } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 5.5, 1.5, 1 ] , + "to": [ 10.5 , 2.5, 7.5 ] , + "faces": { + "south": { "texture": "#wood" } , + "down": { "texture": "#wood" } , + "up": { "texture": "#top" , "uv": [ 3 , 2 , 13 , 15 ] } + } + } , + { + "from": [ 4, 1.5, 1 ] , + "to": [ 5.5 , 2.5, 8 ] , + "faces": { + "south": { "texture": "#wood" } , + "down": { "texture": "#wood" } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 10.5, 1.5, 1 ] , + "to": [ 12 , 2.5, 8 ] , + "faces": { + "south": { "texture": "#wood" } , + "down": { "texture": "#wood" } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 5.5 , 1.5 , 7.5 ] , + "to": [ 10.5 , 2 , 8 ] , + "faces": { + "south": { "texture": "#wood" } , + "down": { "texture": "#wood" } , + "up": { "texture": "#wood" } + } + } , + { + "from": [ 4, 0 , 0 ] , + "to": [ 12 , 2.5 , 1.5 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#wood" } , + "down": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 4, 0 , 6.5 ] , + "to": [ 5 , 4.5 , 7.5 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 11, 0 , 6.5 ] , + "to": [ 12 , 4.5 , 7.5 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + + { + "from": [ 6.5, 2.5, 1 ] , + "to": [ 9.5 , 8 , 1.5 ] , + "faces" : { + "south": { "texture": "#wool" , "uv": [ 5 , 0 , 11 , 11 ] } , + "east": { "texture": "#wool" , "uv": [ 2 , 0 , 3 , 5 ] } , + "west": { "texture": "#wool" , "uv": [ 2 , 0 , 3 , 5 ] } + } + } , + { + "from": [ 6.5, 2.5, 1.5 ] , + "to": [ 9.5 , 3 , 5.5 ] , + "faces" : { + "up": { "texture": "#wool" , "uv": [ 5 , 3 , 11 , 11 ] } , + "south": { "texture": "#wool" } , + "east": { "texture": "#wool" } , + "west": { "texture": "#wool" } + } + } , + { + "from": [ 7, 2.5, 5.5 ] , + "to": [ 9 , 3 , 6 ] , + "faces" : { + "up": { "texture": "#wool" , "uv": [ 6 , 11 , 10 , 12 ] } , + "south": { "texture": "#wool" } , + "east": { "texture": "#wool" } , + "west": { "texture": "#wool" } + } + } , + + { + "from": [ 4, 8, 0 ] , + "to": [ 12 , 12, 1 ] , + "faces": { + "north": { "texture": "#wood" , "uv": [ 0 , 8 , 16 , 16 ] } , + "south": { "texture": "#fronttop" , "uv": [ 0 , 8 , 16 , 16 ] } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 4.5, 12, 0 ] , + "to": [ 11.5 , 13, 1 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#fronttop" , "uv": [ 1 , 6 , 15 , 8 ] } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 5, 13, 0 ] , + "to": [ 11 , 13.5, 1 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#fronttop" , "uv": [ 2 , 5 , 14 , 6 ] } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 5.5, 13.5, 0 ] , + "to": [ 10.5 , 14, 1 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#fronttop" , "uv": [ 3 , 4 , 13 , 5 ] } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + { + "from": [ 6.5, 14, 0 ] , + "to": [ 9.5 , 14.5, 1 ] , + "faces": { + "north": { "texture": "#wood" } , + "south": { "texture": "#fronttop" , "uv": [ 5 , 3 , 11 , 4 ] } , + "up": { "texture": "#wood" } , + "east": { "texture": "#wood" } , + "west": { "texture": "#wood" } + } + } , + + { + "from": [ 6.5, 8, 1 ] , + "to": [ 9.5 , 11 , 1.5 ] , + "faces" : { + "south": { "texture": "#wool" , "uv": [ 5 , 10 , 11 , 16 ] } , + "up": { "texture": "#wool" } , + "east": { "texture": "#wool" } , + "west": { "texture": "#wool" } + } + } + + ] +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak.json b/src/resources/assets/mmm/models/item/deco/throne/oak.json new file mode 100644 index 0000000..ec55e0b --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak.json @@ -0,0 +1,10 @@ +{ + "parent": "mmm:item/deco/throne", + "textures": { + "wood" : "mmm:blocks/deco/throne/oak/wood" , + "frontbottom" : "mmm:blocks/deco/throne/oak/front-bottom" , + "fronttop" : "mmm:blocks/deco/throne/oak/front-top" , + "top" : "mmm:blocks/deco/throne/oak/bottom" , + "wool" : "#wool" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/black.json b/src/resources/assets/mmm/models/item/deco/throne/oak/black.json new file mode 100644 index 0000000..a7e1973 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/black.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_black" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/blue.json b/src/resources/assets/mmm/models/item/deco/throne/oak/blue.json new file mode 100644 index 0000000..e39b04d --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/blue.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_blue" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/brown.json b/src/resources/assets/mmm/models/item/deco/throne/oak/brown.json new file mode 100644 index 0000000..56bc880 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/brown.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_brown" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/cyan.json b/src/resources/assets/mmm/models/item/deco/throne/oak/cyan.json new file mode 100644 index 0000000..69effd7 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/cyan.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_cyan" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/gray.json b/src/resources/assets/mmm/models/item/deco/throne/oak/gray.json new file mode 100644 index 0000000..3233b32 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/gray.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_gray" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/green.json b/src/resources/assets/mmm/models/item/deco/throne/oak/green.json new file mode 100644 index 0000000..f916bdc --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/green.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_green" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/lightBlue.json b/src/resources/assets/mmm/models/item/deco/throne/oak/lightBlue.json new file mode 100644 index 0000000..dd5f05e --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/lightBlue.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_light_blue" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/lime.json b/src/resources/assets/mmm/models/item/deco/throne/oak/lime.json new file mode 100644 index 0000000..6c2bd7f --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/lime.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_lime" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/magenta.json b/src/resources/assets/mmm/models/item/deco/throne/oak/magenta.json new file mode 100644 index 0000000..3d57b31 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/magenta.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_magenta" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/orange.json b/src/resources/assets/mmm/models/item/deco/throne/oak/orange.json new file mode 100644 index 0000000..e6239cc --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/orange.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_orange" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/pink.json b/src/resources/assets/mmm/models/item/deco/throne/oak/pink.json new file mode 100644 index 0000000..8f28f66 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/pink.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_pink" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/purple.json b/src/resources/assets/mmm/models/item/deco/throne/oak/purple.json new file mode 100644 index 0000000..374c0d0 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/purple.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_purple" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/red.json b/src/resources/assets/mmm/models/item/deco/throne/oak/red.json new file mode 100644 index 0000000..c731a7e --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/red.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_red" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/silver.json b/src/resources/assets/mmm/models/item/deco/throne/oak/silver.json new file mode 100644 index 0000000..d94b1c9 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/silver.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_silver" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/white.json b/src/resources/assets/mmm/models/item/deco/throne/oak/white.json new file mode 100644 index 0000000..df281c8 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/white.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_white" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/deco/throne/oak/yellow.json b/src/resources/assets/mmm/models/item/deco/throne/oak/yellow.json new file mode 100644 index 0000000..9bcfcd0 --- /dev/null +++ b/src/resources/assets/mmm/models/item/deco/throne/oak/yellow.json @@ -0,0 +1,6 @@ +{ + "parent": "mmm:item/deco/throne/oak", + "textures": { + "wool" : "minecraft:blocks/wool_colored_yellow" + } +} \ No newline at end of file