Yeet all the lexicon and multiblock code (this temporarily kills the sextant, which will be reimplemented on top of the patchouli multiblocks

This commit is contained in:
Vincent Lee committed 2019-10-30 23:54:03 -05:00
1 parent 8bdf758bab
commit d00349cbc7
223 files changed
+193 -10164

No files matched your search

@@ -38,9 +38,6 @@ import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.internal.DummyMethodHandler;
import vazkii.botania.api.internal.IInternalMethodHandler;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.lexicon.KnowledgeType;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.recipe.RecipeBrew;
import vazkii.botania.api.recipe.RecipeElvenTrade;
import vazkii.botania.api.recipe.RecipeManaInfusion;
@@ -63,11 +60,6 @@ public final class BotaniaAPI {
@CapabilityInject(IFloatingFlower.class)
public static Capability<IFloatingFlower> FLOATING_FLOWER_CAP;
private static final List<LexiconCategory> categories = new ArrayList<>();
private static final List<LexiconEntry> allEntries = new ArrayList<>();
public static final Map<String, KnowledgeType> knowledgeTypes = new HashMap<>();
public static final Map<String, Brew> brewMap = new LinkedHashMap<>();
/*
@@ -342,32 +334,8 @@ public final class BotaniaAPI {
public static final Rarity rarityRelic = Rarity.create("RELIC", TextFormatting.GOLD);
public static final KnowledgeType basicKnowledge;
public static final KnowledgeType elvenKnowledge;
// This is here for completeness sake, but you shouldn't use it
public static final KnowledgeType relicKnowledge;
// All of these categories are initialized during botania's PreInit stage.
public static LexiconCategory categoryBasics;
public static LexiconCategory categoryMana;
public static LexiconCategory categoryFunctionalFlowers;
public static LexiconCategory categoryGenerationFlowers;
public static LexiconCategory categoryDevices;
public static LexiconCategory categoryTools;
public static LexiconCategory categoryBaubles;
public static LexiconCategory categoryEnder;
public static LexiconCategory categoryAlfhomancy;
public static LexiconCategory categoryMisc;
public static final Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0);
static {
basicKnowledge = registerKnowledgeType("minecraft", TextFormatting.RESET, true);
elvenKnowledge = registerKnowledgeType("alfheim", TextFormatting.DARK_GREEN, false);
relicKnowledge = registerKnowledgeType("relic", TextFormatting.DARK_PURPLE, false);
}
/**
* The internal method handler in use.
* <b>DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API.</b>
@@ -376,17 +344,6 @@ public final class BotaniaAPI {
*/
public static volatile IInternalMethodHandler internalHandler = new DummyMethodHandler();
/**
* Registers a new Knowledge Type.
* @param id The ID for this knowledge type.
* @param color The color to display this knowledge type as.
*/
public static KnowledgeType registerKnowledgeType(String id, TextFormatting color, boolean autoUnlock) {
KnowledgeType type = new KnowledgeType(id, color, autoUnlock);
knowledgeTypes.put(id, type);
return type;
}
/**
* Registers a Brew and returns it.
*/
@@ -405,35 +362,6 @@ public final class BotaniaAPI {
return fallbackBrew;
}
/**
* Adds a category to the list of registered categories to appear in the Lexicon.
*/
public static void addCategory(LexiconCategory category) {
categories.add(category);
}
/**
* Gets all registered categories.
*/
public static List<LexiconCategory> getAllCategories() {
return categories;
}
/**
* Gets all registered entries.
*/
public static List<LexiconEntry> getAllEntries() {
return allEntries;
}
/**
* Registers a Lexicon Entry and adds it to the category passed in.
*/
public static void addEntry(LexiconEntry entry, LexiconCategory category) {
allEntries.add(entry);
category.entries.add(entry);
}
public static int getOreWeight(ResourceLocation tag) {
return oreWeights.get(tag);
}
@@ -23,68 +23,12 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.corporea.InvWithLocation;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
import java.util.List;
public class DummyMethodHandler implements IInternalMethodHandler {
@Override
public LexiconPage textPage(String key) {
return dummyPage(key);
}
@Override
public LexiconPage elfPaperTextPage(String key) {
return dummyPage(key);
}
@Override
public LexiconPage imagePage(String key, String resource) {
return dummyPage(key);
}
@Override
public LexiconPage craftingRecipePage(String key, Item... outputItems) {
return dummyPage(key);
}
@Override
public LexiconPage petalRecipePage(String key, Item... outputItems) {
return dummyPage(key);
}
@Override
public LexiconPage runeRecipePage(String key, Item... outputItems) {
return dummyPage(key);
}
@Override
public LexiconPage manaInfusionRecipePage(String key, Item... outputItems) {
return dummyPage(key);
}
@Override
public LexiconPage elvenTradePage(String key, Item... outputItems) {
return dummyPage(key);
}
@Override
public LexiconPage brewPage(String key, String bottomText, Brew outputBrew) {
return dummyPage(key);
}
@Override
public LexiconPage multiblockPage(String key, MultiblockSet mb) {
return dummyPage(key);
}
private LexiconPage dummyPage(String key) {
return new DummyPage(key);
}
@Override
public IManaNetwork getManaNetworkInstance() {
return DummyManaNetwork.instance;
@@ -1,32 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:41:23 PM (GMT)]
*/
package vazkii.botania.api.internal;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.LexiconPage;
/**
* A dummy page. It does absolutely nothing and is only
* existant to make sure everything goes right even if
* Botania isn't loaded.
*/
public class DummyPage extends LexiconPage {
public DummyPage(String unlocalizedName) {
super(unlocalizedName);
}
@Override
@OnlyIn(Dist.CLIENT)
public void renderScreen(IGuiLexiconEntry gui, int x, int y) {}
}
@@ -1,83 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:48:41 PM (GMT)]
*/
package vazkii.botania.api.internal;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.widget.button.Button;
import vazkii.botania.api.lexicon.LexiconEntry;
import java.util.List;
/**
* Internal interface for the Lexicon Entry GUI. This contains
* everything that can be accessed from it. It's safe to cast
* this type to GuiScreen.
*/
public interface IGuiLexiconEntry {
/**
* Gets the entry currently portrayed in this gui.
*/
public LexiconEntry getEntry();
/**
* Gets the current page the lexicon GUI is browsing.
*/
public int getPageOn();
/**
* Gets the leftmost part of the GUI.
*/
public int getLeft();
/**
* Gets the topmost part of the GUI.
*/
public int getTop();
/**
* Gets the GUI's width.
*/
public int getWidth();
/**
* Gets the GUI's height
*/
public int getHeight();
/**
* Gets the GUI's Z level for rendering.
*/
public float getZLevel();
/**
* Gets the list of buttons in this gui.
*/
public List<Widget> getButtonList();
/**
* Gets the total amount of ticks (+ partial ticks) the player
* has been in this gui.
*/
public float getElapsedTicks();
/**
* Gets the current partial ticks.
*/
public float getPartialTicks();
/**
* Gets the delta (1F = 1 tick) between this render call
* and the last one.
*/
public float getTickDelta();
}
@@ -25,8 +25,6 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.corporea.InvWithLocation;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
import java.util.List;
@@ -40,26 +38,6 @@ import java.util.List;
*/
public interface IInternalMethodHandler {
public LexiconPage textPage(String key);
public LexiconPage elfPaperTextPage(String key);
public LexiconPage imagePage(String key, String resource);
public LexiconPage craftingRecipePage(String key, Item... outputItems);
public LexiconPage petalRecipePage(String key, Item... outputItems);
public LexiconPage runeRecipePage(String key, Item... outputItems);
public LexiconPage manaInfusionRecipePage(String key, Item... outputItems);
public LexiconPage elvenTradePage(String key, Item... outputItems);
public LexiconPage brewPage(String key, String bottomText, Brew outputBrew);
public LexiconPage multiblockPage(String key, MultiblockSet mb);
public IManaNetwork getManaNetworkInstance();
public boolean shouldForceCheck();
@@ -1,29 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [04/12/2015, 18:29:56 (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraftforge.eventbus.api.Event;
import java.util.Queue;
/**
* Fired when the Lexica Botania's tutorial is started. You can add your
* own entries to the tutorial here. Please use this responsibly.
*/
public class BotaniaTutorialStartEvent extends Event {
public final Queue<LexiconEntry> tutorial;
public BotaniaTutorialStartEvent(Queue<LexiconEntry> tutorial) {
this.tutorial = tutorial;
}
}
@@ -1,28 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 8, 2014, 7:02:48 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
/**
* Have a LexiconEntry implement this to signify it's an "Addon entry", as
* in, one provided by an Addon. This allows it to draw a subtitle of
* sorts, to prevent the [Mod tag here] nonsense that happened with thaumcraft
* addons. It can also be used for other purposes, such as stating an
* entry is WIP.
*/
public interface IAddonEntry {
/**
* Returns the <b>unlocalized</b> subtitle to show below the title. Here you'd
* return something like "(This Entry is provided by the Botanic Tinkerer addon)".
*/
public String getSubtitle();
}
@@ -1,21 +0,0 @@
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
/**
* Basic interface for the Lexica Botania.
*/
public interface ILexicon {
/**
* Gets if a specific knowledge is unlocked. Check the knowledge types in
* BotaniaAPI.
*/
public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge);
/**
* Unlocks a specfic type of knowledge.
*/
public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge);
}
@@ -1,31 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 20, 2014, 7:05:44 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* Any block that implements this can be right clicked with
* a Lexica Botania to open a entry page.
*/
@FunctionalInterface
public interface ILexiconable {
/**
* Gets the lexicon entry to open at this location. null works too.
*/
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon);
}
@@ -1,23 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 20, 2014, 6:08:48 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
/**
* Have an Item implement this so that the method used for mapping it into
* the lexicon recipe mappings isn't the typical id:meta key.
*/
public interface IRecipeKeyProvider {
public String getKey(ItemStack stack);
}
@@ -1,23 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Nov 3, 2014, 2:59:55 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
/**
* A LexiconPage that implements this has two unlocalized names
* rather than one. (See brew pages)
*/
public interface ITwoNamedPage {
public void setSecondUnlocalizedName(String name);
public String getSecondUnlocalizedName();
}
@@ -1,20 +0,0 @@
package vazkii.botania.api.lexicon;
import net.minecraft.util.text.TextFormatting;
public class KnowledgeType {
public final String id;
public final TextFormatting color;
public final boolean autoUnlock;
public KnowledgeType(String id, TextFormatting color, boolean autoUnlock) {
this.id = id;
this.color = color;
this.autoUnlock = autoUnlock;
}
public String getUnlocalizedName() {
return "botania.knowledge." + id;
}
}
@@ -1,88 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:23:47 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class LexiconCategory implements Comparable<LexiconCategory> {
private static int count = 0;
public final String unlocalizedName;
public final List<LexiconEntry> entries = new ArrayList<>();
private final int sortingId;
private ResourceLocation icon;
private int priority = 5;
/**
* @param unlocalizedName The unlocalized name of this category. This will be localized by the client display.
*/
public LexiconCategory(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
sortingId = count;
count++;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
/**
* Sets the priority for this category for sorting. Higher numbers
* means they'll appear first in the book. The basics category
* is 9, the miscellaneous category is 0, other vanilla botania categories
* are 5. Using 9 and 0 is <b>not</b> recommended, since having your
* categories before basics or after miscellaneous is a bad idea.
* If two categories have the same priority they'll be sorted
* by insertion order.
*/
public LexiconCategory setPriority(int priority) {
this.priority = priority;
return this;
}
public int getSortingPriority() {
return priority;
}
public final int getSortingId() {
return sortingId;
}
public LexiconCategory setIcon(ResourceLocation icon) {
this.icon = icon;
return this;
}
public ResourceLocation getIcon() {
return icon;
}
@Override
public int compareTo(@Nonnull LexiconCategory category) {
return priority == category.priority ? sortingId - category.sortingId : category.priority - priority;
}
/**
* Determines if the category shows up in the lexicon category index.
* Contained entries will still appear in the lexicon index
* and must be hidden separately if desired.
* @param stack The lexicon stack used by the player
*/
public boolean isVisible(ItemStack stack) {
return true;
}
}
@@ -1,377 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:17:06 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.IModRecipe;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lexicon.AlfheimLexiconEntry;
import vazkii.botania.common.lexicon.CompatLexiconEntry;
import vazkii.botania.common.lexicon.RelicLexiconEntry;
import vazkii.botania.common.lexicon.WelcomeLexiconEntry;
import vazkii.botania.common.lexicon.page.PageBrew;
import vazkii.botania.common.lexicon.page.PageCraftingRecipe;
import vazkii.botania.common.lexicon.page.PageElvenRecipe;
import vazkii.botania.common.lexicon.page.PageImage;
import vazkii.botania.common.lexicon.page.PageLoreText;
import vazkii.botania.common.lexicon.page.PageManaInfusionRecipe;
import vazkii.botania.common.lexicon.page.PageModRecipe;
import vazkii.botania.common.lexicon.page.PageMultiblock;
import vazkii.botania.common.lexicon.page.PagePetalRecipe;
import vazkii.botania.common.lexicon.page.PageTerrasteel;
import vazkii.botania.common.lexicon.page.PageText;
import vazkii.botania.common.lib.LibLexicon;
import vazkii.botania.common.lib.ModTags;
import javax.annotation.Nonnull;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
public class LexiconEntry implements Comparable<LexiconEntry> {
public final String unlocalizedName;
public final LexiconCategory category;
private KnowledgeType type = BotaniaAPI.basicKnowledge;
public final List<LexiconPage> pages = new ArrayList<>();
private boolean priority = false;
private ItemStack icon = ItemStack.EMPTY;
private final List<ItemStack> extraDisplayedRecipes = new ArrayList<>();
/**
* @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display.
*/
public LexiconEntry(String unlocalizedName, LexiconCategory category) {
this.unlocalizedName = unlocalizedName;
this.category = category;
}
/**
* Sets this page as prioritized, as in, will appear before others in the lexicon.
*/
public LexiconEntry setPriority() {
priority = true;
return this;
}
/**
* Sets the Knowledge type of this entry.
*/
public LexiconEntry setKnowledgeType(KnowledgeType type) {
this.type = type;
return this;
}
public KnowledgeType getKnowledgeType() {
return type;
}
/**
* Sets the display icon for this entry. Overriding the one already there. When adding recipe pages to the
* entry, this will be called once for the result of the first found recipe.
*/
public void setIcon(ItemStack stack) {
icon = stack;
}
public ItemStack getIcon() {
return icon;
}
public boolean isPriority() {
return priority;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
public String getTagline() {
return ""; // Override this if you want a tagline. You probably do
}
@OnlyIn(Dist.CLIENT)
public boolean isVisible() {
return true;
}
private static Map<String, String> multiblocks = ImmutableMap.<String, String>builder()
.put("botania.page.terrasteel4", "botania:terra_plate")
.put("botania.page.manaEnchanting2", "botania:enchanter")
.put("botania.page.aIntro4", "botania:alfheim_portal")
.put("botania.page.gaiaRitual2", "botania:gaia_ritual").build();
// Basic mapping of input -> advancement, requires manually checking first
private static Map<Predicate<Item>, ResourceLocation> inputsToAdvancements = ImmutableMap.<Predicate<Item>, ResourceLocation>builder()
.put(or(ModTags.Items.INGOTS_TERRASTEEL::contains, ModTags.Items.NUGGETS_TERRASTEEL::contains),
prefix("main/terrasteel_pickup"))
.put(ModTags.Items.RUNES::contains, prefix("main/runic_altar_pickup"))
.put(oneOf(ModItems.manaDiamond, ModItems.manaPearl, ModItems.manaSteel, ModItems.manaPowder, ModItems.manaString),
prefix("main/mana_pool_pickup"))
.put(or(ModTags.Items.LIVINGWOOD::contains, ModTags.Items.LIVINGWOOD::contains), prefix("main/pure_daisy_pickup"))
.put(ModTags.Items.PETALS::contains, prefix("main/flower_pickup"))
.build();
private static <T> Predicate<T> or(Predicate<T> first, Predicate<T> second) {
return first.or(second);
}
private static Predicate<Item> oneOf(Item... items) {
return item -> {
for(Item i : items)
if(i == item) return true;
return false;
};
}
public void dump() {
File dir = Paths.get(".", "entries", fixCamelCase(category.getUnlocalizedName().substring(LibLexicon.CATEGORY_PREFIX.length()))).toFile();
if(!dir.exists())
dir.mkdirs();
File f = new File(dir, fixCamelCase(this.unlocalizedName) + ".json");
if (f.exists())
throw new RuntimeException("preexisting file " + f.getAbsolutePath());
Gson gson = new GsonBuilder().setPrettyPrinting().create();
try (OutputStreamWriter os = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(f)))) {
Map<String, Object> entry = new LinkedHashMap<>();
entry.put("name", this.getUnlocalizedName());
entry.put("category", fixCamelCase(category.getUnlocalizedName().substring("botania.category.".length())));
entry.put("icon", getIcon().getItem().getRegistryName().toString());
if(this.getKnowledgeType().color != TextFormatting.RESET) {
entry.put("entry_color", Integer.toString(this.getKnowledgeType().color.getColor(), 16));
}
if (isPriority()) {
entry.put("priority", true);
}
if (this instanceof WelcomeLexiconEntry)
entry.put("sortnum", -10);
if (this instanceof RelicLexiconEntry) {
ResourceLocation advancement = ((RelicLexiconEntry) this).advancement;
if(advancement != null)
entry.put("advancement", advancement.toString());
} else if(this instanceof AlfheimLexiconEntry) {
entry.put("advancement", "botania:main/elf_lexicon_pickup");
} else if(this instanceof CompatLexiconEntry) {
entry.put("flag", "|debug,mod:" + ((CompatLexiconEntry) this).mod.toLowerCase(Locale.ROOT));
}
if(!entry.containsKey("advancement")) {
for(Map.Entry<Predicate<Item>, ResourceLocation> thing : inputsToAdvancements.entrySet()) {
if(pages.stream().flatMap(this::getRecipeInputs).map(ItemStack::getItem).anyMatch(thing.getKey())) {
entry.put("advancement", thing.getValue().toString());
break;
}
}
}
List<Object> pages = new ArrayList<>();
for (int i = 0; i < this.pages.size(); i++) {
LexiconPage page = this.pages.get(i);
Map<String, Object> json = new LinkedHashMap<>();
String unlocalizedName = page.getUnlocalizedName();
if (page instanceof PageLoreText) {
json.put("type", "lore_page");
json.put("text", unlocalizedName);
json.put(i % 2 == 0 ? "left_side" : "right_side", "true");
} else if (page instanceof PageText) {
json.put("type", "text");
json.put("text", unlocalizedName);
} else if (page instanceof PageImage) {
json.put("type", "image");
json.put("text", unlocalizedName);
json.put("images", Collections.singletonList(((PageImage) page).resource.toString()));
} else if (page instanceof PageCraftingRecipe) {
List<IRecipe<?>> recipes = ((PageCraftingRecipe) page).getRecipes();
json.put("type", recipes.size() <= 2 ? "crafting" : "crafting_multi");
json.put("text", unlocalizedName);
if (recipes.size() <= 2) {
json.put("recipe", recipes.get(0).getId().toString());
if(recipes.size() == 2)
json.put("recipe2", recipes.get(1).getId().toString());
} else
json.put("recipes", recipes.stream().map(r -> r.getId().toString()).collect(Collectors.joining(";")));
} else if (page instanceof PageManaInfusionRecipe) {
json.put("type", "mana_infusion");
json.put("text", unlocalizedName);
json.put("recipes", ((PageManaInfusionRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.joining(";")));
} else if (page instanceof PageModRecipe) {
json.put("type", page instanceof PagePetalRecipe ? "petal_apothecary" : "runic_altar");
json.put("text", unlocalizedName);
List<String> strings = ((PageModRecipe<? extends IModRecipe>) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.toList());
if(strings.size() == 1) {
json.put("recipe", strings.get(0));
} else {
json.put("recipes", strings);
}
} else if (page instanceof PageElvenRecipe) {
json.put("type", "elven_trade");
json.put("text", unlocalizedName);
json.put("recipes", ((PageElvenRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.joining(";")));
} else if (page instanceof PageBrew) {
json.put("type", "brew");
json.put("text", ((PageBrew) page).text);
json.put("flavor", unlocalizedName);
json.put("recipe", ((PageBrew) page).recipe.getId().toString());
} else if (page instanceof PageMultiblock) {
json.put("type", "multiblock");
json.put("multiblock_id", multiblocks.get(unlocalizedName));
json.put("text", unlocalizedName);
if (unlocalizedName.contains("terrasteel") || unlocalizedName.contains("aIntro")) {
json.put("symmetrical", true);
}
} else if(page instanceof PageTerrasteel) {
json.put("type", "terrasteel");
json.put("text", unlocalizedName);
} else {
json.put("type", "_unknown_" + page.getClass().getSimpleName().toLowerCase(Locale.ROOT));
json.put("text", unlocalizedName);
}
pages.add(json);
}
entry.put("pages", pages);
os.write(gson.toJson(entry));
} catch (IOException e) {
e.printStackTrace();
}
}
public Stream<ItemStack> getRecipeInputs(LexiconPage page) {
Stream<Ingredient> stream;
if(page instanceof PageModRecipe) {
stream = ((PageModRecipe<? extends IModRecipe>) page).getRecipes().stream().flatMap(o -> o.getInputs().stream());
} else if(page instanceof PageCraftingRecipe) {
stream = ((PageCraftingRecipe) page).getRecipes().stream().flatMap(o -> o.getIngredients().stream());
} else if(page instanceof PageManaInfusionRecipe) {
stream = ((PageManaInfusionRecipe) page).getRecipes().stream().map(RecipeManaInfusion::getInput);
} else if(page instanceof PageElvenRecipe) {
stream = ((PageElvenRecipe) page).getRecipes().stream().flatMap(o -> o.getInputs().stream());
} else if(page instanceof PageBrew) {
stream = ((PageBrew) page).recipe.getInputs().stream();
} else {
stream = Stream.empty();
}
return stream.flatMap(ingr -> Stream.of(ingr.getMatchingStacks()));
}
private static String fixCamelCase(String s) {
if(LibLexicon.CATEGORY_FUNCTIONAL_FLOWERS.equals(s)) {
return "functional_flowers";
} else if(LibLexicon.CATEGORY_GENERATION_FLOWERS.equals(s)) {
return "generating_flowers";
} else if(s.length() == 6 && s.endsWith("Intro")) {
return "intro";
}
return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, s);
}
/**
* Sets what pages you want this entry to have.
*/
public LexiconEntry setLexiconPages(LexiconPage... pages) {
this.pages.addAll(Arrays.asList(pages));
for(int i = 0; i < this.pages.size(); i++) {
LexiconPage page = this.pages.get(i);
if(!page.skipRegistry)
page.onPageAdded(this, i);
}
return this;
}
/**
* Returns the web link for this entry. If this isn't null, looking at this entry will
* show a "View Online" button in the book. The String returned should be the URL to
* open when the button is clicked.
*/
public String getWebLink() {
return null;
}
/**
* Adds a page to the list of pages.
*/
public void addPage(LexiconPage page) {
pages.add(page);
}
public final String getNameForSorting() {
// todo used to be localized
return (priority ? 0 : 1) + getUnlocalizedName();
}
public List<ItemStack> getDisplayedRecipes() {
ArrayList<ItemStack> list = new ArrayList<>();
for(LexiconPage page : pages) {
ArrayList<ItemStack> itemsAddedThisPage = new ArrayList<>();
for(ItemStack s : page.getDisplayedRecipes()) {
addItem: {
for(ItemStack s1 : itemsAddedThisPage)
if(s1.getItem() == s.getItem())
break addItem;
for(ItemStack s1 : list)
if(s1.isItemEqual(s) && ItemStack.areItemStackTagsEqual(s1, s))
break addItem;
itemsAddedThisPage.add(s);
list.add(s);
}
}
}
list.addAll(extraDisplayedRecipes);
return list;
}
public void addExtraDisplayedRecipe(ItemStack stack) {
extraDisplayedRecipes.add(stack);
}
@Override
public int compareTo(@Nonnull LexiconEntry o) {
return getNameForSorting().compareTo(o.getNameForSorting());
}
}
@@ -1,98 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:17:24 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.internal.IGuiLexiconEntry;
import java.util.List;
public abstract class LexiconPage {
public String unlocalizedName;
public boolean skipRegistry;
public LexiconPage(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
/**
* Does the rendering for this page.
* @param gui The active GuiScreen
* @param mx The mouse's relative X position.
* @param my The mouse's relative Y position.
*/
@OnlyIn(Dist.CLIENT)
public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my);
/**
* Called per update tick. Non gui-sensitive version, kept for backwards compatibility only.
*/
@OnlyIn(Dist.CLIENT)
public void updateScreen() {}
/**
* Called per update tick. Feel free to override fully, the
* call to updateScreen() is for backwards compatibility.
*/
@OnlyIn(Dist.CLIENT)
public void updateScreen(IGuiLexiconEntry gui) {
updateScreen();
}
/**
* Called when this page is opened, be it via initGui() or when the player changes page.
* You can add buttons and whatever you'd do on initGui() here.
*/
@OnlyIn(Dist.CLIENT)
public void onOpened(IGuiLexiconEntry gui) {}
/**
* Called when this page is opened, be it via closing the gui or when the player changes page.
* Make sure to dispose of anything you don't use any more, such as buttons in the gui's buttonList.
*/
@OnlyIn(Dist.CLIENT)
public void onClosed(IGuiLexiconEntry gui) {}
/**
* Called when a key is pressed.
*/
@OnlyIn(Dist.CLIENT)
public boolean keyPressed(int keyCode, int scanCode, int mods) {
return false;
}
/**
* Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called.
*/
public void onPageAdded(LexiconEntry entry, int index) {}
/**
* Shows the list of recipes present in this page for display in the category
* page.
*/
public List<ItemStack> getDisplayedRecipes() {
return ImmutableList.of();
}
public String getUnlocalizedName() {
return unlocalizedName;
}
public LexiconPage setSkipRegistry() {
skipRegistry = true;
return this;
}
}
@@ -1,80 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 6, 2014, 3:54:12 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
import java.util.HashMap;
import java.util.Map;
/**
* This class contains mappings for which entry and page correspond to each
* craftable ItemStack. Use the map method to map an ItemStack to a page in
* an entry in the lexicon.
*/
public final class LexiconRecipeMappings {
private static final Map<String, EntryData> mappings = new HashMap<>();
/**
* Maps the given stack to the given page of the entry.
*/
public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) {
if(stack.isEmpty())
return;
EntryData data = new EntryData(entry, page);
String str = stackToString(stack);
if(force || !mappings.containsKey(str))
mappings.put(str, data);
if(entry.getIcon().isEmpty())
entry.setIcon(stack.copy());
}
public static void map(ItemStack stack, LexiconEntry entry, int page) {
map(stack, entry, page, false);
}
public static void remove(ItemStack stack) {
mappings.remove(stackToString(stack));
}
public static EntryData getDataForStack(ItemStack stack) {
return mappings.get(stackToString(stack));
}
private static String stackToString(ItemStack stack) {
if(stack.isEmpty())
return "NULL";
if(stack.hasTag() && stack.getItem() instanceof IRecipeKeyProvider)
return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);
return stack.getTranslationKey();
}
public static void clear() {
mappings.clear();
}
public static class EntryData {
public final LexiconEntry entry;
public final int page;
EntryData(LexiconEntry entry, int page) {
this.entry = entry;
this.page = page;
}
}
}
@@ -1,33 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 7:48:47 PM (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockState;
import net.minecraft.world.IBlockReader;
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
import java.util.HashMap;
import java.util.Map;
/**
* A hook for rendering blocks in the multiblock display.
*/
public interface IMultiblockRenderHook {
public static Map<Block, IMultiblockRenderHook> renderHooks = new HashMap<>();
public void renderBlockForMultiblock(IBlockReader world, Multiblock mb, BlockState state, MultiblockComponent comp);
public boolean needsTranslate(BlockState state);
}
@@ -1,193 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 2:37:22 PM (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* This class describes a Mutiblock object. It's used to display a
* multiblock in the lexicon and to show the player in a ghost-like
* look in the world.
*/
public class Multiblock {
public final List<MultiblockComponent> components = new ArrayList<>();
public final List<ItemStack> materials = new ArrayList<>();
public BlockPos minPos = BlockPos.ZERO;
public BlockPos maxPos = BlockPos.ZERO;
public BlockPos offPos = BlockPos.ZERO;
public final HashMap<BlockPos, MultiblockComponent> locationCache = new HashMap<>();
/**
* Adds a multiblock component to this multiblock. The component's x y z
* coords should be pivoted to the center of the structure.
*/
public void addComponent(MultiblockComponent component) {
if(getComponentForLocation(component.getRelativePosition()) != null)
throw new IllegalArgumentException("Location in multiblock already occupied");
components.add(component);
changeAxisForNewComponent(component.getRelativePosition());
calculateCostForNewComponent(component);
addComponentToLocationCache(component);
}
/**
* Constructs and adds a multiblock component to this multiblock. The x y z
* coords should be pivoted to the center of the structure.
*/
public void addComponent(BlockPos pos, BlockState state) {
addComponent(new MultiblockComponent(pos, state));
}
private void changeAxisForNewComponent(BlockPos pos) {
if(pos.getX() < minPos.getX())
minPos = new BlockPos(pos.getX(), minPos.getY(), minPos.getZ());
else if(pos.getX() > maxPos.getX())
maxPos = new BlockPos(pos.getX(), maxPos.getY(), maxPos.getZ());
if(pos.getY() < minPos.getY())
minPos = new BlockPos(minPos.getX(), pos.getY(), minPos.getZ());
else if(pos.getY() > maxPos.getY())
maxPos = new BlockPos(maxPos.getX(), pos.getY(), maxPos.getZ());
if(pos.getZ() < minPos.getZ())
minPos = new BlockPos(minPos.getX(), minPos.getY(), pos.getZ());
else if(pos.getZ() > maxPos.getZ())
maxPos = new BlockPos(maxPos.getX(), maxPos.getY(), pos.getZ());
}
private void calculateCostForNewComponent(MultiblockComponent comp) {
ItemStack[] materials = comp.getMaterials();
if(materials != null)
for(ItemStack stack : materials)
addStack(stack);
}
private void addStack(ItemStack stack) {
if(stack.isEmpty())
return;
for(ItemStack oStack : materials)
if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) {
oStack.grow(stack.getCount());
return;
}
materials.add(stack);
}
public void setRenderOffset(BlockPos pos) {
offPos = pos;
}
public List<MultiblockComponent> getComponents() {
return components;
}
/**
* Rotates this multiblock by the angle passed in. For the best results, use
* only multiples of pi/2.
*/
public void rotate(double angle) {
for(MultiblockComponent comp : getComponents())
comp.rotate(angle);
updateLocationCache();
}
public Multiblock copy() {
Multiblock mb = new Multiblock();
for(MultiblockComponent comp : getComponents())
mb.addComponent(comp.copy());
return mb;
}
/**
* Creates a length 4 array of all the rotations multiple of pi/2 required
* to render this multiblock in the world relevant to the 4 cardinal
* orientations.
*/
public Map<Direction, Multiblock> createRotations() {
Map<Direction, Multiblock> ret = new EnumMap<>(Direction.class);
ret.put(Direction.SOUTH, this);
ret.put(Direction.WEST, ret.get(Direction.SOUTH).copy());
ret.get(Direction.WEST).rotate(Math.PI / 2);
ret.put(Direction.NORTH, ret.get(Direction.WEST).copy());
ret.get(Direction.NORTH).rotate(Math.PI / 2);
ret.put(Direction.EAST, ret.get(Direction.NORTH).copy());
ret.get(Direction.EAST).rotate(Math.PI / 2);
return ret;
}
/**
* Makes a MultiblockSet from this Multiblock and its rotations using
* createRotations().
*/
public MultiblockSet makeSet() {
return new MultiblockSet(this);
}
public int getXSize() {
return Math.abs(minPos.getX()) + Math.abs(maxPos.getX()) + 1;
}
public int getYSize() {
return Math.abs(minPos.getY()) + Math.abs(maxPos.getY()) + 1;
}
public int getZSize() {
return Math.abs(minPos.getZ()) + Math.abs(maxPos.getZ()) + 1;
}
/**
* Rebuilds the location cache
*/
public void updateLocationCache() {
locationCache.clear();
for(MultiblockComponent comp : components)
addComponentToLocationCache(comp);
}
/**
* Adds a single component to the location cache
*/
private void addComponentToLocationCache(MultiblockComponent comp) {
BlockPos pos = comp.getRelativePosition();
locationCache.put(pos, comp);
}
/**
* Gets the component for a given location
* @param pos
*/
public MultiblockComponent getComponentForLocation(BlockPos pos) {
return locationCache.get(pos);
}
}
@@ -1,39 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 7:31:58 PM (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction;
import java.util.Collections;
import java.util.Map;
/**
* A set of Multiblock objects for various rotations.
*/
public class MultiblockSet {
private final Map<Direction, Multiblock> mbs;
public MultiblockSet(Multiblock mb) {
mbs = Collections.unmodifiableMap(mb.createRotations());
}
public Multiblock getForEntity(Entity e) {
return getForFacing(e.getHorizontalFacing());
}
public Multiblock getForFacing(Direction facing) {
return mbs.get(facing);
}
}
@@ -1,32 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [01/11/2015, 19:05:57 (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock.component;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* A multiblock component that matches any non air blocks that have a collision box.
*/
public class AnyComponent extends MultiblockComponent {
public AnyComponent(BlockPos relPos, BlockState state) {
super(relPos, state);
}
@Override
public boolean matches(World world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
return !state.getBlock().isAir(state, world, pos) && !state.getCollisionShape(world, pos).isEmpty();
}
}
@@ -1,41 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 28, 2015, 3:23:15 PM (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock.component;
import net.minecraft.block.Block;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.lib.LibMisc;
/**
* A multiblock component that matches any botania flower.
*/
public class FlowerComponent extends TagComponent {
public FlowerComponent(BlockPos relPos, Block block) {
super(relPos, block, new BlockTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "mystical_flowers")));
}
@Override
public boolean matches(World world, BlockPos pos) {
return BotaniaAPI.internalHandler.isBotaniaFlower(world, pos);
}
@Override
public MultiblockComponent copy() {
return new FlowerComponent(relPos, state.getBlock());
}
}
@@ -1,91 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 2:42:32 PM (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock.component;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* A component of a multiblock, the normal one
* is just a block.
*/
public class MultiblockComponent {
protected BlockPos relPos;
protected final BlockState state;
protected final TileEntity tileEntity;
private final boolean doFancyRender;
public MultiblockComponent(BlockPos relPos, BlockState state) {
this(relPos, state, null);
}
public MultiblockComponent(BlockPos relPos, BlockState state, boolean doFancyRender) {
this(relPos, state, doFancyRender, null);
}
public MultiblockComponent(BlockPos relPos, BlockState state, TileEntity tileEntity) {
this(relPos, state, state.getBlock().hasTileEntity(state) == (tileEntity != null), tileEntity);
}
public MultiblockComponent(BlockPos relPos, BlockState state, boolean doFancyRender, TileEntity tileEntity) {
this.relPos = relPos;
this.state = state;
this.tileEntity = tileEntity;
this.doFancyRender = doFancyRender;
}
public BlockPos getRelativePosition() {
return relPos;
}
public BlockState getBlockState() {
return state;
}
public boolean matches(World world, BlockPos pos) {
return world.getBlockState(pos) == state;
}
public ItemStack[] getMaterials() {
return new ItemStack[] { new ItemStack(state.getBlock()) };
}
public void rotate(double angle) {
double x = relPos.getX();
double z = relPos.getZ();
double sin = Math.sin(angle);
double cos = Math.cos(angle);
double xn = x * cos - z * sin;
double zn = x * sin + z * cos;
relPos = new BlockPos((int) Math.round(xn), relPos.getY(), (int) Math.round(zn));
}
public MultiblockComponent copy() {
return new MultiblockComponent(relPos, state, tileEntity);
}
public TileEntity getTileEntity() {
return tileEntity;
}
@OnlyIn(Dist.CLIENT)
public boolean shouldDoFancyRender() {
return doFancyRender;
}
}
@@ -1,50 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 7:20:09 PM (GMT)]
*/
package vazkii.botania.api.lexicon.multiblock.component;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tags.Tag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
public class TagComponent extends MultiblockComponent {
private final Tag<Block> tag;
public TagComponent(BlockPos relPos, Block block, Tag<Block> tag) {
super(relPos, block.getDefaultState());
this.tag = tag;
}
@Override
public BlockState getBlockState() {
if (tag.getAllElements().isEmpty()) {
return super.getBlockState();
} else {
Block[] arr = tag.getAllElements().toArray(new Block[0]);
int idx = (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % arr.length;
return arr[idx].getDefaultState();
}
}
@Override
public boolean matches(World world, BlockPos pos) {
return world.getBlockState(pos).getBlock().isIn(tag);
}
@Override
public MultiblockComponent copy() {
return new TagComponent(getRelativePosition(), getBlockState().getBlock(), tag);
}
}
@@ -54,7 +54,6 @@ import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.capability.FloatingFlowerImpl;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.wand.IWandBindable;
import vazkii.botania.common.block.ModBlocks;
@@ -254,13 +253,6 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
return list;
}
/**
* Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon.
*/
public LexiconEntry getEntry() {
return null;
}
/**
* Gets the block coordinates this is bound to, for use with the wireframe render
* when the sub tile is being hovered with a wand of the forest.
@@ -21,7 +21,6 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import vazkii.botania.api.mana.IManaCollector;
import vazkii.botania.api.mana.TileSignature;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.common.block.subtile.functional.SubTileVinculotus;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.core.handler.ManaNetworkHandler;
@@ -41,9 +41,6 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.items.IItemHandler;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.ILexicon;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.ICreativeManaProvider;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.mana.IManaUsingItem;
@@ -136,12 +133,11 @@ public final class HUDHandler {
((IWandHUD) block).renderHUD(mc, mc.world, bpos);
profiler.endSection();
}
} else if(block != null && PlayerHelper.hasHeldItemClass(mc.player, ILexicon.class))
drawLexiconHUD(PlayerHelper.getFirstHeldItemClass(mc.player, ILexicon.class), state, (BlockRayTraceResult) pos);
}
if(tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty())
renderPoolRecipeHUD((TilePool) tile, mc.player.getHeldItemMainhand());
}
if(!PlayerHelper.hasHeldItemClass(mc.player, ILexicon.class)) {
if(!PlayerHelper.hasHeldItem(mc.player, ModItems.lexicon)) {
if(tile instanceof TileAltar)
((TileAltar) tile).renderHUD(mc);
else if(tile instanceof TileRuneAltar)
@@ -158,13 +154,6 @@ public final class HUDHandler {
profiler.endSection();
}
if(MultiblockRenderHandler.currentMultiblock != null && MultiblockRenderHandler.anchor == null) {
profiler.startSection("multiblockRightClick");
String s = I18n.format("botaniamisc.rightClickToAnchor");
mc.fontRenderer.drawStringWithShadow(s, mc.mainWindow.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(s) / 2, mc.mainWindow.getScaledHeight() / 2 - 30, 0xFFFFFF);
profiler.endSection();
}
if(!main.isEmpty() && main.getItem() instanceof ItemCraftingHalo) {
profiler.startSection("craftingHalo_main");
ItemCraftingHalo.renderHUD(mc.player, main);
@@ -371,58 +360,6 @@ public final class HUDHandler {
profiler.endSection();
}
private static void drawLexiconHUD(ItemStack stack, BlockState state, BlockRayTraceResult pos) {
Minecraft mc = Minecraft.getInstance();
Block block = state.getBlock();
IProfiler profiler = mc.getProfiler();
profiler.startSection("lexicon");
FontRenderer font = mc.fontRenderer;
boolean draw = false;
String drawStr = "";
String secondLine = "";
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int sx = mc.mainWindow.getScaledWidth() / 2 - 17;
int sy = mc.mainWindow.getScaledHeight() / 2 + 2;
if(block instanceof ILexiconable) {
LexiconEntry entry = ((ILexiconable) block).getEntry(mc.world, pos.getPos(), mc.player, stack);
if(entry != null) {
if(!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType()))
font = mc.getFontResourceManager().getFontRenderer(Minecraft.standardGalacticFontRenderer);
drawStr = I18n.format(entry.getUnlocalizedName());
secondLine = TextFormatting.ITALIC + I18n.format(entry.getTagline());
draw = true;
}
}
if(draw) {
if(!mc.player.isSneaking()) {
drawStr = "?";
secondLine = "";
font = mc.fontRenderer;
}
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModItems.lexicon), sx, sy);
GlStateManager.disableLighting();
font.drawStringWithShadow(drawStr, sx + 20, sy + 4, 0xFFFFFFFF);
font.drawStringWithShadow(secondLine, sx + 20, sy + 14, 0xFFAAAAAA);
if(!mc.player.isSneaking()) {
GlStateManager.scalef(0.5F, 0.5F, 1F);
mc.fontRenderer.drawStringWithShadow(TextFormatting.BOLD + mc.gameSettings.keyBindSneak.getLocalizedName(), (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF);
GlStateManager.scalef(2F, 2F, 1F);
}
}
GlStateManager.disableBlend();
GlStateManager.color4f(1F, 1F, 1F, 1F);
profiler.endSection();
}
private static void renderNearIndexDisplay() {
Minecraft mc = Minecraft.getInstance();
String txt0 = I18n.format("botaniamisc.nearIndex0");
@@ -23,7 +23,6 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import vazkii.botania.api.BotaniaAPIClient;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
import vazkii.botania.client.model.FloatingFlowerModel;
import vazkii.botania.client.render.entity.RenderBabylonWeapon;
@@ -115,10 +114,6 @@ public final class ModelHandler {
RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, renderManager -> new SpriteRenderer<>(renderManager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, renderManager -> new SpriteRenderer<>(renderManager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityEnderAirBottle.class, renderManager -> new SpriteRenderer<>(renderManager, Minecraft.getInstance().getItemRenderer()));
IMultiblockRenderHook.renderHooks.put(ModBlocks.manaPylon, renderTilePylon);
IMultiblockRenderHook.renderHooks.put(ModBlocks.naturaPylon, renderTilePylon);
IMultiblockRenderHook.renderHooks.put(ModBlocks.gaiaPylon, renderTilePylon);
}
private static void registerSubtiles() {
@@ -1,78 +0,0 @@
/**
* This class was created by <SoundLogic>. 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 @ [Aug 31, 2015, 11:40:59 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.IFluidState;
import net.minecraft.block.Blocks;
import net.minecraft.fluid.Fluids;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import vazkii.botania.api.lexicon.multiblock.Multiblock;
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
import javax.annotation.Nonnull;
/**
* This class acts as a wrapper around a block access to
* replace blocks with the blocks involved in the multiblock specified
*/
public class MultiblockBlockAccess implements IBlockReader {
private IBlockReader compose;
private BlockPos anchorPos;
protected Multiblock multiblock;
@Nonnull
@Override
public BlockState getBlockState(@Nonnull BlockPos pos) {
MultiblockComponent comp=getComponent(pos);
if(comp != null)
return comp.getBlockState();
if(compose != null)
return compose.getBlockState(pos);
return Blocks.AIR.getDefaultState();
}
@Nonnull
@Override
public IFluidState getFluidState(BlockPos pos) {
return compose != null ? compose.getFluidState(pos) : Fluids.EMPTY.getDefaultState();
}
@Override
public TileEntity getTileEntity(@Nonnull BlockPos pos) {
MultiblockComponent comp=getComponent(pos);
if(comp != null)
return comp.getTileEntity();
if(compose != null)
return compose.getTileEntity(pos);
return null;
}
/**
* Updates the block access to the new parameters
*/
public void update(IBlockReader access, Multiblock mb, BlockPos anchorPos) {
compose = access;
multiblock = mb;
this.anchorPos = anchorPos;
}
/**
* Returns the multiblock component for the coordinates, adjusted based on the anchor
*/
private MultiblockComponent getComponent(BlockPos pos) {
return multiblock.getComponentForLocation(pos.add(new BlockPos(-anchorPos.getX(), -anchorPos.getY(), -anchorPos.getZ())));
}
}
@@ -1,182 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 7:28:29 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import com.mojang.blaze3d.platform.GLX;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.MemoryUtil;
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.MultiblockComponent;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.common.lib.LibMisc;
import java.nio.FloatBuffer;
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID)
public final class MultiblockRenderHandler {
private MultiblockRenderHandler() {}
private static final MultiblockBlockAccess blockAccess = new MultiblockBlockAccess();
private static DimensionType dimension;
public static boolean rendering = false;
public static MultiblockSet currentMultiblock;
public static BlockPos anchor;
public static Direction angle;
public static void setMultiblock(MultiblockSet set) {
currentMultiblock = set;
anchor = null;
angle = Direction.SOUTH;
Minecraft mc = Minecraft.getInstance();
if(mc.world != null)
dimension = mc.world.getDimension().getType();
}
@SubscribeEvent
public static void onWorldRenderLast(RenderWorldLastEvent event) {
Minecraft mc = Minecraft.getInstance();
if(mc.player != null && mc.objectMouseOver != null && mc.objectMouseOver.getType() == RayTraceResult.Type.BLOCK
&& (!mc.player.isSneaking() || anchor != null)) {
renderPlayerLook(mc.player, (BlockRayTraceResult) mc.objectMouseOver);
}
}
@SubscribeEvent
public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
if(currentMultiblock != null && anchor == null && event.getEntityPlayer() == Minecraft.getInstance().player) {
anchor = event.getPos();
angle = event.getEntityPlayer().getHorizontalFacing();
event.setCanceled(true);
event.setCancellationResult(ActionResultType.SUCCESS);
}
}
private static void renderPlayerLook(PlayerEntity player, BlockRayTraceResult src) {
if(currentMultiblock != null && dimension == player.world.getDimension().getType()) {
BlockPos anchorPos = anchor != null ? anchor : src.getPos();
GlStateManager.pushMatrix();
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.disableLighting();
rendering = true;
Multiblock mb = anchor != null ? currentMultiblock.getForFacing(angle) : currentMultiblock.getForEntity(player);
boolean didAny = false;
blockAccess.update(player.world, mb, anchorPos);
ShaderHelper.useShader(ShaderHelper.alpha, shader -> {
int alpha = GLX.glGetUniformLocation(shader, "alpha");
ShaderHelper.FLOAT_BUF.position(0);
ShaderHelper.FLOAT_BUF.put(0, 0.4F);
GLX.glUniform1(alpha, ShaderHelper.FLOAT_BUF);
});
for(MultiblockComponent comp : mb.getComponents()) {
if(renderComponentInWorld(player.world, mb, comp, anchorPos))
didAny = true;
}
ShaderHelper.releaseShader();
rendering = false;
GL11.glPopAttrib();
GlStateManager.popMatrix();
if(!didAny) {
setMultiblock(null);
player.sendMessage(new TranslationTextComponent("botaniamisc.structureComplete").setStyle(new Style().setColor(TextFormatting.GREEN)));
}
}
}
private static boolean renderComponentInWorld(World world, Multiblock mb, MultiblockComponent comp, BlockPos anchorPos) {
double renderPosX = Minecraft.getInstance().getRenderManager().renderPosX;
double renderPosY = Minecraft.getInstance().getRenderManager().renderPosY;
double renderPosZ = Minecraft.getInstance().getRenderManager().renderPosZ;
BlockPos pos = comp.getRelativePosition();
BlockPos pos_ = pos.add(anchorPos);
if(anchor != null && comp.matches(world, pos_))
return false;
GlStateManager.pushMatrix();
GlStateManager.translated(-renderPosX, -renderPosY, -renderPosZ);
GlStateManager.disableDepthTest();
doRenderComponent(mb, comp, pos_);
GlStateManager.popMatrix();
return true;
}
public static void renderMultiblockOnPage(Multiblock mb) {
GlStateManager.translated(-0.5, -0.5, -0.5);
blockAccess.update(null, mb, mb.offPos);
for(MultiblockComponent comp : mb.getComponents()) {
BlockPos pos = comp.getRelativePosition();
doRenderComponent(mb, comp, pos.add(mb.offPos));
}
}
private static void doRenderComponent(Multiblock mb, MultiblockComponent comp, BlockPos pos) {
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
BlockState state = comp.getBlockState();
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
if(state == null)
return;
if(IMultiblockRenderHook.renderHooks.containsKey(state.getBlock())) {
GlStateManager.color4f(1F, 1F, 1F, 1F);
IMultiblockRenderHook renderHook = IMultiblockRenderHook.renderHooks.get(state.getBlock());
if(renderHook.needsTranslate(state)) {
GlStateManager.translated(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
}
renderHook.renderBlockForMultiblock(blockAccess, mb, state, comp);
}
else {
BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRendererDispatcher();
GlStateManager.translated(pos.getX(), pos.getY(), pos.getZ() + 1);
GlStateManager.color4f(1, 1, 1, 1);
brd.renderBlockBrightness(state, 1.0F);
}
GlStateManager.color4f(1F, 1F, 1F, 1F);
GlStateManager.enableDepthTest();
GlStateManager.popMatrix();
}
}
@@ -15,7 +15,6 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.CompoundNBT;
import vazkii.botania.client.challenge.Challenge;
import vazkii.botania.client.challenge.ModChallenges;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.common.lib.LibMisc;
import java.io.File;
@@ -29,41 +28,25 @@ public final class PersistentVariableHelper {
private static final String TAG_FIRST_LOAD = "firstLoad";
private static final String TAG_DOG = "dog";
private static final String TAG_BOOKMARK_COUNT = "bookmarkCount";
private static final String TAG_BOOKMARK_PREFIX = "bookmark";
private static final String TAG_BOOKMARKS = "bookmarks";
private static final String TAG_CHALLENGES = "challenges";
private static final String TAG_LEXICON_NOTES = "lexiconNotes";
private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion";
private static final String TAG_LEXICON_GUI_SCALE = "lexiconGuiScale";
private static File cacheFile;
public static boolean firstLoad = true;
public static boolean dog = true;
public static String lastBotaniaVersion = "";
public static int lexiconGuiScale = 0;
public static void save() throws IOException {
CompoundNBT cmp = new CompoundNBT();
List<GuiLexicon> bookmarks = GuiLexicon.bookmarks;
int count = bookmarks.size();
cmp.putInt(TAG_BOOKMARK_COUNT, count);
CompoundNBT bookmarksCmp = new CompoundNBT();
for(int i = 0; i < count; i++) {
GuiLexicon lex = bookmarks.get(i);
CompoundNBT bookmarkCmp = new CompoundNBT();
lex.serialize(bookmarkCmp);
bookmarksCmp.put(TAG_BOOKMARK_PREFIX + i, bookmarkCmp);
}
cmp.put(TAG_BOOKMARKS, bookmarksCmp);
CompoundNBT challengesCmp = new CompoundNBT();
for(Challenge c : ModChallenges.challengeLookup.values())
c.writeToNBT(challengesCmp);
cmp.put(TAG_CHALLENGES, challengesCmp);
/*
CompoundNBT notesCmp = new CompoundNBT();
for(String s : GuiLexicon.notes.keySet()) {
String note = GuiLexicon.notes.get(s);
@@ -71,11 +54,11 @@ public final class PersistentVariableHelper {
notesCmp.putString(s, note);
}
cmp.put(TAG_LEXICON_NOTES, notesCmp);
*/
cmp.putBoolean(TAG_FIRST_LOAD, firstLoad);
cmp.putBoolean(TAG_DOG, dog);
cmp.putString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion);
cmp.putInt(TAG_LEXICON_GUI_SCALE, lexiconGuiScale);
injectNBTToFile(cmp, getCacheFile());
}
@@ -83,20 +66,6 @@ public final class PersistentVariableHelper {
public static void load() throws IOException {
CompoundNBT cmp = getCacheCompound();
int count = cmp.getInt(TAG_BOOKMARK_COUNT);
GuiLexicon.bookmarks.clear();
if(count > 0) {
CompoundNBT bookmarksCmp = cmp.getCompound(TAG_BOOKMARKS);
for(int i = 0; i < count; i++) {
CompoundNBT bookmarkCmp = bookmarksCmp.getCompound(TAG_BOOKMARK_PREFIX + i);
GuiLexicon gui = GuiLexicon.create(bookmarkCmp);
if(gui != null) {
GuiLexicon.bookmarks.add(gui);
GuiLexicon.bookmarkKeys.add(gui.getNotesKey());
}
}
}
if(cmp.contains(TAG_CHALLENGES)) {
CompoundNBT challengesCmp = cmp.getCompound(TAG_CHALLENGES);
for(Challenge c : ModChallenges.challengeLookup.values())
@@ -106,9 +75,9 @@ public final class PersistentVariableHelper {
if(cmp.contains(TAG_LEXICON_NOTES)) {
CompoundNBT notesCmp = cmp.getCompound(TAG_LEXICON_NOTES);
Set<String> keys = notesCmp.keySet();
GuiLexicon.notes.clear();
// GuiLexicon.notes.clear();
for(String key : keys)
GuiLexicon.notes.put(key, notesCmp.getString(key));
;// GuiLexicon.notes.put(key, notesCmp.getString(key));
}
lastBotaniaVersion = cmp.contains(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)";
@@ -118,7 +87,6 @@ public final class PersistentVariableHelper {
lastBotaniaVersion = LibMisc.VERSION;
dog = cmp.getBoolean(TAG_DOG);
lexiconGuiScale = cmp.getInt(TAG_LEXICON_GUI_SCALE);
}
public static void saveSafe() {
@@ -1,5 +1,6 @@
package vazkii.botania.client.core.handler;
import com.google.common.base.Joiner;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
@@ -20,16 +21,17 @@ import net.minecraftforge.client.event.RenderSpecificHandEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ItemLexicon;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lexicon.page.PageText;
import vazkii.botania.common.lib.LibMisc;
import vazkii.patchouli.client.book.gui.GuiBook;
import java.util.ArrayList;
import java.util.List;
// Hacky way to render 3D lexicon, will be reevaluated in the future.
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID)
public class RenderLexicon {
@@ -132,7 +134,7 @@ public class RenderLexicon {
String quoteStr = QUOTES[quote];
GlStateManager.translatef(-5F, 15F, 0F);
PageText.renderText(0, 0, 140, 100, 0, false, 0x79ff92, quoteStr);
renderText(0, 0, 140, 100, 0, false, 0x79ff92, quoteStr);
GlStateManager.color3f(1F, 1F, 1F);
GlStateManager.translatef(8F, 110F, 0F);
@@ -177,4 +179,81 @@ public class RenderLexicon {
GlStateManager.rotatef(i * -45.0F, 0.0F, 1.0F, 0.0F);
}
private static void renderText(int x, int y, int width, int height, int paragraphSize, boolean useUnicode, int color, String unlocalizedText) {
x += 2;
y += 10;
width -= 4;
FontRenderer font = Minecraft.getInstance().fontRenderer;
String text = I18n.format(unlocalizedText).replaceAll("&", "\u00a7");
String[] textEntries = text.split("<br>");
List<List<String>> lines = new ArrayList<>();
String controlCodes;
for(String s : textEntries) {
List<String> words = new ArrayList<>();
String lineStr = "";
String[] tokens = s.split(" ");
for(String token : tokens) {
String prev = lineStr;
String spaced = token + " ";
lineStr += spaced;
controlCodes = toControlCodes(getControlCodes(prev));
if(font.getStringWidth(lineStr) > width) {
lines.add(words);
lineStr = controlCodes + spaced;
words = new ArrayList<>();
}
words.add(controlCodes + token);
}
if(!lineStr.isEmpty())
lines.add(words);
lines.add(new ArrayList<>());
}
int i = 0;
for(List<String> words : lines) {
words.size();
int xi = x;
int spacing = 4;
int wcount = words.size();
int compensationSpaces = 0;
boolean justify = ConfigHandler.CLIENT.lexiconJustifiedText.get() && wcount > 0 && lines.size() > i && !lines.get(i + 1).isEmpty();
if(justify) {
String s = Joiner.on("").join(words);
int swidth = font.getStringWidth(s);
int space = width - swidth;
spacing = wcount == 1 ? 0 : space / (wcount - 1);
compensationSpaces = wcount == 1 ? 0 : space % (wcount - 1);
}
for(String s : words) {
int extra = 0;
if(compensationSpaces > 0) {
compensationSpaces--;
extra++;
}
font.drawString(s, xi, y, color);
xi += font.getStringWidth(s) + spacing + extra;
}
y += words.isEmpty() ? paragraphSize : 10;
i++;
}
}
private static String getControlCodes(String s) {
String controls = s.replaceAll("(?<!\u00a7)(.)", "");
return controls.replaceAll(".*r", "r");
}
private static String toControlCodes(String s) {
return s.replaceAll(".", "\u00a7$0");
}
}
@@ -17,30 +17,21 @@ import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.settings.ParticleStatus;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.IParticleData;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.lwjgl.glfw.GLFW;
import vazkii.botania.api.boss.IBotaniaBoss;
import vazkii.botania.api.lexicon.LexiconEntry;
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.client.challenge.ModChallenges;
import vazkii.botania.client.core.handler.BaubleRenderHandler;
import vazkii.botania.client.core.handler.BossBarHandler;
@@ -51,29 +42,19 @@ import vazkii.botania.client.core.handler.ContributorFancinessHandler;
import vazkii.botania.client.core.handler.CorporeaAutoCompleteHandler;
import vazkii.botania.client.core.handler.LayerTerraHelmet;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.handler.MultiblockRenderHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.fx.FXLightning;
import vazkii.botania.client.fx.FXSparkle;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconEntry;
import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
import vazkii.botania.client.render.entity.LayerGaiaHead;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.core.proxy.IProxy;
import vazkii.botania.common.item.ItemSextant.MultiblockSextant;
import vazkii.botania.common.item.equipment.bauble.ItemMonocle;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Map;
@@ -165,22 +146,6 @@ public class ClientProxy implements IProxy {
render.addLayer(new LayerGaiaHead(render, render.getEntityModel().bipedHead));
}
@Override
public void setEntryToOpen(LexiconEntry entry) {
GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category));
}
@Override
public void setToTutorialIfFirstLaunch() {
if(PersistentVariableHelper.firstLoad)
GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(LexiconData.welcome, new GuiLexiconEntry(LexiconData.tutorial, new GuiLexicon())).setFirstEntry();
}
@Override
public void setLexiconStack(ItemStack stack) {
GuiLexicon.stackUsed = stack;
}
@Override
public boolean isTheClientPlayer(LivingEntity entity) {
return entity == Minecraft.getInstance().player;
@@ -214,34 +179,6 @@ public class ClientProxy implements IProxy {
return ClientTickHandler.ticksInGame;
}
@Override
public void setMultiblock(World world, int x, int y, int z, double radius, Block block) {
MultiblockSextant mb = new MultiblockSextant();
int iradius = (int) radius + 1;
for(int i = 0; i < iradius * 2 + 1; i++)
for(int j = 0; j < iradius * 2 + 1; j++) {
int xp = x + i - iradius;
int zp = z + j - iradius;
if((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1)
mb.addComponent(new AnyComponent(new BlockPos(xp - x, 1, zp - z), block.getDefaultState()));
}
MultiblockRenderHandler.setMultiblock(mb.makeSet());
MultiblockRenderHandler.anchor = new BlockPos(x, y, z);
}
@Override
public void removeSextantMultiblock() {
MultiblockSet set = MultiblockRenderHandler.currentMultiblock;
if(set != null) {
Multiblock mb = set.getForFacing(Direction.SOUTH);
if(mb instanceof MultiblockSextant)
MultiblockRenderHandler.setMultiblock(null);
}
}
@Override
public void lightningFX(Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
Minecraft.getInstance().particles.addEffect(new FXLightning(Minecraft.getInstance().world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner));
@@ -1,657 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:48:05 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SimpleSound;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.button.Button;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.InputMappings;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SharedConstants;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.BotaniaTutorialStartEvent;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.core.proxy.ClientProxy;
import vazkii.botania.client.gui.lexicon.button.GuiButtonAchievement;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBookmark;
import vazkii.botania.client.gui.lexicon.button.GuiButtonCategory;
import vazkii.botania.client.gui.lexicon.button.GuiButtonChallengeInfo;
import vazkii.botania.client.gui.lexicon.button.GuiButtonChallenges;
import vazkii.botania.client.gui.lexicon.button.GuiButtonDoot;
import vazkii.botania.client.gui.lexicon.button.GuiButtonHistory;
import vazkii.botania.client.gui.lexicon.button.GuiButtonIndexEntry;
import vazkii.botania.client.gui.lexicon.button.GuiButtonNotes;
import vazkii.botania.client.gui.lexicon.button.GuiButtonOptions;
import vazkii.botania.client.gui.lexicon.button.GuiButtonScaleChange;
import vazkii.botania.client.gui.lexicon.button.GuiButtonUpdateWarning;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.item.ItemLexicon;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lexicon.page.PageText;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
public class GuiLexicon extends Screen {
public static GuiLexicon currentOpenLexicon = new GuiLexicon();
public static ItemStack stackUsed = ItemStack.EMPTY;
public static final Map<String, String> notes = new HashMap<>();
private static final String TAG_TYPE = "type";
private static final int[] KONAMI_CODE = {
GLFW.GLFW_KEY_UP, GLFW.GLFW_KEY_UP, GLFW.GLFW_KEY_DOWN, GLFW.GLFW_KEY_DOWN,
GLFW.GLFW_KEY_LEFT, GLFW.GLFW_KEY_RIGHT, GLFW.GLFW_KEY_LEFT, GLFW.GLFW_KEY_RIGHT,
GLFW.GLFW_KEY_B, GLFW.GLFW_KEY_A
};
public static final int BOOKMARK_START = 1337;
public static final int MAX_BOOKMARK_COUNT = 8;
public static final List<GuiLexicon> bookmarks = new ArrayList<>();
public static final List<String> bookmarkKeys = new ArrayList<>();
public boolean bookmarksNeedPopulation = false;
public static final Queue<LexiconEntry> tutorial = new ArrayDeque<>();
public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON);
public static final ResourceLocation textureToff = new ResourceLocation(LibResources.GUI_TOFF);
public float lastTime = 0F;
public float partialTicks = 0F;
public float timeDelta = 0F;
private static final int TUTORIAL_ARROW_WIDTH = 10;
private static final int TUTORIAL_ARROW_HEIGHT = 12;
boolean hasTutorialArrow;
private int tutorialArrowX, tutorialArrowY;
private int konamiIndex;
private int konamiTime;
private static final int NOTE_TWEEN_TIME = 5;
public static boolean notesEnabled;
private static int notesMoveTime;
public String note = "";
public String categoryHighlight = "";
final int guiWidth = 146;
final int guiHeight = 180;
protected final Minecraft mc = Minecraft.getInstance();
int left, top;
public GuiLexicon() {
this(new TranslationTextComponent(ModItems.lexicon.getTranslationKey()));
}
protected GuiLexicon(ITextComponent title) {
super(title);
}
@Override
public final void init() {
super.init();
if(PersistentVariableHelper.firstLoad) {
PersistentVariableHelper.firstLoad = false;
PersistentVariableHelper.saveSafe();
}
String key = getNotesKey();
if(notes.containsKey(key))
note = notes.get(key);
onInitGui();
putTutorialArrow();
}
public void onInitGui() {
int guiScale = mc.gameSettings.guiScale;
int persistentScale = Math.min(PersistentVariableHelper.lexiconGuiScale, getMaxAllowedScale());
if(persistentScale > 0 && persistentScale != guiScale) { //todo changing gui scale with this now results in endless recursion
// // Fake the scale temporarily so we can get the scaled width from mainWindow
// mc.gameSettings.guiScale = persistentScale;
// mc.updateWindowSize();
// mc.mainWindow.setGuiScale(mc.mainWindow.calcGuiScale(persistentScale, Minecraft.getInstance().getForceUnicodeFont()));
// Get the info
width = mc.mainWindow.getScaledWidth();
height = mc.mainWindow.getScaledHeight();
// mc.mainWindow.setGuiScale(guiScale);
// // Change it back
// mc.gameSettings.guiScale = guiScale;
// mc.updateWindowSize();
}
lastTime = ClientTickHandler.ticksInGame;
currentOpenLexicon = this;
left = width / 2 - guiWidth / 2;
top = height / 2 - guiHeight / 2;
buttons.clear();
if(isIndex()) {
int x = 18;
for(int i = 0; i < 12; i++) {
int y = 16 + i * 12;
addButton(new GuiButtonIndexEntry((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, ""));
}
populateIndex();
} else if(isCategoryIndex()) {
List<LexiconCategory> allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
allCategories.removeIf(cat -> !cat.isVisible(stackUsed));
Collections.sort(allCategories);
int categories = allCategories.size();
for(int i = 0; i < categories + 1; i++) {
LexiconCategory category;
category = i >= categories ? null : allCategories.get(i);
int perline = 5;
int x = i % perline;
int y = i / perline;
int size = 22;
GuiButtonCategory button = new GuiButtonCategory(left + 18 + x * size, top + 50 + y * size, this, category);
addButton(button);
}
}
populateBookmarks();
if(isMainPage()) {
addButton(new GuiButtonOptions(left + 20, top + guiHeight - 25));
addButton(new GuiButtonAchievement(left + 33, top + guiHeight - 25));
addButton(new GuiButtonChallenges(left + 45, top + guiHeight - 25));
addButton(new GuiButtonScaleChange(left + 57, top + guiHeight - 25));
GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(left - 6, top + guiHeight - 70);
addButton(button);
if(PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) {
button.active = false;
button.visible = false;
}
LocalDateTime now = LocalDateTime.now();
if(now.getMonth() == Month.NOVEMBER && now.getDayOfMonth() == 22)
addButton(new GuiButtonDoot(left + 100, top + 12));
}
addButton(new GuiButtonNotes(this, left - 4, top - 4));
}
@Override
public void tick() {
if(notesEnabled && notesMoveTime < NOTE_TWEEN_TIME)
notesMoveTime++;
else if(!notesEnabled && notesMoveTime > 0)
notesMoveTime--;
if(konamiTime > 0)
konamiTime--;
}
@Override
public final void render(int x, int y, float partialTicks) {
int guiScale = mc.gameSettings.guiScale;
GlStateManager.pushMatrix();
int persistentScale = Math.min(PersistentVariableHelper.lexiconGuiScale, getMaxAllowedScale());
if(persistentScale > 0 && persistentScale != guiScale) {
mc.gameSettings.guiScale = persistentScale;
float s = (float) persistentScale / (float) mc.mainWindow.getGuiScaleFactor();
GlStateManager.scalef(s, s, s);
int sw = mc.mainWindow.getScaledWidth();
int sh = mc.mainWindow.getScaledHeight();
x = (int) (mc.mouseHelper.getMouseX() * sw / mc.mainWindow.getWidth());
y = (int) (sh - mc.mouseHelper.getMouseY() * sh / mc.mainWindow.getHeight() - 1);
}
drawScreenAfterScale(x, y, partialTicks);
mc.gameSettings.guiScale = guiScale;
GlStateManager.popMatrix();
if(konamiTime > 0) {
String meme = I18n.format("botania.subtitle.way");
GlStateManager.pushMatrix();
int fullWidth = font.getStringWidth(meme);
int left = width;
double widthPerTick = (fullWidth + width) / 240;
double currWidth = left - widthPerTick * (240 - (konamiTime - partialTicks)) * 3.2;
GlStateManager.translated(currWidth, height / 2 - 10, 0);
GlStateManager.scalef(4, 4, 4);
mc.fontRenderer.drawStringWithShadow(meme, 0, 0, 0xFFFFFF);
GlStateManager.popMatrix();
}
}
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
float time = ClientTickHandler.ticksInGame + newPartialTicks;
timeDelta = time - lastTime + partialTicks;
lastTime = time;
partialTicks = newPartialTicks;
GlStateManager.color4f(1F, 1F, 1F, 1F);
mc.textureManager.bindTexture(texture);
drawNotes(newPartialTicks);
GlStateManager.color4f(1F, 1F, 1F, 1F);
mc.textureManager.bindTexture(texture);
blit(left, top, 0, 0, guiWidth, guiHeight);
if(ClientProxy.jingleTheBells)
blit(left + 3, top + 1, 0, 212, 138, 6);
String subtitle = getSubtitle();
if(subtitle != null)
drawBookmark(left + guiWidth / 2, top - getTitleHeight() + 10, subtitle, true, 191);
drawBookmark(left + guiWidth / 2, top - getTitleHeight(), getTitle().getFormattedText(), true);
if(isMainPage())
drawHeader();
if(bookmarksNeedPopulation) {
populateBookmarks();
bookmarksNeedPopulation = false;
}
if(mc.player.getGameProfile().getName().equals("haighyorkie")) {
GlStateManager.color4f(1F, 1F, 1F, 1F);
mc.textureManager.bindTexture(texture);
blit(left - 19, top + 42, 67, 180, 19, 26);
if(xCoord >= left - 19 && xCoord < left && yCoord >= top + 62 && yCoord < top + 88) {
mc.textureManager.bindTexture(textureToff);
GlStateManager.pushMatrix();
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.translatef(0F, 0F, 2F);
int w = 256;
int h = 152;
int x = (int) ((ClientTickHandler.ticksInGame + newPartialTicks) * 6) % (width + w) - w;
int y = (int) (top + guiHeight / 2 - h / 4 + Math.sin((ClientTickHandler.ticksInGame + newPartialTicks) / 6.0) * 40);
blit(x * 2, y * 2, 0, 0, w, h);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
RenderHelper.renderTooltip(xCoord, yCoord, Arrays.asList(TextFormatting.GOLD + "#goldfishchris", TextFormatting.AQUA + "IT SAYS MANUAL"));
}
}
super.render(xCoord, yCoord, newPartialTicks);
if(hasTutorialArrow) {
mc.textureManager.bindTexture(texture);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1F, 1F, 1F, 0.7F + (float) (Math.sin((ClientTickHandler.ticksInGame + newPartialTicks) * 0.3F) + 1) * 0.15F);
blit(tutorialArrowX, tutorialArrowY, 20, 200, TUTORIAL_ARROW_WIDTH, TUTORIAL_ARROW_HEIGHT);
GlStateManager.disableBlend();
}
}
private void drawNotes(float part) {
int size = 105;
float time = notesMoveTime;
if(notesMoveTime < NOTE_TWEEN_TIME && notesEnabled)
time += part;
else if(notesMoveTime > 0 && !notesEnabled)
time -= part;
int drawSize = (int) (size * time / NOTE_TWEEN_TIME);
int x = left - drawSize;
int y = top + 10;
blit(x, y, 146, 0, drawSize, 125);
String noteDisplay = note;
if(notesEnabled && ClientTickHandler.ticksInGame % 20 < 10)
noteDisplay += "&r_";
font.drawString(I18n.format("botaniamisc.notes"), x + 5, y - 7, 0x666666);
PageText.renderText(x + 5, y - 3, 92, 120, 0, true, 0, TextFormatting.RESET + noteDisplay);
}
public void drawBookmark(int x, int y, String s, boolean drawLeft) {
drawBookmark(x, y, s, drawLeft, 180);
}
private void drawBookmark(int x, int y, String s, boolean drawLeft, int v) {
drawBookmark(x, y, s, drawLeft, 0x111111, v);
}
public void drawBookmark(int x, int y, String s, boolean drawLeft, int color, int v) {
// This function is called from the buttons so I can't use font
FontRenderer font = Minecraft.getInstance().fontRenderer;
int l = font.getStringWidth(s);
int fontOff = 0;
if(!drawLeft) {
x += l / 2;
fontOff = 2;
}
Minecraft.getInstance().textureManager.bindTexture(texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x + l / 2 + 3, y - 1, 54, v, 6, 11);
if(drawLeft)
blit(x - l / 2 - 9, y - 1, 61, v, 6, 11);
for(int i = 0; i < l + 6; i++)
blit(x - l / 2 - 3 + i, y - 1, 60, v, 1, 11);
font.drawString(s, x - l / 2 + fontOff, y, color);
}
private void drawHeader() {
GlStateManager.pushMatrix();
GlStateManager.color4f(1F, 1F, 1F, 1F);
Minecraft.getInstance().textureManager.bindTexture(texture);
blit(left - 8, top + 9, 0, 224, 140, 31);
int color = 0xffd200;
font.drawString(title.getFormattedText(), left + 18, top + 13, color);
font.drawString(I18n.format("botaniamisc.edition", ItemLexicon.getEdition()), left + 24, top + 22, color);
String s = TextFormatting.BOLD + categoryHighlight;
font.drawString(s, left + guiWidth / 2 - font.getStringWidth(s) / 2, top + 36, 0);
GlStateManager.popMatrix();
categoryHighlight = "";
}
boolean isMainPage() {
return true;
}
@Override
public boolean isPauseScreen() {
return false;
}
public int bookmarkWidth(String b) {
if(font == null)
font = Minecraft.getInstance().fontRenderer;
return font.getStringWidth(b) + 15;
}
@Nonnull
@Override
public ITextComponent getTitle() {
return ItemLexicon.getTitle(stackUsed);
}
String getSubtitle() {
return null;
}
int getTitleHeight() {
return getSubtitle() == null ? 12 : 22;
}
boolean isIndex() {
return false;
}
boolean isChallenge() {
return false;
}
boolean isCategoryIndex() {
return true;
}
public static int getMaxAllowedScale() {
// Reference: AbstractOption.GUI_SCALE
return Minecraft.getInstance().mainWindow.calcGuiScale(0, Minecraft.getInstance().getForceUnicodeFont());
}
void populateIndex() {
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
int shift = 2;
for(int i = shift; i < 12; i++) {
int i_ = i - shift;
GuiButtonIndexEntry button = (GuiButtonIndexEntry) buttons.get(i);
LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_);
if(category != null)
button.setMessage(I18n.format(category.getUnlocalizedName()));
else {
button.setMessage(I18n.format("botaniamisc.lexiconIndex"));
break;
}
}
}
private void populateBookmarks() {
buttons.removeIf(b -> b instanceof GuiButtonBookmark
|| b instanceof GuiButtonHistory
|| b instanceof GuiButtonChallengeInfo);
int len = bookmarks.size();
boolean thisExists = false;
for(GuiLexicon lex : bookmarks)
if(lex.getTitle().equals(getTitle()))
thisExists = true;
boolean addEnabled = len < MAX_BOOKMARK_COUNT && this instanceof IParented && !thisExists;
for(int i = 0; i < len + (addEnabled ? 1 : 0); i++) {
boolean isAdd = i == bookmarks.size();
GuiLexicon destination = isAdd ? null : bookmarks.get(i);
addButton(new GuiButtonBookmark(i, left + 138, top + 18 + 14 * i, destination == null ? this : destination, destination == null ? "+" : destination.getTitle().getFormattedText()));
}
if(isMainPage())
addButton(new GuiButtonHistory(left + 138, top + guiHeight - 24, I18n.format("botaniamisc.history"), this));
else if(isChallenge())
addButton(new GuiButtonChallengeInfo(left + 138, top + guiHeight - 24, I18n.format("botaniamisc.info"), this));
}
public static void startTutorial() {
tutorial.clear();
tutorial.add(LexiconData.lexicon);
tutorial.add(LexiconData.flowers);
tutorial.add(LexiconData.apothecary);
tutorial.add(LexiconData.pureDaisy);
tutorial.add(LexiconData.wand);
tutorial.add(LexiconData.manaIntro);
tutorial.add(LexiconData.pool);
tutorial.add(LexiconData.spreader);
tutorial.add(LexiconData.generatingIntro);
tutorial.add(LexiconData.endoflame);
tutorial.add(LexiconData.functionalIntro);
tutorial.add(LexiconData.runicAltar);
if(Botania.gardenOfGlassLoaded)
tutorial.add(LexiconData.gardenOfGlass);
MinecraftForge.EVENT_BUS.post(new BotaniaTutorialStartEvent(tutorial));
}
public final void putTutorialArrow() {
hasTutorialArrow = !tutorial.isEmpty();
if(hasTutorialArrow)
positionTutorialArrow();
}
public void positionTutorialArrow() {
LexiconEntry entry = tutorial.peek();
LexiconCategory category = entry.category;
for(Widget button : buttons)
if(button instanceof GuiButtonCategory) {
GuiButtonCategory catButton = (GuiButtonCategory) button;
if(catButton.getCategory() == category) {
orientTutorialArrowWithButton(catButton);
break;
}
}
}
public void orientTutorialArrowWithButton(Button button) {
tutorialArrowX = button.x - TUTORIAL_ARROW_WIDTH;
tutorialArrowY = button.y - TUTORIAL_ARROW_HEIGHT;
}
boolean closeScreenOnInvKey() {
return true;
}
@Override
public boolean charTyped(char codePoint, int mods) {
return handleNoteChar(codePoint) || super.charTyped(codePoint, mods);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int mods) {
if(!notesEnabled && closeScreenOnInvKey() && mc.gameSettings.keyBindInventory.isActiveAndMatches(InputMappings.getInputByCode(keyCode, scanCode))) {
mc.displayGuiScreen(null);
mc.mouseHelper.grabMouse();
return true;
}
if(konamiTime == 0 && keyCode == KONAMI_CODE[konamiIndex]) {
konamiIndex++;
if(konamiIndex >= KONAMI_CODE.length) {
mc.getSoundHandler().play(SimpleSound.master(ModSounds.way, 1.0F));
konamiIndex = 0;
konamiTime = 240;
}
return true;
} else konamiIndex = 0;
return super.keyPressed(keyCode, scanCode, mods);
}
private boolean handleNoteChar(char codePoint) {
if(notesEnabled) {
mc.keyboardListener.enableRepeatEvents(true);
boolean changed = false;
if(codePoint == 8 && note.length() > 0) { // backspace
if(hasControlDown())
note = "";
else {
if(note.endsWith("<br>"))
note = note.substring(0, note.length() - 4);
else note = note.substring(0, note.length() - 1);
}
changed = true;
}
if((SharedConstants.isAllowedCharacter(codePoint) || codePoint == 0xA) && note.length() < 250) {
note += codePoint == 0xA ? "<br>" : codePoint;
changed = true;
}
if(changed) {
notes.put(getNotesKey(), note);
PersistentVariableHelper.saveSafe();
return true;
}
} else mc.keyboardListener.enableRepeatEvents(false);
return false;
}
public static GuiLexicon create(CompoundNBT cmp) {
String type = cmp.getString(TAG_TYPE);
try {
GuiLexicon lex = (GuiLexicon) Class.forName(type).newInstance();
if(lex != null)
lex.load(cmp);
if(isValidLexiconGui(lex))
return lex;
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public void serialize(CompoundNBT cmp) {
cmp.putString(TAG_TYPE, getClass().getName());
}
public String getNotesKey() {
return "index";
}
public void load(CompoundNBT cmp) {}
public GuiLexicon copy() {
return new GuiLexicon();
}
public static boolean isValidLexiconGui(GuiLexicon gui) {
if(gui == null)
return false;
if(gui.isCategoryIndex() || gui.isChallenge())
return true;
if(gui.isIndex()) {
GuiLexiconIndex indexGui = (GuiLexiconIndex) gui;
if(indexGui.category == null)
return true;
return BotaniaAPI.getAllCategories().contains(indexGui.category);
}
GuiLexiconEntry entryGui = (GuiLexiconEntry) gui;
if(!BotaniaAPI.getAllEntries().contains(entryGui.entry))
return false;
return entryGui.page < entryGui.entry.pages.size();
}
}
@@ -1,170 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 29, 2015, 5:25:06 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.widget.button.Button;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import org.lwjgl.glfw.GLFW;
import vazkii.botania.client.challenge.Challenge;
import vazkii.botania.client.challenge.ModChallenges;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBack;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.material.ItemRune;
import vazkii.botania.common.lexicon.page.PageText;
import javax.annotation.Nonnull;
import java.io.IOException;
public class GuiLexiconChallenge extends GuiLexicon implements IParented {
private static final String TAG_CHALLENGE = "challenge";
private Challenge challenge;
private GuiLexicon parent;
private Button backButton, completeButton;
public GuiLexiconChallenge(GuiLexicon parent, Challenge challenge) {
this.parent = parent;
this.challenge = challenge;
}
@Override
public void onInitGui() {
super.onInitGui();
addButton(backButton = new GuiButtonBack(left + guiWidth / 2 - 8, top + guiHeight + 2, b -> {
mc.displayGuiScreen(parent);
ClientTickHandler.notifyPageChange();
}));
addButton(completeButton = new Button(left + 20, top + guiHeight - 35, guiWidth - 40, 20, "", b -> {
challenge.complete = !challenge.complete;
setCompleteButtonTitle();
PersistentVariableHelper.saveSafe();
}));
setCompleteButtonTitle();
}
@Override
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
super.drawScreenAfterScale(xCoord, yCoord, newPartialTicks);
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
mc.getItemRenderer().renderItemIntoGUI(challenge.icon, left + 18, top + 15);
RenderHelper.disableStandardItemLighting();
GlStateManager.enableBlend();
font.drawString(TextFormatting.BOLD + I18n.format(challenge.unlocalizedName), left + 38, top + 13, 0);
font.drawString(I18n.format(challenge.level.getName()) + ((challenge.icon.getItem() instanceof ItemRune) ? "+" : "") + " / " + (challenge.complete ? TextFormatting.DARK_GREEN : TextFormatting.DARK_RED) + I18n.format(challenge.complete ? "botaniamisc.completed" : "botaniamisc.notCompleted"), left + 38, top + 23, 0);
int width = guiWidth - 30;
int x = left + 16;
int y = top + 28;
PageText.renderText(x, y, width, guiHeight, challenge.unlocalizedName + ".desc");
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int mods) {
if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled) {
back();
return true;
} else if(keyCode == GLFW.GLFW_KEY_HOME) {
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
return true;
}
return super.keyPressed(keyCode, scanCode, mods);
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if(button == 1) {
back();
return false;
}
return super.mouseClicked(mouseX, mouseY, button);
}
private void setCompleteButtonTitle() {
completeButton.setMessage(I18n.format(challenge.complete ? "botaniamisc.markNotCompleted" : "botaniamisc.markCompleted"));
}
private void back() {
if(backButton.active) {
backButton.playDownSound(mc.getSoundHandler());
backButton.onClick(backButton.x, backButton.y);
}
}
@Override
public void setParent(GuiLexicon gui) {
parent = gui;
}
@Override
boolean isMainPage() {
return false;
}
@Nonnull
@Override
public ITextComponent getTitle() {
return challenge == null
? super.getTitle()
: new TranslationTextComponent(challenge.unlocalizedName);
}
@Override
boolean isChallenge() {
return true;
}
@Override
boolean isCategoryIndex() {
return false;
}
@Override
public GuiLexicon copy() {
return new GuiLexiconChallenge(parent, challenge);
}
@Override
public void serialize(CompoundNBT cmp) {
super.serialize(cmp);
cmp.putString(TAG_CHALLENGE, challenge.unlocalizedName);
}
@Override
public void load(CompoundNBT cmp) {
super.load(cmp);
String challengeName = cmp.getString(TAG_CHALLENGE);
challenge = ModChallenges.challengeLookup.get(challengeName);
}
@Override
public String getNotesKey() {
return "challenge_" + challenge.unlocalizedName;
}
}
@@ -1,137 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 29, 2015, 4:24:07 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import org.lwjgl.glfw.GLFW;
import vazkii.botania.client.challenge.Challenge;
import vazkii.botania.client.challenge.EnumChallengeLevel;
import vazkii.botania.client.challenge.ModChallenges;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBack;
import vazkii.botania.client.gui.lexicon.button.GuiButtonChallengeIcon;
import java.io.IOException;
import java.util.List;
public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
private GuiLexicon parent;
private Button backButton;
public GuiLexiconChallengesList() {
super(new TranslationTextComponent("botaniamisc.challenges"));
parent = new GuiLexicon(getTitle());
}
@Override
public void onInitGui() {
super.onInitGui();
addButton(backButton = new GuiButtonBack(left + guiWidth / 2 - 8, top + guiHeight + 2, b -> {
mc.displayGuiScreen(parent);
ClientTickHandler.notifyPageChange();
}));
int perline = 6;
int i = 13;
int y = top + 20;
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) {
int j = 0;
for(Challenge c : ModChallenges.challenges.get(level)) {
addButton(new GuiButtonChallengeIcon(left + 20 + j % perline * 18, y + j / perline * 17, c, this));
i++;
j++;
}
y += 44;
}
}
@Override
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
super.drawScreenAfterScale(xCoord, yCoord, newPartialTicks);
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) {
List<Challenge> list = ModChallenges.challenges.get(level);
int complete = 0;
for(Challenge c : list)
if(c.complete)
complete++;
font.drawString(TextFormatting.BOLD + I18n.format(level.getName()) + TextFormatting.RESET + " (" + complete + "/" + list.size() + ")", left + 20, top + 11 + level.ordinal() * 44, 0);
}
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int mods) {
if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled) {
back();
return true;
} else if(keyCode == GLFW.GLFW_KEY_HOME) {
mc.displayGuiScreen(new GuiLexicon(getTitle()));
ClientTickHandler.notifyPageChange();
return true;
}
return super.keyPressed(keyCode, scanCode, mods);
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mods) {
if(mods == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
back();
return true;
}
return super.mouseClicked(mouseX, mouseY, mods);
}
private void back() {
if(backButton.active) {
backButton.playDownSound(mc.getSoundHandler());
backButton.onClick(backButton.x, backButton.y);
}
}
@Override
public void setParent(GuiLexicon gui) {
parent = gui;
}
@Override
boolean isMainPage() {
return false;
}
@Override
boolean isChallenge() {
return true;
}
@Override
boolean isCategoryIndex() {
return false;
}
@Override
public GuiLexicon copy() {
return new GuiLexiconChallengesList();
}
@Override
public String getNotesKey() {
return "challengelist";
}
}
@@ -1,401 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:47:06 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TextFormatting;
import org.lwjgl.glfw.GLFW;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IGuiLexiconEntry;
import vazkii.botania.api.lexicon.IAddonEntry;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBackWithShift;
import vazkii.botania.client.gui.lexicon.button.GuiButtonPage;
import vazkii.botania.client.gui.lexicon.button.GuiButtonShare;
import vazkii.botania.client.gui.lexicon.button.GuiButtonViewOnline;
import java.awt.Desktop;
import java.net.URI;
import java.util.List;
public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IParented {
private static final String TAG_ENTRY = "entry";
private static final String TAG_PAGE = "page";
public int page = 0;
private boolean firstEntry = false;
LexiconEntry entry;
private Screen parent;
private String title;
private String subtitle;
private Button leftButton, rightButton, backButton;
public GuiLexiconEntry() {
parent = new GuiLexicon();
setTitle();
}
public GuiLexiconEntry(LexiconEntry entry, Screen parent) {
this.entry = entry;
this.parent = parent;
setTitle();
}
private void setTitle() {
if(entry == null) {
title = "(null)";
return;
}
title = I18n.format(entry.getUnlocalizedName());
if(entry instanceof IAddonEntry)
subtitle = I18n.format(((IAddonEntry) entry).getSubtitle());
else subtitle = null;
}
@Override
public void onInitGui() {
super.onInitGui();
addButton(backButton = new GuiButtonBackWithShift(left + guiWidth / 2 - 8, top + guiHeight + 2, b -> {
entry.pages.get(page).onClosed(GuiLexiconEntry.this);
mc.displayGuiScreen(Screen.hasShiftDown() ? new GuiLexicon() : parent);
ClientTickHandler.notifyPageChange();
}));
addButton(leftButton = new GuiButtonPage(left, top + guiHeight - 10, false, b -> {
entry.pages.get(page).onClosed(GuiLexiconEntry.this);
page--;
entry.pages.get(page).onOpened(GuiLexiconEntry.this);
ClientTickHandler.notifyPageChange();
updatePageButtons();
}));
addButton(rightButton = new GuiButtonPage(left + guiWidth - 18, top + guiHeight - 10, true, b -> {
entry.pages.get(page).onClosed(GuiLexiconEntry.this);
page++;
entry.pages.get(page).onOpened(GuiLexiconEntry.this);
ClientTickHandler.notifyPageChange();
updatePageButtons();
}));
addButton(new GuiButtonShare(left + guiWidth - 6, top - 2, b -> {
Minecraft mc = Minecraft.getInstance();
String cmd = "/botania-share " + entry.getUnlocalizedName();
mc.ingameGUI.getChatGUI().addToSentMessages(cmd);
mc.player.sendChatMessage(cmd);
}));
if(entry.getWebLink() != null)
addButton(new GuiButtonViewOnline(left - 8, top + 12, b -> {
try {
if(Desktop.isDesktopSupported())
Desktop.getDesktop().browse(new URI(entry.getWebLink()));
} catch(Exception e) {
e.printStackTrace();
}
}));
if(!GuiLexicon.isValidLexiconGui(this)) {
currentOpenLexicon = new GuiLexicon();
mc.displayGuiScreen(currentOpenLexicon);
ClientTickHandler.notifyPageChange();
return;
}
LexiconPage page = entry.pages.get(this.page);
page.onOpened(this);
updatePageButtons();
GuiLexiconHistory.visit(entry);
}
@Override
public LexiconEntry getEntry() {
return entry;
}
@Override
public int getPageOn() {
return page;
}
@Override
boolean isMainPage() {
return false;
}
@Override
public ITextComponent getTitle() {
return new StringTextComponent(String.format("%s " + TextFormatting.ITALIC + "(%s/%s)", title, page + 1, entry.pages.size()));
}
@Override
String getSubtitle() {
return subtitle;
}
@Override
boolean isCategoryIndex() {
return false;
}
public GuiLexiconEntry setFirstEntry() {
firstEntry = true;
return this;
}
private void updatePageButtons() {
leftButton.active = page != 0;
rightButton.active = page + 1 < entry.pages.size();
if(firstEntry)
backButton.active = !rightButton.active;
}
@Override
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
super.drawScreenAfterScale(xCoord, yCoord, newPartialTicks);
LexiconPage page = entry.pages.get(this.page);
page.renderScreen(this, xCoord, yCoord);
}
@Override
public void tick() {
super.tick();
LexiconPage page = entry.pages.get(this.page);
page.updateScreen(this);
if(this.page == entry.pages.size() - 1) {
LexiconEntry entry = tutorial.peek();
if(entry == this.entry) {
tutorial.poll();
positionTutorialArrow();
if(tutorial.isEmpty()) {
mc.player.sendMessage(new TranslationTextComponent("botaniamisc.tutorialEnded").setStyle(new Style().setColor(TextFormatting.RED)));
hasTutorialArrow = false;
}
}
}
}
@Override
public void positionTutorialArrow() {
LexiconEntry entry = tutorial.peek();
if(entry != this.entry) {
orientTutorialArrowWithButton(backButton);
return;
}
if(rightButton.active && rightButton.visible)
orientTutorialArrowWithButton(rightButton);
}
@Override
public int getLeft() {
return left;
}
@Override
public int getTop() {
return top;
}
@Override
public int getWidth() {
return guiWidth;
}
@Override
public int getHeight() {
return guiHeight;
}
@Override
public float getZLevel() {
return blitOffset;
}
@Override
public void setParent(GuiLexicon gui) {
parent = gui;
}
private boolean swiped = false;
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
if(button == GLFW.GLFW_MOUSE_BUTTON_LEFT && dragX > 100 && mc.gameSettings.touchscreen && !swiped) {
// todo 1.13 correct these constants
if(dragX < 0.5) {
nextPage();
swiped = true;
} else if(dragX > 0.5) {
prevPage();
swiped = true;
}
return true;
}
return false;
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if(button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
swiped = false;
}
switch(button) {
case 1:
back();
return true;
case 3:
nextPage();
return true;
case 4:
prevPage();
return true;
default: return super.mouseClicked(mouseX, mouseY, button);
}
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double w) {
if(w < 0)
nextPage();
else if(w > 0)
prevPage();
return true;
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int mods) {
LexiconPage page = entry.pages.get(this.page);
if (page.keyPressed(keyCode, scanCode, mods)) {
return true;
}
if(keyCode == GLFW.GLFW_KEY_ESCAPE) {
mc.displayGuiScreen(null);
mc.mouseHelper.grabMouse();
} else if(keyCode == GLFW.GLFW_KEY_LEFT || keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_PAGE_UP)
prevPage();
else if(keyCode == GLFW.GLFW_KEY_RIGHT || keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_PAGE_DOWN)
nextPage();
if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled)
back();
else if(keyCode == GLFW.GLFW_KEY_HOME) { // Home
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
}
return super.keyPressed(keyCode, scanCode, mods);
}
private void back() {
if(backButton.active) {
backButton.playDownSound(mc.getSoundHandler());
backButton.onClick(backButton.x, backButton.y);
}
}
private void nextPage() {
if(rightButton.active) {
rightButton.playDownSound(mc.getSoundHandler());
rightButton.onClick(rightButton.x, rightButton.y);
updateNote();
}
}
private void prevPage() {
if(leftButton.active) {
leftButton.playDownSound(mc.getSoundHandler());
leftButton.onClick(leftButton.x, leftButton.y);
updateNote();
}
}
private void updateNote() {
String key = getNotesKey();
note = notes.getOrDefault(key, "");
}
@Override
public List<Widget> getButtonList() {
return buttons;
}
@Override
public float getElapsedTicks() {
return lastTime;
}
@Override
public float getPartialTicks() {
return partialTicks;
}
@Override
public float getTickDelta() {
return timeDelta;
}
@Override
public void serialize(CompoundNBT cmp) {
super.serialize(cmp);
cmp.putString(TAG_ENTRY, entry.getUnlocalizedName());
cmp.putInt(TAG_PAGE, page);
}
@Override
public void load(CompoundNBT cmp) {
super.load(cmp);
String entryStr = cmp.getString(TAG_ENTRY);
for(LexiconEntry entry : BotaniaAPI.getAllEntries())
if(entry.getUnlocalizedName().equals(entryStr)) {
this.entry = entry;
break;
}
page = cmp.getInt(TAG_PAGE);
setTitle();
}
@Override
public GuiLexicon copy() {
GuiLexiconEntry gui = new GuiLexiconEntry(entry, parent);
gui.page = page;
gui.setTitle();
return gui;
}
@Override
public String getNotesKey() {
return "entry_" + entry.unlocalizedName + "_" + page;
}
}
@@ -1,59 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 2, 2015, 6:27:58 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.CompoundNBT;
import vazkii.botania.api.lexicon.ILexicon;
import vazkii.botania.api.lexicon.LexiconEntry;
import java.util.ArrayList;
import java.util.List;
public class GuiLexiconHistory extends GuiLexiconIndex {
public static final List<LexiconEntry> history = new ArrayList<>();
public GuiLexiconHistory() {
super(null);
title = I18n.format("botaniamisc.historyLong");
}
@Override
void buildEntries() {
entriesToDisplay.clear();
ILexicon lex = (ILexicon) stackUsed.getItem();
for(int i = history.size() - 1; i >= 0; i--) {
LexiconEntry entry = history.get(i);
if(lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && I18n.format(entry.getUnlocalizedName()).toLowerCase().contains(searchField.getText().toLowerCase().trim()))
entriesToDisplay.add(entry);
}
}
public static void visit(LexiconEntry entry) {
history.remove(entry);
history.add(entry);
}
@Override
public GuiLexicon copy() {
return new GuiLexiconHistory();
}
@Override
public void load(CompoundNBT cmp) {}
@Override
public String getNotesKey() {
return "history";
}
}
@@ -1,464 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 6:46:59 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.button.Button;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import org.lwjgl.glfw.GLFW;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.ILexicon;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBack;
import vazkii.botania.client.gui.lexicon.button.GuiButtonIndexEntry;
import vazkii.botania.client.gui.lexicon.button.GuiButtonPage;
import vazkii.botania.common.lexicon.DogLexiconEntry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class GuiLexiconIndex extends GuiLexicon implements IParented {
private static final String TAG_CATEGORY = "category";
private static final String TAG_PAGE = "page";
LexiconCategory category;
String title;
public int page = 0;
private int tutPage = -1;
private Button leftButton, rightButton, backButton;
private GuiLexicon parent;
TextFieldWidget searchField;
private Button currentButton;
private LexiconEntry currentEntry;
private float infoTime;
final List<LexiconEntry> entriesToDisplay = new ArrayList<>();
public GuiLexiconIndex(LexiconCategory category) {
super(new TranslationTextComponent("botaniamisc.lexiconIndex"));
this.category = category;
this.parent = new GuiLexicon();
}
// No-arg constructor for bookmark serialization
public GuiLexiconIndex() {
this(BotaniaAPI.categoryBasics);
}
@Override
boolean isMainPage() {
return false;
}
@Override
public ITextComponent getTitle() {
return category == null ? super.getTitle() : new TranslationTextComponent(category.getUnlocalizedName());
}
@Override
boolean isIndex() {
return true;
}
@Override
boolean isCategoryIndex() {
return false;
}
@Override
public void onInitGui() {
super.onInitGui();
if(!GuiLexicon.isValidLexiconGui(this)) {
currentOpenLexicon = new GuiLexicon();
mc.displayGuiScreen(currentOpenLexicon);
ClientTickHandler.notifyPageChange();
return;
}
addButton(backButton = new GuiButtonBack(left + guiWidth / 2 - 8, top + guiHeight + 2, b -> {
mc.displayGuiScreen(parent);
ClientTickHandler.notifyPageChange();
}));
addButton(leftButton = new GuiButtonPage(left, top + guiHeight - 10, false, b -> {
page--;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
}));
addButton(rightButton = new GuiButtonPage(left + guiWidth - 18, top + guiHeight - 10, true, b -> {
page++;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
}));
searchField = new TextFieldWidget(font, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10, "");
searchField.setCanLoseFocus(false);
searchField.changeFocus(true);
searchField.setEnableBackgroundDrawing(false);
updateAll();
}
private void updateAll() {
buildEntries();
updatePageButtons();
populateIndex();
}
void buildEntries() {
entriesToDisplay.clear();
ILexicon lex = (ILexicon) stackUsed.getItem();
for(LexiconEntry entry : category == null ? BotaniaAPI.getAllEntries() : category.entries) {
if(entry.isVisible() && lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && matchesSearch(entry))
entriesToDisplay.add(entry);
}
Collections.sort(entriesToDisplay);
}
private boolean matchesSearch(LexiconEntry e) {
String search = searchField.getText().trim();
if(search.isEmpty())
return true;
search = search.toLowerCase();
if(I18n.format(e.getUnlocalizedName()).toLowerCase().contains(search))
return true;
for(ItemStack stack : e.getDisplayedRecipes()) {
String stackName = stack.getDisplayName().getString().trim();
if(stackName.contains(search))
return true;
}
return false;
}
@Override
void populateIndex() {
LexiconEntry tutEntry = !tutorial.isEmpty() ? tutorial.peek() : null;
for(int i = page * 12; i < (page + 1) * 12; i++) {
GuiButtonIndexEntry button = (GuiButtonIndexEntry) buttons.get(i - page * 12);
LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i);
if(entry != null) {
button.setMessage(entry.getKnowledgeType().color + "" + (entry.isPriority() ? TextFormatting.ITALIC : "") + I18n.format(entry.getUnlocalizedName()));
button.displayStack = entry.getIcon();
if(entry == tutEntry)
tutPage = page;
if(entry instanceof DogLexiconEntry)
button.dog = true;
} else button.setMessage("");
}
}
public void setHoveredButton(GuiButtonIndexEntry b) {
if(b == null)
currentEntry = null;
else currentEntry = entriesToDisplay.get(b.ordinal + page * 12);
currentButton = b;
}
@Override
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
super.drawScreenAfterScale(xCoord, yCoord, newPartialTicks);
if(!searchField.getText().isEmpty()) {
drawBookmark(left + 138, top + guiHeight - 24, " " + searchField.getText(), false);
mc.textureManager.bindTexture(texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(left + 134, top + guiHeight - 26, 86, 180, 12, 12);
if(entriesToDisplay.size() == 1) {
String s = I18n.format("botaniamisc.enterToView");
mc.fontRenderer.drawString(s, left + guiWidth / 2 - mc.fontRenderer.getStringWidth(s) / 2, top + 30, 0x666666);
}
} else {
String s = I18n.format("botaniamisc.typeToSearch");
mc.fontRenderer.drawString(s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666);
}
float animationTime = 4F;
if(hasShiftDown()) {
if(currentButton != null)
infoTime = Math.min(animationTime, infoTime + timeDelta);
} else {
infoTime = Math.max(0, infoTime - timeDelta);
if(currentButton != null && infoTime == 0) {
int x;
int y;
x = currentButton.x - 20;
y = currentButton.y;
mc.fontRenderer.drawStringWithShadow("?", x, y, 0xFFFFFF);
GlStateManager.scalef(0.5F, 0.5F, 1F);
mc.fontRenderer.drawStringWithShadow(TextFormatting.BOLD + "Shift", x * 2 - 6, y * 2 + 20, 0xFFFFFF);
GlStateManager.scalef(2F, 2F, 1F);
}
}
if(currentButton != null && infoTime > 0) {
float fract = infoTime / animationTime;
int x = currentButton.x;
int y = currentButton.y;
String s = I18n.format(currentEntry.getTagline());
int width = mc.fontRenderer.getStringWidth(s);
GlStateManager.pushMatrix();
GlStateManager.translatef(x, y, 0);
GlStateManager.scalef(fract, 1F, 1F);
AbstractGui.fill(12, -30, width + 20, -2, 0x44000000);
AbstractGui.fill(10, -32, width + 22, -2, 0x44000000);
drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF, 180);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
ItemStack paper = new ItemStack(Items.PAPER, currentEntry.pages.size());
mc.getItemRenderer().renderItemAndEffectIntoGUI(paper, 14, -28);
mc.getItemRenderer().renderItemOverlays(mc.fontRenderer, paper, 14, -28);
List<ItemStack> stacks = currentEntry.getDisplayedRecipes();
if(stacks.size() > 0) {
int spaceForEach = Math.min(18, (width - 30) / stacks.size());
for(int i = 0; i < stacks.size(); i++) {
ItemStack stack = stacks.get(i);
mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, 38 + spaceForEach * i, -28);
}
}
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
}
setHoveredButton(null);
}
@Override
public void positionTutorialArrow() {
LexiconEntry entry = tutorial.peek();
LexiconCategory category = entry.category;
if(category != this.category) {
orientTutorialArrowWithButton(backButton);
return;
}
if(tutPage != -1 && tutPage != page) {
orientTutorialArrowWithButton(tutPage < page ? leftButton : rightButton);
return;
}
for(Widget widget : buttons) {
if(widget instanceof GuiButtonIndexEntry) {
GuiButtonIndexEntry button = (GuiButtonIndexEntry) widget;
int id = button.ordinal;
int index = id + page * 12;
if(index >= entriesToDisplay.size())
continue;
if(entry == entriesToDisplay.get(index)) {
orientTutorialArrowWithButton(id >= 12 ? rightButton : button);
break;
}
}
}
}
public void openEntry(int index) {
if(index >= entriesToDisplay.size())
return;
LexiconEntry entry = entriesToDisplay.get(index);
mc.displayGuiScreen(new GuiLexiconEntry(entry, this));
ClientTickHandler.notifyPageChange();
}
private void updatePageButtons() {
leftButton.active = page != 0;
rightButton.active = page < (entriesToDisplay.size() - 1) / 12;
putTutorialArrow();
}
@Override
public void setParent(GuiLexicon gui) {
parent = gui;
}
private boolean swiped = false;
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
if(button == GLFW.GLFW_MOUSE_BUTTON_LEFT && dragX > 100 && mc.gameSettings.touchscreen && !swiped) {
// todo 1.13 correct these constants
if(dragX < 0.5) {
nextPage();
swiped = true;
} else if(dragY > 0.5) {
prevPage();
swiped = true;
}
return true;
}
return false;
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if(button == GLFW.GLFW_MOUSE_BUTTON_LEFT)
swiped = false;
// todo 1.13 might not be needed with focus changes in super?
if (searchField.mouseClicked(mouseX, mouseY, button))
return true;
switch(button) {
case 1:
back();
return true;
case 3:
nextPage();
return true;
case 4:
prevPage();
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public boolean mouseScrolled(double x, double y, double w) {
if(w < 0)
nextPage();
else if(w > 0)
prevPage();
return true;
}
@Override
boolean closeScreenOnInvKey() {
return false;
}
@Override
public boolean charTyped(char codePoint, int mods) {
if(!notesEnabled) {
// todo 1.13 use focus system?
String search = searchField.getText();
searchField.charTyped(codePoint, mods);
if(!searchField.getText().equalsIgnoreCase(search))
updateAll();
return true;
}
return super.charTyped(codePoint, mods);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int mods) {
if(keyCode == GLFW.GLFW_KEY_LEFT || keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_PAGE_UP) {
prevPage();
return true;
} else if(keyCode == GLFW.GLFW_KEY_RIGHT || keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_PAGE_DOWN) {
nextPage();
return true;
} else if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled && searchField.getText().isEmpty()) {
back();
return true;
} else if(keyCode == GLFW.GLFW_KEY_HOME) {
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
return true;
} else if(keyCode == GLFW.GLFW_KEY_ENTER && entriesToDisplay.size() == 1) {
openEntry(0);
return true;
} else {
return super.keyPressed(keyCode, scanCode, mods);
}
}
private void back() {
if(backButton.active) {
backButton.playDownSound(mc.getSoundHandler());
backButton.onClick(backButton.x, backButton.y);
}
}
private void nextPage() {
if(rightButton.active) {
rightButton.playDownSound(mc.getSoundHandler());
rightButton.onClick(rightButton.x, rightButton.y);
}
}
private void prevPage() {
if(leftButton.active) {
leftButton.playDownSound(mc.getSoundHandler());
leftButton.onClick(leftButton.x, leftButton.y);
}
}
@Override
public void serialize(CompoundNBT cmp) {
super.serialize(cmp);
cmp.putString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName());
cmp.putInt(TAG_PAGE, page);
}
@Override
public void load(CompoundNBT cmp) {
super.load(cmp);
String categoryStr = cmp.getString(TAG_CATEGORY);
if(categoryStr.isEmpty())
category = null;
else for(LexiconCategory cat : BotaniaAPI.getAllCategories())
if(cat.getUnlocalizedName().equals(categoryStr)) {
category = cat;
break;
}
page = cmp.getInt(TAG_PAGE);
}
@Override
public GuiLexicon copy() {
GuiLexiconIndex gui = new GuiLexiconIndex(category);
gui.page = page;
return gui;
}
@Override
public String getNotesKey() {
return "category_" + (category == null ? "lexindex" : category.unlocalizedName);
}
}
@@ -1,7 +0,0 @@
package vazkii.botania.client.gui.lexicon;
public interface IParented {
public void setParent(GuiLexicon gui);
}
@@ -1,58 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Apr 3, 2015, 5:44:36 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.advancements.AdvancementsScreen;
import net.minecraft.client.gui.advancements.AdvancementsScreen;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonAchievement extends GuiButtonLexicon {
public GuiButtonAchievement(int x, int y) {
super(x, y, 11, 11, "", b -> {
if(Minecraft.getInstance().player != null) {
AdvancementsScreen gui = new AdvancementsScreen(Minecraft.getInstance().player.connection.getAdvancementManager());
Minecraft.getInstance().displayGuiScreen(gui);
ResourceLocation tab = new ResourceLocation(LibMisc.MOD_ID, "main/root");
gui.setSelectedTab(Minecraft.getInstance().player.connection.getAdvancementManager().getAdvancementList().getAdvancement(tab));
}
});
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 109 : 98, 191, 11, 11);
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.advancements"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,50 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 9:54:21 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
public class GuiButtonBack extends GuiButtonLexicon {
public GuiButtonBack(int x, int y, IPressable onPress) {
super(x, y, 18, 9, "", onPress);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
if(active) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, 36, k == 2 ? 180 : 189, 18, 9);
List<String> tooltip = getTooltip();
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
public List<String> getTooltip() {
return Collections.singletonList(I18n.format("botaniamisc.back"));
}
}
@@ -1,30 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 6, 2014, 6:35:32 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import java.util.Arrays;
import java.util.List;
public class GuiButtonBackWithShift extends GuiButtonBack {
public GuiButtonBackWithShift(int x, int y, IPressable onPress) {
super(x, y, onPress);
}
@Override
public List<String> getTooltip() {
return Arrays.asList(I18n.format("botaniamisc.back"), TextFormatting.GRAY + I18n.format("botaniamisc.clickToIndex"));
}
}
@@ -1,77 +0,0 @@
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.IParented;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonBookmark extends GuiButtonLexicon {
private final int ordinal;
final GuiLexicon gui;
public GuiButtonBookmark(int ordinal, int x, int y, GuiLexicon gui, String str) {
super(x, y, gui.bookmarkWidth(str) + 5, 11, str, b -> {
boolean modified = false;
String key = gui.getNotesKey();
if(ordinal == GuiLexicon.bookmarks.size()) {
if(!GuiLexicon.bookmarkKeys.contains(key)) {
GuiLexicon.bookmarks.add(gui.copy());
GuiLexicon.bookmarkKeys.add(key);
modified = true;
}
} else {
if(Screen.hasShiftDown()) {
GuiLexicon.bookmarks.remove(ordinal);
GuiLexicon.bookmarkKeys.remove(ordinal);
modified = true;
} else {
GuiLexicon bookmark = GuiLexicon.bookmarks.get(ordinal).copy();
if(!bookmark.getTitle().equals(gui.getTitle())) {
Minecraft.getInstance().displayGuiScreen(bookmark);
if(bookmark instanceof IParented)
((IParented) bookmark).setParent(gui);
ClientTickHandler.notifyPageChange();
}
}
}
gui.bookmarksNeedPopulation = true;
if(modified)
PersistentVariableHelper.saveSafe();
});
this.ordinal = ordinal;
this.gui = gui;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
gui.drawBookmark(x, y, getMessage(), false);
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
List<String> tooltip = new ArrayList<>();
if(getMessage().equals("+"))
tooltip.add(I18n.format("botaniamisc.clickToAdd"));
else {
tooltip.add(I18n.format("botaniamisc.bookmark", ordinal));
tooltip.add(TextFormatting.GRAY + I18n.format("botaniamisc.clickToSee"));
tooltip.add(TextFormatting.GRAY + I18n.format("botaniamisc.shiftToRemove"));
}
int tooltipY = (tooltip.size() + 1) * 5;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,146 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Oct 18, 2014, 4:00:30 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.ARBMultitexture;
import org.lwjgl.opengl.ARBShaderObjects;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.internal.ShaderCallback;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.ConfigHandler;
import javax.annotation.Nonnull;
public class GuiButtonCategory extends GuiButtonLexicon {
private static final ResourceLocation fallbackResource = new ResourceLocation(LibResources.CATEGORY_INDEX);
private static final ResourceLocation stencilResource = new ResourceLocation(LibResources.GUI_STENCIL);
private static boolean boundStencil = false;
final GuiLexicon gui;
private final LexiconCategory category;
private ResourceLocation resource = null;
private float ticksHovered = 0F;
private final float time = 12F;
private final ShaderCallback shaderCallback = shader -> {
TextureManager r = Minecraft.getInstance().textureManager;
int heightMatchUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "heightMatch");
int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image");
int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask");
float heightMatch = ticksHovered / time;
GLX.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(resource).getGlTextureId());
ARBShaderObjects.glUniform1iARB(imageUniform, 0);
GLX.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.CLIENT.glSecondaryTextureUnit.get());
GlStateManager.enableTexture();
GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(stencilResource).getGlTextureId());
ARBShaderObjects.glUniform1iARB(maskUniform, ConfigHandler.CLIENT.glSecondaryTextureUnit.get());
ARBShaderObjects.glUniform1fARB(heightMatchUniform, heightMatch);
};
public GuiButtonCategory(int x, int y, GuiLexicon gui, LexiconCategory category) {
super(x, y, 16, 16, "", b -> {
Minecraft.getInstance().displayGuiScreen(new GuiLexiconIndex(category));
ClientTickHandler.notifyPageChange();
});
this.gui = gui;
this.category = category;
}
@Override
public void onClick(double mouseX, double mouseY) {
super.onClick(mouseX, mouseY);
}
@Override
public void render(int mx, int my, float partialTicks) {
boolean inside = isHovered();
if(inside)
ticksHovered = Math.min(time, ticksHovered + gui.timeDelta);
else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta);
if(resource == null) {
if(category == null)
resource = fallbackResource;
else resource = category.getIcon();
if(resource == null)
resource = fallbackResource;
}
float s = 1F / 32F;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.color4f(1F, 1F, 1F, 1F);
if(!boundStencil) { // Allow for the texture manager to take care of the ResourceLocation before we use it directly with gl
Minecraft.getInstance().textureManager.bindTexture(stencilResource);
boundStencil = true;
}
Minecraft.getInstance().textureManager.bindTexture(resource);
int texture = 0;
boolean shaders = ShaderHelper.useShaders();
if(shaders) {
GLX.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.CLIENT.glSecondaryTextureUnit.get());
texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
}
ShaderHelper.useShader(ShaderHelper.categoryButton, shaderCallback);
RenderHelper.drawTexturedModalRect(x * 2, y * 2, blitOffset * 2, 0, 0, 32, 32, s, s);
ShaderHelper.releaseShader();
if(shaders) {
GLX.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.CLIENT.glSecondaryTextureUnit.get());
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GLX.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
}
GlStateManager.popMatrix();
if(inside)
gui.categoryHighlight = I18n.format(getTooltipText());
}
private String getTooltipText() {
if(category == null)
return "botaniamisc.lexiconIndex";
return category.getUnlocalizedName();
}
public LexiconCategory getCategory() {
return category;
}
}
@@ -1,64 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 29, 2015, 5:00:30 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.challenge.Challenge;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconChallenge;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonChallengeIcon extends GuiButtonLexicon {
public final Challenge challenge;
private final GuiLexicon owner;
public GuiButtonChallengeIcon(int x, int y, Challenge challenge, GuiLexicon owner) {
super(x, y, 16, 16, "", b -> Minecraft.getInstance().displayGuiScreen(new GuiLexiconChallenge(owner, challenge)));
this.challenge = challenge;
this.owner = owner;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(challenge.icon, x, y);
RenderHelper.disableStandardItemLighting();
GlStateManager.enableBlend();
if(challenge.complete) {
GlStateManager.disableDepthTest();
Minecraft.getInstance().fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00);
Minecraft.getInstance().fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D);
GlStateManager.enableDepthTest();
}
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.AQUA + I18n.format(challenge.unlocalizedName));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,51 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 29, 2015, 7:42:52 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonChallengeInfo extends GuiButtonLexicon {
final GuiLexicon gui;
public GuiButtonChallengeInfo(int x, int y, String str, GuiLexicon gui) {
super(x, y, gui.bookmarkWidth(str) + 5, 11, str, b -> {
Minecraft.getInstance().displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, gui));
ClientTickHandler.notifyPageChange();
});
this.gui = gui;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
gui.drawBookmark(x, y, getMessage(), false);
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
List<String> tooltip = new ArrayList<>();
tooltip.add(I18n.format("botaniamisc.challengeInfo"));
int tooltipY = (tooltip.size() + 1) * 5;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,50 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 29, 2015, 4:16:09 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconChallengesList;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonChallenges extends GuiButtonLexicon {
public GuiButtonChallenges(int x, int y) {
super(x, y, 11, 11, "", b -> {
Minecraft.getInstance().displayGuiScreen(new GuiLexiconChallengesList());
});
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 131 : 120, 180, 11, 11);
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.challenges"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,58 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Oct 11, 2015, 7:04:46 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
// Ssssshhhhhhh
// I should've done this last year
public class GuiButtonDoot extends GuiButtonLexicon {
public GuiButtonDoot(int x, int y) {
super(x, y, 16, 16, "", b -> {});
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
GlStateManager.color4f(1F, 1F, 1F, 1F);
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(new ItemStack(ModItems.cacophonium), x, y);
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(new ItemStack(Items.FIREWORK_ROCKET), x + 8, y + 2);
GlStateManager.disableLighting();
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.LIGHT_PURPLE + "Happy Birthday Vazkii!");
tooltip.add(TextFormatting.GRAY + "doot doot");
if(k == 2)
RenderHelper.renderTooltip(x - 100, y + 36, tooltip);
GlStateManager.enableAlphaTest();
}
}
@@ -1,52 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 2, 2015, 6:01:26 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconHistory;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonHistory extends GuiButtonLexicon {
final GuiLexicon gui;
public GuiButtonHistory(int x, int y, String str, GuiLexicon gui) {
super(x, y, gui.bookmarkWidth(str) + 5, 11, str, b -> {
Minecraft.getInstance().displayGuiScreen(new GuiLexiconHistory());
ClientTickHandler.notifyPageChange();
});
this.gui = gui;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
gui.drawBookmark(x, y, getMessage(), false);
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
List<String> tooltip = new ArrayList<>();
tooltip.add(I18n.format("botaniamisc.historyLong"));
tooltip.add(TextFormatting.GRAY + I18n.format("botaniamisc.historyDesc"));
int tooltipY = (tooltip.size() + 1) * 5;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,120 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 14, 2014, 8:34:01 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.helper.FontHelper;
import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.lib.LibMisc;
public class GuiButtonIndexEntry extends GuiButtonLexicon {
private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG);
private static final IPressable ON_PRESS = b -> {
GuiButtonIndexEntry button = (GuiButtonIndexEntry) b;
if (button.dog) {
button.enableDog = true;
PersistentVariableHelper.dog = true;
PersistentVariableHelper.saveSafe();
} else {
int index = button.ordinal + button.gui.page * 12;
button.gui.openEntry(index);
}
};
public final int ordinal;
private final GuiLexiconIndex gui;
public ItemStack displayStack = ItemStack.EMPTY;
public boolean dog = false;
private float timeHover = 0;
private boolean enableDog = false;
private double dogPos = 0;
public GuiButtonIndexEntry(GuiLexiconIndex gui, int ordinal, int x, int y, int width, int height, String text) {
super(x, y, width, height, text, ON_PRESS);
this.ordinal = ordinal;
this.gui = gui;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
if(enableDog) {
dogPos += ClientTickHandler.delta * 10;
Minecraft.getInstance().textureManager.bindTexture(dogResource);
float f = 1F / 64F;
GlStateManager.translated(dogPos, 0, 0);
GlStateManager.color4f(1F, 1F, 1F, 1F);
vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(0, y, blitOffset + 10, dogPos % 100 < 50 ? 23 : 0, 0, 23, 19, f, f);
x = (int) Math.max(x, dogPos + 10);
GlStateManager.translated(-dogPos, 0, 0);
}
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
boolean showStack = !displayStack.isEmpty() && !getMessage().isEmpty();
if(!getMessage().isEmpty() && k == 2) {
timeHover = Math.min(5, timeHover + gui.timeDelta);
gui.setHoveredButton(this);
} else timeHover = Math.max(0, timeHover - gui.timeDelta);
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.disableAlphaTest();
int color = 0;
String format = FontHelper.getFormatFromString(getMessage());
if(format.length() > 1) {
char key = format.charAt(format.length() - 1);
if(key == 'o' && format.length() > 3)
key = format.charAt(1);
for(TextFormatting ecf : TextFormatting.class.getEnumConstants())
if(ecf.toString().indexOf(ecf.toString().length() - 1) == key) {
if(ecf.ordinal() > 15)
ecf = TextFormatting.BLACK;
color = LibMisc.CONTROL_CODE_COLORS[ecf.ordinal()];
break;
}
}
int maxalpha = 0x22;
int alpha = Math.min(maxalpha, (int) (timeHover / 4 * maxalpha));
fill(x - 5, y, (int) (x - 5 + timeHover * 24), y + height, alpha << 24 | color);
GlStateManager.enableAlphaTest();
Minecraft.getInstance().fontRenderer.drawString(getMessage(), x + (showStack ? 7 : 0), y + (height - 8) / 2, 0);
if(showStack) {
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(displayStack, x * 2 - 6, y * 2 + 4);
RenderHelper.disableStandardItemLighting();
GlStateManager.enableBlend();
}
GlStateManager.popMatrix();
}
}
@@ -1,30 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Aug 7, 2014, 5:53:16 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.audio.SimpleSound;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.widget.button.Button;
import vazkii.botania.common.core.handler.ModSounds;
public class GuiButtonLexicon extends Button {
public GuiButtonLexicon(int x, int y, int width, int height, String text, IPressable onPress) {
super(x, y, width, height, text, onPress);
}
@Override
public void playDownSound(SoundHandler handler) {
handler.play(SimpleSound.master(ModSounds.lexiconPage, 1.0F));
}
}
@@ -1,56 +0,0 @@
/**
* This class was created by <Vazkii>. 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 24, 2015, 2:49:36 AM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonNotes extends GuiButtonLexicon {
private final GuiLexicon parent;
public GuiButtonNotes(GuiLexicon parent, int x, int y) {
super(x, y, 11, 11, "", b -> GuiLexicon.notesEnabled = !GuiLexicon.notesEnabled);
this.parent = parent;
}
@Override
public void render(int x, int y, float partialTicks) {
isHovered = x >= this.x && y >= this.y && x < this.x + width && y < this.y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 130 : 120, 191, 10, 11);
List<String> tooltip = new ArrayList<>();
if(GuiLexicon.notesEnabled)
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.hideNotes"));
else {
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.showNotes"));
if(parent.note != null && !parent.note.isEmpty())
Minecraft.getInstance().fontRenderer.drawStringWithShadow("!", x + 10, y, 0xFF0000);
}
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(x, y + tooltipY, tooltip);
}
}
@@ -1,49 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 6, 2015, 1:14:05 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonOptions extends GuiButtonLexicon {
public GuiButtonOptions(int x, int y) {
super(x, y, 11, 11, "", b -> {
// todo 1.14 config gui
});
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 109 : 98, 180, 11, 11);
List<String> tooltip = new ArrayList<>();
for(int i = 0; i < 3; i++)
tooltip.add((i == 0 ? TextFormatting.GREEN : TextFormatting.GRAY) + I18n.format("botaniamisc.lexiconOptions" + i));
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY, tooltip);
}
}
@@ -1,46 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jan 16, 2014, 4:52:06 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.Collections;
public class GuiButtonPage extends GuiButtonLexicon {
private final boolean right;
public GuiButtonPage(int x, int y, boolean right, IPressable onPress) {
super(x, y, 18, 10, "", onPress);
this.right = right;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
if(active) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10);
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY, Collections.singletonList(I18n.format(right ? "botaniamisc.nextPage" : "botaniamisc.prevPage")));
}
}
}
@@ -1,56 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [12/09/2016, 03:17:42 (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonScaleChange extends GuiButtonLexicon {
public GuiButtonScaleChange(int x, int y) {
super(x, y, 11, 11, "", b -> {
int maxAllowed = GuiLexicon.getMaxAllowedScale();
if(PersistentVariableHelper.lexiconGuiScale >= maxAllowed)
PersistentVariableHelper.lexiconGuiScale = 2;
else PersistentVariableHelper.lexiconGuiScale++;
PersistentVariableHelper.saveSafe();
Minecraft.getInstance().displayGuiScreen(new GuiLexicon());
});
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 152 : 141, 191, 11, 11);
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.scaleChange"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -1,48 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Sep 24, 2014, 3:49:21 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
public class GuiButtonShare extends GuiButtonLexicon {
public GuiButtonShare(int x, int y, IPressable onPress) {
super(x, y, 10, 12, "", onPress);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 10 : 0 , 200, 10, 12);
List<String> tooltip = getTooltip();
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
public List<String> getTooltip() {
return Collections.singletonList(TextFormatting.AQUA + I18n.format("botaniamisc.clickToShare"));
}
}
@@ -1,79 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Aug 25, 2015, 6:13:11 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.Screen;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.awt.*;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
public class GuiButtonUpdateWarning extends GuiButtonLexicon {
private static final IPressable OPEN_CHANGELOG = b -> {
if(Screen.hasShiftDown()) {
try {
if(Desktop.isDesktopSupported())
Desktop.getDesktop().browse(new URI("http://botaniamod.net/changelog.php#" + PersistentVariableHelper.lastBotaniaVersion.replaceAll("\\.|\\s", "-")));
} catch (Exception e) {
e.printStackTrace();
}
} else {
PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION;
PersistentVariableHelper.saveSafe();
b.visible = false;
b.active = false;
}
};
public GuiButtonUpdateWarning(int x, int y) {
super(x, y, 11, 11, "", OPEN_CHANGELOG);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
if(!visible || !active)
return;
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
boolean red = k == 2 || ClientTickHandler.ticksInGame % 10 < 5;
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, red ? 153 : 142, 180, 11, 11);
List<String> tooltip = new ArrayList<>();
String version = PersistentVariableHelper.lastBotaniaVersion;
for(int i = 0; i < 6; i++) {
tooltip.add(TextFormatting.GRAY + I18n.format("botaniamisc.changes" + i, version).replaceAll("&", "\u00a7"));
if(i == 3)
tooltip.add("");
}
int tooltipY = (tooltip.size() - 1) * 10 - 25;
if(k == 2)
RenderHelper.renderTooltip(mouseX - 125, mouseY + tooltipY, tooltip);
}
}
@@ -1,45 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Mar 2, 2015, 5:34:05 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
public class GuiButtonViewOnline extends GuiButtonLexicon {
public GuiButtonViewOnline(int x, int y, IPressable onPress) {
super(x, y, 11, 11, "", onPress);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
int k = getYImage(isHovered());
Minecraft.getInstance().textureManager.bindTexture(GuiLexicon.texture);
GlStateManager.color4f(1F, 1F, 1F, 1F);
blit(x, y, k == 2 ? 41 : 30, 200, 11, 11);
List<String> tooltip = Collections.singletonList(TextFormatting.AQUA + I18n.format("botaniamisc.viewOnline"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(mouseX, mouseY + tooltipY, tooltip);
}
}
@@ -96,7 +96,6 @@ public class MultiCraftingProcessor implements IComponentProcessor {
return recipes.stream().map(IRecipe::getRecipeOutput).map(PatchouliAPI.instance::serializeItemStack).collect(Collectors.joining(","));
}
if(key.equals("shapeless")) {
return shapeless ? I18n.format("patchouli.gui.lexicon.shapeless") : "";
}
return null;
}
@@ -18,21 +18,17 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.mana.IPoolOverlayProvider;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.handler.MultiblockRenderHandler;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.core.proxy.ClientProxy;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.mana.BlockPool;
import vazkii.botania.common.block.tile.mana.TilePool;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.Color;
import java.util.Random;
@@ -53,9 +49,8 @@ public class RenderTilePool extends TileEntityRenderer<TilePool> {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableRescaleNormal();
float a = MultiblockRenderHandler.rendering ? 0.6F : 1F;
GlStateManager.color4f(1F, 1F, 1F, a);
GlStateManager.color4f(1F, 1F, 1F, 1F);
if (pool == null) { // A null pool means we are calling the TESR without a pool (on a minecart). Adjust accordingly
GlStateManager.translatef(0, 0, -1);
} else {
@@ -83,7 +78,7 @@ public class RenderTilePool extends TileEntityRenderer<TilePool> {
}
GlStateManager.translatef(0.5F, 1.5F, 0.5F);
GlStateManager.color4f(1, 1, 1, a);
GlStateManager.color4f(1, 1, 1, 1);
GlStateManager.enableRescaleNormal();
int mana = pool == null ? forceManaNumber : pool.getCurrentMana();
@@ -106,7 +101,7 @@ public class RenderTilePool extends TileEntityRenderer<TilePool> {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.disableAlphaTest();
GlStateManager.color4f(1F, 1F, 1F, a * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2));
GlStateManager.color4f(1F, 1F, 1F, 1 * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2));
GlStateManager.translatef(-0.5F, -1F - 0.43F, -0.5F);
GlStateManager.rotatef(90F, 1F, 0F, 0F);
GlStateManager.scalef(s, s, s);
@@ -126,7 +121,7 @@ public class RenderTilePool extends TileEntityRenderer<TilePool> {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.disableAlphaTest();
GlStateManager.color4f(1F, 1F, 1F, a);
GlStateManager.color4f(1F, 1F, 1F, 1F);
GlStateManager.translatef(w, -1F - (0.43F - waterLevel), w);
GlStateManager.rotatef(90F, 1F, 0F, 0F);
GlStateManager.scalef(s, s, s);
@@ -24,16 +24,10 @@ import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockReader;
import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook;
import vazkii.botania.api.lexicon.multiblock.Multiblock;
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.MultiblockRenderHandler;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.IPylonModel;
@@ -41,10 +35,9 @@ import vazkii.botania.client.model.ModelPylonGaia;
import vazkii.botania.client.model.ModelPylonMana;
import vazkii.botania.client.model.ModelPylonNatura;
import vazkii.botania.common.block.BlockPylon;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TilePylon;
public class RenderTilePylon extends TileEntityRenderer<TilePylon> implements IMultiblockRenderHook {
public class RenderTilePylon extends TileEntityRenderer<TilePylon> {
private static final ResourceLocation MANA_TEXTURE = new ResourceLocation(LibResources.MODEL_PYLON_MANA);
private static final ResourceLocation NATURA_TEXTURE = new ResourceLocation(LibResources.MODEL_PYLON_NATURA);
@@ -91,8 +84,7 @@ public class RenderTilePylon extends TileEntityRenderer<TilePylon> implements IM
GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
float a = MultiblockRenderHandler.rendering ? 0.6F : 1F;
GlStateManager.color4f(1F, 1F, 1F, a);
GlStateManager.color4f(1F, 1F, 1F, 1F);
double worldTime = (double) (ClientTickHandler.ticksInGame + pticks);
@@ -147,17 +139,4 @@ public class RenderTilePylon extends TileEntityRenderer<TilePylon> implements IM
}
}
}
@Override
public void renderBlockForMultiblock(IBlockReader world, Multiblock mb, BlockState state, MultiblockComponent comp) {
forceVariant = ((BlockPylon) state.getBlock()).variant;
GlStateManager.translatef(-0.5F, -0.25F, -0.5F);
renderPylon(null, 0, 0, 0, 0);
forceVariant = BlockPylon.Variant.MANA;
}
@Override
public boolean needsTranslate(BlockState state) {
return true;
}
}
@@ -35,14 +35,10 @@ import org.apache.logging.log4j.Logger;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.capability.FloatingFlowerImpl;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.lexicon.ITwoNamedPage;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.client.core.proxy.ClientProxy;
import vazkii.botania.common.advancements.*;
import vazkii.botania.common.block.ModBanners;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.ModMultiblocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.brew.ModBrews;
import vazkii.botania.common.core.command.CommandSkyblockSpread;
@@ -116,7 +112,6 @@ public class Botania {
PacketHandler.init();
ModBrews.init();
ModMultiblocks.init();
if(Botania.thaumcraftLoaded) {
if(ConfigHandler.COMMON.enableThaumcraftAspects.get()) {
@@ -27,21 +27,18 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.state.enums.AlfPortalState;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.advancements.AlfPortalTrigger;
import vazkii.botania.common.block.tile.TileAlfPortal;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class BlockAlfPortal extends BlockMod implements IWandable, ILexiconable {
public class BlockAlfPortal extends BlockMod implements IWandable {
public BlockAlfPortal(Properties builder) {
super(builder);
@@ -64,11 +61,6 @@ public class BlockAlfPortal extends BlockMod implements IWandable, ILexiconable
return new TileAlfPortal();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.alfhomancyIntro;
}
@Override
public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) {
boolean did = ((TileAlfPortal) world.getTileEntity(pos)).onWanded();
@@ -28,15 +28,12 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.PlantType;
import net.minecraftforge.common.ToolType;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.fx.SparkleParticleData;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockAltGrass extends BlockMod implements ILexiconable {
public class BlockAltGrass extends BlockMod {
public enum Variant {
DRY,
@@ -124,9 +121,4 @@ public class BlockAltGrass extends BlockMod implements ILexiconable {
break;
}
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.grassSeeds;
}
}
@@ -42,8 +42,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.ItemHandlerHelper;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.tile.TileAltar;
@@ -51,11 +49,10 @@ import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.rod.ItemWaterRod;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockAltar extends BlockMod implements ILexiconable {
public class BlockAltar extends BlockMod {
private static final VoxelShape BASE = Block.makeCuboidShape(0, 0, 0, 16, 2, 16);
private static final VoxelShape MIDDLE = Block.makeCuboidShape(2, 2, 2, 14, 12, 14);
@@ -230,9 +227,4 @@ public class BlockAltar extends BlockMod implements ILexiconable {
TileAltar altar = (TileAltar) world.getTileEntity(pos);
return altar.getFluid() == Fluids.WATER ? 15 : 0;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.apothecary;
}
}
@@ -30,17 +30,14 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.item.IHourglassTrigger;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.IManaTrigger;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.tile.TileAnimatedTorch;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrigger, IHourglassTrigger, IWandHUD, ILexiconable {
public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrigger, IHourglassTrigger, IWandHUD {
private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 4, 16);
@@ -138,9 +135,4 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig
super.onPlayerDestroy(world, pos, state);
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.animatedTorch;
}
}
@@ -30,18 +30,15 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.items.ItemHandlerHelper;
import vazkii.botania.api.item.IAvatarWieldable;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.tile.TileAvatar;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockAvatar extends BlockMod implements ILexiconable {
public class BlockAvatar extends BlockMod {
private static final VoxelShape X_AABB = makeCuboidShape(5, 0, 3.5, 11, 17, 12.5);
private static final VoxelShape Z_AABB = makeCuboidShape(3.5, 0, 5, 12.5, 17, 11);
@@ -113,11 +110,6 @@ public class BlockAvatar extends BlockMod implements ILexiconable {
return new TileAvatar();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.avatar;
}
@Nonnull
@Override
public BlockState mirror(@Nonnull BlockState state, Mirror mirror) {
@@ -17,14 +17,13 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockReader;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.common.block.tile.TileBifrost;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockBifrost extends BlockBifrostPerm implements ILexiconable {
public class BlockBifrost extends BlockBifrostPerm {
public BlockBifrost(Properties builder) {
super(builder);
@@ -18,15 +18,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.fx.SparkleParticleData;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockBifrostPerm extends BlockMod implements ILexiconable {
public class BlockBifrostPerm extends BlockMod {
public BlockBifrostPerm(Properties builder) {
super(builder);
}
@@ -46,10 +43,4 @@ public class BlockBifrostPerm extends BlockMod implements ILexiconable {
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.rainbowRod;
}
}
@@ -23,16 +23,13 @@ import net.minecraft.util.IItemProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileCell;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockCell extends BlockMod implements ILexiconable {
public class BlockCell extends BlockMod {
public BlockCell(Properties builder) {
super(builder);
@@ -49,9 +46,4 @@ public class BlockCell extends BlockMod implements ILexiconable {
return new TileCell();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.dandelifeon;
}
}
@@ -29,14 +29,11 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileCocoon;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockCocoon extends BlockMod implements ILexiconable {
public class BlockCocoon extends BlockMod {
private static final VoxelShape SHAPE = makeCuboidShape(3, 0, 3, 13, 14, 13);;
@@ -110,8 +107,4 @@ public class BlockCocoon extends BlockMod implements ILexiconable {
return new TileCocoon();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.cocoon;
}
}
@@ -17,12 +17,10 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.state.enums.CratePattern;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.common.block.tile.TileCraftCrate;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import javax.annotation.Nonnull;
@@ -45,11 +43,6 @@ public class BlockCraftyCrate extends BlockOpenCrate implements IWandHUD {
return new TileCraftCrate();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.craftCrate;
}
@OnlyIn(Dist.CLIENT)
@Override
public void renderHUD(Minecraft mc, World world, BlockPos pos) {
@@ -27,15 +27,12 @@ import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.PlantType;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockEnchantedSoil extends BlockMod implements ILexiconable {
public class BlockEnchantedSoil extends BlockMod {
public BlockEnchantedSoil(Properties builder) {
super(builder);
@@ -46,9 +43,4 @@ public class BlockEnchantedSoil extends BlockMod implements ILexiconable {
return plantable.getPlantType(world, pos.down()) == PlantType.Plains;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.overgrowthSeed;
}
}
@@ -26,17 +26,14 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.tile.TileEnderEye;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockEnderEye extends BlockMod implements ILexiconable {
public class BlockEnderEye extends BlockMod {
protected BlockEnderEye(Properties builder) {
super(builder);
@@ -69,11 +66,6 @@ public class BlockEnderEye extends BlockMod implements ILexiconable {
return new TileEnderEye();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.enderEyeBlock;
}
@Override
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
if(state.get(BotaniaStateProps.POWERED)) {
@@ -26,13 +26,10 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Mod;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public class BlockFelPumpkin extends BlockMod implements ILexiconable {
public class BlockFelPumpkin extends BlockMod {
private static final ResourceLocation LOOT_TABLE = new ResourceLocation(LibMisc.MOD_ID, "fel_blaze");
private static final String TAG_FEL_SPAWNED = "Botania-FelSpawned";
@@ -67,9 +64,4 @@ public class BlockFelPumpkin extends BlockMod implements ILexiconable {
return getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.gardenOfGlass;
}
}
@@ -37,8 +37,6 @@ import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.ISpecialFlower;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
import vazkii.botania.api.wand.IWandHUD;
@@ -51,7 +49,7 @@ import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements ISpecialFlower, IWandable, ILexiconable, IWandHUD {
public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements ISpecialFlower, IWandable, IWandHUD {
private final Supplier<? extends TileEntitySpecialFlower> teProvider;
public BlockFloatingSpecialFlower(Properties props, Supplier<? extends TileEntitySpecialFlower> teProvider) {
@@ -144,9 +142,4 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
public TileEntity createTileEntity(@Nonnull BlockState state, @Nonnull IBlockReader world) {
return teProvider.get();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return ((TileEntitySpecialFlower) world.getTileEntity(pos)).getEntry();
}
}
@@ -19,14 +19,11 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileForestEye;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockForestEye extends BlockMod implements ILexiconable {
public class BlockForestEye extends BlockMod {
private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12);
@@ -62,9 +59,4 @@ public class BlockForestEye extends BlockMod implements ILexiconable {
return new TileForestEye();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.forestEye;
}
}
@@ -27,9 +27,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.Mod;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
@@ -41,7 +38,7 @@ import java.util.Set;
import java.util.WeakHashMap;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public class BlockGhostRail extends AbstractRailBlock implements ILexiconable {
public class BlockGhostRail extends AbstractRailBlock {
private static final String TAG_FLOAT_TICKS = "botania:float_ticks";
@@ -112,11 +109,6 @@ public class BlockGhostRail extends AbstractRailBlock implements ILexiconable {
}
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.ghostRail;
}
@Nonnull
@Override
public IProperty<RailShape> getShapeProperty() {
@@ -33,8 +33,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.ItemHandlerHelper;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.IManaTrigger;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.wand.IWandHUD;
@@ -43,12 +41,11 @@ import vazkii.botania.common.block.tile.TileHourglass;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, IWandHUD, ILexiconable {
public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, IWandHUD {
private static final VoxelShape SHAPE = makeCuboidShape(4, 0, 4, 12, 18.4, 12);
@@ -168,9 +165,4 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable,
tile.renderHUD();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.hourglass;
}
}
@@ -28,15 +28,12 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.items.ItemHandlerHelper;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.tile.TileIncensePlate;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockIncensePlate extends BlockMod implements ILexiconable {
public class BlockIncensePlate extends BlockMod {
private static final VoxelShape X_SHAPE = makeCuboidShape(6, 0, 2, 10, 1, 14);
private static final VoxelShape Z_SHAPE = makeCuboidShape(2, 0, 6, 14, 1, 10);
@@ -120,9 +117,5 @@ public class BlockIncensePlate extends BlockMod implements ILexiconable {
return new TileIncensePlate();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.incense;
}
}
@@ -26,17 +26,14 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.tile.TileLightRelay;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class BlockLightLauncher extends BlockMod implements ILexiconable {
public class BlockLightLauncher extends BlockMod {
private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 4, 16);
@@ -93,9 +90,4 @@ public class BlockLightLauncher extends BlockMod implements ILexiconable {
}
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.luminizerTransport;
}
}
@@ -26,18 +26,15 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.state.enums.LuminizerVariant;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.tile.TileLightRelay;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockLightRelay extends BlockMod implements IWandable, ILexiconable {
public class BlockLightRelay extends BlockMod implements IWandable {
private static final VoxelShape SHAPE = makeCuboidShape(5, 5, 5, 11, 11, 11);
public final LuminizerVariant variant;
@@ -118,9 +115,4 @@ public class BlockLightRelay extends BlockMod implements IWandable, ILexiconable
return false;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.luminizerTransport;
}
}
@@ -19,14 +19,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.IManaTrigger;
import vazkii.botania.common.entity.EntityManaStorm;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
public class BlockManaBomb extends BlockMod implements IManaTrigger, ILexiconable {
public class BlockManaBomb extends BlockMod implements IManaTrigger {
public BlockManaBomb(Properties builder) {
super(builder);
@@ -42,9 +39,4 @@ public class BlockManaBomb extends BlockMod implements IManaTrigger, ILexiconabl
world.addEntity(storm);
}
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.manaBomb;
}
}
@@ -20,16 +20,13 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.fx.SparkleParticleData;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockModDoubleFlower extends TallFlowerBlock implements ILexiconable {
public class BlockModDoubleFlower extends TallFlowerBlock {
private final DyeColor color;
public BlockModDoubleFlower(DyeColor color, Properties builder) {
@@ -56,9 +53,4 @@ public class BlockModDoubleFlower extends TallFlowerBlock implements ILexiconabl
}
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.flowers;
}
}
@@ -26,16 +26,13 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.fx.SparkleParticleData;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockModFlower extends FlowerBlock implements ILexiconable, IGrowable {
public class BlockModFlower extends FlowerBlock implements IGrowable {
public final DyeColor color;
protected BlockModFlower(DyeColor color, Properties builder) {
super(effectForFlower(color), 4, builder);
@@ -82,11 +79,6 @@ public class BlockModFlower extends FlowerBlock implements ILexiconable, IGrowab
}
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.flowers;
}
@Override
public boolean canGrow(@Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, boolean fuckifiknow) {
return world.getBlockState(pos.up()).isAir(world, pos);
@@ -1,22 +0,0 @@
package vazkii.botania.common.block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
public class BlockModLexiconable extends BlockMod implements ILexiconable {
private final ILexiconable delegate;
public BlockModLexiconable(Properties builder, ILexiconable delegate) {
super(builder);
this.delegate = delegate;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return delegate.getEntry(world, pos, player, lexicon);
}
}
@@ -22,18 +22,15 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.tile.TileOpenCrate;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import javax.annotation.Nonnull;
public class BlockOpenCrate extends BlockMod implements ILexiconable, IWandable {
public class BlockOpenCrate extends BlockMod implements IWandable {
protected BlockOpenCrate(Properties builder) {
super(builder);
@@ -70,11 +67,6 @@ public class BlockOpenCrate extends BlockMod implements ILexiconable, IWandable
return new TileOpenCrate();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.openCrate;
}
@Override
public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) {
TileOpenCrate crate = (TileOpenCrate) world.getTileEntity(pos);
@@ -40,11 +40,8 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.HashMap;
@@ -53,7 +50,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconable {
public class BlockPistonRelay extends BlockMod implements IWandable {
// Currently active binding attempts
public final Map<UUID, GlobalPos> activeBindingAttempts = new HashMap<>();
@@ -250,9 +247,4 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
if(data != null)
data.markDirty();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.pistonRelay;
}
}
@@ -30,16 +30,13 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.IManaCollisionGhost;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.tile.TilePlatform;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockPlatform extends BlockMod implements ILexiconable, IWandable, IManaCollisionGhost {
public class BlockPlatform extends BlockMod implements IWandable, IManaCollisionGhost {
public enum Variant {
ABSTRUSE,
@@ -90,11 +87,6 @@ public class BlockPlatform extends BlockMod implements ILexiconable, IWandable,
return new TilePlatform();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return variant == Variant.ABSTRUSE ? LexiconData.platform : variant == Variant.INFRANGIBLE ? null : LexiconData.spectralPlatform;
}
@Override
public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) {
TilePlatform tile = (TilePlatform) world.getTileEntity(pos);
@@ -22,14 +22,11 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TilePylon;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockPylon extends BlockMod implements ILexiconable {
public class BlockPylon extends BlockMod {
private static final VoxelShape SHAPE = Block.makeCuboidShape(2, 0, 2, 14, 21, 14);
public enum Variant {
@@ -76,8 +73,4 @@ public class BlockPylon extends BlockMod implements ILexiconable {
return new TilePylon();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return variant == Variant.MANA ? LexiconData.pylon : variant == Variant.NATURA ? LexiconData.alfhomancyIntro : LexiconData.gaiaRitual;
}
}
@@ -16,23 +16,15 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockRoot extends BlockMod implements ILexiconable {
public class BlockRoot extends BlockMod {
public BlockRoot(Properties builder) {
super(builder);
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.gardenOfGlass;
}
}
@@ -20,14 +20,11 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
import java.util.Random;
public class BlockSolidVines extends VineBlock implements ILexiconable {
public class BlockSolidVines extends VineBlock {
public BlockSolidVines(Properties builder) {
super(builder);
@@ -46,9 +43,4 @@ public class BlockSolidVines extends VineBlock implements ILexiconable {
public ItemStack getPickBlock(@Nonnull BlockState state, RayTraceResult target, @Nonnull IBlockReader world, @Nonnull BlockPos pos, PlayerEntity player) {
return new ItemStack(Blocks.VINE);
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.vineBall;
}
}
@@ -24,18 +24,15 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.items.ItemHandlerHelper;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.block.tile.TileSparkChanger;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.item.ItemSparkUpgrade;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockSparkChanger extends BlockMod implements ILexiconable {
public class BlockSparkChanger extends BlockMod {
private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 3, 16);
@@ -123,9 +120,4 @@ public class BlockSparkChanger extends BlockMod implements ILexiconable {
return new TileSparkChanger();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.sparkChanger;
}
}
@@ -36,8 +36,6 @@ import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.subtile.ISpecialFlower;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
@@ -49,7 +47,7 @@ import javax.annotation.Nonnull;
import java.util.List;
import java.util.function.Supplier;
public class BlockSpecialFlower extends FlowerBlock implements ISpecialFlower, IWandable, ILexiconable, IWandHUD {
public class BlockSpecialFlower extends FlowerBlock implements ISpecialFlower, IWandable, IWandHUD {
private static final VoxelShape SHAPE = makeCuboidShape(4.8, 0, 4.8, 12.8, 16, 12.8);
private final Supplier<? extends TileEntitySpecialFlower> teProvider;
@@ -141,11 +139,6 @@ public class BlockSpecialFlower extends FlowerBlock implements ISpecialFlower, I
return teProvider.get();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return ((TileEntitySpecialFlower) world.getTileEntity(pos)).getEntry();
}
@Override
public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) {
return ((TileEntitySpecialFlower) world.getTileEntity(pos)).onWanded(player, stack);
@@ -21,15 +21,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.recipe.IElvenItem;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import java.util.Locale;
public class BlockStorage extends BlockMod implements IElvenItem, ILexiconable {
public class BlockStorage extends BlockMod implements IElvenItem {
public BlockStorage(Properties builder) {
super(builder);
@@ -40,11 +37,6 @@ public class BlockStorage extends BlockMod implements IElvenItem, ILexiconable {
return true;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return this == ModBlocks.manasteelBlock ? LexiconData.pool : LexiconData.terrasteel;
}
@Override
public boolean isElvenItem(ItemStack stack) {
return this == ModBlocks.elementiumBlock;
@@ -25,14 +25,11 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileTeruTeruBozu;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockTeruTeruBozu extends BlockMod implements ILexiconable {
public class BlockTeruTeruBozu extends BlockMod {
private static final VoxelShape SHAPE = makeCuboidShape(4, 0.16, 4, 12, 15.84, 12);
@@ -123,9 +120,4 @@ public class BlockTeruTeruBozu extends BlockMod implements ILexiconable {
return new TileTeruTeruBozu();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.teruTeruBozu;
}
}
@@ -19,15 +19,12 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.mana.IManaCollisionGhost;
import vazkii.botania.common.block.tile.TileTinyPlanet;
import vazkii.botania.common.lexicon.LexiconData;
import javax.annotation.Nonnull;
public class BlockTinyPlanet extends BlockMod implements ILexiconable, IManaCollisionGhost {
public class BlockTinyPlanet extends BlockMod implements IManaCollisionGhost {
private static final VoxelShape AABB = makeCuboidShape(3, 3, 3, 13, 13, 13);
@@ -52,11 +49,6 @@ public class BlockTinyPlanet extends BlockMod implements ILexiconable, IManaColl
return new TileTinyPlanet();
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, PlayerEntity player, ItemStack lexicon) {
return LexiconData.tinyPlanet;
}
@Override
public boolean isGhost(BlockState state, World world, BlockPos pos) {
return true;
@@ -31,7 +31,6 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.state.enums.LuminizerVariant;
import vazkii.botania.client.render.tile.RenderTilePylon;
import vazkii.botania.client.render.tile.TEISR;
@@ -97,7 +96,6 @@ import vazkii.botania.common.item.block.ItemBlockElven;
import vazkii.botania.common.item.block.ItemBlockMod;
import vazkii.botania.common.item.block.ItemBlockPool;
import vazkii.botania.common.item.block.ItemBlockTinyPotato;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibMisc;
@@ -367,8 +365,6 @@ public final class ModBlocks {
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> evt) {
IForgeRegistry<Block> r = evt.getRegistry();
ILexiconable decorative = (w, po, pl, st) -> LexiconData.decorativeBlocks;
ILexiconable elvenResource = (w, po, pl, st) -> LexiconData.elvenResources;
Block.Properties builder = Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT);
for(DyeColor color : DyeColor.values()) {
@@ -382,20 +378,20 @@ public final class ModBlocks {
}
builder = Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE);
register(r, new BlockModLexiconable(builder, (w, po, pl, st) -> LexiconData.pureDaisy), LibBlockNames.LIVING_ROCK);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_ROCK_BRICK);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_ROCK_BRICK_MOSSY);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_ROCK_BRICK_CRACKED);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_ROCK_BRICK_CHISELED);
register(r, new BlockMod(builder), LibBlockNames.LIVING_ROCK);
register(r, new BlockMod(builder), LibBlockNames.LIVING_ROCK_BRICK);
register(r, new BlockMod(builder), LibBlockNames.LIVING_ROCK_BRICK_MOSSY);
register(r, new BlockMod(builder), LibBlockNames.LIVING_ROCK_BRICK_CRACKED);
register(r, new BlockMod(builder), LibBlockNames.LIVING_ROCK_BRICK_CHISELED);
builder = Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD);
// todo 1.13: livingwood should support leaves
register(r, new BlockModLexiconable(builder, (w, po, pl, st) -> LexiconData.pureDaisy), LibBlockNames.LIVING_WOOD);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_WOOD_PLANKS);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_WOOD_PLANKS_MOSSY);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_WOOD_FRAMED);
register(r, new BlockModLexiconable(builder, decorative), LibBlockNames.LIVING_WOOD_PATTERN_FRAMED);
register(r, new BlockModLexiconable(builder.lightValue(12), decorative), LibBlockNames.LIVING_WOOD_GLIMMERING);
register(r, new BlockMod(builder), LibBlockNames.LIVING_WOOD);
register(r, new BlockMod(builder), LibBlockNames.LIVING_WOOD_PLANKS);
register(r, new BlockMod(builder), LibBlockNames.LIVING_WOOD_PLANKS_MOSSY);
register(r, new BlockMod(builder), LibBlockNames.LIVING_WOOD_FRAMED);
register(r, new BlockMod(builder), LibBlockNames.LIVING_WOOD_PATTERN_FRAMED);
register(r, new BlockMod(builder.lightValue(12)), LibBlockNames.LIVING_WOOD_GLIMMERING);
builder = Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD);
register(r, new BlockSpreader(BlockSpreader.Variant.MANA, builder), LibBlockNames.SPREADER);
@@ -465,12 +461,12 @@ public final class ModBlocks {
builder = Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD);
// todo 1.13: dreamwood should support leaves?
register(r, new BlockModLexiconable(builder, elvenResource), LibBlockNames.DREAM_WOOD);
register(r, new BlockModLexiconable(builder, elvenResource), LibBlockNames.DREAM_WOOD_PLANKS);
register(r, new BlockModLexiconable(builder, elvenResource), LibBlockNames.DREAM_WOOD_PLANKS_MOSSY);
register(r, new BlockModLexiconable(builder, elvenResource), LibBlockNames.DREAM_WOOD_FRAMED);
register(r, new BlockModLexiconable(builder, elvenResource), LibBlockNames.DREAM_WOOD_PATTERN_FRAMED);
register(r, new BlockModLexiconable(builder.lightValue(12), elvenResource), LibBlockNames.DREAM_WOOD_GLIMMERING);
register(r, new BlockMod(builder), LibBlockNames.DREAM_WOOD);
register(r, new BlockMod(builder), LibBlockNames.DREAM_WOOD_PLANKS);
register(r, new BlockMod(builder), LibBlockNames.DREAM_WOOD_PLANKS_MOSSY);
register(r, new BlockMod(builder), LibBlockNames.DREAM_WOOD_FRAMED);
register(r, new BlockMod(builder), LibBlockNames.DREAM_WOOD_PATTERN_FRAMED);
register(r, new BlockMod(builder.lightValue(12)), LibBlockNames.DREAM_WOOD_GLIMMERING);
register(r, new BlockConjurationCatalyst(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.CONJURATION_CATALYST);
register(r, new BlockBifrost(Block.Properties.create(Material.GLASS).hardnessAndResistance(-1, 0.3F).lightValue(15).sound(SoundType.GLASS)), LibBlockNames.BIFROST);
@@ -490,9 +486,8 @@ public final class ModBlocks {
register(r, new BlockSpawnerClaw(Block.Properties.create(Material.IRON).hardnessAndResistance(3)), LibBlockNames.SPAWNER_CLAW);
builder = Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 5).sound(SoundType.STONE);
ILexiconable azulejo = (w, po ,pl, st) -> LexiconData.azulejo;
for (int i = 0; i < 16; i++) {
register(r, new BlockModLexiconable(builder, azulejo), LibBlockNames.AZULEJO_PREFIX + i);
register(r, new BlockMod(builder), LibBlockNames.AZULEJO_PREFIX + i);
}
register(r, new BlockEnderEye(Block.Properties.create(Material.IRON).hardnessAndResistance(3, 10).sound(SoundType.METAL)), LibBlockNames.ENDER_EYE_BLOCK);
@@ -535,7 +530,7 @@ public final class ModBlocks {
}
register(r, new BlockFakeAir(Block.Properties.create(Material.STRUCTURE_VOID).tickRandomly()), LibBlockNames.FAKE_AIR);
register(r, new BlockModLexiconable(Block.Properties.create(Material.IRON).hardnessAndResistance(3, 10).sound(SoundType.METAL).lightValue(15), (w, po, pl, st) -> LexiconData.blazeBlock), LibBlockNames.BLAZE_BLOCK);
register(r, new BlockMod(Block.Properties.create(Material.IRON).hardnessAndResistance(3, 10).sound(SoundType.METAL).lightValue(15)), LibBlockNames.BLAZE_BLOCK);
register(r, new BlockCorporeaInterceptor(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)), LibBlockNames.CORPOREA_INTERCEPTOR);
register(r, new BlockCorporeaCrystalCube(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)), LibBlockNames.CORPOREA_CRYSTAL_CUBE);
register(r, new BlockIncensePlate(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.INCENSE_PLATE);
@@ -562,9 +557,8 @@ public final class ModBlocks {
register(r, new BlockGaiaHead(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1)), LibBlockNames.GAIA_HEAD);
register(r, new BlockCorporeaRetainer(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)), LibBlockNames.CORPOREA_RETAINER);
register(r, new BlockTeruTeruBozu(Block.Properties.create(Material.WOOL)), LibBlockNames.TERU_TERU_BOZU);
ILexiconable rainbowRod = (w, po, pl, st) -> LexiconData.rainbowRod;
register(r, new BlockModLexiconable(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE), rainbowRod), LibBlockNames.SHIMMERROCK);
register(r, new BlockModLexiconable(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD), rainbowRod), LibBlockNames.SHIMMERWOOD_PLANKS);
register(r, new BlockMod(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.SHIMMERROCK);
register(r, new BlockMod(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.SHIMMERWOOD_PLANKS);
register(r, new BlockAvatar(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.AVATAR);
builder = Block.Properties.create(Material.ORGANIC).hardnessAndResistance(0.6F).tickRandomly().sound(SoundType.PLANT);
@@ -21,7 +21,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.common.block.decor.panes.BlockModPane;
import vazkii.botania.common.block.decor.quartz.BlockSpecialQuartzPillar;
import vazkii.botania.common.block.decor.quartz.BlockElfQuartzSlab;
@@ -36,7 +35,6 @@ import vazkii.botania.common.block.decor.walls.BlockBiomeStoneWall;
import vazkii.botania.common.block.decor.walls.BlockModWall;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.block.ItemBlockMod;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibMisc;
@@ -266,11 +264,10 @@ public final class ModFluffBlocks {
Block.Properties props = Block.Properties.from(Blocks.QUARTZ_BLOCK);
for (String variant : LibBlockNames.QUARTZ_VARIANTS) {
ILexiconable lexicon = (world, pos, player, lex) -> LexiconData.decorativeBlocks;
base = new BlockModLexiconable(props, lexicon);
base = new BlockMod(props);
register(r, base, variant);
register(r, new BlockModLexiconable(props, lexicon), "chiseled_" + variant);
register(r, new BlockMod(props), "chiseled_" + variant);
register(r, new BlockSpecialQuartzPillar(props), variant + "_pillar");
register(r, new BlockModSlab(props), variant + SLAB_SUFFIX);
register(r, new BlockModStairs(base.getDefaultState(), props), variant + STAIR_SUFFIX);
@@ -285,24 +282,23 @@ public final class ModFluffBlocks {
}
props = Block.Properties.create(Material.ROCK).hardnessAndResistance(1.5F, 10).sound(SoundType.STONE);
ILexiconable marimorph = (world, pos, player, lex) -> LexiconData.marimorphosis;
for (String variant : LibBlockNames.METAMORPHIC_VARIANTS) {
base = new BlockModLexiconable(props, marimorph);
base = new BlockMod(props);
register(r, base, LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone");
register(r, new BlockBiomeStoneStairs(base.getDefaultState(), props), base.getRegistryName().getPath() + STAIR_SUFFIX);
register(r, new BlockBiomeStoneSlab(props), base.getRegistryName().getPath() + SLAB_SUFFIX);
base = new BlockModLexiconable(props, marimorph);
base = new BlockMod(props);
register(r, base, LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone");
register(r, new BlockBiomeStoneStairs(base.getDefaultState(), props), base.getRegistryName().getPath() + STAIR_SUFFIX);
register(r, new BlockBiomeStoneSlab(props), base.getRegistryName().getPath() + SLAB_SUFFIX);
register(r, new BlockBiomeStoneWall(props), LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + WALL_SUFFIX);
base = new BlockModLexiconable(props, marimorph);
base = new BlockMod(props);
register(r, base, LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks");
register(r, new BlockBiomeStoneStairs(base.getDefaultState(), props), base.getRegistryName().getPath() + STAIR_SUFFIX);
register(r, new BlockBiomeStoneSlab(props), base.getRegistryName().getPath() + SLAB_SUFFIX);
register(r, new BlockModLexiconable(props, marimorph), "chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks");
register(r, new BlockMod(props), "chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks");
}
base = r.getValue(new ResourceLocation(LibMisc.MOD_ID, LibBlockNames.SHIMMERROCK));
@@ -1,33 +0,0 @@
/**
* This class was created by <Vazkii>. 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 @ [Jun 27, 2015, 3:11:36 PM (GMT)]
*/
package vazkii.botania.common.block;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.common.block.tile.TileAlfPortal;
import vazkii.botania.common.block.tile.TileEnchanter;
import vazkii.botania.common.block.tile.TileTerraPlate;
import vazkii.botania.common.entity.EntityDoppleganger;
public final class ModMultiblocks {
public static MultiblockSet enchanter;
public static MultiblockSet alfPortal;
public static MultiblockSet terrasteelPlate;
public static MultiblockSet gaiaRitual;
public static void init() {
enchanter = TileEnchanter.makeMultiblockSet();
alfPortal = TileAlfPortal.makeMultiblockSet();
terrasteelPlate = TileTerraPlate.makeMultiblockSet();
gaiaRitual = EntityDoppleganger.makeMultiblockSet();
}
}
Loaded 100 of 223 files, more files were not shown because too many files have changed in this diff. Show more