diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index 93cc3f753..bffa03032 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -140,7 +140,7 @@ public final class BotaniaAPI { public static final Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); static { - registerSubTile(DUMMY_SUBTILE_NAME, DummySubTile.class); + subTiles.register(0, DUMMY_SUBTILE_NAME, DummySubTile.class); // int id irrelevant, this is just to set the default value basicKnowledge = registerKnowledgeType("minecraft", TextFormatting.RESET, true); elvenKnowledge = registerKnowledgeType("alfheim", TextFormatting.DARK_GREEN, false); diff --git a/src/main/java/vazkii/botania/api/BotaniaAPIClient.java b/src/main/java/vazkii/botania/api/BotaniaAPIClient.java index 8ac7492ce..b813bd05a 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPIClient.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPIClient.java @@ -10,6 +10,7 @@ package vazkii.botania.api; import com.google.common.collect.Maps; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.item.IFloatingFlower; @@ -24,8 +25,8 @@ import java.util.Map; @SideOnly(Side.CLIENT) public final class BotaniaAPIClient { - private static final Map subtileBlockModels = Maps.newHashMap(); - private static final Map subtileItemModels = Maps.newHashMap(); + private static final Map subtileBlockModels = Maps.newHashMap(); + private static final Map subtileItemModels = Maps.newHashMap(); private static final Map islandTypeModels = Maps.newHashMap(); private BotaniaAPIClient() { @@ -41,7 +42,7 @@ public final class BotaniaAPIClient { * @param model A path to a blockstate json and variant to be used for this subtile * @param itemModel A path to a blockstate json and variant to be used for this subtile's item form */ - public static void registerSubtileModel(String subTileName, ModelResourceLocation model, ModelResourceLocation itemModel) { + public static void registerSubtileModel(ResourceLocation subTileName, ModelResourceLocation model, ModelResourceLocation itemModel) { subtileBlockModels.put(subTileName, model); subtileItemModels.put(subTileName, itemModel); } @@ -55,7 +56,7 @@ public final class BotaniaAPIClient { * @param subTileName The String ID of the subtile * @param model A path to a blockstate json and variant to be used the block. The item model will be drawn from the same blockstate json, from variant "inventory" */ - public static void registerSubtileModel(String subTileName, ModelResourceLocation model) { + public static void registerSubtileModel(ResourceLocation subTileName, ModelResourceLocation model) { registerSubtileModel(subTileName, model, new ModelResourceLocation(model.getResourceDomain() + ":" + model.getResourcePath(), "inventory")); } @@ -71,14 +72,14 @@ public final class BotaniaAPIClient { /** * @return An immutable and live view of the registered subtile block model map */ - public static Map getRegisteredSubtileBlockModels() { + public static Map getRegisteredSubtileBlockModels() { return Collections.unmodifiableMap(subtileBlockModels); } /** * @return An immutable and live view of the registered subtile item model map */ - public static Map getRegisteredSubtileItemModels() { + public static Map getRegisteredSubtileItemModels() { return Collections.unmodifiableMap(subtileItemModels); } diff --git a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java index cba241c7a..89a624357 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -81,57 +81,57 @@ public final class ModelHandler { BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.INFUSED, new ModelResourceLocation("botania:miniIsland", "variant=infused")); BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.MUTATED, new ModelResourceLocation("botania:miniIsland", "variant=mutated")); - BotaniaAPIClient.registerSubtileModel(SubTileManastar.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MANASTAR)); - BotaniaAPIClient.registerSubtileModel(SubTilePureDaisy.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_PUREDAISY)); + BotaniaAPIClient.registerSubtileModel(SubTileManastar.class, new ModelResourceLocation(LibBlockNames.SUBTILE_MANASTAR.toString())); + BotaniaAPIClient.registerSubtileModel(SubTilePureDaisy.class, new ModelResourceLocation(LibBlockNames.SUBTILE_PUREDAISY.toString())); - BotaniaAPIClient.registerSubtileModel(SubTileEndoflame.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ENDOFLAME)); - BotaniaAPIClient.registerSubtileModel(SubTileHydroangeas.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYDROANGEAS)); - BotaniaAPIClient.registerSubtileModel(SubTileThermalily.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_THERMALILY)); - BotaniaAPIClient.registerSubtileModel(SubTileArcaneRose.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ARCANE_ROSE)); - BotaniaAPIClient.registerSubtileModel(SubTileMunchdew.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MUNCHDEW)); - BotaniaAPIClient.registerSubtileModel(SubTileEntropinnyum.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ENTROPINNYUM)); - BotaniaAPIClient.registerSubtileModel(SubTileKekimurus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_KEKIMURUS)); - BotaniaAPIClient.registerSubtileModel(SubTileGourmaryllis.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_GOURMARYLLIS)); - BotaniaAPIClient.registerSubtileModel(SubTileNarslimmus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NARSLIMMUS)); - BotaniaAPIClient.registerSubtileModel(SubTileSpectrolus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SPECTROLUS)); - BotaniaAPIClient.registerSubtileModel(SubTileDandelifeon.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DANDELIFEON)); - BotaniaAPIClient.registerSubtileModel(SubTileRafflowsia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_RAFFLOWSIA)); - BotaniaAPIClient.registerSubtileModel(SubTileShulkMeNot.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SHULK_ME_NOT)); + BotaniaAPIClient.registerSubtileModel(SubTileEndoflame.class, new ModelResourceLocation(LibBlockNames.SUBTILE_ENDOFLAME.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileHydroangeas.class, new ModelResourceLocation(LibBlockNames.SUBTILE_HYDROANGEAS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileThermalily.class, new ModelResourceLocation(LibBlockNames.SUBTILE_THERMALILY.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileArcaneRose.class, new ModelResourceLocation(LibBlockNames.SUBTILE_ARCANE_ROSE.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileMunchdew.class, new ModelResourceLocation(LibBlockNames.SUBTILE_MUNCHDEW.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileEntropinnyum.class, new ModelResourceLocation(LibBlockNames.SUBTILE_ENTROPINNYUM.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileKekimurus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_KEKIMURUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileGourmaryllis.class, new ModelResourceLocation(LibBlockNames.SUBTILE_GOURMARYLLIS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileNarslimmus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_NARSLIMMUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileSpectrolus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_SPECTROLUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileDandelifeon.class, new ModelResourceLocation(LibBlockNames.SUBTILE_DANDELIFEON.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileRafflowsia.class, new ModelResourceLocation(LibBlockNames.SUBTILE_RAFFLOWSIA.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileShulkMeNot.class, new ModelResourceLocation(LibBlockNames.SUBTILE_SHULK_ME_NOT.toString())); - BotaniaAPIClient.registerSubtileModel(SubTileBellethorn.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BELLETHORN)); - BotaniaAPIClient.registerSubtileModel(SubTileBellethorn.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileDreadthorn.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DREADTHORN)); - BotaniaAPIClient.registerSubtileModel(SubTileHeiseiDream.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HEISEI_DREAM)); - BotaniaAPIClient.registerSubtileModel(SubTileTigerseye.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_TIGERSEYE)); - BotaniaAPIClient.registerSubtileModel(SubTileJadedAmaranthus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_JADED_AMARANTHUS)); - BotaniaAPIClient.registerSubtileModel(SubTileOrechid.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ORECHID)); - BotaniaAPIClient.registerSubtileModel(SubTileOrechidIgnem.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ORECHID_IGNEM)); - BotaniaAPIClient.registerSubtileModel(SubTileFallenKanade.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_FALLEN_KANADE)); - BotaniaAPIClient.registerSubtileModel(SubTileExoflame.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_EXOFLAME)); - BotaniaAPIClient.registerSubtileModel(SubTileAgricarnation.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_AGRICARNATION)); - BotaniaAPIClient.registerSubtileModel(SubTileAgricarnation.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_AGRICARNATION + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileHopperhock.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HOPPERHOCK)); - BotaniaAPIClient.registerSubtileModel(SubTileHopperhock.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HOPPERHOCK + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileTangleberrie.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_TANGLEBERRIE)); - BotaniaAPIClient.registerSubtileModel(SubTileJiyuulia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_JIYUULIA)); - BotaniaAPIClient.registerSubtileModel(SubTileRannuncarpus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_RANNUNCARPUS)); - BotaniaAPIClient.registerSubtileModel(SubTileRannuncarpus.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_RANNUNCARPUS + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileHyacidus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYACIDUS)); - BotaniaAPIClient.registerSubtileModel(SubTilePollidisiac.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_POLLIDISIAC)); - BotaniaAPIClient.registerSubtileModel(SubTileClayconia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_CLAYCONIA)); - BotaniaAPIClient.registerSubtileModel(SubTileClayconia.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_CLAYCONIA + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileLoonuim.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_LOONIUM)); - BotaniaAPIClient.registerSubtileModel(SubTileDaffomill.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAFFOMILL)); - BotaniaAPIClient.registerSubtileModel(SubTileVinculotus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_VINCULOTUS)); - BotaniaAPIClient.registerSubtileModel(SubTileSpectranthemum.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SPECTRANTHEMUM)); - BotaniaAPIClient.registerSubtileModel(SubTileMedumone.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MEDUMONE)); - BotaniaAPIClient.registerSubtileModel(SubTileMarimorphosis.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MARIMORPHOSIS)); - BotaniaAPIClient.registerSubtileModel(SubTileMarimorphosis.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MARIMORPHOSIS + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileBubbell.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BUBBELL)); - BotaniaAPIClient.registerSubtileModel(SubTileBubbell.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BUBBELL + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileSolegnolia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SOLEGNOLIA)); - BotaniaAPIClient.registerSubtileModel(SubTileSolegnolia.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SOLEGNOLIA + "Chibi")); - BotaniaAPIClient.registerSubtileModel(SubTileBergamute.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BERGAMUTE)); + BotaniaAPIClient.registerSubtileModel(SubTileBellethorn.class, new ModelResourceLocation(LibBlockNames.SUBTILE_BELLETHORN.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileBellethorn.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileDreadthorn.class, new ModelResourceLocation(LibBlockNames.SUBTILE_DREADTHORN.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileHeiseiDream.class, new ModelResourceLocation(LibBlockNames.SUBTILE_HEISEI_DREAM.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileTigerseye.class, new ModelResourceLocation(LibBlockNames.SUBTILE_TIGERSEYE.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileJadedAmaranthus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_JADED_AMARANTHUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileOrechid.class, new ModelResourceLocation(LibBlockNames.SUBTILE_ORECHID.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileOrechidIgnem.class, new ModelResourceLocation(LibBlockNames.SUBTILE_ORECHID_IGNEM.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileFallenKanade.class, new ModelResourceLocation(LibBlockNames.SUBTILE_FALLEN_KANADE.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileExoflame.class, new ModelResourceLocation(LibBlockNames.SUBTILE_EXOFLAME.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileAgricarnation.class, new ModelResourceLocation(LibBlockNames.SUBTILE_AGRICARNATION.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileAgricarnation.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_AGRICARNATION + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileHopperhock.class, new ModelResourceLocation(LibBlockNames.SUBTILE_HOPPERHOCK.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileHopperhock.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_HOPPERHOCK + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileTangleberrie.class, new ModelResourceLocation(LibBlockNames.SUBTILE_TANGLEBERRIE.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileJiyuulia.class, new ModelResourceLocation(LibBlockNames.SUBTILE_JIYUULIA.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileRannuncarpus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_RANNUNCARPUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileRannuncarpus.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_RANNUNCARPUS + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileHyacidus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_HYACIDUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTilePollidisiac.class, new ModelResourceLocation(LibBlockNames.SUBTILE_POLLIDISIAC.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileClayconia.class, new ModelResourceLocation(LibBlockNames.SUBTILE_CLAYCONIA.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileClayconia.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_CLAYCONIA + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileLoonuim.class, new ModelResourceLocation(LibBlockNames.SUBTILE_LOONIUM.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileDaffomill.class, new ModelResourceLocation(LibBlockNames.SUBTILE_DAFFOMILL.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileVinculotus.class, new ModelResourceLocation(LibBlockNames.SUBTILE_VINCULOTUS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileSpectranthemum.class, new ModelResourceLocation(LibBlockNames.SUBTILE_SPECTRANTHEMUM.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileMedumone.class, new ModelResourceLocation(LibBlockNames.SUBTILE_MEDUMONE.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileMarimorphosis.class, new ModelResourceLocation(LibBlockNames.SUBTILE_MARIMORPHOSIS.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileMarimorphosis.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_MARIMORPHOSIS + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileBubbell.class, new ModelResourceLocation(LibBlockNames.SUBTILE_BUBBELL.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileBubbell.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_BUBBELL + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileSolegnolia.class, new ModelResourceLocation(LibBlockNames.SUBTILE_SOLEGNOLIA.toString())); + BotaniaAPIClient.registerSubtileModel(SubTileSolegnolia.Mini.class, new ModelResourceLocation(LibBlockNames.SUBTILE_SOLEGNOLIA + "Chibi")); + BotaniaAPIClient.registerSubtileModel(SubTileBergamute.class, new ModelResourceLocation(LibBlockNames.SUBTILE_BERGAMUTE.toString())); } public static void registerItemAllMeta(Item item, int range) { diff --git a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java index 2aa9b0ec9..065096fc0 100644 --- a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java +++ b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java @@ -25,6 +25,7 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; @@ -40,6 +41,7 @@ import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; +import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.vecmath.Matrix4f; @@ -52,8 +54,8 @@ import java.util.Map; public class FloatingFlowerModel implements IBakedModel { - private static final String MUNDANE_PREFIX = "botania:shimmeringFlower_"; - private final Table CACHE = HashBasedTable.create(); + private static final String MUNDANE_PREFIX = "shimmeringFlower_"; + private final Table CACHE = HashBasedTable.create(); protected static BakedQuad transform(BakedQuad quad, final TRSRTransformation transform) { UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(DefaultVertexFormats.ITEM); @@ -88,21 +90,21 @@ public class FloatingFlowerModel implements IBakedModel { return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel().getQuads(state, face, rand); IExtendedBlockState realState = (IExtendedBlockState) state; IFloatingFlower.IslandType islandType = realState.getValue(BotaniaStateProps.ISLAND_TYPE); - String identifier; + ResourceLocation identifier; if(state.getBlock() == ModBlocks.floatingSpecialFlower) { // Magic flower identifier = realState.getValue(BotaniaStateProps.SUBTILE_ID); } else { // Mundane flower - identifier = MUNDANE_PREFIX + state.getValue(BotaniaStateProps.COLOR).getMetadata(); + identifier = new ResourceLocation(LibMisc.MOD_ID, MUNDANE_PREFIX + state.getValue(BotaniaStateProps.COLOR).getMetadata()); } return getModel(islandType, identifier).getQuads(state, face, rand); } // Get the model for this islandtype + flower type combination. If it's not cached already, generate it. - private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, String identifier) { + private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, ResourceLocation identifier) { ModelManager modelManager = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager(); if(CACHE.contains(islandType, identifier)) { @@ -117,8 +119,8 @@ public class FloatingFlowerModel implements IBakedModel { IBakedModel flowerModel; - if(identifier.startsWith(MUNDANE_PREFIX)) { - int meta = Integer.parseInt(identifier.substring(identifier.indexOf(MUNDANE_PREFIX) + MUNDANE_PREFIX.length())); + if(identifier.getResourcePath().startsWith(MUNDANE_PREFIX)) { + int meta = Integer.parseInt(identifier.getResourcePath().substring(identifier.getResourcePath().indexOf(MUNDANE_PREFIX) + MUNDANE_PREFIX.length())); flowerModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(new ItemStack(ModBlocks.shinyFlower, 1, meta)); } else { ItemStack stack = ItemBlockSpecialFlower.ofType(identifier); @@ -215,14 +217,14 @@ public class FloatingFlowerModel implements IBakedModel { public IBakedModel handleItemState(@Nonnull IBakedModel model, ItemStack stack, World world, EntityLivingBase entity) { // Items always have GRASS island IFloatingFlower.IslandType islandType = IFloatingFlower.IslandType.GRASS; - String identifier; + ResourceLocation identifier; if(Block.getBlockFromItem(stack.getItem()) == ModBlocks.floatingSpecialFlower) { // Magic flower identifier = ItemBlockSpecialFlower.getType(stack); } else { // Mundane flower - identifier = MUNDANE_PREFIX + stack.getItemDamage(); + identifier = new ResourceLocation(LibMisc.MOD_ID, MUNDANE_PREFIX + stack.getItemDamage()); } return FloatingFlowerModel.this.getModel(islandType, identifier); diff --git a/src/main/java/vazkii/botania/client/model/SpecialFlowerModel.java b/src/main/java/vazkii/botania/client/model/SpecialFlowerModel.java index 62a1d3745..17971a270 100644 --- a/src/main/java/vazkii/botania/client/model/SpecialFlowerModel.java +++ b/src/main/java/vazkii/botania/client/model/SpecialFlowerModel.java @@ -38,6 +38,7 @@ import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.property.IExtendedBlockState; import org.apache.commons.lang3.tuple.Pair; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.BotaniaAPIClient; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; @@ -52,12 +53,12 @@ import java.util.function.Function; public class SpecialFlowerModel implements IModel { private static final ModelResourceLocation MISSING = new ModelResourceLocation("builtin/missing", "missing"); private final ModelResourceLocation baseModel; - private final ImmutableMap blockModels; - private final ImmutableMap itemModels; + private final ImmutableMap blockModels; + private final ImmutableMap itemModels; private SpecialFlowerModel(ModelResourceLocation baseModel, - ImmutableMap blockModels, - ImmutableMap itemModels) { + ImmutableMap blockModels, + ImmutableMap itemModels) { this.baseModel = baseModel; this.blockModels = blockModels; this.itemModels = itemModels; @@ -90,15 +91,15 @@ public class SpecialFlowerModel implements IModel { IBakedModel baseModelBaked = ModelLoaderRegistry.getModelOrMissing(baseModel) .bake(transformState, DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); - ImmutableMap.Builder bakedBlockBuilder = ImmutableMap.builder(); - for(Map.Entry e : blockModels.entrySet()) { + ImmutableMap.Builder bakedBlockBuilder = ImmutableMap.builder(); + for(Map.Entry e : blockModels.entrySet()) { IModel model = ModelLoaderRegistry.getModelOrMissing(e.getValue()); if(model != ModelLoaderRegistry.getMissingModel()) bakedBlockBuilder.put(e.getKey(), model.bake(transformState, DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter())); } - ImmutableMap.Builder bakedItemBuilder = ImmutableMap.builder(); - for(Map.Entry e : itemModels.entrySet()) { + ImmutableMap.Builder bakedItemBuilder = ImmutableMap.builder(); + for(Map.Entry e : itemModels.entrySet()) { IModel model = ModelLoaderRegistry.getModelOrMissing(e.getValue()); if(model != ModelLoaderRegistry.getMissingModel()) bakedItemBuilder.put(e.getKey(), model.bake(transformState, DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter())); @@ -121,8 +122,8 @@ public class SpecialFlowerModel implements IModel { // Forge blockstate gives custom data in json form, have to drop the quotes base = new ModelResourceLocation(customData.get("base").substring(1, customData.get("base").length() - 1)); - ImmutableMap blockModels = ImmutableMap.copyOf(BotaniaAPIClient.getRegisteredSubtileBlockModels()); - ImmutableMap itemModels = ImmutableMap.copyOf(BotaniaAPIClient.getRegisteredSubtileItemModels()); + ImmutableMap blockModels = ImmutableMap.copyOf(BotaniaAPIClient.getRegisteredSubtileBlockModels()); + ImmutableMap itemModels = ImmutableMap.copyOf(BotaniaAPIClient.getRegisteredSubtileItemModels()); return new SpecialFlowerModel(base, blockModels, itemModels); } @@ -150,13 +151,13 @@ public class SpecialFlowerModel implements IModel { private static class SpecialFlowerBakedModel implements IBakedModel { private final IBakedModel baseModel; - private final ImmutableMap bakedBlockModels; - private final ImmutableMap bakedItemModels; + private final ImmutableMap bakedBlockModels; + private final ImmutableMap bakedItemModels; private final ImmutableMap transforms; SpecialFlowerBakedModel(IBakedModel baseModel, - ImmutableMap bakedBlockModels, - ImmutableMap bakedItemModels, + ImmutableMap bakedBlockModels, + ImmutableMap bakedItemModels, ImmutableMap cameraTransforms) { this.baseModel = baseModel; this.bakedBlockModels = bakedBlockModels; @@ -168,9 +169,9 @@ public class SpecialFlowerModel implements IModel { @Override public List getQuads(IBlockState state, EnumFacing face, long rand) { IExtendedBlockState extendedState = (IExtendedBlockState) state; - String subtileId = extendedState.getValue(BotaniaStateProps.SUBTILE_ID); + ResourceLocation subtileId = extendedState.getValue(BotaniaStateProps.SUBTILE_ID); - IBakedModel model = bakedBlockModels.get(subtileId == null ? "" : subtileId); + IBakedModel model = bakedBlockModels.get(subtileId == null ? BotaniaAPI.DUMMY_SUBTILE_NAME : subtileId); if(model == null) model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel(); diff --git a/src/main/java/vazkii/botania/common/fixers/FlattenItems.java b/src/main/java/vazkii/botania/common/fixers/FlattenItems.java index 6d48e1cad..91c77d2e5 100644 --- a/src/main/java/vazkii/botania/common/fixers/FlattenItems.java +++ b/src/main/java/vazkii/botania/common/fixers/FlattenItems.java @@ -20,6 +20,7 @@ import java.util.Locale; import java.util.Map; import java.util.function.IntFunction; +// TODO add support for migrating subtiles to add a domain // Flattens meta variants by splitting out to new ID's public class FlattenItems implements IFixableData { // old id to (meta -> new id) diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java index 638a13dba..dae70a23a 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java @@ -110,7 +110,7 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyPr } public static ResourceLocation getType(ItemStack stack) { - return stack.hasTagCompound() ? new ResourceLocation(ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, "")) : BotaniaAPI.DUMMY_SUBTILE_NAME; + return stack.hasTagCompound() ? new ResourceLocation(ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, BotaniaAPI.DUMMY_SUBTILE_NAME.toString())) : BotaniaAPI.DUMMY_SUBTILE_NAME; } public static ItemStack ofType(ResourceLocation type) {