From 34fae04641a9a44a2030fa0d4f1cf6871efeebb3 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Tue, 5 Jan 2016 21:39:56 -0600 Subject: [PATCH] Made API dediserver-safe. Remove icon methods from SubTileSignature. --- .../vazkii/botania/api/BotaniaAPIClient.java | 61 ++++++++++ .../api/subtile/signature/BasicSignature.java | 14 --- .../subtile/signature/SubTileSignature.java | 10 -- .../client/core/handler/ModelHandler.java | 113 +++++++++--------- .../client/core/proxy/ClientProxy.java | 8 -- .../render/SpecialFlowerModel.java | 56 +-------- .../common/block/BlockSpecialFlower.java | 11 -- .../common/block/tile/mana/TilePool.java | 2 +- 8 files changed, 121 insertions(+), 154 deletions(-) create mode 100644 src/main/java/vazkii/botania/api/BotaniaAPIClient.java rename src/main/java/vazkii/botania/{api => client}/render/SpecialFlowerModel.java (81%) diff --git a/src/main/java/vazkii/botania/api/BotaniaAPIClient.java b/src/main/java/vazkii/botania/api/BotaniaAPIClient.java new file mode 100644 index 000000000..e2de209a0 --- /dev/null +++ b/src/main/java/vazkii/botania/api/BotaniaAPIClient.java @@ -0,0 +1,61 @@ +package vazkii.botania.api; + +import com.google.common.collect.Maps; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import vazkii.botania.api.subtile.SubTileEntity; + +import java.util.Map; + +/** + * Class for API calls that must be made clientside + */ +@SideOnly(Side.CLIENT) +public final class BotaniaAPIClient { + + public static final Map queuedBlockModels = Maps.newHashMap(); + public static final Map queuedItemModels = Maps.newHashMap(); + + /** + * Register your model for the given subtile class here. + * Call this DURING PREINIT. Calling it anytime after blockModels have already baked does not guarantee that your model will work. + * Your model json must specify key "tintindex" in all the faces it wants tint applied. + * Tint is applied whenever a player recolors the flower using floral dye + * todo 1.8.8 move this elsewhere or otherwise make it fit better with the rest of the subtile registration process + * + * @param subTileName The String ID of the subtile + * @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) { + queuedBlockModels.put(subTileName, model); + queuedItemModels.put(subTileName, itemModel); + } + + /** + * Register your model for the given subtile class here. + * Call this DURING PREINIT. Calling it anytime after blockModels have already baked does not guarantee that your model will work. + * Your model json must specify key "tintindex" in all the faces it wants tint applied. + * Tint is applied whenever a player recolors the flower using floral dye + * todo 1.8.8 move this elsewhere or otherwise make it fit better with the rest of the subtile registration process + * + * @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) { + registerSubtileModel(subTileName, model, new ModelResourceLocation(model.getResourceDomain() + ":" + model.getResourcePath(), "inventory")); + } + + // Convenience overloads for the above two calls + public static void registerSubtileModel(Class clazz, ModelResourceLocation model) { + registerSubtileModel(BotaniaAPI.getSubTileStringMapping(clazz), model); + } + + public static void registerSubtileModel(Class clazz, ModelResourceLocation model, ModelResourceLocation itemModel) { + registerSubtileModel(BotaniaAPI.getSubTileStringMapping(clazz), model, itemModel); + } + + private BotaniaAPIClient() {} + +} diff --git a/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java b/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java index c454fdd2f..66b710147 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java @@ -10,15 +10,11 @@ */ package vazkii.botania.api.subtile.signature; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -38,16 +34,6 @@ public class BasicSignature extends SubTileSignature { this.name = name; } - @Override - public void registerIcons(TextureMap register) { - BotaniaAPI.internalHandler.registerBasicSignatureIcons(name, register); - } - - @Override - public TextureAtlasSprite getIconForStack(ItemStack stack) { - return BotaniaAPI.internalHandler.getSubTileIconForName(name); - } - @Override public String getUnlocalizedNameForStack(ItemStack stack) { return unlocalizedName(""); diff --git a/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java b/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java index 1128b0602..949f0c8e6 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java @@ -24,16 +24,6 @@ public abstract class SubTileSignature { public static final String SPECIAL_FLOWER_PREFIX = "flower."; - /** - * Equivalent to Block.registerBlockIcons. - */ - public abstract void registerIcons(TextureMap map); - // todo 1.8 evaluate need for these two - /** - * Gets the icon to display for the flower item. - */ - public abstract TextureAtlasSprite getIconForStack(ItemStack stack); - /** * Gets the display name for the flower item. */ 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 527585913..a1eb126aa 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -9,11 +9,9 @@ package vazkii.botania.client.core.handler; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; import net.minecraft.block.BlockFlower; -import net.minecraft.block.BlockRailPowered; import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockWall; import net.minecraft.block.state.IBlockState; @@ -33,7 +31,8 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.fml.common.registry.GameData; -import vazkii.botania.api.render.SpecialFlowerModel; +import vazkii.botania.api.BotaniaAPIClient; +import vazkii.botania.client.render.SpecialFlowerModel; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.AltGrassVariant; import vazkii.botania.api.state.enums.AltarVariant; @@ -53,7 +52,6 @@ import vazkii.botania.api.state.enums.PylonVariant; import vazkii.botania.api.state.enums.StorageVariant; import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.model.FloatingFlowerModel; -import vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.decor.slabs.BlockModSlab; @@ -114,7 +112,6 @@ import vazkii.botania.common.lib.LibMisc; import static vazkii.botania.common.item.ModItems.*; -import java.util.Collection; import java.util.List; import java.util.Locale; @@ -302,61 +299,61 @@ public final class ModelHandler { } private static void registerSubtiles() { - SpecialFlowerModel.register(SubTileManastar.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MANASTAR)); - SpecialFlowerModel.register(SubTilePureDaisy.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_PUREDAISY)); + BotaniaAPIClient.registerSubtileModel(SubTileManastar.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MANASTAR)); + BotaniaAPIClient.registerSubtileModel(SubTilePureDaisy.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_PUREDAISY)); - SpecialFlowerModel.register(SubTileDaybloom.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAYBLOOM)); - SpecialFlowerModel.register(SubTileDecor.Daybloom.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAYBLOOM + "Decor")); - SpecialFlowerModel.register(SubTileDaybloom.Prime.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); - SpecialFlowerModel.register(SubTileEndoflame.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ENDOFLAME)); - SpecialFlowerModel.register(SubTileHydroangeas.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYDROANGEAS)); - SpecialFlowerModel.register(SubTileDecor.Hydroangeas.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYDROANGEAS + "Decor")); - SpecialFlowerModel.register(SubTileThermalily.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_THERMALILY)); - SpecialFlowerModel.register(SubTileNightshade.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NIGHTSHADE)); - SpecialFlowerModel.register(SubTileDecor.Nightshade.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NIGHTSHADE + "Decor")); - SpecialFlowerModel.register(SubTileNightshade.Prime.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NIGHTSHADE_PRIME)); - SpecialFlowerModel.register(SubTileArcaneRose.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ARCANE_ROSE)); - SpecialFlowerModel.register(SubTileMunchdew.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MUNCHDEW)); - SpecialFlowerModel.register(SubTileEntropinnyum.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ENTROPINNYUM)); - SpecialFlowerModel.register(SubTileKekimurus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_KEKIMURUS)); - SpecialFlowerModel.register(SubTileGourmaryllis.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_GOURMARYLLIS)); - SpecialFlowerModel.register(SubTileNarslimmus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NARSLIMMUS)); - SpecialFlowerModel.register(SubTileSpectrolus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SPECTROLUS)); - SpecialFlowerModel.register(SubTileDandelifeon.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DANDELIFEON)); - SpecialFlowerModel.register(SubTileRafflowsia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_RAFFLOWSIA)); + BotaniaAPIClient.registerSubtileModel(SubTileDaybloom.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAYBLOOM)); + BotaniaAPIClient.registerSubtileModel(SubTileDecor.Daybloom.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAYBLOOM + "Decor")); + BotaniaAPIClient.registerSubtileModel(SubTileDaybloom.Prime.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); + BotaniaAPIClient.registerSubtileModel(SubTileEndoflame.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ENDOFLAME)); + BotaniaAPIClient.registerSubtileModel(SubTileHydroangeas.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYDROANGEAS)); + BotaniaAPIClient.registerSubtileModel(SubTileDecor.Hydroangeas.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYDROANGEAS + "Decor")); + BotaniaAPIClient.registerSubtileModel(SubTileThermalily.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_THERMALILY)); + BotaniaAPIClient.registerSubtileModel(SubTileNightshade.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NIGHTSHADE)); + BotaniaAPIClient.registerSubtileModel(SubTileDecor.Nightshade.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NIGHTSHADE + "Decor")); + BotaniaAPIClient.registerSubtileModel(SubTileNightshade.Prime.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_NIGHTSHADE_PRIME)); + 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)); - SpecialFlowerModel.register(SubTileBellethorn.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BELLETHORN)); - SpecialFlowerModel.register(SubTileBellethorn.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); - SpecialFlowerModel.register(SubTileDreadthorn.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DREADTHORN)); - SpecialFlowerModel.register(SubTileHeiseiDream.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HEISEI_DREAM)); - SpecialFlowerModel.register(SubTileTigerseye.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_TIGERSEYE)); - SpecialFlowerModel.register(SubTileJadedAmaranthus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_JADED_AMARANTHUS)); - SpecialFlowerModel.register(SubTileOrechid.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ORECHID)); - SpecialFlowerModel.register(SubTileOrechidIgnem.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_ORECHID_IGNEM)); - SpecialFlowerModel.register(SubTileFallenKanade.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_FALLEN_KANADE)); - SpecialFlowerModel.register(SubTileExoflame.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_EXOFLAME)); - SpecialFlowerModel.register(SubTileAgricarnation.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_AGRICARNATION)); - SpecialFlowerModel.register(SubTileAgricarnation.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_AGRICARNATION + "Chibi")); - SpecialFlowerModel.register(SubTileHopperhock.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HOPPERHOCK)); - SpecialFlowerModel.register(SubTileHopperhock.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HOPPERHOCK + "Chibi")); - SpecialFlowerModel.register(SubTileTangleberrie.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_TANGLEBERRIE)); - SpecialFlowerModel.register(SubTileJiyuulia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_JIYUULIA)); - SpecialFlowerModel.register(SubTileRannuncarpus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_RANNUNCARPUS)); - SpecialFlowerModel.register(SubTileRannuncarpus.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_RANNUNCARPUS + "Chibi")); - SpecialFlowerModel.register(SubTileHyacidus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_HYACIDUS)); - SpecialFlowerModel.register(SubTilePollidisiac.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_POLLIDISIAC)); - SpecialFlowerModel.register(SubTileClayconia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_CLAYCONIA)); - SpecialFlowerModel.register(SubTileLoonuim.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_LOONIUM)); - SpecialFlowerModel.register(SubTileDaffomill.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_DAFFOMILL)); - SpecialFlowerModel.register(SubTileVinculotus.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_VINCULOTUS)); - SpecialFlowerModel.register(SubTileSpectranthemum.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SPECTRANTHEMUM)); - SpecialFlowerModel.register(SubTileMedumone.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MEDUMONE)); - SpecialFlowerModel.register(SubTileMarimorphosis.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MARIMORPHOSIS)); - SpecialFlowerModel.register(SubTileMarimorphosis.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_MARIMORPHOSIS + "Chibi")); - SpecialFlowerModel.register(SubTileBubbell.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BUBBELL)); - SpecialFlowerModel.register(SubTileBubbell.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_BUBBELL + "Chibi")); - SpecialFlowerModel.register(SubTileSolegnolia.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SOLEGNOLIA)); - SpecialFlowerModel.register(SubTileSolegnolia.Mini.class, new ModelResourceLocation("botania:" + LibBlockNames.SUBTILE_SOLEGNOLIA + "Chibi")); + 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(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")); } private static void registerStandardBlocks() { diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index 90caf2b5a..adab4f63a 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -34,16 +34,12 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraft.world.WorldSettings.GameType; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.common.MinecraftForge; import vazkii.botania.api.item.IExtendedPlayerController; import vazkii.botania.api.lexicon.LexiconEntry; -import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.api.lexicon.multiblock.component.AnyComponent; -import vazkii.botania.api.render.SpecialFlowerModel; import vazkii.botania.api.wiki.IWikiProvider; import vazkii.botania.api.wiki.WikiHooks; import vazkii.botania.client.challenge.ModChallenges; @@ -106,8 +102,6 @@ import vazkii.botania.client.render.tile.RenderTileTerraPlate; import vazkii.botania.client.render.tile.RenderTileTeruTeruBozu; import vazkii.botania.client.render.tile.RenderTileTinyPotato; import vazkii.botania.client.render.world.SkyblockRenderEvents; -import vazkii.botania.common.Botania; -import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileAlfPortal; import vazkii.botania.common.block.tile.TileAltar; import vazkii.botania.common.block.tile.TileAvatar; @@ -116,7 +110,6 @@ import vazkii.botania.common.block.tile.TileCocoon; import vazkii.botania.common.block.tile.TileEnchanter; import vazkii.botania.common.block.tile.TileFloatingFlower; import vazkii.botania.common.block.tile.TileFloatingSpecialFlower; -import vazkii.botania.common.block.tile.TileGaiaHead; import vazkii.botania.common.block.tile.TileHourglass; import vazkii.botania.common.block.tile.TileIncensePlate; import vazkii.botania.common.block.tile.TileLightRelay; @@ -160,7 +153,6 @@ import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.common.event.FMLInitializationEvent; diff --git a/src/main/java/vazkii/botania/api/render/SpecialFlowerModel.java b/src/main/java/vazkii/botania/client/render/SpecialFlowerModel.java similarity index 81% rename from src/main/java/vazkii/botania/api/render/SpecialFlowerModel.java rename to src/main/java/vazkii/botania/client/render/SpecialFlowerModel.java index 4b5f1a274..0b2b61734 100644 --- a/src/main/java/vazkii/botania/api/render/SpecialFlowerModel.java +++ b/src/main/java/vazkii/botania/client/render/SpecialFlowerModel.java @@ -6,14 +6,13 @@ * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php */ -package vazkii.botania.api.render; +package vazkii.botania.client.render; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import net.minecraft.block.state.IBlockState; @@ -41,9 +40,8 @@ import net.minecraftforge.client.model.TRSRTransformation; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.common.FMLLog; 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.api.subtile.SubTileEntity; import vazkii.botania.common.block.decor.IFloatingFlower; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; @@ -56,53 +54,8 @@ import java.util.Map; public class SpecialFlowerModel implements IModelCustomData { - /** - * Register your model for the given subtile class here. - * Call this DURING PREINIT. Calling it anytime after blockModels have already baked does not guarantee that your model will work. - * Your model json must specify key "tintindex" in all the faces it wants tint applied. - * Tint is applied whenever a player recolors the flower using floral dye - * todo 1.8.8 move this elsewhere or otherwise make it fit better with the rest of the subtile registration process - * - * @param subTileName The String ID of the subtile - * @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 register(String subTileName, ModelResourceLocation model, ModelResourceLocation itemModel) { - queuedBlockModels.put(subTileName, model); - queuedItemModels.put(subTileName, itemModel); - } - - /** - * Register your model for the given subtile class here. - * Call this DURING PREINIT. Calling it anytime after blockModels have already baked does not guarantee that your model will work. - * Your model json must specify key "tintindex" in all the faces it wants tint applied. - * Tint is applied whenever a player recolors the flower using floral dye - * todo 1.8.8 move this elsewhere or otherwise make it fit better with the rest of the subtile registration process - * - * @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 register(String subTileName, ModelResourceLocation model) { - register(subTileName, model, new ModelResourceLocation(model.getResourceDomain() + ":" + model.getResourcePath(), "inventory")); - } - - public static void register(Class clazz, ModelResourceLocation model) { - register(BotaniaAPI.getSubTileStringMapping(clazz), model); - } - - public static void register(Class clazz, ModelResourceLocation model, ModelResourceLocation itemModel) { - register(BotaniaAPI.getSubTileStringMapping(clazz), model, itemModel); - } - - /** - * Internal implementation - **/ // SpecialFlowerModel for when there are no blockModels registered for a subtile public static final SpecialFlowerModel INSTANCE = new SpecialFlowerModel(ImmutableMap., ModelResourceLocation>of(), ImmutableMap., ModelResourceLocation>of()); - // Models registered from the externel API thus far - private static final Map queuedBlockModels = Maps.newHashMap(); - private static final Map queuedItemModels = Maps.newHashMap(); - private final ImmutableMap, ModelResourceLocation> blockModels; private final ImmutableMap, ModelResourceLocation> itemModels; @@ -120,7 +73,6 @@ public class SpecialFlowerModel implements IModelCustomData { builder.addAll(itemModels.values()); // Force mini island model to be loaded and baked, for use elsewhere. See FloatingFlowerModel - // TODO 1.8.8!!!! IslandType is not in the API, will crash when botania is not present!! Must relocate this elsewhere! for (IFloatingFlower.IslandType i : IFloatingFlower.IslandType.values()) { builder.add(new ModelResourceLocation("botania:miniIsland", "variant=" + i.name().toLowerCase(Locale.ROOT))); } @@ -156,10 +108,10 @@ public class SpecialFlowerModel implements IModelCustomData { } } - for (Map.Entry e : queuedBlockModels.entrySet()) { + for (Map.Entry e : BotaniaAPIClient.queuedBlockModels.entrySet()) { blockBuilder.put(Optional.of(e.getKey()), e.getValue()); } - for (Map.Entry e : queuedItemModels.entrySet()) { + for (Map.Entry e : BotaniaAPIClient.queuedItemModels.entrySet()) { itemBuilder.put(Optional.of(e.getKey()), e.getValue()); } diff --git a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java index 1281c26f9..759dfcd1e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java @@ -17,7 +17,6 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; @@ -25,9 +24,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EntityDiggingFX; -import net.minecraft.client.renderer.block.statemap.DefaultStateMapper; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -42,20 +38,14 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.RegistrySimple; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.render.SpecialFlowerModel; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; @@ -63,7 +53,6 @@ import vazkii.botania.api.subtile.ISpecialFlower; import vazkii.botania.api.subtile.SubTileEntity; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; -import vazkii.botania.common.block.subtile.generating.SubTileDaybloom; import vazkii.botania.common.block.tile.TileSpecialFlower; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.integration.coloredlights.LightHelper; diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java index 9bf47933b..d1466210b 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java @@ -142,7 +142,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc item.setDead(); } - int age = ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE) + int age = ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE); if(age > 100 && age < 130 || !catalystsRegistered) return false;