mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-13 16:54:02 +00:00
Hurray! It can display the result now!
This commit is contained in:
1 parent
67784ce0f0
commit
9437fbf03f
10 files changed
+213
-144
No files matched your search
@@ -239,6 +239,36 @@ public class Calculator {
|
||||
}
|
||||
input = builder.build();
|
||||
}
|
||||
|
||||
public ItemStack[] getOutputStack(){
|
||||
ItemStack[] outputStack = new ItemStack[output.size()];
|
||||
int i = 0;
|
||||
for (ItemRecord record : output){
|
||||
outputStack[i] = record.toItemStack();
|
||||
i++;
|
||||
}
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
public ItemStack[] getInputStack(){
|
||||
ItemStack[] inputStack = new ItemStack[input.size()];
|
||||
int i = 0;
|
||||
for (ItemRecord record : input){
|
||||
inputStack[i] = record.toItemStack();
|
||||
i++;
|
||||
}
|
||||
return inputStack;
|
||||
}
|
||||
|
||||
public ItemStack[] getCatalystStack(){
|
||||
ItemStack[] catalystStack = new ItemStack[catalyst.size()];
|
||||
int i = 0;
|
||||
for (ItemRecord record : catalyst){
|
||||
catalystStack[i] = record.toItemStack();
|
||||
i++;
|
||||
}
|
||||
return catalystStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package pers.towdium.tudicraft.core;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* @author Towdium
|
||||
@@ -75,6 +76,10 @@ public class ItemRecord{
|
||||
}
|
||||
|
||||
public ItemStack toItemStack(){
|
||||
return new ItemStack(item, (int) amount, meta);
|
||||
ItemStack itemStack = new ItemStack(item, 1, meta);
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setLong("amount", amount);
|
||||
itemStack.setTagCompound(tagCompound);
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,13 @@ public class ItemStackWrapper {
|
||||
return itemStack.stackSize*100;
|
||||
}
|
||||
|
||||
public static String getDisplayAmount(ItemStack itemStack){
|
||||
if(itemStack != null && itemStack.getTagCompound() != null){
|
||||
return itemStack.getTagCompound().getLong("amount")+"";
|
||||
}
|
||||
else return "";
|
||||
}
|
||||
|
||||
public static class NBT {
|
||||
public static void initNBT(ItemStack itemStack){
|
||||
if(!itemStack.hasTagCompound()){
|
||||
@@ -100,5 +107,12 @@ public class ItemStackWrapper {
|
||||
}
|
||||
else return "";
|
||||
}
|
||||
|
||||
public static long getLong(ItemStack dest, String key){
|
||||
if(dest.getTagCompound() != null){
|
||||
return dest.getTagCompound().getLong(key);
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class GuiEventHandler {
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onMouseClick(GuiScreenEvent.MouseInputEvent.Pre event){
|
||||
if(event.gui instanceof GuiRecipeEditor){
|
||||
if(new Date().getTime() - time < 500){
|
||||
if(new Date().getTime() - time < 200){
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
@@ -60,20 +60,33 @@ public class GuiEventHandler {
|
||||
}
|
||||
}
|
||||
}else if(event.gui instanceof GuiCalculator){
|
||||
if(new Date().getTime() - time < 200){
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
if (((GuiCalculator) event.gui).getActiveSlot() == 0){
|
||||
Slot slot = ((GuiCalculator) event.gui).inventorySlots.getSlot(((GuiCalculator) event.gui).getActiveSlot());
|
||||
Slot slot = ((GuiCalculator) event.gui).inventorySlots.getSlot(0);
|
||||
ItemStack itemStack = JEIPlugin.runtime.getItemListOverlay().getStackUnderMouse();
|
||||
if (itemStack != null){
|
||||
slot.inventory.setInventorySlotContents(slot.getSlotIndex(), itemStack);
|
||||
}
|
||||
slot.inventory.setInventorySlotContents(slot.getSlotIndex(), itemStack);
|
||||
if (Mouse.isButtonDown(0)){
|
||||
((GuiCalculator) event.gui).setActiveSlot(-1);
|
||||
time = new Date().getTime();
|
||||
Slot slot1 = ((GuiCalculator) event.gui).getSlotUnderMouse();
|
||||
if(slot1 != null){
|
||||
((GuiCalculator) event.gui).setActiveSlot(slot1.getSlotIndex());
|
||||
}else {
|
||||
((GuiCalculator) event.gui).setActiveSlot(-1);
|
||||
}
|
||||
((ContainerCalculator)((GuiCalculator) event.gui).inventorySlots).getPlayer().playSound("random.click", 1f, 1f );
|
||||
event.setCanceled(true);
|
||||
}
|
||||
} else if(((GuiCalculator) event.gui).getActiveSlot() != -1) {
|
||||
if (Mouse.isButtonDown(0)){
|
||||
((GuiCalculator) event.gui).setActiveSlot(-1);
|
||||
Slot slot1 = ((GuiCalculator) event.gui).getSlotUnderMouse();
|
||||
if(slot1 != null){
|
||||
((GuiCalculator) event.gui).setActiveSlot(slot1.getSlotIndex());
|
||||
}else {
|
||||
((GuiCalculator) event.gui).setActiveSlot(-1);
|
||||
}
|
||||
((ContainerCalculator)((GuiCalculator) event.gui).inventorySlots).getPlayer().playSound("random.click", 1f, 1f );
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
/**
|
||||
@@ -45,8 +46,9 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
public void drawScreen(int mouseX, int mouseY, float f)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
DrawTooltipScreen(mouseX, mouseY);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,8 +62,6 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
/**
|
||||
* Renders any special effects applied to tooltip buttons, and renders any tooltips for GuiButtons
|
||||
* that are being mouseovered.
|
||||
* @param mouseX
|
||||
* @param mouseY
|
||||
*/
|
||||
protected void DrawTooltipScreen(int mouseX, int mouseY)
|
||||
{
|
||||
@@ -71,15 +71,11 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
int mousedOverButtonId = -1;
|
||||
|
||||
//find out which button is being mouseovered
|
||||
for(int i = 0; i < buttonList.size(); i++)
|
||||
{
|
||||
GuiButton button = (GuiButton)buttonList.get(i);
|
||||
|
||||
if(IsButtonMouseovered(mouseX, mouseY, button))
|
||||
{
|
||||
for (GuiButton button : buttonList) {
|
||||
if (IsButtonMouseovered(mouseX, mouseY, button)) {
|
||||
mousedOverButtonId = button.id;
|
||||
|
||||
if(ShowTooltipButtonMouseoverEffect && GetButtonTooltip(mousedOverButtonId) != null)
|
||||
if (ShowTooltipButtonMouseoverEffect && GetButtonTooltip(mousedOverButtonId) != null)
|
||||
RenderTooltipButtonMouseoverEffect(button);
|
||||
|
||||
break;
|
||||
@@ -114,9 +110,6 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
|
||||
/**
|
||||
* Determines if a GuiButton is being mouseovered.
|
||||
* @param mouseX
|
||||
* @param mouseY
|
||||
* @param button
|
||||
* @return true if this button is mouseovered
|
||||
*/
|
||||
protected boolean IsButtonMouseovered(int mouseX, int mouseY, GuiButton button)
|
||||
@@ -130,15 +123,11 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
*/
|
||||
protected void RenderTooltipButtonEffect()
|
||||
{
|
||||
for(int i = 0; i < buttonList.size(); i++)
|
||||
{
|
||||
GuiButton button = buttonList.get(i);
|
||||
|
||||
if(GetButtonTooltip(button.id) != null)
|
||||
{
|
||||
for (GuiButton button : buttonList) {
|
||||
if (GetButtonTooltip(button.id) != null) {
|
||||
boolean flag = mc.fontRendererObj.getUnicodeFlag();
|
||||
mc.fontRendererObj.setUnicodeFlag(true);
|
||||
mc.fontRendererObj.drawStringWithShadow("?", button.xPosition+button.getButtonWidth()-5, button.yPosition, 0x99FFFFFF);
|
||||
mc.fontRendererObj.drawStringWithShadow("?", button.xPosition + button.getButtonWidth() - 7, button.yPosition + 1, 14737632);
|
||||
mc.fontRendererObj.setUnicodeFlag(flag);
|
||||
}
|
||||
}
|
||||
@@ -146,21 +135,17 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
|
||||
/**
|
||||
* Render anything special onto buttons that have tooltips assigned to them when they are mousevered.
|
||||
* @param button
|
||||
*/
|
||||
protected void RenderTooltipButtonMouseoverEffect(GuiButton button)
|
||||
{
|
||||
boolean flag = mc.fontRendererObj.getUnicodeFlag();
|
||||
mc.fontRendererObj.setUnicodeFlag(true);
|
||||
mc.fontRendererObj.drawStringWithShadow(FontCodes.AQUA + "?", button.xPosition+button.getButtonWidth()-5, button.yPosition, 0xFFFFFF);
|
||||
mc.fontRendererObj.drawStringWithShadow(FontCodes.AQUA + "?", button.xPosition+button.getButtonWidth()-7, button.yPosition+1, 14737632);
|
||||
mc.fontRendererObj.setUnicodeFlag(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a tooltip at (x,y).
|
||||
* @param x
|
||||
* @param y
|
||||
* @param tooltip
|
||||
*/
|
||||
protected void RenderTooltip(int x, int y, String tooltip)
|
||||
{
|
||||
@@ -211,24 +196,20 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
{
|
||||
s = DecodeStringCodes(s);
|
||||
String[] tooltipSections = s.split(tooltipNewlineDelimeter);
|
||||
ArrayList<String> tooltipArrayList = new ArrayList<String>();
|
||||
ArrayList<String> tooltipArrayList = new ArrayList<>();
|
||||
|
||||
for(String section : tooltipSections)
|
||||
{
|
||||
String tooltip = "";
|
||||
String[] tooltipWords = section.split(" ");
|
||||
|
||||
for(int i = 0; i < tooltipWords.length; i++)
|
||||
{
|
||||
int lineWidthWithNextWord = mc.fontRendererObj.getStringWidth(tooltip + tooltipWords[i]);
|
||||
if(lineWidthWithNextWord > tooltipMaxWidth)
|
||||
{
|
||||
for (String tooltipWord : tooltipWords) {
|
||||
int lineWidthWithNextWord = mc.fontRendererObj.getStringWidth(tooltip + tooltipWord);
|
||||
if (lineWidthWithNextWord > tooltipMaxWidth) {
|
||||
tooltipArrayList.add(tooltip.trim());
|
||||
tooltip = tooltipWords[i] + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip += tooltipWords[i] + " ";
|
||||
tooltip = tooltipWord + " ";
|
||||
} else {
|
||||
tooltip += tooltipWord + " ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,8 +255,6 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
|
||||
/***
|
||||
* Gets the width of the tooltip in pixels.
|
||||
* @param tooltipArray
|
||||
* @return
|
||||
*/
|
||||
private int GetTooltipWidth(String[] tooltipArray)
|
||||
{
|
||||
@@ -291,8 +270,6 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
|
||||
/**
|
||||
* Gets the height of the tooltip in pixels.
|
||||
* @param tooltipArray
|
||||
* @return
|
||||
*/
|
||||
private int GetTooltipHeight(String[] tooltipArray)
|
||||
{
|
||||
@@ -304,47 +281,6 @@ public abstract class GuiTooltipScreen extends GuiContainer
|
||||
return tooltipHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a protected/private field from a class using reflection.
|
||||
* @param <T> The return type of the field you are getting
|
||||
* @param <E> The class the field is in
|
||||
* @param classToAccess The ".class" of the class the field is in
|
||||
* @param instance The instance of the class
|
||||
* @param fieldNames comma seperated names the field may have (i.e. obfuscated, non obfuscated).
|
||||
* Obfustated field names can be found in fml/conf/fields.csv
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> T GetFieldByReflection(Class<? super E> classToAccess, E instance, String... fieldNames)
|
||||
{
|
||||
Field field = null;
|
||||
for(String fieldName : fieldNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
field = classToAccess.getDeclaredField(fieldName);
|
||||
}
|
||||
catch(NoSuchFieldException e){}
|
||||
|
||||
if(field != null)
|
||||
break;
|
||||
}
|
||||
|
||||
if(field != null)
|
||||
{
|
||||
field.setAccessible(true);
|
||||
T fieldT = null;
|
||||
try
|
||||
{
|
||||
fieldT = (T) field.get(instance);
|
||||
}
|
||||
catch (IllegalArgumentException e){}
|
||||
catch (IllegalAccessException e){}
|
||||
|
||||
return fieldT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public class FontCodes
|
||||
{
|
||||
|
||||
@@ -6,11 +6,8 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -20,26 +17,27 @@ import pers.towdium.tudicraft.core.ItemStackWrapper;
|
||||
import pers.towdium.tudicraft.gui.GuiTooltipScreen;
|
||||
import pers.towdium.tudicraft.gui.recipeEditor.ContainerRecipeEditor;
|
||||
import pers.towdium.tudicraft.gui.recipeEditor.GuiRecipeEditor;
|
||||
import pers.towdium.tudicraft.network.packages.PackageCalculatorUpdate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* @author Towdium
|
||||
*/
|
||||
public class GuiCalculator extends GuiTooltipScreen{
|
||||
GuiTextField textFieldAmount;
|
||||
GuiButton edit;
|
||||
GuiButton editButton;
|
||||
GuiButton modeButton;
|
||||
Calculator.CostRecord costRecord;
|
||||
int activeSlot = -1;
|
||||
int page = 1;
|
||||
EnumMode mode = EnumMode.input;
|
||||
int total = 1;
|
||||
EnumMode mode = EnumMode.INPUT;
|
||||
|
||||
|
||||
public enum EnumMode {input, output, catalyst}
|
||||
public enum EnumMode {INPUT, OUTPUT, CATALYST}
|
||||
|
||||
public GuiCalculator(ContainerCalculator containerCalculator){
|
||||
super(containerCalculator);
|
||||
@@ -48,14 +46,16 @@ public class GuiCalculator extends GuiTooltipScreen{
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
edit = new GuiButton(3, guiLeft+125, guiTop+31, 44, 20, StatCollector.translateToLocal("gui.calculator.edit"));
|
||||
edit.enabled = false;
|
||||
editButton = new GuiButton(3, guiLeft+90, guiTop+7, 37, 20, StatCollector.translateToLocal("gui.calculator.edit"));
|
||||
editButton.enabled = false;
|
||||
buttonList.add(new GuiButton(1, guiLeft+7, guiTop+31, 79, 20, StatCollector.translateToLocal("gui.calculator.calculate")));
|
||||
buttonList.add(new GuiButton(2, guiLeft+125, guiTop+7, 44, 20, StatCollector.translateToLocal("gui.calculator.add")));
|
||||
buttonList.add(edit);
|
||||
buttonList.add(new GuiButton(2, guiLeft+131, guiTop+7, 37, 20, StatCollector.translateToLocal("gui.calculator.add")));
|
||||
buttonList.add(editButton);
|
||||
buttonList.add(new GuiButton(4, guiLeft+7, guiTop+139, 20, 20, "<"));
|
||||
buttonList.add(new GuiButton(5, guiLeft+149, guiTop+139, 20, 20, ">"));
|
||||
textFieldAmount = new GuiTextField(0, fontRendererObj, guiLeft+39, guiTop+8, 44, 18);
|
||||
modeButton = new GuiButton(6, guiLeft+90, guiTop+31, 79, 20, StatCollector.translateToLocal("gui.calculator.input"));
|
||||
buttonList.add(modeButton);
|
||||
textFieldAmount = new GuiTextField(0, fontRendererObj, guiLeft+39, guiTop+8, 45, 18);
|
||||
Slot dest = inventorySlots.getSlot(0);
|
||||
ItemStack itemStack = ((ContainerCalculator)inventorySlots).getPlayer().getHeldItem();
|
||||
dest.inventory.setInventorySlotContents(dest.getSlotIndex(), ItemStackWrapper.NBT.getItem(itemStack, "dest"));
|
||||
@@ -79,7 +79,8 @@ public class GuiCalculator extends GuiTooltipScreen{
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
this.fontRendererObj.drawString("x", 30, 13, 4210752);
|
||||
fontRendererObj.drawString("x", 30, 13, 4210752);
|
||||
drawCenteredStringWithoutShadow(fontRendererObj, page + " / " + total, 88, 145, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,15 +98,43 @@ public class GuiCalculator extends GuiTooltipScreen{
|
||||
switch (button.id){
|
||||
case 1:
|
||||
if(inventorySlots.getSlot(0).getStack() != null){
|
||||
Calculator calculator = new Calculator(inventorySlots.getSlot(0).getStack(), Integer.valueOf(textFieldAmount.getText()));
|
||||
Calculator.CostRecord record = calculator.getCost();
|
||||
record.unify();
|
||||
costRecord = record;
|
||||
try{
|
||||
int i = Integer.valueOf(textFieldAmount.getText());
|
||||
Calculator calculator = new Calculator(inventorySlots.getSlot(0).getStack(), i);
|
||||
Calculator.CostRecord record = calculator.getCost();
|
||||
record.unify();
|
||||
costRecord = record;
|
||||
updateScreen();
|
||||
}catch (Exception e){
|
||||
textFieldAmount.setTextColor(16711680);
|
||||
TimerTask r = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
textFieldAmount.setTextColor(14737632);
|
||||
}
|
||||
};
|
||||
Timer t = new Timer();
|
||||
t.schedule(r, 1000);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Tudicraft.proxy.getPlayerHandler().syncItemCalculator(inventorySlots.getSlot(0).getStack(), textFieldAmount.getText());
|
||||
mc.displayGuiScreen(new GuiRecipeEditor(new ContainerRecipeEditor(((ContainerCalculator)inventorySlots).getPlayer()), this));
|
||||
break;
|
||||
case 6:
|
||||
switch (mode){
|
||||
case INPUT:
|
||||
mode = EnumMode.OUTPUT;
|
||||
break;
|
||||
case OUTPUT:
|
||||
mode = EnumMode.CATALYST;
|
||||
break;
|
||||
case CATALYST:
|
||||
mode = EnumMode.INPUT;
|
||||
break;
|
||||
}
|
||||
updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,38 +149,15 @@ public class GuiCalculator extends GuiTooltipScreen{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
//Method
|
||||
}
|
||||
|
||||
public int getActiveSlot() {
|
||||
return activeSlot;
|
||||
}
|
||||
|
||||
public void setActiveSlot(int activeSlot) {
|
||||
this.activeSlot = activeSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if (!this.textFieldAmount.textboxKeyTyped(typedChar, keyCode)){
|
||||
|
||||
if(keyCode == 1){
|
||||
ItemStack itemStack = ((ContainerCalculator)inventorySlots).getPlayer().getHeldItem();
|
||||
ItemStackWrapper.NBT.setItem(itemStack, "dest", inventorySlots.getSlot(0).inventory.getStackInSlot(inventorySlots.getSlot(0).getSlotIndex()));
|
||||
ItemStackWrapper.NBT.setString(itemStack, "text", textFieldAmount.getText());
|
||||
Tudicraft.networkWrapper.sendToServer(new PackageCalculatorUpdate(((ContainerCalculator)inventorySlots).getPlayer().getHeldItem()));
|
||||
Tudicraft.proxy.getPlayerHandler().syncItemCalculator(inventorySlots.getSlot(0).getStack(), textFieldAmount.getText());
|
||||
((ContainerCalculator)inventorySlots).getPlayer().closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateScreen(){
|
||||
|
||||
}
|
||||
|
||||
public void updateSlots(){
|
||||
|
||||
}
|
||||
|
||||
@@ -177,10 +183,69 @@ public class GuiCalculator extends GuiTooltipScreen{
|
||||
public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text) {
|
||||
boolean b = fr.getUnicodeFlag();
|
||||
fr.setUnicodeFlag(true);
|
||||
super.renderItemOverlayIntoGUI(fr, stack, xPosition, yPosition, "≈1.23k");
|
||||
super.renderItemOverlayIntoGUI(fr, stack, xPosition, yPosition, ItemStackWrapper.getDisplayAmount(stack));
|
||||
fr.setUnicodeFlag(b);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
|
||||
if (slotIn != null)
|
||||
{
|
||||
slotId = slotIn.slotNumber;
|
||||
}
|
||||
mc.thePlayer.openContainer.slotClick(slotId, clickedButton, clickType, mc.thePlayer);
|
||||
}
|
||||
|
||||
public void updateScreen(){
|
||||
switch (mode){
|
||||
case OUTPUT:
|
||||
modeButton.displayString = StatCollector.translateToLocal("gui.calculator.output");
|
||||
break;
|
||||
case INPUT:
|
||||
modeButton.displayString = StatCollector.translateToLocal("gui.calculator.input");
|
||||
break;
|
||||
case CATALYST:
|
||||
modeButton.displayString = StatCollector.translateToLocal("gui.calculator.catalyst");
|
||||
break;
|
||||
}
|
||||
editButton.enabled = Tudicraft.proxy.getPlayerHandler().getHasRecipeOf(inventorySlots.getSlot(0).getStack());
|
||||
|
||||
|
||||
|
||||
if(costRecord != null){
|
||||
switch (mode){
|
||||
case OUTPUT:
|
||||
fillSlotsWith(costRecord.getOutputStack(), (page-1)*36);break;
|
||||
case INPUT:
|
||||
fillSlotsWith(costRecord.getInputStack(), (page-1)*36);break;
|
||||
case CATALYST:
|
||||
fillSlotsWith(costRecord.getCatalystStack(), (page-1)*36);break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getActiveSlot() {
|
||||
return activeSlot;
|
||||
}
|
||||
|
||||
public void setActiveSlot(int activeSlot) {
|
||||
this.activeSlot = activeSlot;
|
||||
if(activeSlot == -1){
|
||||
Tudicraft.proxy.getPlayerHandler().syncItemCalculator(inventorySlots.getSlot(0).getStack(), textFieldAmount.getText());
|
||||
}
|
||||
}
|
||||
|
||||
public void drawCenteredStringWithoutShadow(FontRenderer fontRendererIn, String text, int x, int y, int color) {
|
||||
fontRendererIn.drawString(text, x - fontRendererIn.getStringWidth(text) / 2, y, color);
|
||||
}
|
||||
|
||||
private void fillSlotsWith(ItemStack[] itemStacks, int start){
|
||||
int pos = 1;
|
||||
for(int i=start ;i<=itemStacks.length-1 && i<=start+36; i++){
|
||||
inventorySlots.getSlot(pos++).putStack(itemStacks[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,5 @@ public interface IPlayerHandler {
|
||||
|
||||
Recipe getRecipe(int index);
|
||||
|
||||
ImmutableList<ItemStack> getCostOf(ItemStack itemStack, int amount);
|
||||
void syncItemCalculator(ItemStack itemIn, String string);
|
||||
}
|
||||
@@ -2,8 +2,13 @@ package pers.towdium.tudicraft.network;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import pers.towdium.tudicraft.Tudicraft;
|
||||
import pers.towdium.tudicraft.core.ItemStackWrapper;
|
||||
import pers.towdium.tudicraft.core.Recipe;
|
||||
import pers.towdium.tudicraft.gui.calculator.ContainerCalculator;
|
||||
import pers.towdium.tudicraft.network.packages.PackageCalculatorUpdate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -101,14 +106,12 @@ public class PlayerHandlerClient implements IPlayerHandler {
|
||||
return recipes.get(index);
|
||||
}
|
||||
|
||||
//TODO
|
||||
@Override
|
||||
public ImmutableList<ItemStack> getCostOf(ItemStack itemStack, int amount) {
|
||||
ImmutableList.Builder<ItemStack> builder = new ImmutableList.Builder<>();
|
||||
//recipes.get(getRecipeIndexOf(itemStack))
|
||||
|
||||
|
||||
return null;
|
||||
public void syncItemCalculator(ItemStack itemIn, String string) {
|
||||
ItemStack itemStack = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
ItemStackWrapper.NBT.setItem(itemStack, "dest",itemIn );
|
||||
ItemStackWrapper.NBT.setString(itemStack, "text", string);
|
||||
Tudicraft.networkWrapper.sendToServer(new PackageCalculatorUpdate(itemStack));
|
||||
}
|
||||
|
||||
ImmutableList<int[]> getAllUnsortedRecipeIndexOf(ItemStack itemStack){
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PlayerHandlerServer implements IPlayerHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ItemStack> getCostOf(ItemStack itemStack, int amount) {
|
||||
return null;
|
||||
public void syncItemCalculator(ItemStack itemIn, String string) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user