From 42bf760bcb89797491f8559316b86bf74a3f3ff2 Mon Sep 17 00:00:00 2001 From: Discreater Date: Mon, 26 Apr 2021 14:26:06 +0800 Subject: [PATCH] feat: Basic gui --- .../me/towdium/jecalculation/JecaConfig.java | 14 +- .../me/towdium/jecalculation/JecaItem.java | 32 - .../jecalculation/JustEnoughCalculation.java | 61 +- .../jecalculation/client/gui/JecGui.java | 132 ++ .../client/gui/guis/GuiCalculator.java | 35 + .../client/resource/Resource.java | 48 + .../jecalculation/client/widget/Widget.java | 22 + .../client/widget/widgets/WButton.java | 57 + .../client/widget/widgets/WButtonIcon.java | 46 + .../client/widget/widgets/WEntry.java | 44 + .../client/widget/widgets/WEntryGroup.java | 44 + .../client/widget/widgets/WLine.java | 22 + .../jecalculation/command/Commands.java | 30 + .../jecalculation/command/JecaCommand.java | 69 + .../jecalculation/command/SubCommand.java | 26 + .../command/commands/CommandHelp.java | 40 + .../command/commands/CommandState.java | 33 + .../jecalculation/core/entry/Entry.java | 143 ++ .../core/entry/entries/EntryItemStack.java | 39 + .../towdium/jecalculation/event/Handlers.java | 15 + .../event/handlers/InputEventHandler.java | 27 + .../jecalculation/gui/JecaContainer.java | 2 +- .../jecalculation/gui/JecaGuiContainer.java | 3 +- .../jecalculation/gui/guis/GuiCalculator.java | 2 +- .../me/towdium/jecalculation/item/Items.java | 17 + .../towdium/jecalculation/item/JecaItem.java | 44 + .../item/items/ItemCalculator.java | 40 + .../towdium/jecalculation/network/IProxy.java | 8 - .../jecalculation/network/ProxyClient.java | 27 +- .../jecalculation/network/ProxyCommon.java | 24 + .../jecalculation/network/ProxyServer.java | 14 - .../{utils => }/polyfill/ClickType.java | 2 +- .../{utils => }/polyfill/Event.java | 0 .../{utils => }/polyfill/Loader.java | 0 .../{utils => }/polyfill/Polyfill.java | 2 +- .../{utils => }/polyfill/SoundEvents.java | 2 +- .../mc/client/renderer/GlStateManager.java | 1449 +++++++++++++++++ .../jecalculation/utils/ClientUtils.java | 16 + .../jecalculation/utils/ItemStackHelper.java | 2 +- .../jecalculation/utils/Utilities.java | 511 +----- .../utils/helpers/LocalizationHelper.java | 58 + .../jecalculation/utils/wrappers/Pair.java | 2 +- .../wrappers/{Wrapper.java => Single.java} | 21 +- .../utils/wrappers/{Trio.java => Triple.java} | 4 +- .../assets/jecalculation/lang/en_US.lang | 38 +- .../assets/jecalculation/lang/zh_CN.lang | 20 - .../models/item/itemCalculator.json | 6 - .../models/item/item_calculator_crafting.json | 6 + .../models/item/item_calculator_math.json | 6 + .../textures/gui/guiCalculator.png | Bin 16720 -> 0 bytes .../jecalculation/textures/gui/guiRecipe.png | Bin 16692 -> 0 bytes .../textures/gui/guiRecipeViewer.png | Bin 16622 -> 0 bytes .../textures/gui/gui_calculator.png | Bin 0 -> 2962 bytes .../jecalculation/textures/gui/resources.png | Bin 0 -> 4393 bytes .../textures/items/itemCalculator.png | Bin 17717 -> 0 bytes .../items/item_calculator_crafting.png | Bin 0 -> 594 bytes .../textures/items/item_calculator_math.png | Bin 0 -> 591 bytes 57 files changed, 2705 insertions(+), 600 deletions(-) delete mode 100644 src/main/java/me/towdium/jecalculation/JecaItem.java create mode 100644 src/main/java/me/towdium/jecalculation/client/gui/JecGui.java create mode 100644 src/main/java/me/towdium/jecalculation/client/gui/guis/GuiCalculator.java create mode 100644 src/main/java/me/towdium/jecalculation/client/resource/Resource.java create mode 100644 src/main/java/me/towdium/jecalculation/client/widget/Widget.java create mode 100644 src/main/java/me/towdium/jecalculation/client/widget/widgets/WButton.java create mode 100644 src/main/java/me/towdium/jecalculation/client/widget/widgets/WButtonIcon.java create mode 100644 src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntry.java create mode 100644 src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntryGroup.java create mode 100644 src/main/java/me/towdium/jecalculation/client/widget/widgets/WLine.java create mode 100644 src/main/java/me/towdium/jecalculation/command/Commands.java create mode 100644 src/main/java/me/towdium/jecalculation/command/JecaCommand.java create mode 100644 src/main/java/me/towdium/jecalculation/command/SubCommand.java create mode 100644 src/main/java/me/towdium/jecalculation/command/commands/CommandHelp.java create mode 100644 src/main/java/me/towdium/jecalculation/command/commands/CommandState.java create mode 100644 src/main/java/me/towdium/jecalculation/core/entry/Entry.java create mode 100644 src/main/java/me/towdium/jecalculation/core/entry/entries/EntryItemStack.java create mode 100644 src/main/java/me/towdium/jecalculation/event/Handlers.java create mode 100644 src/main/java/me/towdium/jecalculation/event/handlers/InputEventHandler.java create mode 100644 src/main/java/me/towdium/jecalculation/item/Items.java create mode 100644 src/main/java/me/towdium/jecalculation/item/JecaItem.java create mode 100644 src/main/java/me/towdium/jecalculation/item/items/ItemCalculator.java delete mode 100644 src/main/java/me/towdium/jecalculation/network/IProxy.java create mode 100644 src/main/java/me/towdium/jecalculation/network/ProxyCommon.java delete mode 100644 src/main/java/me/towdium/jecalculation/network/ProxyServer.java rename src/main/java/me/towdium/jecalculation/{utils => }/polyfill/ClickType.java (86%) rename src/main/java/me/towdium/jecalculation/{utils => }/polyfill/Event.java (100%) rename src/main/java/me/towdium/jecalculation/{utils => }/polyfill/Loader.java (100%) rename src/main/java/me/towdium/jecalculation/{utils => }/polyfill/Polyfill.java (94%) rename src/main/java/me/towdium/jecalculation/{utils => }/polyfill/SoundEvents.java (66%) create mode 100644 src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java create mode 100644 src/main/java/me/towdium/jecalculation/utils/ClientUtils.java create mode 100644 src/main/java/me/towdium/jecalculation/utils/helpers/LocalizationHelper.java rename src/main/java/me/towdium/jecalculation/utils/wrappers/{Wrapper.java => Single.java} (55%) rename src/main/java/me/towdium/jecalculation/utils/wrappers/{Trio.java => Triple.java} (76%) delete mode 100644 src/main/resources/assets/jecalculation/lang/zh_CN.lang delete mode 100644 src/main/resources/assets/jecalculation/models/item/itemCalculator.json create mode 100644 src/main/resources/assets/jecalculation/models/item/item_calculator_crafting.json create mode 100644 src/main/resources/assets/jecalculation/models/item/item_calculator_math.json delete mode 100644 src/main/resources/assets/jecalculation/textures/gui/guiCalculator.png delete mode 100644 src/main/resources/assets/jecalculation/textures/gui/guiRecipe.png delete mode 100644 src/main/resources/assets/jecalculation/textures/gui/guiRecipeViewer.png create mode 100644 src/main/resources/assets/jecalculation/textures/gui/gui_calculator.png create mode 100644 src/main/resources/assets/jecalculation/textures/gui/resources.png delete mode 100644 src/main/resources/assets/jecalculation/textures/items/itemCalculator.png create mode 100644 src/main/resources/assets/jecalculation/textures/items/item_calculator_crafting.png create mode 100644 src/main/resources/assets/jecalculation/textures/items/item_calculator_math.png diff --git a/src/main/java/me/towdium/jecalculation/JecaConfig.java b/src/main/java/me/towdium/jecalculation/JecaConfig.java index 4798200..bafcd8e 100644 --- a/src/main/java/me/towdium/jecalculation/JecaConfig.java +++ b/src/main/java/me/towdium/jecalculation/JecaConfig.java @@ -10,11 +10,17 @@ public class JecaConfig { public static boolean initialized = false; public static Configuration config; + public static boolean isForceClient() { + return EnumItems.ForceClient.getProperty().getBoolean(); + } + public enum EnumItems { - EnableInventoryCheck, ListRecipeBlackList, ListRecipeCategory; + ForceClient, EnableInventoryCheck, ListRecipeBlackList, ListRecipeCategory; public String getComment() { switch (this) { + case ForceClient: + return "Set to true to force client mode: no item and recipe allowed, use key bindings instead."; case EnableInventoryCheck: return "Set to false to disable auto inventory check"; case ListRecipeBlackList: @@ -28,6 +34,8 @@ public class JecaConfig { public String getName() { switch (this) { + case ForceClient: + return "ForceClient"; case EnableInventoryCheck: return "EnableInventoryCheck"; case ListRecipeBlackList: @@ -40,6 +48,7 @@ public class JecaConfig { public String getCategory() { switch (this) { + case ForceClient: case EnableInventoryCheck: case ListRecipeBlackList: case ListRecipeCategory: @@ -50,6 +59,7 @@ public class JecaConfig { public EnumType getType() { switch (this) { + case ForceClient: case EnableInventoryCheck: return EnumType.Boolean; case ListRecipeBlackList: @@ -61,6 +71,8 @@ public class JecaConfig { public Object getDefault() { switch (this) { + case ForceClient: + return false; case EnableInventoryCheck: return true; case ListRecipeBlackList: diff --git a/src/main/java/me/towdium/jecalculation/JecaItem.java b/src/main/java/me/towdium/jecalculation/JecaItem.java deleted file mode 100644 index 724ab4d..0000000 --- a/src/main/java/me/towdium/jecalculation/JecaItem.java +++ /dev/null @@ -1,32 +0,0 @@ -package me.towdium.jecalculation; - -import me.towdium.jecalculation.gui.GuiHandler; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - - -/** - * @author Towdium - */ -public class JecaItem extends Item { - public static JecaItem INSTANCE = new JecaItem(); - - public static final String NAME = "itemCalculator"; - - public JecaItem() { - setHasSubtypes(true); - setMaxStackSize(1); - setUnlocalizedName(NAME); - setTextureName(JustEnoughCalculation.Reference.MODID + ":" + NAME); - setCreativeTab(CreativeTabs.tabTools); - } - - @Override - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { - playerIn.openGui(JustEnoughCalculation.INSTANCE, GuiHandler.GuiId.EDITOR, worldIn, 0, 0, 0); - return itemStackIn; - } -} \ No newline at end of file diff --git a/src/main/java/me/towdium/jecalculation/JustEnoughCalculation.java b/src/main/java/me/towdium/jecalculation/JustEnoughCalculation.java index b27a3b4..266d9cb 100644 --- a/src/main/java/me/towdium/jecalculation/JustEnoughCalculation.java +++ b/src/main/java/me/towdium/jecalculation/JustEnoughCalculation.java @@ -5,20 +5,28 @@ import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.NetworkCheckHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import cpw.mods.fml.common.registry.GameRegistry; -import me.towdium.jecalculation.gui.GuiHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import me.towdium.jecalculation.command.JecaCommand; import me.towdium.jecalculation.nei.NEIPlugin; -import me.towdium.jecalculation.network.IProxy; +import me.towdium.jecalculation.network.ProxyCommon; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Map; + /** * @author Towdium */ +@ParametersAreNonnullByDefault @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) @Mod(modid = JustEnoughCalculation.Reference.MODID, name = JustEnoughCalculation.Reference.MODNAME, version = JustEnoughCalculation.Reference.VERSION, @@ -29,35 +37,70 @@ public class JustEnoughCalculation { @SidedProxy(modId = Reference.MODID, clientSide = "me.towdium.jecalculation.network.ProxyClient", - serverSide = "me.towdium.jecalculation.network.ProxyServer") - public static IProxy proxy; + serverSide = "me.towdium.jecalculation.network.ProxyCommon") + public static ProxyCommon proxy; public static SimpleNetworkWrapper network; public static Logger logger = LogManager.getLogger(Reference.MODID); + public static enumSide side = enumSide.UNDEFINED; + + @NetworkCheckHandler + public static boolean networkCheck(Map mods, Side s) { + if (s == Side.SERVER) { + if (mods.containsKey(Reference.MODID) && !JecaConfig.isForceClient()) { + side = enumSide.BOTH; + } else { + side = enumSide.CLIENT; + } + } else { + if (mods.containsKey(Reference.MODID)) { + side = enumSide.SERVER; + } else { + return false; + } + } + return true; + } @Mod.EventHandler - public static void preInit(FMLPreInitializationEvent event) { + public static void initPre(FMLPreInitializationEvent event) { JecaConfig.preInit(event); - GameRegistry.registerItem(JecaItem.INSTANCE, JecaItem.NAME); network = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID); - proxy.preInit(); + proxy.initPre(); } @Mod.EventHandler public static void init(FMLInitializationEvent event) { - NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler()); proxy.init(); } @Mod.EventHandler public static void postInit(FMLPostInitializationEvent event) { + proxy.initPost(); NEIPlugin.init(); } + @Mod.EventHandler + public static void onServerStart(FMLServerStartingEvent event) { + if (side == enumSide.SERVER) { + event.registerServerCommand(new JecaCommand()); + } + } + public static class Reference { public static final String MODID = "jecalculation"; public static final String MODNAME = "Just Enough Calculation"; public static final String VERSION = "@VERSION@"; } + + /** + * CLIENT: running at client side and server not installed + * SERVER: running at server side whether client is installed + * BOTH: running at client side and both installed + * UNDEFINED: default unknown + */ + public enum enumSide { + CLIENT, SERVER, BOTH, UNDEFINED + } } diff --git a/src/main/java/me/towdium/jecalculation/client/gui/JecGui.java b/src/main/java/me/towdium/jecalculation/client/gui/JecGui.java new file mode 100644 index 0000000..1e893bd --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/gui/JecGui.java @@ -0,0 +1,132 @@ +package me.towdium.jecalculation.client.gui; + +import cpw.mods.fml.client.config.GuiUtils; +import me.towdium.jecalculation.JustEnoughCalculation; +import me.towdium.jecalculation.client.resource.Resource; +import me.towdium.jecalculation.client.widget.Widget; +import me.towdium.jecalculation.polyfill.mc.client.renderer.GlStateManager; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.ArrayList; +import java.util.List; + +/** + * Author: towdium + * Date: 8/12/17. + */ +@ParametersAreNonnullByDefault +public class JecGui extends GuiContainer { + public List buttonList = super.buttonList; + + public WidgetManager widgetManager = new WidgetManager(); + GuiScreen parent; + + public JecGui(@Nullable GuiScreen parent) { + super(new Container() { + @Override + public boolean canInteractWith(EntityPlayer playerIn) { + return true; + } + }); + this.parent = parent; + } + + @Override + public void initGui() { + super.initGui(); + widgetManager.onInit(); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + GlStateManager.disableLighting(); + widgetManager.onDraw(mouseX, mouseY); + GlStateManager.enableLighting(); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { + drawTexture(new ResourceLocation(JustEnoughCalculation.Reference.MODID, + "textures/gui/" + getBackground() + ".png"), guiLeft, guiTop, 0, 0, this.xSize, this.ySize); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + // here I haven't copied the event thingy, don't think anyone will use it + widgetManager.onClick(mouseX, mouseY, mouseButton); + } + + // new functions + + public void drawResource(Resource r, int xPos, int yPos) { + drawTexture(Resource.location, xPos, yPos, r.getXPos(), r.getYPos(), r.getXSize(), r.getYSize()); + } + + public void drawResourceContinuous( + Resource r, int xPos, int yPos, int xSize, int ySize, + int borderTop, int borderBottom, int borderLeft, int borderRight) { + drawTextureContinuous(Resource.location, xPos, yPos, xSize, ySize, + r.getXPos(), r.getYPos(), r.getXSize(), r.getYSize(), + borderTop, borderBottom, borderLeft, borderRight); + } + + public void drawTexture(ResourceLocation l, int destXPos, int destYPos, + int sourceXPos, int sourceYPos, int sourceXSize, int sourceYSize) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(l); + this.drawTexturedModalRect(destXPos, destYPos, sourceXPos, sourceYPos, sourceXSize, sourceYSize); + } + + public void drawTextureContinuous( + ResourceLocation l, int destXPos, int destYPos, int destXSize, int destYSize, + int sourceXPos, int sourceYPos, int sourceXSize, int sourceYSize, + int borderTop, int borderBottom, int borderLeft, int borderRight) { + GuiUtils.drawContinuousTexturedBox(l, destXPos, destYPos, sourceXPos, sourceYPos, destXSize, destYSize, + sourceXSize, sourceYSize, borderTop, borderBottom, borderLeft, borderRight, zLevel); + } + + protected String getBackground() { + return "error"; + } + + public class WidgetManager { + protected List widgets = new ArrayList<>(); + + public void add(Widget w) { + widgets.add(w); + } + + public void remove(Widget w) { + widgets.remove(w); + w.onRemoved(JecGui.this); + } + + public void onInit() { + widgets.forEach(w -> w.onGuiInit(JecGui.this)); + } + + public void onDraw(int mouseX, int mouseY) { + widgets.forEach(widget -> widget.onDraw(JecGui.this, mouseX, mouseY)); + } + + public void onClick(int xMouse, int yMouse, int button) { + widgets.forEach(w -> w.onClicked(JecGui.this, xMouse, yMouse, button)); + } + } + + public int getGuiLeft() { return guiLeft; } + public int getGuiTop() { return guiTop; } +} diff --git a/src/main/java/me/towdium/jecalculation/client/gui/guis/GuiCalculator.java b/src/main/java/me/towdium/jecalculation/client/gui/guis/GuiCalculator.java new file mode 100644 index 0000000..523b489 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/gui/guis/GuiCalculator.java @@ -0,0 +1,35 @@ +package me.towdium.jecalculation.client.gui.guis; + +import me.towdium.jecalculation.client.gui.JecGui; +import me.towdium.jecalculation.client.resource.Resource; +import me.towdium.jecalculation.client.widget.widgets.WButtonIcon; +import me.towdium.jecalculation.client.widget.widgets.WEntryGroup; +import me.towdium.jecalculation.client.widget.widgets.WLine; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + +/** + * Author: towdium + * Date: 8/14/17. + */ +@ParametersAreNonnullByDefault +public class GuiCalculator extends JecGui { + public GuiCalculator(@Nullable GuiScreen parent) { + super(parent); + widgetManager.add(new WButtonIcon(7, 7, Resource.LABEL_NORMAL, Resource.LABEL_FOCUSED) + .setListenerLeft(() -> Minecraft.getMinecraft().displayGuiScreen(null)) + .setListenerRight(() -> Minecraft.getMinecraft().displayGuiScreen(null))); + widgetManager.add(new WButtonIcon(130, 7, Resource.NEW_NORMAL, Resource.NEW_FOCUSED)); + widgetManager.add(new WButtonIcon(149, 7, Resource.SEARCH_NORMAL, Resource.SEARCH_FOCUSED)); + widgetManager.add(new WEntryGroup(7, 87, 9, 4)); + widgetManager.add(new WLine(52)); + } + + @Override + protected String getBackground() { + return "gui_calculator"; + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/resource/Resource.java b/src/main/java/me/towdium/jecalculation/client/resource/Resource.java new file mode 100644 index 0000000..5ab7d7a --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/resource/Resource.java @@ -0,0 +1,48 @@ +package me.towdium.jecalculation.client.resource; + +import me.towdium.jecalculation.JustEnoughCalculation; +import net.minecraft.util.ResourceLocation; + +/** + * Author: towdium + * Date: 17-8-17. + */ +public class Resource { + public static final ResourceLocation location = new ResourceLocation( + JustEnoughCalculation.Reference.MODID, "textures/gui/resources.png"); + public static final Resource LABEL_NORMAL = new Resource(0, 14, 14, 14); + public static final Resource LABEL_FOCUSED = new Resource(0, 0, 14, 14); + public static final Resource NEW_NORMAL = new Resource(14, 14, 14, 14); + public static final Resource NEW_FOCUSED = new Resource(14, 0, 14, 14); + public static final Resource SEARCH_NORMAL = new Resource(28, 14, 14, 14); + public static final Resource SEARCH_FOCUSED = new Resource(28, 0, 14, 14); + public static final Resource BUTTON_NORMAL = new Resource(216, 0, 20, 20); + public static final Resource BUTTON_FOCUSED = new Resource(236, 0, 20, 20); + public static final Resource SLOT = new Resource(196, 0, 20, 20); + public static final Resource LINE = new Resource(0, 28, 163, 4); + + protected int xPos, yPos, xSize, ySize; + + public Resource(int xPos, int yPos, int xSize, int ySize) { + this.xPos = xPos; + this.yPos = yPos; + this.xSize = xSize; + this.ySize = ySize; + } + + public int getXPos() { + return xPos; + } + + public int getYPos() { + return yPos; + } + + public int getXSize() { + return xSize; + } + + public int getYSize() { + return ySize; + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/widget/Widget.java b/src/main/java/me/towdium/jecalculation/client/widget/Widget.java new file mode 100644 index 0000000..f48540d --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/widget/Widget.java @@ -0,0 +1,22 @@ +package me.towdium.jecalculation.client.widget; + +import me.towdium.jecalculation.client.gui.JecGui; +import net.minecraft.client.gui.Gui; + +/** + * Author: towdium + * Date: 8/14/17. + */ +public class Widget extends Gui { + public void onGuiInit(JecGui gui) { + } + + public void onDraw(JecGui gui, int xMouse, int yMouse) { + } + + public void onRemoved(JecGui gui) { + } + + public void onClicked(JecGui gui, int xMouse, int yMouse, int button) { + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/widget/widgets/WButton.java b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WButton.java new file mode 100644 index 0000000..fdf0f73 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WButton.java @@ -0,0 +1,57 @@ +package me.towdium.jecalculation.client.widget.widgets; + +import cpw.mods.fml.client.config.GuiButtonExt; +import me.towdium.jecalculation.client.gui.JecGui; +import me.towdium.jecalculation.client.widget.Widget; +import me.towdium.jecalculation.utils.ClientUtils; +import net.minecraft.client.Minecraft; + +/** + * Author: towdium + * Date: 8/14/17. + */ +public class WButton extends Widget { + protected int xPos, yPos, xSize, ySize; + protected Runnable lsnrLeft, lsnrRight; + protected String text; + protected GuiButtonExt button; + + public WButton(int xPos, int yPos, int xSize, int ySize, String text) { + this.xPos = xPos; + this.yPos = yPos; + this.xSize = xSize; + this.ySize = ySize; + this.text = text; + } + + public WButton setListenerLeft(Runnable r) { + lsnrLeft = r; + return this; + } + + public WButton setListenerRight(Runnable r) { + lsnrRight = r; + return this; + } + + @Override + public void onGuiInit(JecGui gui) { + super.onGuiInit(gui); + button = new GuiButtonExt(0, xPos + gui.getGuiLeft(), yPos + gui.getGuiTop(), xSize, ySize, text); + gui.buttonList.add(button); + } + + @Override + public void onClicked(JecGui gui, int xMouse, int yMouse, int button) { + if (this.button.mousePressed(Minecraft.getMinecraft(), xMouse, yMouse)) { + if (button == 0 && lsnrLeft != null) { + lsnrLeft.run(); + ClientUtils.playClickSound(1.0F); + } else if (button == 1 && lsnrRight != null) { + lsnrLeft.run(); + ClientUtils.playClickSound(0.8F); + } + + } + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/widget/widgets/WButtonIcon.java b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WButtonIcon.java new file mode 100644 index 0000000..4d64bea --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WButtonIcon.java @@ -0,0 +1,46 @@ +package me.towdium.jecalculation.client.widget.widgets; + +import cpw.mods.fml.client.config.GuiButtonExt; +import me.towdium.jecalculation.client.gui.JecGui; +import me.towdium.jecalculation.client.resource.Resource; +import net.minecraft.client.Minecraft; + +/** + * Author: towdium + * Date: 17-8-17. + */ +public class WButtonIcon extends WButton { + protected int xPos, yPos; + protected Resource normal, focused; + + public WButtonIcon(int xPos, int yPos, Resource normal, Resource focused) { + super(xPos, yPos, 20, 20, ""); + this.xPos = xPos; + this.yPos = yPos; + this.normal = normal; + this.focused = focused; + } + + @Override + public void onGuiInit(JecGui gui) { + super.onGuiInit(gui); + gui.buttonList.add(new GuiButtonExt(0, xPos + gui.getGuiLeft(), yPos + gui.getGuiTop(), 20, 20, "") { + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + final int x = this.xPosition; + final int y = this.yPosition; + this.field_146123_n = mouseX > x + 1 && mouseY > y + 1 && mouseX <= x + width - 1 && mouseY <= y + height - 1; + boolean hovered = this.field_146123_n; + gui.drawResource(hovered ? Resource.BUTTON_FOCUSED : Resource.BUTTON_NORMAL, x, y); + String text = displayString; + int strWidth = mc.fontRenderer.getStringWidth(text); + int ellipsisWidth = mc.fontRenderer.getStringWidth("..."); + if (strWidth > width - 6 && strWidth > ellipsisWidth) + text = mc.fontRenderer.trimStringToWidth(text, width - 6 - ellipsisWidth).trim() + "..."; + this.drawCenteredString(mc.fontRenderer, text, x + this.width / 2, y + (this.height - 8) / 2, + hovered ? 16777120 : 14737632); + gui.drawResource(hovered ? focused : normal, x + 3, y + 3); + } + }); + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntry.java b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntry.java new file mode 100644 index 0000000..5e53d17 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntry.java @@ -0,0 +1,44 @@ +package me.towdium.jecalculation.client.widget.widgets; + +import me.towdium.jecalculation.client.gui.JecGui; +import me.towdium.jecalculation.client.resource.Resource; +import me.towdium.jecalculation.client.widget.Widget; +import me.towdium.jecalculation.core.entry.Entry; + +/** + * Author: towdium + * Date: 17-8-17. + */ +public class WEntry extends Widget { + protected int xPos, yPos, xSize, ySize; + protected Entry entry; + + public WEntry(int xPos, int yPos, int xSize, int ySize) { + this.xPos = xPos; + this.yPos = yPos; + this.xSize = xSize; + this.ySize = ySize; + } + + public Entry getEntry() { + return entry; + } + + public void setEntry(Entry entry) { + this.entry = entry; + } + + @Override + public void onDraw(JecGui gui, int xMouse, int yMouse) { + gui.drawResourceContinuous(Resource.SLOT, xPos + gui.getGuiLeft(), yPos + gui.getGuiTop(), + xSize, ySize, 3, 3, 3, 3); + if (mouseIn(gui, xMouse, yMouse)) drawRect(gui.getGuiLeft() + xPos + 1, gui.getGuiTop() + yPos + 1, + gui.getGuiLeft() + xPos + xSize - 1, gui.getGuiTop() + yPos + ySize - 1, 0x80FFFFFF); + } + + public boolean mouseIn(JecGui gui, int x, int y) { + int xx = x - gui.getGuiLeft() - xPos; + int yy = y - gui.getGuiTop() - yPos; + return xx >= 0 && xx < xSize && yy >= 0 && yy < ySize; + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntryGroup.java b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntryGroup.java new file mode 100644 index 0000000..ac804f4 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WEntryGroup.java @@ -0,0 +1,44 @@ +package me.towdium.jecalculation.client.widget.widgets; + +import me.towdium.jecalculation.client.gui.JecGui; +import me.towdium.jecalculation.client.widget.Widget; + +import java.util.ArrayList; +import java.util.stream.IntStream; + +/** + * Author: towdium + * Date: 17-8-17. + */ +public class WEntryGroup extends Widget { + ArrayList widgets = new ArrayList<>(); + + public WEntryGroup(int xPos, int yPos, int column, int row) { + this(xPos, yPos, column, row, 18, 18); + } + + public WEntryGroup(int xPos, int yPos, int column, int row, int xSize, int ySize) { + IntStream.range(0, column).forEach(c -> IntStream.range(0, row).forEach(r -> + widgets.add(new WEntry(xPos + c * xSize, yPos + r * ySize, xSize, ySize)))); + } + + @Override + public void onGuiInit(JecGui gui) { + widgets.forEach(w -> w.onGuiInit(gui)); + } + + @Override + public void onDraw(JecGui gui, int xMouse, int yMouse) { + widgets.forEach(w -> w.onDraw(gui, xMouse, yMouse)); + } + + @Override + public void onRemoved(JecGui gui) { + widgets.forEach(w -> w.onRemoved(gui)); + } + + @Override + public void onClicked(JecGui gui, int xMouse, int yMouse, int button) { + widgets.forEach(w -> w.onClicked(gui, xMouse, yMouse, button)); + } +} diff --git a/src/main/java/me/towdium/jecalculation/client/widget/widgets/WLine.java b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WLine.java new file mode 100644 index 0000000..75d2138 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/client/widget/widgets/WLine.java @@ -0,0 +1,22 @@ +package me.towdium.jecalculation.client.widget.widgets; + +import me.towdium.jecalculation.client.gui.JecGui; +import me.towdium.jecalculation.client.resource.Resource; +import me.towdium.jecalculation.client.widget.Widget; + +/** + * Author: towdium + * Date: 17-8-18. + */ +public class WLine extends Widget { + protected int y; + + public WLine(int y) { + this.y = y; + } + + @Override + public void onDraw(JecGui gui, int xMouse, int yMouse) { + gui.drawResource(Resource.LINE, 6 + gui.getGuiLeft(), y + gui.getGuiTop() - 1); + } +} diff --git a/src/main/java/me/towdium/jecalculation/command/Commands.java b/src/main/java/me/towdium/jecalculation/command/Commands.java new file mode 100644 index 0000000..7b6934b --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/command/Commands.java @@ -0,0 +1,30 @@ +package me.towdium.jecalculation.command; + +import me.towdium.jecalculation.command.commands.CommandHelp; +import me.towdium.jecalculation.command.commands.CommandState; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.HashMap; + +/** + * Author: towdium + * Date: 8/10/17. + */ +@ParametersAreNonnullByDefault +public class Commands { + public static final HashMap commands; + + public static final CommandHelp commandHelp = new CommandHelp(); + public static final CommandState commandState = new CommandState(); + + static { + commands = new HashMap<>(); + + add(commandHelp); + add(commandState); + } + + static void add(SubCommand c) { + commands.put(c.getName(), c); + } +} diff --git a/src/main/java/me/towdium/jecalculation/command/JecaCommand.java b/src/main/java/me/towdium/jecalculation/command/JecaCommand.java new file mode 100644 index 0000000..17456c5 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/command/JecaCommand.java @@ -0,0 +1,69 @@ +package me.towdium.jecalculation.command; + +import me.towdium.jecalculation.utils.wrappers.Single; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentTranslation; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Collections; +import java.util.List; + +/** + * Author: towdium + * Date: 8/10/17. + */ +@ParametersAreNonnullByDefault +public class JecaCommand extends CommandBase { + @Override + public String getCommandName() { + return "jec"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "/jec [help]"; + } + + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 0 || args[0].toLowerCase().equals("help")) { + Commands.commandHelp.execute(sender, cut(args)); + } else { + SubCommand cmd = Commands.commands.get(args[0].toLowerCase()); + if (cmd != null) { + cmd.execute(sender, args); + } else { + sender.addChatMessage(new ChatComponentTranslation("command.not_found", args[0])); + } + } + } + + private String[] cut(String[] args) { + if (args.length == 0) + return new String[0]; + String[] ret = new String[args.length - 1]; + System.arraycopy(args, 1, ret, 0, args.length - 1); + return ret; + } + + @Override + public List addTabCompletionOptions(ICommandSender sender, String[] args) { + if (args.length == 0) { + return Collections.emptyList(); + } + + String cmd = args[0].toLowerCase(); + if (args.length == 1) { + return getListOfStringsFromIterableMatchingLastWord(args, Commands.commands.keySet()); + } else { + Single sub = new Single<>(null); + Commands.commands.values().stream().filter(c -> c.getName().equals(cmd)) + .findFirst().ifPresent(sub::push); + return sub.value == null ? sub.value.getTabCompletions(sender, cut(args)) + : Collections.emptyList(); + } + } +} diff --git a/src/main/java/me/towdium/jecalculation/command/SubCommand.java b/src/main/java/me/towdium/jecalculation/command/SubCommand.java new file mode 100644 index 0000000..69dda15 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/command/SubCommand.java @@ -0,0 +1,26 @@ +package me.towdium.jecalculation.command; + +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Collections; +import java.util.List; + +/** + * Author: towdium + * Date: 8/10/17. + */ +@ParametersAreNonnullByDefault +public interface SubCommand { + String getName(); + + String getUsage(ICommandSender sender); + + void execute(ICommandSender sender, String[] args) throws CommandException; + + @SuppressWarnings("unused") + default List getTabCompletions(ICommandSender sender, String[] args) { + return Collections.emptyList(); + } +} diff --git a/src/main/java/me/towdium/jecalculation/command/commands/CommandHelp.java b/src/main/java/me/towdium/jecalculation/command/commands/CommandHelp.java new file mode 100644 index 0000000..be69fbc --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/command/commands/CommandHelp.java @@ -0,0 +1,40 @@ +package me.towdium.jecalculation.command.commands; + +import me.towdium.jecalculation.command.Commands; +import me.towdium.jecalculation.command.SubCommand; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Comparator; + +/** + * Author: towdium + * Date: 8/10/17. + */ +@ParametersAreNonnullByDefault +public class CommandHelp implements SubCommand { + @Override + public String getName() { + return "help"; + } + + @Override + public String getUsage(ICommandSender sender) { + return "/jec [help]"; + } + + @Override + public void execute(ICommandSender sender, String[] args) throws CommandException { + if (args.length != 0) { + sender.addChatMessage(new ChatComponentTranslation("command.unexpected_arg", String.join(" ", args))); + return; + } + + sender.addChatMessage(new ChatComponentTranslation("command.help.list")); + Commands.commands.values().stream().sorted(Comparator.comparing(SubCommand::getName)) + .forEachOrdered(c -> sender.addChatMessage(new ChatComponentText(c.getUsage(sender)))); + } +} diff --git a/src/main/java/me/towdium/jecalculation/command/commands/CommandState.java b/src/main/java/me/towdium/jecalculation/command/commands/CommandState.java new file mode 100644 index 0000000..0931534 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/command/commands/CommandState.java @@ -0,0 +1,33 @@ +package me.towdium.jecalculation.command.commands; + +import me.towdium.jecalculation.JustEnoughCalculation; +import me.towdium.jecalculation.command.SubCommand; +import me.towdium.jecalculation.utils.helpers.LocalizationHelper; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentTranslation; + +import javax.annotation.ParametersAreNonnullByDefault; + +/** + * Author: towdium + * Date: 8/10/17. + */ +@ParametersAreNonnullByDefault +public class CommandState implements SubCommand { + @Override + public String getName() { + return "state"; + } + + @Override + public String getUsage(ICommandSender sender) { + return "/jec state"; + } + + @Override + public void execute(ICommandSender sender, String[] args) throws CommandException { + sender.addChatMessage(new ChatComponentTranslation("command.state.desc", + LocalizationHelper.format(JustEnoughCalculation.side.toString()))); + } +} diff --git a/src/main/java/me/towdium/jecalculation/core/entry/Entry.java b/src/main/java/me/towdium/jecalculation/core/entry/Entry.java new file mode 100644 index 0000000..904ffd9 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/core/entry/Entry.java @@ -0,0 +1,143 @@ +package me.towdium.jecalculation.core.entry; + +import me.towdium.jecalculation.core.entry.entries.EntryItemStack; +import me.towdium.jecalculation.utils.wrappers.Pair; +import me.towdium.jecalculation.utils.wrappers.Single; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.HashMap; +import java.util.Optional; +import java.util.function.Function; + +/** + * Author: towdium + * Date: 8/11/17. + */ +public interface Entry { + EntryMerger MERGER = EntryMerger.INSTANCE; + EntryRegistry REGISTRY = EntryRegistry.INSTANCE; + Entry EMPTY = new EntryItemStack(new ItemStack(new Item()), 0); + + int getAmount(); + + void setAmount(int amount); + + ItemStack getRepresentation(); + + String getAmountString(); + + /** + * Since {@link Entry} merging is bidirectional, it is redundant to + * implement on both side. So this class is created for merging + * {@link Entry Entry(s)}. + * It uses singleton mode. First register merge functions, then use + * {@link #test(Entry, Entry)} and {@link #merge(Entry, Entry, boolean)} + * to operate the {@link Entry}. + * For registering, see {@link EntryRegistry}. + */ + class EntryMerger { + private static final EntryMerger INSTANCE; + + static { + INSTANCE = new EntryMerger(); + // register functions here + } + + private Relation functions = new Relation<>(); + + private EntryMerger() { + } + + public void addFunction(String a, String b, MergerFunction func) { + functions.add(a, b, func); + } + + public Pair merge(Entry a, Entry b, boolean add) { + return functions.get(REGISTRY.getIdentifier(a), REGISTRY.getIdentifier(b)) + .orElse((x, y, f) -> new Pair<>(x, y)).merge(a, b, add); + } + + public boolean test(Entry a, Entry b) { + Optional f = functions.get(REGISTRY.getIdentifier(a), REGISTRY.getIdentifier(b)); + if (!f.isPresent()) return false; + else { + Pair p = f.get().merge(a, b, true); + return (!(p.one == a && p.two == b) && !(p.two == a && p.one == a)); + } + } + + @FunctionalInterface + public interface MergerFunction { + /** + * @param a an {@link Entry} to merge + * @param b another {@link Entry} to merge + * @param add add together or cancel each other + * @return merged {@link Entry Entry(s)} if not changed (no matter order), they cannot merge. + */ + Pair merge(Entry a, Entry b, boolean add); + } + } + + /** + * This class is used to register an {@link Entry} type. + * Here you can find the identifier and deserializer of one type. + * For {@link Entry} operations, see {@link EntryMerger} + */ + class EntryRegistry { + public static final String KEY_IDENTIFIER = "identifier"; + public static final String KEY_CONTENT = "content"; + private static final EntryRegistry INSTANCE; + + static { + INSTANCE = new EntryRegistry(); + } + + private HashMap, Pair>>> clazzToData = new HashMap<>(); + private HashMap, + Function>>> idToData = new HashMap<>(); + + private EntryRegistry() { + } + + public void register( + Class clazz, String identifier, Function> deserializer) { + clazzToData.put(clazz, new Pair<>(identifier, deserializer)); + idToData.put(identifier, new Pair<>(clazz, deserializer)); + } + + public Entry deserialization(NBTTagCompound nbt) { + String s = nbt.getString(KEY_IDENTIFIER); + Optional e = idToData.get(s).two.apply(nbt.getCompoundTag(KEY_CONTENT)); + if (e.isPresent()) return e.get(); + else throw new RuntimeException("Fail to deserialize entry type: " + s); + } + + public String getIdentifier(Entry e) { + Pair>> p = clazzToData.get(e.getClass()); + if (p == null) throw new RuntimeException("Unregistered entry type: " + e.getClass()); + else return p.one; + } + } + + class Relation { + HashMap, R> data = new HashMap<>(); + + public void add(T a, T b, R relation) { + data.put(a.hashCode() < b.hashCode() ? new Pair<>(a, b) : new Pair<>(b, a), relation); + } + + public Optional get(T a, T b) { + int ah = a.hashCode(); + int bh = b.hashCode(); + Single ret = new Single<>(null); + if (ah == bh) + ret.push(data.get(new Pair<>(a, b))).push(data.get(new Pair<>(b, a))); + else + ret.push(data.get(ah < bh ? new Pair<>(a, b) : new Pair<>(b, a))); + return Optional.ofNullable(ret.value); + } + } +} diff --git a/src/main/java/me/towdium/jecalculation/core/entry/entries/EntryItemStack.java b/src/main/java/me/towdium/jecalculation/core/entry/entries/EntryItemStack.java new file mode 100644 index 0000000..32961c5 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/core/entry/entries/EntryItemStack.java @@ -0,0 +1,39 @@ +package me.towdium.jecalculation.core.entry.entries; + +import me.towdium.jecalculation.core.entry.Entry; +import net.minecraft.item.ItemStack; + +/** + * Author: towdium + * Date: 8/11/17. + */ +public class EntryItemStack implements Entry { + int amount; + ItemStack itemStack; + + // I will copy it! + public EntryItemStack(ItemStack is, int amount) { + itemStack = is.copy(); + this.amount = amount; + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public void setAmount(int amount) { + this.amount = amount; + } + + @Override + public ItemStack getRepresentation() { + return itemStack; + } + + @Override + public String getAmountString() { + return Integer.toString(amount); // TODO format + } +} diff --git a/src/main/java/me/towdium/jecalculation/event/Handlers.java b/src/main/java/me/towdium/jecalculation/event/Handlers.java new file mode 100644 index 0000000..6b4f17c --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/event/Handlers.java @@ -0,0 +1,15 @@ +package me.towdium.jecalculation.event; + +import me.towdium.jecalculation.event.handlers.InputEventHandler; + +import java.util.ArrayList; + +public class Handlers { + public static final ArrayList handlers; + + static { + handlers = new ArrayList<>(); + + handlers.add(new InputEventHandler()); + } +} diff --git a/src/main/java/me/towdium/jecalculation/event/handlers/InputEventHandler.java b/src/main/java/me/towdium/jecalculation/event/handlers/InputEventHandler.java new file mode 100644 index 0000000..862afcc --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/event/handlers/InputEventHandler.java @@ -0,0 +1,27 @@ +package me.towdium.jecalculation.event.handlers; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import me.towdium.jecalculation.JustEnoughCalculation; +import me.towdium.jecalculation.client.gui.guis.GuiCalculator; +import me.towdium.jecalculation.network.ProxyClient; +import net.minecraft.client.Minecraft; + +/** + * Author: towdium + * Date: 8/13/17. + */ +public class InputEventHandler { + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) + public void onKey(InputEvent.KeyInputEvent event) { + if (ProxyClient.keyOpenGui.isPressed() && JustEnoughCalculation.side != JustEnoughCalculation.enumSide.SERVER) { + JustEnoughCalculation.logger.info("key pressed"); + Minecraft.getMinecraft().displayGuiScreen(new GuiCalculator(null)); + } + } +} + diff --git a/src/main/java/me/towdium/jecalculation/gui/JecaContainer.java b/src/main/java/me/towdium/jecalculation/gui/JecaContainer.java index aceb2dc..5fad611 100644 --- a/src/main/java/me/towdium/jecalculation/gui/JecaContainer.java +++ b/src/main/java/me/towdium/jecalculation/gui/JecaContainer.java @@ -1,7 +1,7 @@ package me.towdium.jecalculation.gui; import me.towdium.jecalculation.utils.ItemStackHelper; -import me.towdium.jecalculation.utils.polyfill.ClickType; +import me.towdium.jecalculation.polyfill.ClickType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryBasic; diff --git a/src/main/java/me/towdium/jecalculation/gui/JecaGuiContainer.java b/src/main/java/me/towdium/jecalculation/gui/JecaGuiContainer.java index 389c097..4da9899 100644 --- a/src/main/java/me/towdium/jecalculation/gui/JecaGuiContainer.java +++ b/src/main/java/me/towdium/jecalculation/gui/JecaGuiContainer.java @@ -1,7 +1,7 @@ package me.towdium.jecalculation.gui; import me.towdium.jecalculation.utils.ItemStackHelper; -import me.towdium.jecalculation.utils.polyfill.SoundEvents; +import me.towdium.jecalculation.polyfill.SoundEvents; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -9,7 +9,6 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; diff --git a/src/main/java/me/towdium/jecalculation/gui/guis/GuiCalculator.java b/src/main/java/me/towdium/jecalculation/gui/guis/GuiCalculator.java index 36ec225..5e48212 100644 --- a/src/main/java/me/towdium/jecalculation/gui/guis/GuiCalculator.java +++ b/src/main/java/me/towdium/jecalculation/gui/guis/GuiCalculator.java @@ -97,7 +97,7 @@ public class GuiCalculator extends JecaGuiContainer { protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture( - new ResourceLocation(JustEnoughCalculation.Reference.MODID, "textures/gui/guiCalculator.png")); + new ResourceLocation(JustEnoughCalculation.Reference.MODID, "textures/gui/gui_calculator.png")); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); textFieldAmount.drawTextBox(); } diff --git a/src/main/java/me/towdium/jecalculation/item/Items.java b/src/main/java/me/towdium/jecalculation/item/Items.java new file mode 100644 index 0000000..2ca361c --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/item/Items.java @@ -0,0 +1,17 @@ +package me.towdium.jecalculation.item; + +import me.towdium.jecalculation.item.items.ItemCalculator; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.ArrayList; + +@ParametersAreNonnullByDefault +public class Items { + public static final ArrayList items; + public static final ItemCalculator itemCalculator = new ItemCalculator(); + + static { + items = new ArrayList<>(); + items.add(itemCalculator); + } +} diff --git a/src/main/java/me/towdium/jecalculation/item/JecaItem.java b/src/main/java/me/towdium/jecalculation/item/JecaItem.java new file mode 100644 index 0000000..b85776d --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/item/JecaItem.java @@ -0,0 +1,44 @@ +package me.towdium.jecalculation.item; + +import me.towdium.jecalculation.JustEnoughCalculation; +import me.towdium.jecalculation.gui.GuiHandler; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + + +/** + * @author Towdium + */ +public class JecaItem extends Item { + public static JecaItem INSTANCE = new JecaItem(); + + public static final String CRAFTING_NAME = "item_calculator_crafting"; + public static final String MATH_NAME = "item_calculator_math"; + + + public JecaItem() { + setHasSubtypes(true); + setMaxStackSize(1); + setUnlocalizedName(CRAFTING_NAME); + setTextureName(JustEnoughCalculation.Reference.MODID + ":" + CRAFTING_NAME); + setCreativeTab(CreativeTabs.tabTools); + } + +// @Override +// public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { +// playerIn.openGui(JustEnoughCalculation.INSTANCE, GuiHandler.GuiId.EDITOR, worldIn, 0, 0, 0); +// return itemStackIn; +// } + + public String getUnlocalizedName(int meta) { + return getUnlocalizedName(); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return getUnlocalizedName(stack.getItemDamage()); + } +} \ No newline at end of file diff --git a/src/main/java/me/towdium/jecalculation/item/items/ItemCalculator.java b/src/main/java/me/towdium/jecalculation/item/items/ItemCalculator.java new file mode 100644 index 0000000..4e0f6ba --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/item/items/ItemCalculator.java @@ -0,0 +1,40 @@ +package me.towdium.jecalculation.item.items; + +import me.towdium.jecalculation.JustEnoughCalculation; +import me.towdium.jecalculation.item.JecaItem; +import me.towdium.jecalculation.utils.IllegalPositionException; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public class ItemCalculator extends JecaItem { + public ItemCalculator() { + setHasSubtypes(true); + setMaxStackSize(1); + setCreativeTab(CreativeTabs.tabTools); + setUnlocalizedName("item_calculator"); + setTextureName(JustEnoughCalculation.Reference.MODID + ":" + CRAFTING_NAME); + } + + @Override + public String getUnlocalizedName(int meta) { + switch (meta) { + case 0: + return "item.item_calculator_crafting"; + case 1: + return "item.item_calculator_math"; + default: + throw new IllegalPositionException(); + } + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List items) { + if (tab == CreativeTabs.tabAllSearch || tab == CreativeTabs.tabTools) { + items.add(new ItemStack(this, 1, 0)); + items.add(new ItemStack(this, 1, 1)); + } + } +} diff --git a/src/main/java/me/towdium/jecalculation/network/IProxy.java b/src/main/java/me/towdium/jecalculation/network/IProxy.java deleted file mode 100644 index fcd0a74..0000000 --- a/src/main/java/me/towdium/jecalculation/network/IProxy.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.towdium.jecalculation.network; - -public interface IProxy { - void preInit(); - - void init(); - -} diff --git a/src/main/java/me/towdium/jecalculation/network/ProxyClient.java b/src/main/java/me/towdium/jecalculation/network/ProxyClient.java index 9f1011e..a626e9d 100644 --- a/src/main/java/me/towdium/jecalculation/network/ProxyClient.java +++ b/src/main/java/me/towdium/jecalculation/network/ProxyClient.java @@ -1,21 +1,28 @@ package me.towdium.jecalculation.network; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import cpw.mods.fml.client.registry.ClientRegistry; import me.towdium.jecalculation.JustEnoughCalculation; -import me.towdium.jecalculation.gui.GuiHandler; +import me.towdium.jecalculation.command.JecaCommand; +import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.client.ClientCommandHandler; +import org.lwjgl.input.Keyboard; + +public class ProxyClient extends ProxyCommon{ + public static final KeyBinding keyOpenGui = + new KeyBinding("key.open_gui", Keyboard.KEY_F, "key.category"); + -@SideOnly(Side.CLIENT) -public class ProxyClient implements IProxy { @Override - public void preInit() { - + public void initPost() { + super.initPost(); + JustEnoughCalculation.logger.info("client proxy init post"); + ClientCommandHandler.instance.registerCommand(new JecaCommand()); } @Override public void init() { - NetworkRegistry.INSTANCE.registerGuiHandler(JustEnoughCalculation.INSTANCE, new GuiHandler()); + super.init(); + JustEnoughCalculation.logger.info("client proxy init"); + ClientRegistry.registerKeyBinding(keyOpenGui); } - } diff --git a/src/main/java/me/towdium/jecalculation/network/ProxyCommon.java b/src/main/java/me/towdium/jecalculation/network/ProxyCommon.java new file mode 100644 index 0000000..a57933e --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/network/ProxyCommon.java @@ -0,0 +1,24 @@ +package me.towdium.jecalculation.network; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.registry.GameRegistry; +import me.towdium.jecalculation.JustEnoughCalculation; +import me.towdium.jecalculation.event.Handlers; +import me.towdium.jecalculation.item.JecaItem; +import net.minecraftforge.common.MinecraftForge; + +public class ProxyCommon { + public void initPre() { + JustEnoughCalculation.logger.info("common proxy init pre"); + GameRegistry.registerItem(JecaItem.INSTANCE, JecaItem.CRAFTING_NAME); + Handlers.handlers.forEach(FMLCommonHandler.instance().bus()::register); + } + + public void init() { + JustEnoughCalculation.logger.info("common proxy init"); + } + + public void initPost() { + JustEnoughCalculation.logger.info("common proxy init post"); + } +} diff --git a/src/main/java/me/towdium/jecalculation/network/ProxyServer.java b/src/main/java/me/towdium/jecalculation/network/ProxyServer.java deleted file mode 100644 index 0f4ea29..0000000 --- a/src/main/java/me/towdium/jecalculation/network/ProxyServer.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.towdium.jecalculation.network; - -public class ProxyServer implements IProxy { - @Override - public void preInit() { - - } - - @Override - public void init() { - - } - -} diff --git a/src/main/java/me/towdium/jecalculation/utils/polyfill/ClickType.java b/src/main/java/me/towdium/jecalculation/polyfill/ClickType.java similarity index 86% rename from src/main/java/me/towdium/jecalculation/utils/polyfill/ClickType.java rename to src/main/java/me/towdium/jecalculation/polyfill/ClickType.java index 791f0e9..8fa0bd5 100644 --- a/src/main/java/me/towdium/jecalculation/utils/polyfill/ClickType.java +++ b/src/main/java/me/towdium/jecalculation/polyfill/ClickType.java @@ -1,4 +1,4 @@ -package me.towdium.jecalculation.utils.polyfill; +package me.towdium.jecalculation.polyfill; public class ClickType { public static final int PICKUP = 0; diff --git a/src/main/java/me/towdium/jecalculation/utils/polyfill/Event.java b/src/main/java/me/towdium/jecalculation/polyfill/Event.java similarity index 100% rename from src/main/java/me/towdium/jecalculation/utils/polyfill/Event.java rename to src/main/java/me/towdium/jecalculation/polyfill/Event.java diff --git a/src/main/java/me/towdium/jecalculation/utils/polyfill/Loader.java b/src/main/java/me/towdium/jecalculation/polyfill/Loader.java similarity index 100% rename from src/main/java/me/towdium/jecalculation/utils/polyfill/Loader.java rename to src/main/java/me/towdium/jecalculation/polyfill/Loader.java diff --git a/src/main/java/me/towdium/jecalculation/utils/polyfill/Polyfill.java b/src/main/java/me/towdium/jecalculation/polyfill/Polyfill.java similarity index 94% rename from src/main/java/me/towdium/jecalculation/utils/polyfill/Polyfill.java rename to src/main/java/me/towdium/jecalculation/polyfill/Polyfill.java index 4131573..5e120f2 100644 --- a/src/main/java/me/towdium/jecalculation/utils/polyfill/Polyfill.java +++ b/src/main/java/me/towdium/jecalculation/polyfill/Polyfill.java @@ -1,4 +1,4 @@ -package me.towdium.jecalculation.utils.polyfill; +package me.towdium.jecalculation.polyfill; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/me/towdium/jecalculation/utils/polyfill/SoundEvents.java b/src/main/java/me/towdium/jecalculation/polyfill/SoundEvents.java similarity index 66% rename from src/main/java/me/towdium/jecalculation/utils/polyfill/SoundEvents.java rename to src/main/java/me/towdium/jecalculation/polyfill/SoundEvents.java index 5a659d9..7b0fc3d 100644 --- a/src/main/java/me/towdium/jecalculation/utils/polyfill/SoundEvents.java +++ b/src/main/java/me/towdium/jecalculation/polyfill/SoundEvents.java @@ -1,4 +1,4 @@ -package me.towdium.jecalculation.utils.polyfill; +package me.towdium.jecalculation.polyfill; public class SoundEvents { public static final String UI_BUTTON_CLICK = "gui.button.press"; diff --git a/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java b/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java new file mode 100644 index 0000000..194daee --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java @@ -0,0 +1,1449 @@ +package me.towdium.jecalculation.polyfill.mc.client.renderer; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import javax.annotation.Nullable; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL15; +import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.GL12; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.util.vector.Quaternion; + +@SuppressWarnings("ALL") +@SideOnly(Side.CLIENT) +public class GlStateManager +{ + private static final FloatBuffer BUF_FLOAT_16 = BufferUtils.createFloatBuffer(16); + private static final FloatBuffer BUF_FLOAT_4 = BufferUtils.createFloatBuffer(4); + private static final GlStateManager.AlphaState alphaState = new GlStateManager.AlphaState(); + private static final GlStateManager.BooleanState lightingState = new GlStateManager.BooleanState(2896); + private static final GlStateManager.BooleanState[] lightState = new GlStateManager.BooleanState[8]; + private static final GlStateManager.ColorMaterialState colorMaterialState; + private static final GlStateManager.BlendState blendState; + private static final GlStateManager.DepthState depthState; + private static final GlStateManager.FogState fogState; + private static final GlStateManager.CullState cullState; + private static final GlStateManager.PolygonOffsetState polygonOffsetState; + private static final GlStateManager.ColorLogicState colorLogicState; + private static final GlStateManager.TexGenState texGenState; + private static final GlStateManager.ClearState clearState; + private static final GlStateManager.StencilState stencilState; + private static final GlStateManager.BooleanState normalizeState; + private static int activeTextureUnit; + private static final GlStateManager.TextureState[] textureState; + private static int activeShadeModel; + private static final GlStateManager.BooleanState rescaleNormalState; + private static final GlStateManager.ColorMask colorMaskState; + private static final GlStateManager.Color colorState; + + public static void pushAttrib() + { + GL11.glPushAttrib(8256); + } + + public static void popAttrib() + { + GL11.glPopAttrib(); + } + + public static void disableAlpha() + { + alphaState.alphaTest.setDisabled(); + } + + public static void enableAlpha() + { + alphaState.alphaTest.setEnabled(); + } + + public static void alphaFunc(int func, float ref) + { + if (func != alphaState.func || ref != alphaState.ref) + { + alphaState.func = func; + alphaState.ref = ref; + GL11.glAlphaFunc(func, ref); + } + } + + public static void enableLighting() + { + lightingState.setEnabled(); + } + + public static void disableLighting() + { + lightingState.setDisabled(); + } + + public static void enableLight(int light) + { + lightState[light].setEnabled(); + } + + public static void disableLight(int light) + { + lightState[light].setDisabled(); + } + + public static void enableColorMaterial() + { + colorMaterialState.colorMaterial.setEnabled(); + } + + public static void disableColorMaterial() + { + colorMaterialState.colorMaterial.setDisabled(); + } + + public static void colorMaterial(int face, int mode) + { + if (face != colorMaterialState.face || mode != colorMaterialState.mode) + { + colorMaterialState.face = face; + colorMaterialState.mode = mode; + GL11.glColorMaterial(face, mode); + } + } + + public static void glLight(int light, int pname, FloatBuffer params) + { + GL11.glLight(light, pname, params); + } + + public static void glLightModel(int pname, FloatBuffer params) + { + GL11.glLightModel(pname, params); + } + + public static void glNormal3f(float nx, float ny, float nz) + { + GL11.glNormal3f(nx, ny, nz); + } + + public static void disableDepth() + { + depthState.depthTest.setDisabled(); + } + + public static void enableDepth() + { + depthState.depthTest.setEnabled(); + } + + public static void depthFunc(int depthFunc) + { + if (depthFunc != depthState.depthFunc) + { + depthState.depthFunc = depthFunc; + GL11.glDepthFunc(depthFunc); + } + } + + public static void depthMask(boolean flagIn) + { + if (flagIn != depthState.maskEnabled) + { + depthState.maskEnabled = flagIn; + GL11.glDepthMask(flagIn); + } + } + + public static void disableBlend() + { + blendState.blend.setDisabled(); + } + + public static void enableBlend() + { + blendState.blend.setEnabled(); + } + + public static void blendFunc(GlStateManager.SourceFactor srcFactor, GlStateManager.DestFactor dstFactor) + { + blendFunc(srcFactor.factor, dstFactor.factor); + } + + public static void blendFunc(int srcFactor, int dstFactor) + { + if (srcFactor != blendState.srcFactor || dstFactor != blendState.dstFactor) + { + blendState.srcFactor = srcFactor; + blendState.dstFactor = dstFactor; + GL11.glBlendFunc(srcFactor, dstFactor); + } + } + + public static void tryBlendFuncSeparate(GlStateManager.SourceFactor srcFactor, GlStateManager.DestFactor dstFactor, GlStateManager.SourceFactor srcFactorAlpha, GlStateManager.DestFactor dstFactorAlpha) + { + tryBlendFuncSeparate(srcFactor.factor, dstFactor.factor, srcFactorAlpha.factor, dstFactorAlpha.factor); + } + + public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) + { + if (srcFactor != blendState.srcFactor || dstFactor != blendState.dstFactor || srcFactorAlpha != blendState.srcFactorAlpha || dstFactorAlpha != blendState.dstFactorAlpha) + { + blendState.srcFactor = srcFactor; + blendState.dstFactor = dstFactor; + blendState.srcFactorAlpha = srcFactorAlpha; + blendState.dstFactorAlpha = dstFactorAlpha; + OpenGlHelper.glBlendFunc(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); + } + } + + public static void glBlendEquation(int blendEquation) + { + GL14.glBlendEquation(blendEquation); + } + + @SuppressWarnings("PointlessBitwiseExpression") + public static void enableOutlineMode(int color) + { + BUF_FLOAT_4.put(0, (float)(color >> 16 & 255) / 255.0F); + BUF_FLOAT_4.put(1, (float)(color >> 8 & 255) / 255.0F); + BUF_FLOAT_4.put(2, (float)(color >> 0 & 255) / 255.0F); + BUF_FLOAT_4.put(3, (float)(color >> 24 & 255) / 255.0F); + glTexEnv(8960, 8705, BUF_FLOAT_4); + glTexEnvi(8960, 8704, 34160); + glTexEnvi(8960, 34161, 7681); + glTexEnvi(8960, 34176, 34166); + glTexEnvi(8960, 34192, 768); + glTexEnvi(8960, 34162, 7681); + glTexEnvi(8960, 34184, 5890); + glTexEnvi(8960, 34200, 770); + } + + public static void disableOutlineMode() + { + glTexEnvi(8960, 8704, 8448); + glTexEnvi(8960, 34161, 8448); + glTexEnvi(8960, 34162, 8448); + glTexEnvi(8960, 34176, 5890); + glTexEnvi(8960, 34184, 5890); + glTexEnvi(8960, 34192, 768); + glTexEnvi(8960, 34200, 770); + } + + public static void enableFog() + { + fogState.fog.setEnabled(); + } + + public static void disableFog() + { + fogState.fog.setDisabled(); + } + + public static void setFog(GlStateManager.FogMode fogMode) + { + setFog(fogMode.capabilityId); + } + + private static void setFog(int param) + { + if (param != fogState.mode) + { + fogState.mode = param; + GL11.glFogi(GL11.GL_FOG_MODE, param); + } + } + + public static void setFogDensity(float param) + { + if (param != fogState.density) + { + fogState.density = param; + GL11.glFogf(GL11.GL_FOG_DENSITY, param); + } + } + + public static void setFogStart(float param) + { + if (param != fogState.start) + { + fogState.start = param; + GL11.glFogf(GL11.GL_FOG_START, param); + } + } + + public static void setFogEnd(float param) + { + if (param != fogState.end) + { + fogState.end = param; + GL11.glFogf(GL11.GL_FOG_END, param); + } + } + + public static void glFog(int pname, FloatBuffer param) + { + GL11.glFog(pname, param); + } + + public static void glFogi(int pname, int param) + { + GL11.glFogi(pname, param); + } + + public static void enableCull() + { + cullState.cullFace.setEnabled(); + } + + public static void disableCull() + { + cullState.cullFace.setDisabled(); + } + + public static void cullFace(GlStateManager.CullFace cullFace) + { + cullFace(cullFace.mode); + } + + private static void cullFace(int mode) + { + if (mode != cullState.mode) + { + cullState.mode = mode; + GL11.glCullFace(mode); + } + } + + public static void glPolygonMode(int face, int mode) + { + GL11.glPolygonMode(face, mode); + } + + public static void enablePolygonOffset() + { + polygonOffsetState.polygonOffsetFill.setEnabled(); + } + + public static void disablePolygonOffset() + { + polygonOffsetState.polygonOffsetFill.setDisabled(); + } + + public static void doPolygonOffset(float factor, float units) + { + if (factor != polygonOffsetState.factor || units != polygonOffsetState.units) + { + polygonOffsetState.factor = factor; + polygonOffsetState.units = units; + GL11.glPolygonOffset(factor, units); + } + } + + public static void enableColorLogic() + { + colorLogicState.colorLogicOp.setEnabled(); + } + + public static void disableColorLogic() + { + colorLogicState.colorLogicOp.setDisabled(); + } + + public static void colorLogicOp(GlStateManager.LogicOp logicOperation) + { + colorLogicOp(logicOperation.opcode); + } + + public static void colorLogicOp(int opcode) + { + if (opcode != colorLogicState.opcode) + { + colorLogicState.opcode = opcode; + GL11.glLogicOp(opcode); + } + } + + public static void enableTexGenCoord(GlStateManager.TexGen texGen) + { + texGenCoord(texGen).textureGen.setEnabled(); + } + + public static void disableTexGenCoord(GlStateManager.TexGen texGen) + { + texGenCoord(texGen).textureGen.setDisabled(); + } + + public static void texGen(GlStateManager.TexGen texGen, int param) + { + GlStateManager.TexGenCoord glstatemanager$texgencoord = texGenCoord(texGen); + + if (param != glstatemanager$texgencoord.param) + { + glstatemanager$texgencoord.param = param; + GL11.glTexGeni(glstatemanager$texgencoord.coord, GL11.GL_TEXTURE_GEN_MODE, param); + } + } + + public static void texGen(GlStateManager.TexGen texGen, int pname, FloatBuffer params) + { + GL11.glTexGen(texGenCoord(texGen).coord, pname, params); + } + + private static GlStateManager.TexGenCoord texGenCoord(GlStateManager.TexGen texGen) + { + switch (texGen) + { + case S: + return texGenState.s; + case T: + return texGenState.t; + case R: + return texGenState.r; + case Q: + return texGenState.q; + default: + return texGenState.s; + } + } + + public static void setActiveTexture(int texture) + { + if (activeTextureUnit != texture - OpenGlHelper.defaultTexUnit) + { + activeTextureUnit = texture - OpenGlHelper.defaultTexUnit; + OpenGlHelper.setActiveTexture(texture); + } + } + + public static void enableTexture2D() + { + textureState[activeTextureUnit].texture2DState.setEnabled(); + } + + public static void disableTexture2D() + { + textureState[activeTextureUnit].texture2DState.setDisabled(); + } + + public static void glTexEnv(int target, int parameterName, FloatBuffer parameters) + { + GL11.glTexEnv(target, parameterName, parameters); + } + + public static void glTexEnvi(int target, int parameterName, int parameter) + { + GL11.glTexEnvi(target, parameterName, parameter); + } + + public static void glTexEnvf(int target, int parameterName, float parameter) + { + GL11.glTexEnvf(target, parameterName, parameter); + } + + public static void glTexParameterf(int target, int parameterName, float parameter) + { + GL11.glTexParameterf(target, parameterName, parameter); + } + + public static void glTexParameteri(int target, int parameterName, int parameter) + { + GL11.glTexParameteri(target, parameterName, parameter); + } + + public static int glGetTexLevelParameteri(int target, int level, int parameterName) + { + return GL11.glGetTexLevelParameteri(target, level, parameterName); + } + + public static int generateTexture() + { + return GL11.glGenTextures(); + } + + public static void deleteTexture(int texture) + { + GL11.glDeleteTextures(texture); + + for (GlStateManager.TextureState glstatemanager$texturestate : textureState) + { + if (glstatemanager$texturestate.textureName == texture) + { + glstatemanager$texturestate.textureName = -1; + } + } + } + + public static void bindTexture(int texture) + { + if (texture != textureState[activeTextureUnit].textureName) + { + textureState[activeTextureUnit].textureName = texture; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); + } + } + + public static void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, @Nullable IntBuffer pixels) + { + GL11.glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); + } + + public static void glTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, IntBuffer pixels) + { + GL11.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, pixels); + } + + public static void glCopyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) + { + GL11.glCopyTexSubImage2D(target, level, xOffset, yOffset, x, y, width, height); + } + + public static void glGetTexImage(int target, int level, int format, int type, IntBuffer pixels) + { + GL11.glGetTexImage(target, level, format, type, pixels); + } + + public static void enableNormalize() + { + normalizeState.setEnabled(); + } + + public static void disableNormalize() + { + normalizeState.setDisabled(); + } + + public static void shadeModel(int mode) + { + if (mode != activeShadeModel) + { + activeShadeModel = mode; + GL11.glShadeModel(mode); + } + } + + public static void enableRescaleNormal() + { + rescaleNormalState.setEnabled(); + } + + public static void disableRescaleNormal() + { + rescaleNormalState.setDisabled(); + } + + public static void viewport(int x, int y, int width, int height) + { + GL11.glViewport(x, y, width, height); + } + + public static void colorMask(boolean red, boolean green, boolean blue, boolean alpha) + { + if (red != colorMaskState.red || green != colorMaskState.green || blue != colorMaskState.blue || alpha != colorMaskState.alpha) + { + colorMaskState.red = red; + colorMaskState.green = green; + colorMaskState.blue = blue; + colorMaskState.alpha = alpha; + GL11.glColorMask(red, green, blue, alpha); + } + } + + public static void clearDepth(double depth) + { + if (depth != clearState.depth) + { + clearState.depth = depth; + GL11.glClearDepth(depth); + } + } + + public static void clearColor(float red, float green, float blue, float alpha) + { + if (red != clearState.color.red || green != clearState.color.green || blue != clearState.color.blue || alpha != clearState.color.alpha) + { + clearState.color.red = red; + clearState.color.green = green; + clearState.color.blue = blue; + clearState.color.alpha = alpha; + GL11.glClearColor(red, green, blue, alpha); + } + } + + public static void clear(int mask) + { + GL11.glClear(mask); + } + + public static void matrixMode(int mode) + { + GL11.glMatrixMode(mode); + } + + public static void loadIdentity() + { + GL11.glLoadIdentity(); + } + + public static void pushMatrix() + { + GL11.glPushMatrix(); + } + + public static void popMatrix() + { + GL11.glPopMatrix(); + } + + public static void getFloat(int pname, FloatBuffer params) + { + GL11.glGetFloat(pname, params); + } + + public static void ortho(double left, double right, double bottom, double top, double zNear, double zFar) + { + GL11.glOrtho(left, right, bottom, top, zNear, zFar); + } + + public static void rotate(float angle, float x, float y, float z) + { + GL11.glRotatef(angle, x, y, z); + } + + public static void scale(float x, float y, float z) + { + GL11.glScalef(x, y, z); + } + + public static void scale(double x, double y, double z) + { + GL11.glScaled(x, y, z); + } + + public static void translate(float x, float y, float z) + { + GL11.glTranslatef(x, y, z); + } + + public static void translate(double x, double y, double z) + { + GL11.glTranslated(x, y, z); + } + + public static void multMatrix(FloatBuffer matrix) + { + GL11.glMultMatrix(matrix); + } + + public static void rotate(Quaternion quaternionIn) + { + multMatrix(quatToGlMatrix(BUF_FLOAT_16, quaternionIn)); + } + + public static FloatBuffer quatToGlMatrix(FloatBuffer buffer, Quaternion quaternionIn) + { + buffer.clear(); + float f = quaternionIn.x * quaternionIn.x; + float f1 = quaternionIn.x * quaternionIn.y; + float f2 = quaternionIn.x * quaternionIn.z; + float f3 = quaternionIn.x * quaternionIn.w; + float f4 = quaternionIn.y * quaternionIn.y; + float f5 = quaternionIn.y * quaternionIn.z; + float f6 = quaternionIn.y * quaternionIn.w; + float f7 = quaternionIn.z * quaternionIn.z; + float f8 = quaternionIn.z * quaternionIn.w; + buffer.put(1.0F - 2.0F * (f4 + f7)); + buffer.put(2.0F * (f1 + f8)); + buffer.put(2.0F * (f2 - f6)); + buffer.put(0.0F); + buffer.put(2.0F * (f1 - f8)); + buffer.put(1.0F - 2.0F * (f + f7)); + buffer.put(2.0F * (f5 + f3)); + buffer.put(0.0F); + buffer.put(2.0F * (f2 + f6)); + buffer.put(2.0F * (f5 - f3)); + buffer.put(1.0F - 2.0F * (f + f4)); + buffer.put(0.0F); + buffer.put(0.0F); + buffer.put(0.0F); + buffer.put(0.0F); + buffer.put(1.0F); + buffer.rewind(); + return buffer; + } + + public static void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) + { + if (colorRed != colorState.red || colorGreen != colorState.green || colorBlue != colorState.blue || colorAlpha != colorState.alpha) + { + colorState.red = colorRed; + colorState.green = colorGreen; + colorState.blue = colorBlue; + colorState.alpha = colorAlpha; + GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); + } + } + + public static void color(float colorRed, float colorGreen, float colorBlue) + { + color(colorRed, colorGreen, colorBlue, 1.0F); + } + + public static void glTexCoord2f(float sCoord, float tCoord) + { + GL11.glTexCoord2f(sCoord, tCoord); + } + + public static void glVertex3f(float x, float y, float z) + { + GL11.glVertex3f(x, y, z); + } + + public static void resetColor() + { + colorState.red = -1.0F; + colorState.green = -1.0F; + colorState.blue = -1.0F; + colorState.alpha = -1.0F; + } + + public static void glNormalPointer(int type, int stride, ByteBuffer buffer) + { + GL11.glNormalPointer(type, stride, buffer); + } + + public static void glTexCoordPointer(int size, int type, int stride, int buffer_offset) + { + GL11.glTexCoordPointer(size, type, stride, buffer_offset); + } + + public static void glTexCoordPointer(int size, int type, int stride, ByteBuffer buffer) + { + GL11.glTexCoordPointer(size, type, stride, buffer); + } + + public static void glVertexPointer(int size, int type, int stride, int buffer_offset) + { + GL11.glVertexPointer(size, type, stride, buffer_offset); + } + + public static void glVertexPointer(int size, int type, int stride, ByteBuffer buffer) + { + GL11.glVertexPointer(size, type, stride, buffer); + } + + public static void glColorPointer(int size, int type, int stride, int buffer_offset) + { + GL11.glColorPointer(size, type, stride, buffer_offset); + } + + public static void glColorPointer(int size, int type, int stride, ByteBuffer buffer) + { + GL11.glColorPointer(size, type, stride, buffer); + } + + public static void glDisableClientState(int cap) + { + GL11.glDisableClientState(cap); + } + + public static void glEnableClientState(int cap) + { + GL11.glEnableClientState(cap); + } + + public static void glBegin(int mode) + { + GL11.glBegin(mode); + } + + public static void glEnd() + { + GL11.glEnd(); + } + + public static void glDrawArrays(int mode, int first, int count) + { + GL11.glDrawArrays(mode, first, count); + } + + public static void glLineWidth(float width) + { + GL11.glLineWidth(width); + } + + public static void callList(int list) + { + GL11.glCallList(list); + } + + public static void glDeleteLists(int list, int range) + { + GL11.glDeleteLists(list, range); + } + + public static void glNewList(int list, int mode) + { + GL11.glNewList(list, mode); + } + + public static void glEndList() + { + GL11.glEndList(); + } + + public static int glGenLists(int range) + { + return GL11.glGenLists(range); + } + + public static void glPixelStorei(int parameterName, int param) + { + GL11.glPixelStorei(parameterName, param); + } + + public static void glReadPixels(int x, int y, int width, int height, int format, int type, IntBuffer pixels) + { + GL11.glReadPixels(x, y, width, height, format, type, pixels); + } + + public static int glGetError() + { + return GL11.glGetError(); + } + + public static String glGetString(int name) + { + return GL11.glGetString(name); + } + + public static void glGetInteger(int parameterName, IntBuffer parameters) + { + GL11.glGetInteger(parameterName, parameters); + } + + public static int glGetInteger(int parameterName) + { + return GL11.glGetInteger(parameterName); + } + + public static void enableBlendProfile(GlStateManager.Profile p_187408_0_) + { + p_187408_0_.apply(); + } + + public static void disableBlendProfile(GlStateManager.Profile p_187440_0_) + { + p_187440_0_.clean(); + } + + static + { + for (int i = 0; i < 8; ++i) + { + lightState[i] = new GlStateManager.BooleanState(16384 + i); + } + + colorMaterialState = new GlStateManager.ColorMaterialState(); + blendState = new GlStateManager.BlendState(); + depthState = new GlStateManager.DepthState(); + fogState = new GlStateManager.FogState(); + cullState = new GlStateManager.CullState(); + polygonOffsetState = new GlStateManager.PolygonOffsetState(); + colorLogicState = new GlStateManager.ColorLogicState(); + texGenState = new GlStateManager.TexGenState(); + clearState = new GlStateManager.ClearState(); + stencilState = new GlStateManager.StencilState(); + normalizeState = new GlStateManager.BooleanState(2977); + textureState = new GlStateManager.TextureState[8]; + + for (int j = 0; j < 8; ++j) + { + textureState[j] = new GlStateManager.TextureState(); + } + + activeShadeModel = 7425; + rescaleNormalState = new GlStateManager.BooleanState(32826); + colorMaskState = new GlStateManager.ColorMask(); + colorState = new GlStateManager.Color(); + } + + @SideOnly(Side.CLIENT) + static class AlphaState + { + public GlStateManager.BooleanState alphaTest; + public int func; + public float ref; + + private AlphaState() + { + this.alphaTest = new GlStateManager.BooleanState(3008); + this.func = 519; + this.ref = -1.0F; + } + } + + @SideOnly(Side.CLIENT) + static class BlendState + { + public GlStateManager.BooleanState blend; + public int srcFactor; + public int dstFactor; + public int srcFactorAlpha; + public int dstFactorAlpha; + + private BlendState() + { + this.blend = new GlStateManager.BooleanState(3042); + this.srcFactor = 1; + this.dstFactor = 0; + this.srcFactorAlpha = 1; + this.dstFactorAlpha = 0; + } + } + + @SideOnly(Side.CLIENT) + static class BooleanState + { + private final int capability; + private boolean currentState; + + public BooleanState(int capabilityIn) + { + this.capability = capabilityIn; + } + + public void setDisabled() + { + this.setState(false); + } + + public void setEnabled() + { + this.setState(true); + } + + public void setState(boolean state) + { + if (state != this.currentState) + { + this.currentState = state; + + if (state) + { + GL11.glEnable(this.capability); + } + else + { + GL11.glDisable(this.capability); + } + } + } + } + + @SideOnly(Side.CLIENT) + static class ClearState + { + public double depth; + public GlStateManager.Color color; + + private ClearState() + { + this.depth = 1.0D; + this.color = new GlStateManager.Color(0.0F, 0.0F, 0.0F, 0.0F); + } + } + + @SideOnly(Side.CLIENT) + static class Color + { + public float red; + public float green; + public float blue; + public float alpha; + + public Color() + { + this(1.0F, 1.0F, 1.0F, 1.0F); + } + + public Color(float redIn, float greenIn, float blueIn, float alphaIn) + { + this.red = 1.0F; + this.green = 1.0F; + this.blue = 1.0F; + this.alpha = 1.0F; + this.red = redIn; + this.green = greenIn; + this.blue = blueIn; + this.alpha = alphaIn; + } + } + + @SideOnly(Side.CLIENT) + static class ColorLogicState + { + public GlStateManager.BooleanState colorLogicOp; + public int opcode; + + private ColorLogicState() + { + this.colorLogicOp = new GlStateManager.BooleanState(3058); + this.opcode = 5379; + } + } + + @SideOnly(Side.CLIENT) + static class ColorMask + { + public boolean red; + public boolean green; + public boolean blue; + public boolean alpha; + + private ColorMask() + { + this.red = true; + this.green = true; + this.blue = true; + this.alpha = true; + } + } + + @SideOnly(Side.CLIENT) + static class ColorMaterialState + { + public GlStateManager.BooleanState colorMaterial; + public int face; + public int mode; + + private ColorMaterialState() + { + this.colorMaterial = new GlStateManager.BooleanState(2903); + this.face = 1032; + this.mode = 5634; + } + } + + @SideOnly(Side.CLIENT) + public static enum CullFace + { + FRONT(1028), + BACK(1029), + FRONT_AND_BACK(1032); + + public final int mode; + + private CullFace(int modeIn) + { + this.mode = modeIn; + } + } + + @SideOnly(Side.CLIENT) + static class CullState + { + public GlStateManager.BooleanState cullFace; + public int mode; + + private CullState() + { + this.cullFace = new GlStateManager.BooleanState(2884); + this.mode = 1029; + } + } + + @SideOnly(Side.CLIENT) + static class DepthState + { + public GlStateManager.BooleanState depthTest; + public boolean maskEnabled; + public int depthFunc; + + private DepthState() + { + this.depthTest = new GlStateManager.BooleanState(2929); + this.maskEnabled = true; + this.depthFunc = 513; + } + } + + @SideOnly(Side.CLIENT) + public static enum DestFactor + { + CONSTANT_ALPHA(32771), + CONSTANT_COLOR(32769), + DST_ALPHA(772), + DST_COLOR(774), + ONE(1), + ONE_MINUS_CONSTANT_ALPHA(32772), + ONE_MINUS_CONSTANT_COLOR(32770), + ONE_MINUS_DST_ALPHA(773), + ONE_MINUS_DST_COLOR(775), + ONE_MINUS_SRC_ALPHA(771), + ONE_MINUS_SRC_COLOR(769), + SRC_ALPHA(770), + SRC_COLOR(768), + ZERO(0); + + public final int factor; + + private DestFactor(int factorIn) + { + this.factor = factorIn; + } + } + + @SideOnly(Side.CLIENT) + public static enum FogMode + { + LINEAR(9729), + EXP(2048), + EXP2(2049); + + public final int capabilityId; + + private FogMode(int capabilityIn) + { + this.capabilityId = capabilityIn; + } + } + + @SideOnly(Side.CLIENT) + static class FogState + { + public GlStateManager.BooleanState fog; + public int mode; + public float density; + public float start; + public float end; + + private FogState() + { + this.fog = new GlStateManager.BooleanState(2912); + this.mode = 2048; + this.density = 1.0F; + this.end = 1.0F; + } + } + + @SideOnly(Side.CLIENT) + public static enum LogicOp + { + AND(5377), + AND_INVERTED(5380), + AND_REVERSE(5378), + CLEAR(5376), + COPY(5379), + COPY_INVERTED(5388), + EQUIV(5385), + INVERT(5386), + NAND(5390), + NOOP(5381), + NOR(5384), + OR(5383), + OR_INVERTED(5389), + OR_REVERSE(5387), + SET(5391), + XOR(5382); + + public final int opcode; + + private LogicOp(int opcodeIn) + { + this.opcode = opcodeIn; + } + } + + @SideOnly(Side.CLIENT) + static class PolygonOffsetState + { + public GlStateManager.BooleanState polygonOffsetFill; + public GlStateManager.BooleanState polygonOffsetLine; + public float factor; + public float units; + + private PolygonOffsetState() + { + this.polygonOffsetFill = new GlStateManager.BooleanState(32823); + this.polygonOffsetLine = new GlStateManager.BooleanState(10754); + } + } + + @SideOnly(Side.CLIENT) + public static enum Profile + { + DEFAULT { + public void apply() + { + GlStateManager.disableAlpha(); + GlStateManager.alphaFunc(519, 0.0F); + GlStateManager.disableLighting(); + GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, reflectSetColorBuffer(0.2F, 0.2F, 0.2F, 1.0F)); + + for (int i = 0; i < 8; ++i) + { + GlStateManager.disableLight(i); + GL11.glLight(GL11.GL_LIGHT0 + i, GL11.GL_AMBIENT, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0 + i, GL11.GL_POSITION, reflectSetColorBuffer(0.0F, 0.0F, 1.0F, 0.0F)); + + if (i == 0) + { + GL11.glLight(GL11.GL_LIGHT0 + i, GL11.GL_DIFFUSE, reflectSetColorBuffer(1.0F, 1.0F, 1.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0 + i, GL11.GL_SPECULAR, reflectSetColorBuffer(1.0F, 1.0F, 1.0F, 1.0F)); + } + else + { + GL11.glLight(GL11.GL_LIGHT0 + i, GL11.GL_DIFFUSE, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0 + i, GL11.GL_SPECULAR, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + } + } + + GlStateManager.disableColorMaterial(); + GlStateManager.colorMaterial(1032, 5634); + GlStateManager.disableDepth(); + GlStateManager.depthFunc(513); + GlStateManager.depthMask(true); + GlStateManager.disableBlend(); + GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GL14.glBlendEquation(GL14.GL_FUNC_ADD); + GlStateManager.disableFog(); + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); + GlStateManager.setFogDensity(1.0F); + GlStateManager.setFogStart(0.0F); + GlStateManager.setFogEnd(1.0F); + GL11.glFog(GL11.GL_FOG_COLOR, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + + if (GLContext.getCapabilities().GL_NV_fog_distance) + { + GL11.glFogi(GL11.GL_FOG_MODE, 34140); + } + + GlStateManager.doPolygonOffset(0.0F, 0.0F); + GlStateManager.disableColorLogic(); + GlStateManager.colorLogicOp(5379); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S); + GlStateManager.texGen(GlStateManager.TexGen.S, 9216); + GlStateManager.texGen(GlStateManager.TexGen.S, 9474, reflectSetColorBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.S, 9217, reflectSetColorBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T); + GlStateManager.texGen(GlStateManager.TexGen.T, 9216); + GlStateManager.texGen(GlStateManager.TexGen.T, 9474, reflectSetColorBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.T, 9217, reflectSetColorBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R); + GlStateManager.texGen(GlStateManager.TexGen.R, 9216); + GlStateManager.texGen(GlStateManager.TexGen.R, 9474, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.R, 9217, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q); + GlStateManager.texGen(GlStateManager.TexGen.Q, 9216); + GlStateManager.texGen(GlStateManager.TexGen.Q, 9474, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.texGen(GlStateManager.TexGen.Q, 9217, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.setActiveTexture(0); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 1000); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, 1000); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, -1000); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); + GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F)); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_COMBINE_RGB, GL11.GL_MODULATE); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_COMBINE_ALPHA, GL11.GL_MODULATE); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC0_RGB, GL11.GL_TEXTURE); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC1_RGB, GL13.GL_PREVIOUS); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC2_RGB, GL13.GL_CONSTANT); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC0_ALPHA, GL11.GL_TEXTURE); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC1_ALPHA, GL13.GL_PREVIOUS); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC2_ALPHA, GL13.GL_CONSTANT); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_OPERAND2_RGB, GL11.GL_SRC_ALPHA); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_OPERAND1_ALPHA, GL11.GL_SRC_ALPHA); + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_OPERAND2_ALPHA, GL11.GL_SRC_ALPHA); + GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL13.GL_RGB_SCALE, 1.0F); + GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_ALPHA_SCALE, 1.0F); + GlStateManager.disableNormalize(); + GlStateManager.shadeModel(7425); + GlStateManager.disableRescaleNormal(); + GlStateManager.colorMask(true, true, true, true); + GlStateManager.clearDepth(1.0D); + GL11.glLineWidth(1.0F); + GL11.glNormal3f(0.0F, 0.0F, 1.0F); + GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); + GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL); + } + + public void clean() + { + } + }, + PLAYER_SKIN { + public void apply() + { + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + } + + public void clean() + { + GlStateManager.disableBlend(); + } + }, + TRANSPARENT_MODEL { + public void apply() + { + GlStateManager.color(1.0F, 1.0F, 1.0F, 0.15F); + GlStateManager.depthMask(false); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.alphaFunc(516, 0.003921569F); + } + + public void clean() + { + GlStateManager.disableBlend(); + GlStateManager.alphaFunc(516, 0.1F); + GlStateManager.depthMask(true); + } + }; + + private Profile() + { + } + + public abstract void apply(); + + public abstract void clean(); + } + + @SideOnly(Side.CLIENT) + public static enum SourceFactor + { + CONSTANT_ALPHA(32771), + CONSTANT_COLOR(32769), + DST_ALPHA(772), + DST_COLOR(774), + ONE(1), + ONE_MINUS_CONSTANT_ALPHA(32772), + ONE_MINUS_CONSTANT_COLOR(32770), + ONE_MINUS_DST_ALPHA(773), + ONE_MINUS_DST_COLOR(775), + ONE_MINUS_SRC_ALPHA(771), + ONE_MINUS_SRC_COLOR(769), + SRC_ALPHA(770), + SRC_ALPHA_SATURATE(776), + SRC_COLOR(768), + ZERO(0); + + public final int factor; + + private SourceFactor(int factorIn) + { + this.factor = factorIn; + } + } + + @SideOnly(Side.CLIENT) + static class StencilFunc + { + public int func; + public int mask; + + private StencilFunc() + { + this.func = 519; + this.mask = -1; + } + } + + @SideOnly(Side.CLIENT) + static class StencilState + { + public GlStateManager.StencilFunc func; + public int mask; + public int fail; + public int zfail; + public int zpass; + + private StencilState() + { + this.func = new GlStateManager.StencilFunc(); + this.mask = -1; + this.fail = 7680; + this.zfail = 7680; + this.zpass = 7680; + } + } + + @SideOnly(Side.CLIENT) + public static enum TexGen + { + S, + T, + R, + Q; + } + + @SideOnly(Side.CLIENT) + static class TexGenCoord + { + public GlStateManager.BooleanState textureGen; + public int coord; + public int param = -1; + + public TexGenCoord(int coordIn, int capabilityIn) + { + this.coord = coordIn; + this.textureGen = new GlStateManager.BooleanState(capabilityIn); + } + } + + @SideOnly(Side.CLIENT) + static class TexGenState + { + public GlStateManager.TexGenCoord s; + public GlStateManager.TexGenCoord t; + public GlStateManager.TexGenCoord r; + public GlStateManager.TexGenCoord q; + + private TexGenState() + { + this.s = new GlStateManager.TexGenCoord(8192, 3168); + this.t = new GlStateManager.TexGenCoord(8193, 3169); + this.r = new GlStateManager.TexGenCoord(8194, 3170); + this.q = new GlStateManager.TexGenCoord(8195, 3171); + } + } + + @SideOnly(Side.CLIENT) + static class TextureState + { + public GlStateManager.BooleanState texture2DState; + public int textureName; + + private TextureState() + { + this.texture2DState = new GlStateManager.BooleanState(3553); + } + } + private static FloatBuffer reflectSetColorBuffer(float p_74521_0_, float p_74521_1_, float p_74521_2_, float p_74521_3_) { + FloatBuffer res = null; + try { + Method m = RenderHelper.class.getDeclaredMethod("setColorBuffer", float.class, float.class, float.class, float.class); + m.setAccessible(true); + res = (FloatBuffer) m.invoke(null, p_74521_0_, p_74521_1_, p_74521_2_, p_74521_3_); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + return res; + } +} diff --git a/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java b/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java new file mode 100644 index 0000000..4a9b3f3 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java @@ -0,0 +1,16 @@ +package me.towdium.jecalculation.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.util.ResourceLocation; + +public class ClientUtils { + public static Minecraft mc() { + return Minecraft.getMinecraft(); + } + + public static void playClickSound(float pitchIn) { + mc().getSoundHandler().playSound( + PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), pitchIn)); + } +} diff --git a/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java b/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java index 0ba7c92..53cfcda 100644 --- a/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java +++ b/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java @@ -1,7 +1,7 @@ package me.towdium.jecalculation.utils; import me.towdium.jecalculation.JustEnoughCalculation; -import me.towdium.jecalculation.utils.polyfill.Polyfill; +import me.towdium.jecalculation.polyfill.Polyfill; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/me/towdium/jecalculation/utils/Utilities.java b/src/main/java/me/towdium/jecalculation/utils/Utilities.java index 4379745..dd70605 100644 --- a/src/main/java/me/towdium/jecalculation/utils/Utilities.java +++ b/src/main/java/me/towdium/jecalculation/utils/Utilities.java @@ -1,476 +1,93 @@ package me.towdium.jecalculation.utils; - +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.registry.GameData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import me.towdium.jecalculation.JecaItem; import me.towdium.jecalculation.JustEnoughCalculation; -import me.towdium.jecalculation.utils.wrappers.Pair; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.resources.Language; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.*; -import net.minecraftforge.fluids.Fluid; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringEscapeUtils; +import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.text.BreakIterator; -import java.text.DecimalFormat; -import java.util.*; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; import java.util.function.BiFunction; -import java.util.function.BiPredicate; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -import static net.minecraft.client.resources.I18n.format; /** * Author: Towdium * Date: 2016/6/25. */ -@SuppressWarnings("UnusedReturnValue") -@ParametersAreNonnullByDefault +@SuppressWarnings("unused") public class Utilities { + final static int[] scaleTable = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE}; + static Map dictionary = new HashMap<>(); + + static { + Map modMap = Loader.instance().getIndexedModList(); + for (Map.Entry modEntry : modMap.entrySet()) { + String lowercaseId = modEntry.getKey().toLowerCase(Locale.ENGLISH); + String modName = modEntry.getValue().getName(); + dictionary.put(lowercaseId, modName); + } + } + // FLOAT FORMATTING - public static char[] suffix = new char[]{'K', 'M', 'B', 'G', 'T', 'P'}; - public static DecimalFormat[] format = new DecimalFormat[]{new DecimalFormat("#."), - new DecimalFormat("#.#"), - new DecimalFormat("#.##"), - new DecimalFormat("#.###"), - new DecimalFormat("#.####")}; - - public static String cutNumber(float f, int size) { - BiFunction form = (fl, len) -> format[len - 1 - (int) Math.log10(fl)].format(fl); - int scale = (int) Math.log10(f) / 3; - if (scale == 0) - return form.apply(f, size); - else - return form.apply(f / (float) Math.pow(1000, scale), size - 1) + suffix[scale - 1]; - } - - @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - public static Stream stream(Optional o) { - return o.map(Stream::of).orElse(Stream.empty()); - } - - public static Supplier fake(Runnable r) { - return () -> { - r.run(); - return null; + public static String cutFloat(float f, int size) { + BiFunction form = (fl, len) -> { + // here 2 means floating point and unit character + // represents for maximum acceptable decimal digits + int scale = len - 2 - String.valueOf(fl.intValue()).length(); + // maximum decimal limits to 2 + int cut = Math.min(scale, 2); + return String.format("%." + (Math.max(cut, 0)) + 'f', fl); }; + int scale = (int) Math.log10(f) / 3; + switch (scale) { + case 0: + return form.apply(f, size); + case 1: + return form.apply(f / 1000.0f, size) + 'K'; + case 2: + return form.apply(f / 1000000.0f, size) + 'M'; + case 3: + return form.apply(f / 1000000000.0f, size) + 'B'; + case 4: + return form.apply(f / 1000000000000.0f, size) + 'G'; + default: + return form.apply(f / 1000000000000000.0f, size) + 'T'; + } } - public static String repeat(String s, int n) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < n; i++) - sb.append(s); - return sb.toString(); + public static String cutLong(long i, int size) { + if (i < 1000) { + return String.valueOf(i); + } else { + return cutFloat(i, size); + } + } + + // CIRCULATE STRUCTURE + public static int circulate(int current, int total, boolean forward) { + if (forward) { + if (current == total - 1) return 0; + else return current + 1; + } else { + if (current == 0) return total - 1; + else return current - 1; + } } // MOD NAME - @Nullable - - - - public static String getModName(Item item) { - String name = GameData.getItemRegistry().getNameForObject(item); + public static String getModName(ItemStack stack) { + String name = GameData.getItemRegistry().getNameForObject(stack.getItem()); JustEnoughCalculation.logger.warn(String.format("item name: %s", name)); // TODO check return name; - // ResourceLocation tmp = item.getRegistryName(); - // if (tmp == null) return null; - // String id = tmp.getNamespace(); - // return id.equals("minecraft") ? "Minecraft" : Loader.instance().getIndexedModList().get(id).getName(); } - public static String getModName(Fluid fluid) { - String name = GameData.getItemRegistry().getNameForObject(fluid); - JustEnoughCalculation.logger.warn(String.format("fluid name: %s", fluid)); + public static String getModName(FluidStack stack) { + String name = GameData.getItemRegistry().getNameForObject(stack.getFluid()); + JustEnoughCalculation.logger.warn(String.format("fluid name: %s", stack.getFluid())); // TODO check return name; } - - public static NBTTagCompound getTag(ItemStack is) { - NBTTagCompound tagCompound = is.getTagCompound(); - if (tagCompound == null) { - tagCompound = new NBTTagCompound(); - is.setTagCompound(tagCompound); - } - return tagCompound; - // TODO check return is.getOrCreateSubCompound(JustEnoughCalculation.Reference.MODID); - } - - public static String translate(String unlocalized, Object... args) { - return net.minecraft.client.resources.I18n.format(unlocalized, args); - } - - public static class Relation { - public HashMap, V> data = new HashMap<>(); - - public void put(K a, K b, V v) { - Pair pair = new Pair<>(a, b); - V tmp = data.get(pair); - data.put(tmp == null ? new Pair<>(b, a) : pair, v); - } - - @Nullable - public V get(K a, K b) { - V ret = data.get(new Pair<>(a, b)); - if (ret == null) - ret = data.get(new Pair<>(b, a)); - return ret; - } - } - - public static class Timer { - long time = System.currentTimeMillis(); - boolean running = false; - - public void setState(boolean b) { - if (!b && running) - running = false; - if (b && !running) { - running = true; - time = System.currentTimeMillis(); - } - } - - public long getTime() { - return running ? System.currentTimeMillis() - time : 0; - } - } - - @SuppressWarnings("UnusedReturnValue") - public static class Circulator { - int total, current; - - public Circulator(int total) { - this(total, 0); - } - - public Circulator(int total, int current) { - this.total = total; - this.current = current; - } - - public int next() { - return current + 1 == total ? 0 : current + 1; - } - - public int prev() { - return current == 0 ? total - 1 : current - 1; - } - - public Circulator move(int steps) { - current += steps; - if (current < 0) - current += (-current) / total * total + total; - else - current = current % total; - return this; - } - - public int current() { - return current; - } - - public Circulator set(int index) { - if (index >= 0 && index < total) - current = index; - else - throw new RuntimeException(String.format("Expected: [0, %d), given: %d.", total, index)); - return this; - } - - public Circulator copy() { - return new Circulator(total).set(current); - } - } - - public static class ReversedIterator implements Iterator { - ListIterator i; - - public ReversedIterator(List l) { - i = l.listIterator(l.size()); - } - - @Override - public boolean hasNext() { - return i.hasPrevious(); - } - - @Override - public T next() { - return i.previous(); - } - - public Stream stream() { - return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED), false); - } - } - - @Deprecated - @SideOnly(Side.CLIENT) - public static class I18n { - public static boolean contains(String s1, String s2) { - return s1.contains(s2); - } - - public static Pair search(String translateKey, Object... parameters) { - Pair ret = new Pair<>(null, null); - translateKey = "jecalculation." + translateKey; - String buffer = format(translateKey, parameters); - ret.two = !buffer.equals(translateKey); - buffer = StringEscapeUtils.unescapeJava(buffer); - ret.one = buffer.replace("\t", " "); - return ret; - } - - public static String get(String translateKey, Object... parameters) { - return search(translateKey, parameters).one; - } - - public static List wrap(String s, int width) { - return new TextWrapper().wrap(s, getLocale(), i -> TextWrapper.renderer.getCharWidth(i), width); - } - - /** - * Copy from `net.minecraft.client.resources.Language()` 1.12.2 - * - * @return Locale - */ - public static Locale getLocale() { - Language language = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage(); - String languageCode = language.getLanguageCode(); - String[] splitLangCode = languageCode.split("_", 2); - if (splitLangCode.length == 1) { // Vanilla has some languages without underscores - return new Locale(languageCode); - } else { - return new Locale(splitLangCode[0], splitLangCode[1]); - } - } - - static class TextWrapper { - static FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; - - String str; - BreakIterator it; - List temp = new ArrayList<>(); - Function func; - int start, end, section, space, cursor, width; - - private void cut() { - char c = str.charAt(cursor); - if (c == '\f') - cursor++; - temp.add(str.substring(start, cursor)); - if (c == ' ' || c == ' ' || c == '\n') - cursor++; - start = cursor; - end = cursor; - space = width; - section = func.apply(str.charAt(cursor)); - } - - private void move() { - temp.add(str.substring(start, end)); - start = end; - space = width; - } - - private List wrap(String s, Locale l, Function func, int width) { - temp.clear(); - start = 0; - end = 0; - cursor = 0; - space = width; - str = s; - it = BreakIterator.getLineInstance(l); - it.setText(s); - this.width = width; - this.func = func; - for (int i = it.next(); i != BreakIterator.DONE; i = it.next()) { - for (cursor = end; cursor < i; cursor++) { - char ch = str.charAt(cursor); - section += func.apply(str.charAt(cursor)); - if (ch == '\n' || ch == '\f') - cut(); - else if (section > space) { - if (start == end) - cut(); - else - move(); - } - } - space -= section; - section = 0; - end = cursor; - } - move(); - return temp; - } - } - } - - public static class Recent { - LinkedList data = new LinkedList<>(); - BiPredicate tester; - int limit; - - public Recent(BiPredicate tester, int limit) { - this.tester = tester; - this.limit = limit; - } - - public Recent(int limit) { - this.limit = limit; - } - - public boolean push(T obj, boolean replace) { - if (replace) - data.pop(); - boolean ret = data.removeIf(t -> tester != null ? tester.test(t, obj) : t.equals(obj)); - data.addFirst(obj); - if (data.size() > limit) - data.removeLast(); - return ret; - } - - public List toList() { - //noinspection unchecked - return (List) data.clone(); - } - - public void clear() { - data.clear(); - } - - public int size() { - return data.size(); - } - } - - public static class Json { - @Nullable - public static NBTTagCompound read(File f) { - try { - String s = FileUtils.readFileToString(f, "UTF-8"); - return read(s); - } catch (IOException e) { - return null; - } - } - - @Nullable - public static NBTTagCompound read(String s) { - try { - return (NBTTagCompound) JsonToNBT.func_150315_a(s); - } catch (NBTException e) { - e.printStackTrace(); - return null; - } - } - - public static void write(NBTTagCompound nbt, File f) { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(f); - fos.write(write(nbt).getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static String write(NBTTagCompound nbt) { - Writer w = new Writer(); - write(nbt, w); - w.enter(); - return w.build(); - } - - private static void write(NBTBase nbt, Writer w) { - if (nbt instanceof NBTTagCompound) { - NBTTagCompound tags = (NBTTagCompound) nbt; - boolean wrap = tags.func_150296_c().size() > 1; - boolean first = true; - w.sb.append('{'); - if (wrap) - w.indent++; - //noinspection unchecked - for (String i : (Set) tags.func_150296_c()) { - if (first) - first = false; - else - w.sb.append(','); - if (wrap) - w.enter(); - w.sb.append('"'); - w.sb.append(i); - w.sb.append("\": "); - write(tags.getTag(i), w); - } - if (wrap) { - w.indent--; - w.enter(); - } - w.sb.append('}'); - } else if (nbt instanceof NBTTagList) { - JustEnoughCalculation.logger.error("nbt is TagList"); - // TODO - // NBTTagList tags = (NBTTagList) nbt; - // boolean wrap = tags.tagCount() > 1; - // boolean first = true; - // w.sb.append('['); - // if (wrap) w.indent++; - // for (NBTBase i : tags) { - // if (first) first = false; - // else w.sb.append(','); - // if (wrap) w.enter(); - // write(i, w); - // } - // if (wrap) { - // w.indent--; - // w.enter(); - // } - // w.sb.append(']'); - } else - w.sb.append(nbt.toString()); - } - - private static class Writer { - public int indent = 0; - StringBuilder sb = new StringBuilder(); - - public void enter() { - sb.append('\n'); - char[] tmp = new char[4 * indent]; - Arrays.fill(tmp, ' '); - sb.append(tmp); - } - - public String build() { - return sb.toString(); - } - } - } } diff --git a/src/main/java/me/towdium/jecalculation/utils/helpers/LocalizationHelper.java b/src/main/java/me/towdium/jecalculation/utils/helpers/LocalizationHelper.java new file mode 100644 index 0000000..7faad99 --- /dev/null +++ b/src/main/java/me/towdium/jecalculation/utils/helpers/LocalizationHelper.java @@ -0,0 +1,58 @@ +package me.towdium.jecalculation.utils.helpers; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import me.towdium.jecalculation.utils.wrappers.Pair; +import net.minecraft.client.resources.I18n; +import org.apache.commons.lang3.StringEscapeUtils; + +/** + * Author: Towdium + * Created: 2016/6/22. + */ +@SideOnly(Side.CLIENT) +public class LocalizationHelper { + + public static Pair search(String translateKey, Object... parameters) { + Pair ret = new Pair<>(null, null); + String buffer = I18n.format(translateKey, parameters); + ret.two = !buffer.equals(translateKey); + buffer = StringEscapeUtils.unescapeJava(buffer); + ret.one = buffer.replace("\t", " "); + return ret; + } + + /** + * @param c the (super) class name will be used after prefix translation key + * @param prefix the prefix of translation key + * @param translateKey the body of translation key + * @param parameters format parameters + * @return the localized value + * The localized key is "prefix.className(superClassName).translateKey". + * It will search all the super classes. + */ + public static Pair search(Class c, String prefix, String translateKey, Object... parameters) { + StringBuilder builder = new StringBuilder(c.getName()); + builder.delete(0, builder.lastIndexOf(".") + 1).setCharAt(0, Character.toLowerCase(builder.charAt(0))); + builder.insert(0, prefix).append('.').append(translateKey); // TODO simplify and change underscore + String key = builder.toString(); + Pair ret = LocalizationHelper.search(key, parameters); + if (ret.two || c.equals(Object.class)) + return ret; + else { + ret = search(c.getSuperclass(), prefix, translateKey, parameters); + if (ret.two) + return ret; + else + return ret.setOne(key); + } + } + + public static String format(String translateKey, Object... parameters) { + return search(translateKey, parameters).one; + } + + public static String format(Class c, String prefix, String translateKey, Object... parameters) { + return search(c, prefix, translateKey, parameters).one; + } +} diff --git a/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java b/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java index d435b3d..ab5626d 100644 --- a/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java +++ b/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java @@ -15,7 +15,7 @@ public class Pair { @Override public int hashCode() { - return one.hashCode() + two.hashCode(); + return one.hashCode() ^ two.hashCode(); } @Override diff --git a/src/main/java/me/towdium/jecalculation/utils/wrappers/Wrapper.java b/src/main/java/me/towdium/jecalculation/utils/wrappers/Single.java similarity index 55% rename from src/main/java/me/towdium/jecalculation/utils/wrappers/Wrapper.java rename to src/main/java/me/towdium/jecalculation/utils/wrappers/Single.java index 1e84be2..4a20107 100644 --- a/src/main/java/me/towdium/jecalculation/utils/wrappers/Wrapper.java +++ b/src/main/java/me/towdium/jecalculation/utils/wrappers/Single.java @@ -1,45 +1,34 @@ package me.towdium.jecalculation.utils.wrappers; import javax.annotation.Nullable; -import java.util.Optional; import java.util.function.Consumer; import java.util.function.Predicate; -import java.util.function.Supplier; /** * Author: Towdium * Date: 2016/7/1. */ -public class Wrapper { +public class Single { public T value; public Predicate predicate = t -> true; - public Wrapper(T value) { + public Single(T value) { this.value = value; } - public Wrapper push(@Nullable T value) { + public Single push(@Nullable T value) { if (value != null && predicate.test(value)) this.value = value; return this; } - public Wrapper or(Supplier s) { - if (value == null) value = s.get(); - return this; - } - - public Optional toOptional() { - return Optional.ofNullable(value); - } - - public Wrapper ifPresent(Consumer c) { + public Single ifPresent(Consumer c) { if (value != null) c.accept(value); return this; } - public Wrapper ifPresentNot(Runnable r) { + public Single ifPresentNot(Runnable r) { if (value == null) r.run(); return this; diff --git a/src/main/java/me/towdium/jecalculation/utils/wrappers/Trio.java b/src/main/java/me/towdium/jecalculation/utils/wrappers/Triple.java similarity index 76% rename from src/main/java/me/towdium/jecalculation/utils/wrappers/Trio.java rename to src/main/java/me/towdium/jecalculation/utils/wrappers/Triple.java index 5a75900..fe03022 100644 --- a/src/main/java/me/towdium/jecalculation/utils/wrappers/Trio.java +++ b/src/main/java/me/towdium/jecalculation/utils/wrappers/Triple.java @@ -4,12 +4,12 @@ package me.towdium.jecalculation.utils.wrappers; * Author: Towdium * Date: 2016/7/1. */ -public class Trio { +public class Triple { public T one; public U two; public V three; - public Trio(T one, U two, V three) { + public Triple(T one, U two, V three) { this.one = one; this.two = two; this.three = three; diff --git a/src/main/resources/assets/jecalculation/lang/en_US.lang b/src/main/resources/assets/jecalculation/lang/en_US.lang index ebe571b..6b9d664 100644 --- a/src/main/resources/assets/jecalculation/lang/en_US.lang +++ b/src/main/resources/assets/jecalculation/lang/en_US.lang @@ -1,27 +1,13 @@ -gui.calculator.edit=Edit recipes -gui.calculator.add=Add recipe -gui.calculator.output=Output -gui.calculator.procedure=Procedure -gui.calculator.input=Input -gui.calculator.catalyst=Catalyst -gui.calculator.view=All records -gui.calculator.recent=Recent -gui.calculator.editTooltip=Show and edit recorded recipes of selected item -gui.calculator.addTooltip=Add new recipe to the records -gui.calculator.viewTooltip=Show the list of all recorded recipes -gui.calculator.modeTooltip=Switch between:_pInput:_pthe ingredients needed_pProcedure:_psequence of what to craft_pOutput:_pextra output produced_pCatalyst:_presources needed but not consumed -gui.calculator.tooltipUse=Switch between_p#: normal mode_p%: percentage mode_pShift-click for quick change -gui.recipePicker.delete=Delete -gui.recipeEditor.save=Save -gui.recipeEditor.clear=Clear -gui.recipeViewer.edit=Edit -gui.recipeViewer.delete=Delete -item.itemCalculator.name=Calculator +item.item_calculator_crafting.name=Crafting Calculator +item.item_calculator_math.name=Math Calculator -gui.editor.output=Output -gui.editor.catalyst=Cata-\nlyst -gui.editor.input=Input -gui.editor.newGroup=New Group -gui.editor.save=Save -gui.editor.clear=Clear -gui.editor.help=Help \ No newline at end of file +command.not_found=Invalid option: %s +command.unexpected_arg=Unexpected arg: %s +command.help.list=Here is the list of all commands available: +command.state.desc=This mod is working on state: %s +command.state.s_server=server +command.state.s_client=client only +command.state.s_both=client with server +command.state.s_undefined=error state + +config.force_client=Force Client diff --git a/src/main/resources/assets/jecalculation/lang/zh_CN.lang b/src/main/resources/assets/jecalculation/lang/zh_CN.lang deleted file mode 100644 index 36484ab..0000000 --- a/src/main/resources/assets/jecalculation/lang/zh_CN.lang +++ /dev/null @@ -1,20 +0,0 @@ -gui.calculator.edit=编辑记录 -gui.calculator.add=添加合成表 -gui.calculator.output=产出 -gui.calculator.procedure=步骤 -gui.calculator.input=材料 -gui.calculator.catalyst=催化 -gui.calculator.view=浏览记录 -gui.calculator.recent=记录 -gui.calculator.editTooltip=编辑当前物品的合成表记录 -gui.calculator.addTooltip=添加新合成表 -gui.calculator.viewTooltip=浏览所有合成表记录 -gui.calculator.modeTooltip=在不同模式下切换:_p输入:_p需要的材料_p步骤:_p合成步骤_p产出:_p合成的额外产出_p催化:_p合成时需要但是不被消耗的物品 -gui.calculator.tooltipUse=在不同模式下切换_p#: 普通模式_p%: 百分率模式_p按下shift一次改变10 -gui.recipePicker.delete=删除 -gui.recipeEditor.save=储存 -gui.recipeEditor.clear=清除 -gui.recipeViewer.edit=编辑 -gui.recipeViewer.delete=删除 -item.itemCalculator.name=合成计算器 - diff --git a/src/main/resources/assets/jecalculation/models/item/itemCalculator.json b/src/main/resources/assets/jecalculation/models/item/itemCalculator.json deleted file mode 100644 index 63059a6..0000000 --- a/src/main/resources/assets/jecalculation/models/item/itemCalculator.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "builtin/generated", - "textures": { - "layer0": "jecalculation:items/itemCalculator" - } -} diff --git a/src/main/resources/assets/jecalculation/models/item/item_calculator_crafting.json b/src/main/resources/assets/jecalculation/models/item/item_calculator_crafting.json new file mode 100644 index 0000000..a9bbc66 --- /dev/null +++ b/src/main/resources/assets/jecalculation/models/item/item_calculator_crafting.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "jecalculation:items/item_calculator_crafting" + } +} diff --git a/src/main/resources/assets/jecalculation/models/item/item_calculator_math.json b/src/main/resources/assets/jecalculation/models/item/item_calculator_math.json new file mode 100644 index 0000000..74adbb0 --- /dev/null +++ b/src/main/resources/assets/jecalculation/models/item/item_calculator_math.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "jecalculation:items/item_calculator_math" + } +} diff --git a/src/main/resources/assets/jecalculation/textures/gui/guiCalculator.png b/src/main/resources/assets/jecalculation/textures/gui/guiCalculator.png deleted file mode 100644 index baee09909b969a3ab996a2eaef458a99bd19b98c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16720 zcmeI3e{2)i9l&2gLPG?UP}*!2VwM^0D81aB?X!I++X=*>`BA4Vq$Oe1;C%O-++zD& z--S5o1nJncMk-lBXro&;I<3`KZERFDD`o8(Iv_}}4pwa|ur-KIflfioG%XZZVekAq zFV0h@^2aotqsaGt-}n8#_x*go_kDMNcwj^GBa6!KF9!fDYN+?O08oT3i$K|Y^z~%? zCn5B;AXeY50kHU}@n3X!ch^+_Jm;0xHoYzIs3574Dp6L0uqqLWq1i}RorsB27t}35 z*r7zd*1!MiZL39*z1B@!fCs5E{T_|)xL61LO>28P!}zUNI0qq z39mKjS3uXsFm1IYr|4Z?>sn($OIu)rrB;nY3s=Qa5@Ta6F20K8IG4-zu*Jr(4w_+U z)=sg!;BW{GV@ZFkzH)TsiOV6O#lJqi9Fn}&PF;@)G~LtFQ`KXyQsW&o%kwH>!&XDypqaIm!6(Lrsb+FT7e+Y=1hQ)v+;1dO zaA{4i+lCONkruSnT6<%VZh@NG9hYF;HWbRrLec9=D3_dRo(#>bdxr^S7BfSWGE0_1 zDnlL=t56$dO3zH{E7U(}%w)uWSQ zY!u^eWmtjX1-p9<<3?4P=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i}r2rUv=Zx-%5}8_HN1#BO6cp zVhLzM5Qok*EiUComrt#(^LHJnJ2v*?UkDW^hrFk+_gT*{3o9zvLFu(W?z!-B!(-sR zyAOW-9`$s)Fgj2(mE(gu&Jc^OYc8>MT+K_IIk@cq{&mzCZr`2< ZdOvz+Wc1|cP9PC9)HVBmzHaN+{sUFe2i5=p diff --git a/src/main/resources/assets/jecalculation/textures/gui/guiRecipe.png b/src/main/resources/assets/jecalculation/textures/gui/guiRecipe.png deleted file mode 100644 index 36f9792c844504dec6e64e4848d051ba5f5698df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16692 zcmeI3e{2)i9l)O_`MOdHiuwYf%9htl)?u+R409ET7G5@k-akfsUH!TIj&9N0eB zcOedt&0?c;n$~sgy3v-Y)4Gmn%2=ligo?(GcG;k;g+DsMDq3i(bz-4qE1@mp*WUU3 zWE&QBAr9NsY?xY%&dJLtS$=Er=Ur z-5HhRN~+0qVgEswQ<0in_p=cyl5Uj;mG(^;dF7_AUUAa~k&|4_p@v|VhYpgmE;zHv zL`vhcO|HCO9$p*6q|2F~qHkz&wHN`N{gG~GtD2FWteYi7ilLo;&P}td-_P9RWGLE8 zQZz|>2%6))UY??yg`X?b0Iz}>DaQANmlwi8smV2{>uH`OhlhvV!ydPqiIX(PaU{i% z3`4*fgf^1Wg)EWM7Mo6re!{XQW|Xw9s41u6SBR=ZdXvj#1S=w^ORaY#Et5U6rVeF9xosm%WpSD)^JU$uqqB2+qxws z${H+&W+@UZRsP0ZCd4a8i;9F2GTVlvii*USgLLDMoz1Sna6jl)O# zS(>Be039Tan-{t$udA>(3gfk1vm(U`QD14mTPmg zG8ro=913HHMIwAhO49{Msv{hN18xN-&H4O-81upeIhunz&Px+f$s-Vy%y6tHCNQ)h z<+oj>c{%BV>tb~1x_07TQQ`uOk1?1Q60gD3T&KlZRiJw_3Op%?AGPEe}LIWq)R=F`U*9+XqK zhGe?R&zjzerpEMPAtSfM;jKE8UTJ!*G(+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_vjP2d^&O zy>>tOrB#X4*%izj*H@3OxVQE%hhMwxSm1?q>&eH3W0&Ss&kN1jAdD`WF@+f92h0a& z%??i;sdY6}KhY6CvEr>uYcJpMv*G(k%#Z(een$B5zxP%BYQ?w6$hx0?ImFa|BcNvriRuJFF5|Yi%WN}oYge@Y|Xt}p1bvH zPb+I*8r6qS+lRjW<{w`i9*XSPJ7xW&ZM(N`f9Bx9gYVXN4jvUZUg7)q%sp1Ua(IVy zvePi!%iP=kwJ1Jy*6f$we(eXX`@UDR@+10^MI8Fat-rXZ?Y?u)i%nXZ7KaZsbUyZ9 DDW;a8 diff --git a/src/main/resources/assets/jecalculation/textures/items/item_calculator_crafting.png b/src/main/resources/assets/jecalculation/textures/items/item_calculator_crafting.png new file mode 100644 index 0000000000000000000000000000000000000000..d4a0f3f2c709a638af674cc066e130809eb36772 GIT binary patch literal 594 zcmV-Y00pCeP zK~y-)rIXKV6HySyKQAx4X(g8mq6a~8h_}QlD2k~NB`AU*3X1rPLg_!`UmzZP_2?zn zoRzjV7Hm_r={7ZC)9$`~?~NC&jdnfg9EX_?-}%mr5)u9}l5K>LlmS5gepQ7@!XlbTs7D+cv@a)&!(*l;)h{{rp{) zF5hO#Ix>WG^%L3NkT}_Ay-}x7m}r>P$M=>X+rm;H_J{lmy7-LMn z2hKTMJm$@r3q1PJMg)??;J!pq3K5fGt<48`@A3NyPuAZ-5JHmR#wnCaNNN!0{up5b zptYv4Bk%J)u+}o$xX#1p&kzwV-I(LW;sROrOL`Cl`2b@K zJKNjzcO$|uWOt`euiwWx$CX<*x%1#YwU&*Qk8G~4;k{?Lx5veL zjWkX36)2^sUAxNT`Ii)nMP}z3JY8HM2m-9la9$3t@>m6N9P@Rn$IQtYk|g2VV3%kx zU^E($WtNTJCRvt|d&<>nRm$b^;SX4Aan9j?IIon#7(=()RmTDVDwT@-TqA&pptU{( g^?JShXZn};4#RvKvKS9=K>z>%07*qoM6N<$f|)Q5X#fBK literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/jecalculation/textures/items/item_calculator_math.png b/src/main/resources/assets/jecalculation/textures/items/item_calculator_math.png new file mode 100644 index 0000000000000000000000000000000000000000..7ec63c4563c21e188203781592008cfc6aa87f01 GIT binary patch literal 591 zcmV-V0R-{L zC~ZtA*rsUHq-mGL?9RTK=RpjOc0K4j4l^G<-#70Cs>=UV@%Mv;g#}erthIRWF~$%C z0RYxo*4Ea7qxXZO2DMsE&z-c)&onrHI$ zm6z`jCc$UacT#%&jAYQKdS;VCVeH8`AWc&|1=io(W9rT-@z66lb%MPEp%Z%!lb_LY zd*Ga-KXja3e9NcRhbT%S314H!L=mhgB9agA-t*mhHeWv`3?Z>F5XVFasVL6t9}&g? z#u#3GsGzE-D$Y4nl_-i35sWc-ALsW#M3}4I;K8$}s4ACl&hva_nJmjj>R}k>1FW^| z?e5ag?p~W#yNz>>tG91)ckw=h!Qk%^b{b8-tZyJ9Y;AmIyWYTi&tb2}rHd8P zG|e{%f`H2PYdl(dL9tk5ZobNsm1V*(L?pv`9Zlu22K|1YZ#ylfPfe2~2?zUKI{W*? zaZHv8Tdi%fEF*W6%jL3`N~O^bhzQO(y!RtRYc0)YGdLCiFgrV|zrGPbRWZhlK&@6Q df0_QJegM^h8PKFty$t{W002ovPDHLkV1lNv1quKF literal 0 HcmV?d00001