From bd2be73856c09778d1529c9f7915979772f3c03a Mon Sep 17 00:00:00 2001 From: "(Com)buster" Date: Sun, 27 Dec 2020 21:48:17 +0100 Subject: [PATCH] =?UTF-8?q?Fixes=20for=20recipe=20editing:=20l=C3=82exicon?= =?UTF-8?q?=20in=20general=20and=20apothecary=20oredicting,itemblocks,=20a?= =?UTF-8?q?nd=20API=20updates=20in=20particular?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 594b0bb4622e4662ea5fe454396fb55ad90e55b2) --- .../client/render/tile/RenderTileAltar.java | 35 +++++++++++++------ .../botania/common/CustomBotaniaAPI.java | 12 +++++++ .../botania/common/block/tile/TileAltar.java | 20 +++++++++-- .../common/core/handler/ConfigHandler.java | 2 +- .../common/core/proxy/CommonProxy.java | 6 ++-- .../botania/common/lexicon/LexiconData.java | 4 ++- .../common/lexicon/page/PagePetalRecipe.java | 11 ++++-- 7 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 src/main/java/vazkii/botania/common/CustomBotaniaAPI.java diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java index 24cca1942..3ce7df9a0 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java @@ -15,11 +15,13 @@ import java.awt.Color; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -51,6 +53,7 @@ public class RenderTileAltar extends TileEntitySpecialRenderer { ModelAltar model = new ModelAltar(); RenderItem renderItem = new RenderItem(); + RenderBlocks renderBlocks = new RenderBlocks(); public static int forceMeta = -1; @Override @@ -84,6 +87,7 @@ public class RenderTileAltar extends TileEntitySpecialRenderer { else break; if(petals > 0) { + Minecraft minecraft = Minecraft.getMinecraft(); final float modifier = 6F; final float rotationModifier = 0.25F; final float radiusBase = 1.2F; @@ -120,17 +124,26 @@ public class RenderTileAltar extends TileEntitySpecialRenderer { GL11.glColor4f(1F, 1F, 1F, 1F); ItemStack stack = altar.getStackInSlot(i); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - IIcon icon = stack.getItem().getIcon(stack, 0); - if(icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); + minecraft.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + + if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + IIcon icon = stack.getItem().getIcon(stack, 0); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } } GL11.glPopMatrix(); diff --git a/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java b/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java new file mode 100644 index 000000000..0bf1db8bc --- /dev/null +++ b/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java @@ -0,0 +1,12 @@ +package vazkii.botania.common; + +import net.minecraft.item.Item; +import vazkii.botania.api.recipe.IFlowerComponent; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class CustomBotaniaAPI { + public static Map extraFlowerComponents = new HashMap(); +} diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index d6e58645c..483e49021 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -41,6 +41,7 @@ import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.Botania; +import vazkii.botania.common.CustomBotaniaAPI; import vazkii.botania.common.lib.LibBlockNames; public class TileAltar extends TileSimpleInventory implements ISidedInventory, IPetalApothecary { @@ -94,7 +95,7 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I boolean didChange = false; - if(stack.getItem() instanceof IFlowerComponent && ((IFlowerComponent) stack.getItem()).canFit(stack, this)) { + if(canGoInAltar(stack, this)) { if(getStackInSlot(getSizeInventory() - 1) != null) return false; @@ -145,6 +146,21 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I return didChange; } + private IFlowerComponent getFlowerComponent(ItemStack stack) { + IFlowerComponent component = CustomBotaniaAPI.extraFlowerComponents.get(stack.getItem()); + if (component == null) { + if (stack.getItem() instanceof IFlowerComponent) { + component = (IFlowerComponent) stack.getItem(); + } + } + return component; + } + + private boolean canGoInAltar(ItemStack stack, TileAltar reference) { + IFlowerComponent component = getFlowerComponent(stack); + return component != null && component.canFit(stack, reference); + } + public void saveLastRecipe() { lastRecipe = new ArrayList(); for(int i = 0; i < getSizeInventory(); i++) { @@ -235,7 +251,7 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I break; if(Math.random() >= 0.97) { - Color color = new Color(((IFlowerComponent) stackAt.getItem()).getParticleColor(stackAt)); + Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt)); float red = color.getRed() / 255F; float green = color.getGreen() / 255F; float blue = color.getBlue() / 255F; diff --git a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java index a79a293ca..2fef1cdda 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -94,7 +94,7 @@ public final class ConfigHandler { public static int harvestLevelWeight = 2; public static int harvestLevelBore = 3; - public static int flowerQuantity = 2; + public static int flowerQuantity = 0; public static int flowerDensity = 2; public static int flowerPatchSize = 6; public static int flowerPatchChance = 16; diff --git a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java index cb8a3d6ed..e441a92b5 100644 --- a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java +++ b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java @@ -121,10 +121,10 @@ public class CommonProxy { ChestGenHandler.init(); - LexiconData.init(); - if(Botania.gardenOfGlassLoaded) new WorldTypeSkyblock(); + + LexiconData.preInit(); } public void init(FMLInitializationEvent event) { @@ -147,6 +147,8 @@ public class CommonProxy { if(Botania.bcTriggersLoaded) new StatementAPIPlugin(); + + LexiconData.init(); } public void postInit(FMLPostInitializationEvent event) { diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 76a3c6882..2c291d353 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -295,7 +295,7 @@ public final class LexiconData { public static LexiconEntry bcIntegration; public static LexiconEntry banners; - public static void init() { + public static void preInit() { BotaniaAPI.addCategory(BotaniaAPI.categoryBasics = new BLexiconCategory(LibLexicon.CATEGORY_BASICS, 9)); BotaniaAPI.addCategory(BotaniaAPI.categoryMana = new BLexiconCategory(LibLexicon.CATEGORY_MANA, 5)); BotaniaAPI.addCategory( @@ -308,7 +308,9 @@ public final class LexiconData { BotaniaAPI.addCategory(BotaniaAPI.categoryEnder = new BLexiconCategory(LibLexicon.CATEGORY_ENDER, 5)); BotaniaAPI.addCategory(BotaniaAPI.categoryAlfhomancy = new BLexiconCategory(LibLexicon.CATEGORY_ALFHOMANCY, 5)); BotaniaAPI.addCategory(BotaniaAPI.categoryMisc = new BLexiconCategory(LibLexicon.CATEGORY_MISC, 0)); + } + public static void init() { LexiconCategory categoryBasics = BotaniaAPI.categoryBasics; LexiconCategory categoryMana = BotaniaAPI.categoryMana; LexiconCategory categoryGenerationFlowers = BotaniaAPI.categoryGenerationFlowers; diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java index e9c050059..3b3b9b482 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java @@ -43,6 +43,7 @@ public class PagePetalRecipe extends PageRecipe { List recipes; int ticksElapsed = 0; int recipeAt = 0; + int oredictCounter = 0; public PagePetalRecipe(String unlocalizedName, List recipes) { super(unlocalizedName); @@ -77,8 +78,10 @@ public class PagePetalRecipe extends PageRecipe { for(Object obj : inputs) { Object input = obj; - if(input instanceof String) - input = OreDictionary.getOres((String) input).get(0); + if(input instanceof String) { + List ores = OreDictionary.getOres((String) input); + input = ores.get(oredictCounter % ores.size()); + } renderItemAtAngle(gui, currentDegree, (ItemStack) input); @@ -127,8 +130,10 @@ public class PagePetalRecipe extends PageRecipe { if(ticksElapsed % 20 == 0) { recipeAt++; - if(recipeAt == recipes.size()) + if(recipeAt == recipes.size()) { recipeAt = 0; + oredictCounter++; + } } ++ticksElapsed; }