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 47c3477c4..e4481b632 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -84,7 +84,6 @@ public final class ConfigHandler { public static boolean invertMagnetRing = false; public static boolean enableThaumcraftStablizers = true; public static boolean enableThaumcraftAspects = true; - public static boolean enableShedding = false; public static int harvestLevelWeight = 2; public static int harvestLevelBore = 3; @@ -236,9 +235,6 @@ public final class ConfigHandler { desc = "Set this to false to disable Thaumcraft aspects on Botania items"; enableThaumcraftAspects = loadPropBool("thaumcraftAspects.enabled", desc, enableThaumcraftAspects); - desc = "Set this to true to enable the Shedding feature from 1.7.10. You'll need to load the game to generate the options. No options are enabled by default. This increases load time."; - enableShedding = loadPropBool("shedding.enable", desc, enableShedding); - desc = "The harvest level of the Mana Lens: Weight. 3 is diamond level. Defaults to 2 (iron level)"; harvestLevelWeight = loadPropInt("harvestLevel.weightLens", desc, harvestLevelWeight); @@ -274,9 +270,6 @@ public final class ConfigHandler { } public static void loadPostInit() { - if(enableShedding) - SheddingHandler.loadFromConfig(config); - if(config.hasChanged()) config.save(); } diff --git a/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java deleted file mode 100644 index 0e5263dff..000000000 --- a/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] - */ -package vazkii.botania.common.core.handler; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.ForgeRegistries; -import vazkii.botania.common.lexicon.LexiconData; -import vazkii.botania.common.lexicon.page.PageShedding; -import vazkii.botania.common.lib.LibMisc; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) -public final class SheddingHandler { - - private SheddingHandler() {} - - private static final List patterns = new ArrayList<>(); - private static final List defaultPatterns = new ArrayList<>(); - - @SubscribeEvent - public static void onLivingUpdate(LivingUpdateEvent event) { - if(event.getEntityLiving().world.isRemote) - return; - - ShedPattern pattern = getShedPattern(event.getEntityLiving()); - - if(pattern != null) { - if(event.getEntityLiving().world.rand.nextInt(pattern.getRate()) == 0) - event.getEntityLiving().entityDropItem(pattern.getItemStack(), 0.0F); - } - } - - private static ShedPattern getShedPattern(Entity entity) { - for(ShedPattern pattern : patterns) - if(pattern.type.getEntityClass().isInstance(entity)) - return pattern; - - return null; - } - - public static boolean hasShedding() { - return patterns.size() > 0; - } - - public static void addToLexicon() { - if(!hasShedding()) - return; - - int i = 1; - for(ShedPattern pattern : patterns) { - PageShedding page = new PageShedding(String.valueOf(i), pattern.getEntityString(), pattern.lexiconSize, pattern.getItemStack()); - LexiconData.shedding.addPage(page); - } - } - - public static void loadFromConfig(Configuration config) { - // defaultPatterns.add(new ShedPattern(EntityChicken.class, new ItemStack(Items.FEATHER), 26000, 20)); - // defaultPatterns.add(new ShedPattern(EntitySquid.class, new ItemStack(Items.DYE), 18000, 20)); - // defaultPatterns.add(new ShedPattern(EntityVillager.class, new ItemStack(Items.EMERALD), 226000, 40)); - // defaultPatterns.add(new ShedPattern(EntitySpider.class, new ItemStack(Items.STRING), 12000, 40)); - // defaultPatterns.add(new ShedPattern(EntityBlaze.class, new ItemStack(Items.BLAZE_POWDER), 8000, 40)); - // defaultPatterns.add(new ShedPattern(EntityGhast.class, new ItemStack(Items.GHAST_TEAR), 9001, 30)); - // defaultPatterns.add(new ShedPattern(EntitySkeleton.class, new ItemStack(Items.BONE), 36000, 40)); - // defaultPatterns.add(new ShedPattern(EntitySlime.class, new ItemStack(Items.SLIME_BALL), 21000, 40)); - - ArrayList defaultNames = new ArrayList<>(); - - for(ShedPattern pattern : defaultPatterns) { - loadFromConfig(config, pattern.getEntityString(), pattern); - defaultNames.add(pattern.getEntityString()); - } - - for(Entry> entry : ForgeRegistries.ENTITIES.getEntries()) { - if(EntityLiving.class.isAssignableFrom(entry.getValue().getEntityClass())) { - String name = entry.getKey().toString(); - if(!defaultNames.contains(name)) - loadFromConfig(config, name, null); - } - } - } - - private static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) { - String itemName = ""; - int rate = -1; - int lexiconSize = 40; - - if(defaultPattern != null) { - itemName = defaultPattern.getItemStack().getItem().getRegistryName().toString(); - rate = defaultPattern.rate; - lexiconSize = defaultPattern.lexiconSize; - } - - Property prop = config.get("Shedding", key + ".item", itemName); - prop.setComment("Configuration of Shedding for "+key); - itemName = prop.getString(); - rate = config.get("Shedding", key + ".rate", rate).getInt(); - lexiconSize = config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt(); - - if(itemName != null && Item.REGISTRY.getObject(new ResourceLocation(itemName)) != null && rate != -1) - patterns.add(new ShedPattern(EntityList.getClass(new ResourceLocation(key)), new ItemStack(Item.REGISTRY.getObject(new ResourceLocation(itemName))), rate, lexiconSize)); - } - - private static class ShedPattern { - - private final EntityType type; - private final ItemStack itemStack; - private final int rate; - private final int lexiconSize; - - public ShedPattern(EntityType type, ItemStack itemStack, int rate, int lexiconSize) { - this.type = type; - this.itemStack = itemStack; - this.rate = rate; - this.lexiconSize = lexiconSize; - } - public ItemStack getItemStack() { - return itemStack.copy(); - } - - public int getRate() { - return rate; - } - - public String getEntityString() { - return type.getRegistryName().toString(); - } - } - -} diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 8c46e64f2..bbef25eff 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -26,7 +26,6 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModMultiblocks; import vazkii.botania.common.brew.ModBrews; import vazkii.botania.common.core.handler.ConfigHandler; -import vazkii.botania.common.core.handler.SheddingHandler; import vazkii.botania.common.crafting.ModBrewRecipes; import vazkii.botania.common.crafting.ModCraftingRecipes; import vazkii.botania.common.crafting.ModElvenTradeRecipes; @@ -280,7 +279,6 @@ public final class LexiconData { public static LexiconEntry decorativeBlocks; public static LexiconEntry dispenserTweaks; public static LexiconEntry shinyFlowers; - public static LexiconEntry shedding; public static LexiconEntry tinyPotato; public static LexiconEntry headCreating; public static LexiconEntry azulejo; @@ -1406,12 +1404,6 @@ public final class LexiconData { } public static void postInit() { - if (SheddingHandler.hasShedding()) { - shedding = new BasicLexiconEntry(LibLexicon.MISC_SHEDDING, BotaniaAPI.categoryMisc); - shedding.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Items.FEATHER)); - SheddingHandler.addToLexicon(); - } - if (Botania.thaumcraftLoaded) { tcIntegration = new CompatLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft"); diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java b/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java deleted file mode 100644 index 483fd1f66..000000000 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] - */ -package vazkii.botania.common.lexicon.page; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityType; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.GL11; -import vazkii.botania.api.internal.IGuiLexiconEntry; -import vazkii.botania.api.lexicon.LexiconRecipeMappings; -import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; -import vazkii.botania.client.gui.lexicon.GuiLexiconEntry; -import vazkii.botania.client.lib.LibResources; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class PageShedding extends PageEntity { - - private static final ResourceLocation sheddingOverlay = new ResourceLocation(LibResources.GUI_SHEDDING_OVERLAY); - - private final ItemStack shedStack; - private ItemStack tooltipStack; - private boolean tooltipEntry; - - private static boolean mouseDownLastTick = false; - - public PageShedding(String unlocalizedName, EntityType type, int size, ItemStack shedStack) { - super(unlocalizedName, type, size); - this.shedStack = shedStack; - } - - @Override - @OnlyIn(Dist.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - prepDummy(); - relativeMouseX = mx; - relativeMouseY = my; - int stack_x = gui.getLeft() + gui.getWidth() / 2 - 8; - int stack_y = gui.getTop() + gui.getHeight() - 40 - 18 - 5; - int entity_scale = getEntityScale(size); - int entity_x = gui.getLeft() + gui.getWidth() / 2; - int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor(dummyEntity.height * entity_scale / 2) - 29; - - renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); - - renderItem(gui, stack_x, stack_y, shedStack); - - TextureManager render = Minecraft.getInstance().textureManager; - render.bindTexture(sheddingOverlay); - - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.color4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - - if(!tooltipStack.isEmpty()) { - List tooltipData = tooltipStack.getTooltip(Minecraft.getInstance().player, ITooltipFlag.TooltipFlags.NORMAL); - List parsedTooltip = new ArrayList<>(); - boolean first = true; - - for(ITextComponent s : tooltipData) { - String s_ = s.getFormattedText(); - if(!first) - s_ = TextFormatting.GRAY + s.getFormattedText(); - parsedTooltip.add(s_); - first = false; - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - - int tooltipY = 8 + tooltipData.size() * 11; - - if(tooltipEntry) { - vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange(mx, my + tooltipY, Collections.singletonList(TextFormatting.GRAY + I18n.format("botaniamisc.clickToRecipe"))); - } - } - else if(tooltipEntity) { - List parsedTooltip = new ArrayList<>(); - parsedTooltip.add(I18n.format(dummyEntity.getType().getTranslationKey())); - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - } - - tooltipStack = null; - tooltipEntry = tooltipEntity = false; - GlStateManager.disableBlend(); - mouseDownLastTick = GLFW.glfwGetMouseButton(Minecraft.getInstance().mainWindow.getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS; - } - - @OnlyIn(Dist.CLIENT) - public void renderItem(IGuiLexiconEntry gui, int xPos, int yPos, ItemStack stack) { - ItemRenderer render = Minecraft.getInstance().getItemRenderer(); - boolean mouseDown = GLFW.glfwGetMouseButton(Minecraft.getInstance().mainWindow.getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS; - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableDepthTest(); - render.renderItemAndEffectIntoGUI(stack, xPos, yPos); - render.renderItemOverlays(Minecraft.getInstance().fontRenderer, stack, xPos, yPos); - RenderHelper.disableStandardItemLighting(); - GlStateManager.popMatrix(); - - if(relativeMouseX >= xPos && relativeMouseY >= yPos && relativeMouseX <= xPos + 16 && relativeMouseY <= yPos + 16) { - tooltipStack = stack; - - EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); - if(data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn())) { - tooltipEntry = true; - - if(!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { - GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); - newGui.page = data.page; - Minecraft.getInstance().displayGuiScreen(newGui); - } - } - } - - GlStateManager.disableLighting(); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList<>(); - list.add(shedStack); - return list; - } - -}