From 2519f88bbe271b7b272e1750be155324ececd82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Tue, 14 Jun 2016 17:12:51 +0200 Subject: [PATCH] Re-organised assets --- src/java/mmm/deco/DBlockChair.java | 8 ++--- src/java/mmm/deco/DBlockTable.java | 8 ++--- src/java/mmm/utils/URegistration.java | 34 +++++++++++++++++++ .../chair/acacia.json} | 0 .../chair/birch.json} | 0 .../chair/dark_oak.json} | 0 .../chair/jungle.json} | 0 .../chair/oak.json} | 0 .../chair/spruce.json} | 0 .../table/acacia.json} | 0 .../table/birch.json} | 0 .../table/dark_oak.json} | 0 .../table/jungle.json} | 0 .../table/oak.json} | 0 .../table/spruce.json} | 0 src/resources/assets/mmm/lang/en_US.lang | 24 ++++++------- .../item/{deco_chair.json => deco/chair.json} | 0 .../chair/acacia.json} | 2 +- .../chair/birch.json} | 2 +- .../chair/dark_oak.json} | 2 +- .../chair/jungle.json} | 2 +- .../chair/oak.json} | 2 +- .../chair/spruce.json} | 2 +- .../item/{deco_table.json => deco/table.json} | 0 .../table/acacia.json} | 2 +- .../table/birch.json} | 2 +- .../table/dark_oak.json} | 2 +- .../table/jungle.json} | 2 +- .../table/oak.json} | 2 +- .../table/spruce.json} | 2 +- 30 files changed, 62 insertions(+), 36 deletions(-) rename src/resources/assets/mmm/blockstates/{deco_chair_acacia.json => deco/chair/acacia.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_chair_birch.json => deco/chair/birch.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_chair_dark_oak.json => deco/chair/dark_oak.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_chair_jungle.json => deco/chair/jungle.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_chair_oak.json => deco/chair/oak.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_chair_spruce.json => deco/chair/spruce.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_table_acacia.json => deco/table/acacia.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_table_birch.json => deco/table/birch.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_table_dark_oak.json => deco/table/dark_oak.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_table_jungle.json => deco/table/jungle.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_table_oak.json => deco/table/oak.json} (100%) rename src/resources/assets/mmm/blockstates/{deco_table_spruce.json => deco/table/spruce.json} (100%) rename src/resources/assets/mmm/models/item/{deco_chair.json => deco/chair.json} (100%) rename src/resources/assets/mmm/models/item/{deco_chair_acacia.json => deco/chair/acacia.json} (78%) rename src/resources/assets/mmm/models/item/{deco_table_birch.json => deco/chair/birch.json} (78%) rename src/resources/assets/mmm/models/item/{deco_table_dark_oak.json => deco/chair/dark_oak.json} (78%) rename src/resources/assets/mmm/models/item/{deco_table_jungle.json => deco/chair/jungle.json} (78%) rename src/resources/assets/mmm/models/item/{deco_chair_oak.json => deco/chair/oak.json} (77%) rename src/resources/assets/mmm/models/item/{deco_chair_spruce.json => deco/chair/spruce.json} (78%) rename src/resources/assets/mmm/models/item/{deco_table.json => deco/table.json} (100%) rename src/resources/assets/mmm/models/item/{deco_table_acacia.json => deco/table/acacia.json} (78%) rename src/resources/assets/mmm/models/item/{deco_chair_birch.json => deco/table/birch.json} (78%) rename src/resources/assets/mmm/models/item/{deco_chair_dark_oak.json => deco/table/dark_oak.json} (78%) rename src/resources/assets/mmm/models/item/{deco_chair_jungle.json => deco/table/jungle.json} (78%) rename src/resources/assets/mmm/models/item/{deco_table_oak.json => deco/table/oak.json} (77%) rename src/resources/assets/mmm/models/item/{deco_table_spruce.json => deco/table/spruce.json} (78%) diff --git a/src/java/mmm/deco/DBlockChair.java b/src/java/mmm/deco/DBlockChair.java index c3de16e..e480e1f 100644 --- a/src/java/mmm/deco/DBlockChair.java +++ b/src/java/mmm/deco/DBlockChair.java @@ -3,10 +3,10 @@ package mmm.deco; import java.util.List; -import mmm.Mmm; import mmm.utils.I_UBlockSeat; import mmm.utils.I_URecipeRegistrar; import mmm.utils.UMaths; +import mmm.utils.URegistration; import mmm.utils.USeat; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; @@ -43,9 +43,6 @@ public class DBlockChair extends Block implements I_URecipeRegistrar , I_UBlockSeat { - public final static String ID = "deco_chair_"; - public final static String NAME = Mmm.PREFIX + DBlockChair.ID; - public static final PropertyDirection FACING = BlockHorizontal.FACING; private static final AxisAlignedBB BOUNDING_BOX = UMaths.makeBlockAABB( 1 , 0 , 1 , 15 , 16 , 15 ); @@ -65,8 +62,7 @@ public class DBlockChair this.setDefaultState( this.blockState.getBaseState( ).withProperty( DBlockChair.FACING , EnumFacing.NORTH ) ); this.setCreativeTab( CreativeTabs.DECORATIONS ); - this.setRegistryName( DBlockChair.ID + type.suffix ); - this.setUnlocalizedName( DBlockChair.NAME + type.suffix ); + URegistration.setIdentifiers( this , "deco" , "chair" , type.suffix ); this.lightOpacity = 0; this.translucent = false; diff --git a/src/java/mmm/deco/DBlockTable.java b/src/java/mmm/deco/DBlockTable.java index 9583945..af887d7 100644 --- a/src/java/mmm/deco/DBlockTable.java +++ b/src/java/mmm/deco/DBlockTable.java @@ -3,9 +3,9 @@ package mmm.deco; import java.util.List; -import mmm.Mmm; import mmm.utils.I_URecipeRegistrar; import mmm.utils.UMaths; +import mmm.utils.URegistration; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -36,9 +36,6 @@ public class DBlockTable implements I_URecipeRegistrar { - public final static String ID = "deco_table_"; - public final static String NAME = Mmm.PREFIX + DBlockTable.ID; - protected static final AxisAlignedBB COLLISION_TOP = UMaths.makeBlockAABB( 0 , 12 , 0 , 16 , 16 , 16 ); protected static final AxisAlignedBB COLLISION_LEGS[] = { // UMaths.makeBlockAABB( 1 , 0 , 1 , 3 , 12 , 3 ) , // @@ -79,8 +76,7 @@ public class DBlockTable .withProperty( DBlockTable.SE , Boolean.valueOf( false ) ) ); this.setCreativeTab( CreativeTabs.DECORATIONS ); - this.setRegistryName( DBlockTable.ID + type.suffix ); - this.setUnlocalizedName( DBlockTable.NAME + type.suffix ); + URegistration.setIdentifiers( this , "deco" , "table" , type.suffix ); this.lightOpacity = 0; this.translucent = false; diff --git a/src/java/mmm/utils/URegistration.java b/src/java/mmm/utils/URegistration.java index 18298d8..151fda7 100644 --- a/src/java/mmm/utils/URegistration.java +++ b/src/java/mmm/utils/URegistration.java @@ -5,12 +5,15 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import mmm.Mmm; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.common.registry.IForgeRegistryEntry; @@ -21,6 +24,37 @@ public class URegistration private static final HashSet< Block > BLOCKS = new HashSet< Block >( ); + public static void setIdentifiers( final IForgeRegistryEntry< ? > thing , String... strings ) + { + int nStrings = strings.length; + if ( nStrings == 0 ) { + throw new IllegalArgumentException( "no identifier specified" ); + } + + StringBuilder sb = new StringBuilder( ); + for ( int i = 0 ; i < nStrings ; i++ ) { + if ( i > 0 ) { + sb.append( '/' ); + } + sb.append( strings[ i ] ); + } + thing.setRegistryName( new ResourceLocation( Mmm.ID , sb.toString( ) ) ); + + if ( thing instanceof Block || thing instanceof Item ) { + sb.setLength( 0 ); + sb.append( Mmm.ID ); + for ( int i = 0 ; i < nStrings ; i++ ) { + sb.append( '.' ).append( strings[ i ] ); + } + if ( thing instanceof Block ) { + ( (Block) thing ).setUnlocalizedName( sb.toString( ) ); + } else { + ( (Item) thing ).setUnlocalizedName( sb.toString( ) ); + } + } + } + + public static void addItem( final Item item ) { URegistration.addItem( item , true ); diff --git a/src/resources/assets/mmm/blockstates/deco_chair_acacia.json b/src/resources/assets/mmm/blockstates/deco/chair/acacia.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_chair_acacia.json rename to src/resources/assets/mmm/blockstates/deco/chair/acacia.json diff --git a/src/resources/assets/mmm/blockstates/deco_chair_birch.json b/src/resources/assets/mmm/blockstates/deco/chair/birch.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_chair_birch.json rename to src/resources/assets/mmm/blockstates/deco/chair/birch.json diff --git a/src/resources/assets/mmm/blockstates/deco_chair_dark_oak.json b/src/resources/assets/mmm/blockstates/deco/chair/dark_oak.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_chair_dark_oak.json rename to src/resources/assets/mmm/blockstates/deco/chair/dark_oak.json diff --git a/src/resources/assets/mmm/blockstates/deco_chair_jungle.json b/src/resources/assets/mmm/blockstates/deco/chair/jungle.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_chair_jungle.json rename to src/resources/assets/mmm/blockstates/deco/chair/jungle.json diff --git a/src/resources/assets/mmm/blockstates/deco_chair_oak.json b/src/resources/assets/mmm/blockstates/deco/chair/oak.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_chair_oak.json rename to src/resources/assets/mmm/blockstates/deco/chair/oak.json diff --git a/src/resources/assets/mmm/blockstates/deco_chair_spruce.json b/src/resources/assets/mmm/blockstates/deco/chair/spruce.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_chair_spruce.json rename to src/resources/assets/mmm/blockstates/deco/chair/spruce.json diff --git a/src/resources/assets/mmm/blockstates/deco_table_acacia.json b/src/resources/assets/mmm/blockstates/deco/table/acacia.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_table_acacia.json rename to src/resources/assets/mmm/blockstates/deco/table/acacia.json diff --git a/src/resources/assets/mmm/blockstates/deco_table_birch.json b/src/resources/assets/mmm/blockstates/deco/table/birch.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_table_birch.json rename to src/resources/assets/mmm/blockstates/deco/table/birch.json diff --git a/src/resources/assets/mmm/blockstates/deco_table_dark_oak.json b/src/resources/assets/mmm/blockstates/deco/table/dark_oak.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_table_dark_oak.json rename to src/resources/assets/mmm/blockstates/deco/table/dark_oak.json diff --git a/src/resources/assets/mmm/blockstates/deco_table_jungle.json b/src/resources/assets/mmm/blockstates/deco/table/jungle.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_table_jungle.json rename to src/resources/assets/mmm/blockstates/deco/table/jungle.json diff --git a/src/resources/assets/mmm/blockstates/deco_table_oak.json b/src/resources/assets/mmm/blockstates/deco/table/oak.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_table_oak.json rename to src/resources/assets/mmm/blockstates/deco/table/oak.json diff --git a/src/resources/assets/mmm/blockstates/deco_table_spruce.json b/src/resources/assets/mmm/blockstates/deco/table/spruce.json similarity index 100% rename from src/resources/assets/mmm/blockstates/deco_table_spruce.json rename to src/resources/assets/mmm/blockstates/deco/table/spruce.json diff --git a/src/resources/assets/mmm/lang/en_US.lang b/src/resources/assets/mmm/lang/en_US.lang index 8d9b6b1..df92673 100644 --- a/src/resources/assets/mmm/lang/en_US.lang +++ b/src/resources/assets/mmm/lang/en_US.lang @@ -1,13 +1,13 @@ -tile.mmm.deco_table_oak.name=Oak table -tile.mmm.deco_table_birch.name=Birch table -tile.mmm.deco_table_spruce.name=Spruce table -tile.mmm.deco_table_acacia.name=Acacia table -tile.mmm.deco_table_jungle.name=Jungle wood table -tile.mmm.deco_table_dark_oak.name=Dark oak table +tile.mmm.deco.table.oak.name=Oak table +tile.mmm.deco.table.birch.name=Birch table +tile.mmm.deco.table.spruce.name=Spruce table +tile.mmm.deco.table.acacia.name=Acacia table +tile.mmm.deco.table.jungle.name=Jungle wood table +tile.mmm.deco.table.dark_oak.name=Dark oak table -tile.mmm.deco_chair_oak.name=Oak chair -tile.mmm.deco_chair_birch.name=Birch chair -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 +tile.mmm.deco.chair.oak.name=Oak chair +tile.mmm.deco.chair.birch.name=Birch chair +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 diff --git a/src/resources/assets/mmm/models/item/deco_chair.json b/src/resources/assets/mmm/models/item/deco/chair.json similarity index 100% rename from src/resources/assets/mmm/models/item/deco_chair.json rename to src/resources/assets/mmm/models/item/deco/chair.json diff --git a/src/resources/assets/mmm/models/item/deco_chair_acacia.json b/src/resources/assets/mmm/models/item/deco/chair/acacia.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_chair_acacia.json rename to src/resources/assets/mmm/models/item/deco/chair/acacia.json index 093764a..c65908d 100644 --- a/src/resources/assets/mmm/models/item/deco_chair_acacia.json +++ b/src/resources/assets/mmm/models/item/deco/chair/acacia.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_chair", + "parent": "mmm:item/deco/chair", "textures": { "body": "minecraft:blocks/planks_acacia", "legs": "minecraft:blocks/log_acacia" diff --git a/src/resources/assets/mmm/models/item/deco_table_birch.json b/src/resources/assets/mmm/models/item/deco/chair/birch.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_table_birch.json rename to src/resources/assets/mmm/models/item/deco/chair/birch.json index e6a39b8..0e44f7e 100644 --- a/src/resources/assets/mmm/models/item/deco_table_birch.json +++ b/src/resources/assets/mmm/models/item/deco/chair/birch.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_table", + "parent": "mmm:item/deco/chair", "textures": { "body": "minecraft:blocks/planks_birch", "legs": "minecraft:blocks/log_birch" diff --git a/src/resources/assets/mmm/models/item/deco_table_dark_oak.json b/src/resources/assets/mmm/models/item/deco/chair/dark_oak.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_table_dark_oak.json rename to src/resources/assets/mmm/models/item/deco/chair/dark_oak.json index 0791c4a..1736396 100644 --- a/src/resources/assets/mmm/models/item/deco_table_dark_oak.json +++ b/src/resources/assets/mmm/models/item/deco/chair/dark_oak.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_table", + "parent": "mmm:item/deco/chair", "textures": { "body": "minecraft:blocks/planks_big_oak", "legs": "minecraft:blocks/log_big_oak" diff --git a/src/resources/assets/mmm/models/item/deco_table_jungle.json b/src/resources/assets/mmm/models/item/deco/chair/jungle.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_table_jungle.json rename to src/resources/assets/mmm/models/item/deco/chair/jungle.json index e9c4f81..3b32d1a 100644 --- a/src/resources/assets/mmm/models/item/deco_table_jungle.json +++ b/src/resources/assets/mmm/models/item/deco/chair/jungle.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_table", + "parent": "mmm:item/deco/chair", "textures": { "body": "minecraft:blocks/planks_jungle", "legs": "minecraft:blocks/log_jungle" diff --git a/src/resources/assets/mmm/models/item/deco_chair_oak.json b/src/resources/assets/mmm/models/item/deco/chair/oak.json similarity index 77% rename from src/resources/assets/mmm/models/item/deco_chair_oak.json rename to src/resources/assets/mmm/models/item/deco/chair/oak.json index df7363e..a648247 100644 --- a/src/resources/assets/mmm/models/item/deco_chair_oak.json +++ b/src/resources/assets/mmm/models/item/deco/chair/oak.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_chair", + "parent": "mmm:item/deco/chair", "textures": { "body": "minecraft:blocks/planks_oak", "legs": "minecraft:blocks/log_oak" diff --git a/src/resources/assets/mmm/models/item/deco_chair_spruce.json b/src/resources/assets/mmm/models/item/deco/chair/spruce.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_chair_spruce.json rename to src/resources/assets/mmm/models/item/deco/chair/spruce.json index cbe0ff7..f21a4e2 100644 --- a/src/resources/assets/mmm/models/item/deco_chair_spruce.json +++ b/src/resources/assets/mmm/models/item/deco/chair/spruce.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_chair", + "parent": "mmm:item/deco/chair", "textures": { "body": "minecraft:blocks/planks_spruce", "legs": "minecraft:blocks/log_spruce" diff --git a/src/resources/assets/mmm/models/item/deco_table.json b/src/resources/assets/mmm/models/item/deco/table.json similarity index 100% rename from src/resources/assets/mmm/models/item/deco_table.json rename to src/resources/assets/mmm/models/item/deco/table.json diff --git a/src/resources/assets/mmm/models/item/deco_table_acacia.json b/src/resources/assets/mmm/models/item/deco/table/acacia.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_table_acacia.json rename to src/resources/assets/mmm/models/item/deco/table/acacia.json index 04ba117..a979891 100644 --- a/src/resources/assets/mmm/models/item/deco_table_acacia.json +++ b/src/resources/assets/mmm/models/item/deco/table/acacia.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_table", + "parent": "mmm:item/deco/table", "textures": { "body": "minecraft:blocks/planks_acacia", "legs": "minecraft:blocks/log_acacia" diff --git a/src/resources/assets/mmm/models/item/deco_chair_birch.json b/src/resources/assets/mmm/models/item/deco/table/birch.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_chair_birch.json rename to src/resources/assets/mmm/models/item/deco/table/birch.json index e88d4b2..b6a6d58 100644 --- a/src/resources/assets/mmm/models/item/deco_chair_birch.json +++ b/src/resources/assets/mmm/models/item/deco/table/birch.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_chair", + "parent": "mmm:item/deco/table", "textures": { "body": "minecraft:blocks/planks_birch", "legs": "minecraft:blocks/log_birch" diff --git a/src/resources/assets/mmm/models/item/deco_chair_dark_oak.json b/src/resources/assets/mmm/models/item/deco/table/dark_oak.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_chair_dark_oak.json rename to src/resources/assets/mmm/models/item/deco/table/dark_oak.json index 31daa83..b468927 100644 --- a/src/resources/assets/mmm/models/item/deco_chair_dark_oak.json +++ b/src/resources/assets/mmm/models/item/deco/table/dark_oak.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_chair", + "parent": "mmm:item/deco/table", "textures": { "body": "minecraft:blocks/planks_big_oak", "legs": "minecraft:blocks/log_big_oak" diff --git a/src/resources/assets/mmm/models/item/deco_chair_jungle.json b/src/resources/assets/mmm/models/item/deco/table/jungle.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_chair_jungle.json rename to src/resources/assets/mmm/models/item/deco/table/jungle.json index 77798ef..21558de 100644 --- a/src/resources/assets/mmm/models/item/deco_chair_jungle.json +++ b/src/resources/assets/mmm/models/item/deco/table/jungle.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_chair", + "parent": "mmm:item/deco/table", "textures": { "body": "minecraft:blocks/planks_jungle", "legs": "minecraft:blocks/log_jungle" diff --git a/src/resources/assets/mmm/models/item/deco_table_oak.json b/src/resources/assets/mmm/models/item/deco/table/oak.json similarity index 77% rename from src/resources/assets/mmm/models/item/deco_table_oak.json rename to src/resources/assets/mmm/models/item/deco/table/oak.json index 4aab987..f13e68b 100644 --- a/src/resources/assets/mmm/models/item/deco_table_oak.json +++ b/src/resources/assets/mmm/models/item/deco/table/oak.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_table", + "parent": "mmm:item/deco/table", "textures": { "body": "minecraft:blocks/planks_oak", "legs": "minecraft:blocks/log_oak" diff --git a/src/resources/assets/mmm/models/item/deco_table_spruce.json b/src/resources/assets/mmm/models/item/deco/table/spruce.json similarity index 78% rename from src/resources/assets/mmm/models/item/deco_table_spruce.json rename to src/resources/assets/mmm/models/item/deco/table/spruce.json index eadfeae..b2619fb 100644 --- a/src/resources/assets/mmm/models/item/deco_table_spruce.json +++ b/src/resources/assets/mmm/models/item/deco/table/spruce.json @@ -1,5 +1,5 @@ { - "parent": "mmm:item/deco_table", + "parent": "mmm:item/deco/table", "textures": { "body": "minecraft:blocks/planks_spruce", "legs": "minecraft:blocks/log_spruce"