Fixes for recipe editing: lÂexicon in general and apothecary oredicting,itemblocks, and API updates in particular

(cherry picked from commit 594b0bb4622e4662ea5fe454396fb55ad90e55b2)
This commit is contained in:
(Com)buster authored and Martin Robertz committed 2022-01-01 18:57:32 +01:00
1 parent 3527358443
commit bd2be73856
7 files changed
+70 -20

No files matched your search

@@ -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();
@@ -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<Item, IFlowerComponent> extraFlowerComponents = new HashMap<Item, IFlowerComponent>();
}
@@ -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;
@@ -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;
@@ -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) {
@@ -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;
@@ -43,6 +43,7 @@ public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
List<T> recipes;
int ticksElapsed = 0;
int recipeAt = 0;
int oredictCounter = 0;
public PagePetalRecipe(String unlocalizedName, List<T> recipes) {
super(unlocalizedName);
@@ -77,8 +78,10 @@ public class PagePetalRecipe<T extends RecipePetals> 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<ItemStack> ores = OreDictionary.getOres((String) input);
input = ores.get(oredictCounter % ores.size());
}
renderItemAtAngle(gui, currentDegree, (ItemStack) input);
@@ -127,8 +130,10 @@ public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
if(ticksElapsed % 20 == 0) {
recipeAt++;
if(recipeAt == recipes.size())
if(recipeAt == recipes.size()) {
recipeAt = 0;
oredictCounter++;
}
}
++ticksElapsed;
}