From 7393a8bdd67008cb2f63ed448901cf68e570fcbc Mon Sep 17 00:00:00 2001
From: drcrazy <hcb@wowhcb.ru>
Date: Wed, 12 Sep 2018 16:15:05 +0300
Subject: [PATCH] Ores flattened

---
 src/main/java/techreborn/blocks/BlockOre.java | 12 -----------
 .../techreborn/client/RegisterItemJsons.java  | 14 -------------
 .../java/techreborn/init/TRIngredients.java   | 20 +++++++++++++------
 3 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/src/main/java/techreborn/blocks/BlockOre.java b/src/main/java/techreborn/blocks/BlockOre.java
index 1e1445f4d..ccf2de8ab 100644
--- a/src/main/java/techreborn/blocks/BlockOre.java
+++ b/src/main/java/techreborn/blocks/BlockOre.java
@@ -26,7 +26,6 @@ package techreborn.blocks;
 
 import net.minecraft.block.Block;
 import net.minecraft.block.material.Material;
-import net.minecraft.block.state.BlockStateContainer;
 import net.minecraft.block.state.IBlockState;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.item.Item;
@@ -36,8 +35,6 @@ import net.minecraft.util.math.BlockPos;
 import net.minecraft.util.math.RayTraceResult;
 import net.minecraft.world.IBlockAccess;
 import net.minecraft.world.World;
-import reborncore.client.models.ModelCompound;
-import reborncore.client.models.RebornModelRegistry;
 import reborncore.common.blocks.PropertyString;
 import reborncore.common.registration.RebornRegistry;
 import reborncore.common.registration.impl.ConfigRegistry;
@@ -52,11 +49,6 @@ import java.util.Random;
 @RebornRegistry(modID = ModInfo.MOD_ID)
 public class BlockOre extends Block implements IOreNameProvider {
 
-//	public static final String[] ores = new String[] {
-//		"galena", "iridium", "ruby", "sapphire", "bauxite", "pyrite",
-//		"cinnabar", "sphalerite", "tungsten", "sheldonite", "peridot", "sodalite",
-//		"lead", "silver" };
-//	public static List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
 	public static final PropertyString VARIANTS = getVarients();
 	@ConfigRegistry(config = "misc", category = "blocks", key = "rubyMinQuatity", comment = "Minimum quantity of Ruby gems per Ruby ore")
 	public static int rubyMinQuatity = 1;
@@ -88,10 +80,6 @@ public class BlockOre extends Block implements IOreNameProvider {
 		setCreativeTab(TechRebornCreativeTab.instance);
 		setHardness(2.0f);
 		setHarvestLevel("pickaxe", 2);
-		// TODO: Fix block
-//		for (int i = 0; i < ores.length; i++) {
-//			RebornModelRegistry.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i).setInvVariant("type=" + OreBlockStateManager.convert(ores[i])).setFileName("ores"));
-//		}
 	}
 
 //	public static ItemStack getOreByName(String name, int count) {
diff --git a/src/main/java/techreborn/client/RegisterItemJsons.java b/src/main/java/techreborn/client/RegisterItemJsons.java
index ce371017f..9aa035821 100644
--- a/src/main/java/techreborn/client/RegisterItemJsons.java
+++ b/src/main/java/techreborn/client/RegisterItemJsons.java
@@ -150,20 +150,6 @@ public class RegisterItemJsons {
 		});
 	}
 
-	public static void setBlockStateMapper(Block block, String path, IProperty<?>... ignoredProperties) {
-		final String slash = !path.isEmpty() ? "/" : "";
-		ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
-			@Override
-			protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
-				Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties());
-				for (IProperty<?> iproperty : ignoredProperties) {
-					map.remove(iproperty);
-				}
-				return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getNamespace(), path + slash + block.getRegistryName().getPath()), this.getPropertyString(map));
-			}
-		});
-	}
-
 	private static void registerBlocks() {
 		register(ModBlocks.REFINED_IRON_FENCE, "iron_fence");
 	}
diff --git a/src/main/java/techreborn/init/TRIngredients.java b/src/main/java/techreborn/init/TRIngredients.java
index ed004919a..4f2dd1fb1 100644
--- a/src/main/java/techreborn/init/TRIngredients.java
+++ b/src/main/java/techreborn/init/TRIngredients.java
@@ -24,11 +24,11 @@
 package techreborn.init;
 
 import java.util.Arrays;
-
 import com.google.common.base.CaseFormat;
-
 import net.minecraft.block.Block;
+import net.minecraft.block.state.IBlockState;
 import net.minecraft.client.renderer.block.model.ModelResourceLocation;
+import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.util.IStringSerializable;
@@ -37,8 +37,6 @@ import net.minecraftforge.client.model.ModelLoader;
 import net.minecraftforge.fml.relauncher.Side;
 import net.minecraftforge.fml.relauncher.SideOnly;
 import reborncore.RebornRegistry;
-import reborncore.client.models.ModelCompound;
-import reborncore.client.models.RebornModelRegistry;
 import techreborn.blocks.BlockOre;
 import techreborn.events.TRRecipeHandler;
 import techreborn.items.ItemTR;
@@ -97,8 +95,19 @@ public class TRIngredients {
 		ResourceLocation platesRL = new ResourceLocation(ModInfo.MOD_ID, "items/materials/plates");
 		Arrays.stream(Plates.values()).forEach(value -> ModelLoader.setCustomModelResourceLocation(value.item, 0,
 				new ModelResourceLocation(platesRL, "type=" + value.name)));
+
+		ResourceLocation oresRL = new ResourceLocation(ModInfo.MOD_ID, "ores");
+		for (Ores ore : Ores.values()) {
+			ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ore.block), 0, new ModelResourceLocation(oresRL, "type=" + ore.name));
+			ModelLoader.setCustomStateMapper(ore.block, new DefaultStateMapper() {
+				@Override
+				protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
+					return new ModelResourceLocation(oresRL, "type=" + ore.name);
+				}
+			});
+		}
 	}
-		
+	
 	public static enum Ores implements IStringSerializable {
 		BAUXITE, CINNABAR, COPPER, GALENA, IRIDIUM, LEAD, PERIDOT, PYRITE, RUBY, SAPPHIRE, SHELDONITE, SILVER, SODALITE,
 		SPHALERITE, TIN, TUNGSTEN;
@@ -111,7 +120,6 @@ public class TRIngredients {
 			block = new BlockOre();
 			block.setRegistryName(new ResourceLocation(ModInfo.MOD_ID, name));
 			block.setTranslationKey(ModInfo.MOD_ID + ".ore." + this.toString().toLowerCase());
-			RebornModelRegistry.registerModel(new ModelCompound(ModInfo.MOD_ID, block).setInvVariant("type=" + name).setFileName("ores"));
 			TRRecipeHandler.hideEntry(block);
 		}