Throne - Item(s)

Holy shit that was annoying.
Wood is not properly aligned on item model, but fuck it. With a
chainsaw.
This commit is contained in:
Emmanuel BENOîT 2016-07-07 12:19:37 +02:00
parent 9edf2c80fc
commit 071165f45c
21 changed files with 449 additions and 4 deletions

View file

@ -1,9 +1,9 @@
package mmm.deco; package mmm.deco;
import mmm.utils.UBlockItemWithVariants;
import mmm.utils.URegistry; import mmm.utils.URegistry;
import net.minecraft.item.Item; 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.BOTTOM = new DThroneBlock( this , woodType , false ) , null );
URegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null ); URegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null );
this.ITEM = new ItemCloth( this.BOTTOM ); this.ITEM = new UBlockItemWithVariants( this.BOTTOM , "deco" , "throne" , woodType.suffix ) //
URegistry.setIdentifiers( this.ITEM , "deco" , "throne" , woodType.suffix ); .useColorVariants( ) //
URegistry.addItem( this.ITEM ); .register( );
} }
} }

View file

@ -367,6 +367,9 @@ public class DThroneBlock
@Override @Override
public void registerRecipes( ) public void registerRecipes( )
{ {
if ( this.isTop ) {
return;
}
for ( final EnumDyeColor dyeColor : EnumDyeColor.values( ) ) { for ( final EnumDyeColor dyeColor : EnumDyeColor.values( ) ) {
GameRegistry.addShapedRecipe( new ItemStack( this , 1 , dyeColor.getMetadata( ) ) , // GameRegistry.addShapedRecipe( new ItemStack( this , 1 , dyeColor.getMetadata( ) ) , //
" E " , // " E " , //

View file

@ -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( );
}
}

View file

@ -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" }
}
}
]
}

View file

@ -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"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_black"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_blue"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_brown"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_cyan"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_gray"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_green"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_light_blue"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_lime"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_magenta"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_orange"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_pink"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_purple"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_red"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_silver"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_white"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "mmm:item/deco/throne/oak",
"textures": {
"wool" : "minecraft:blocks/wool_colored_yellow"
}
}