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 baee099..0000000 Binary files a/src/main/resources/assets/jecalculation/textures/gui/guiCalculator.png and /dev/null differ 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 36f9792..0000000 Binary files a/src/main/resources/assets/jecalculation/textures/gui/guiRecipe.png and /dev/null differ diff --git a/src/main/resources/assets/jecalculation/textures/gui/guiRecipeViewer.png b/src/main/resources/assets/jecalculation/textures/gui/guiRecipeViewer.png deleted file mode 100644 index 8eb2b6a..0000000 Binary files a/src/main/resources/assets/jecalculation/textures/gui/guiRecipeViewer.png and /dev/null differ diff --git a/src/main/resources/assets/jecalculation/textures/gui/gui_calculator.png b/src/main/resources/assets/jecalculation/textures/gui/gui_calculator.png new file mode 100644 index 0000000..6647cce Binary files /dev/null and b/src/main/resources/assets/jecalculation/textures/gui/gui_calculator.png differ diff --git a/src/main/resources/assets/jecalculation/textures/gui/resources.png b/src/main/resources/assets/jecalculation/textures/gui/resources.png new file mode 100644 index 0000000..6a226e0 Binary files /dev/null and b/src/main/resources/assets/jecalculation/textures/gui/resources.png differ diff --git a/src/main/resources/assets/jecalculation/textures/items/itemCalculator.png b/src/main/resources/assets/jecalculation/textures/items/itemCalculator.png deleted file mode 100644 index 9805e16..0000000 Binary files a/src/main/resources/assets/jecalculation/textures/items/itemCalculator.png and /dev/null differ 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 0000000..d4a0f3f Binary files /dev/null and b/src/main/resources/assets/jecalculation/textures/items/item_calculator_crafting.png differ 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 0000000..7ec63c4 Binary files /dev/null and b/src/main/resources/assets/jecalculation/textures/items/item_calculator_math.png differ