feat: framework tweaked

This commit is contained in:
Discreater committed 2021-04-30 16:13:43 +08:00
1 parent 8ee76a5f8a
commit 5bbc857407
42 files changed
+317 -176

No files matched your search

@@ -3,7 +3,7 @@ package me.towdium.jecalculation.data.label;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import me.towdium.jecalculation.gui.IWPicker;
import me.towdium.jecalculation.gui.JecGui;
import me.towdium.jecalculation.gui.JecaGui;
import me.towdium.jecalculation.gui.guis.pickers.PickerSimple;
import me.towdium.jecalculation.gui.guis.pickers.PickerUniversal;
import me.towdium.jecalculation.data.label.labels.LFluidStack;
@@ -37,7 +37,7 @@ public interface ILabel {
Serializer DESERIALIZER = new Serializer();
Converter CONVERTER = new Converter();
RegistryEditor EDITOR = new RegistryEditor();
ILabel EMPTY = new LItemStack(ItemStackHelper.EMPTY_ITEM_STACK, 0);
ILabel EMPTY = new LEmpty();
String FORMAT_BLUE = "\u00A79";
String FORMAT_GREY = "\u00A78";
@@ -63,6 +63,7 @@ public interface ILabel {
DESERIALIZER.register(LItemStack.IDENTIFIER, LItemStack::new);
DESERIALIZER.register(LOreDict.IDENTIFIER, LOreDict::new);
DESERIALIZER.register(LString.IDENTIFIER, LString::new);
DESERIALIZER.register(LEmpty.IDENTIFIER, i -> EMPTY);
}
List<String> getToolTip(List<String> existing, boolean detailed);
@@ -83,14 +84,14 @@ public interface ILabel {
String getIdentifier();
@SideOnly(Side.CLIENT)
default void drawLabel(JecGui gui, int xPos, int yPos, boolean center) {
default void drawLabel(JecaGui gui, int xPos, int yPos, boolean center) {
GlStateManager.pushMatrix();
GlStateManager.translate(center ? xPos - 8 : xPos, center ? yPos - 8 : yPos, 0);
drawLabel(gui);
GlStateManager.popMatrix();
}
void drawLabel(JecGui gui);
void drawLabel(JecaGui gui);
/**
* Since {@link ILabel} merging is bidirectional, it is redundant to
@@ -112,7 +113,7 @@ public interface ILabel {
}
static Optional<ILabel> mergeItemStackNItemStack(ILabel a, ILabel b, boolean add) {
if (a instanceof LItemStack && b instanceof LItemStack && a != ILabel.EMPTY && b != ILabel.EMPTY) {
if (a instanceof LItemStack && b instanceof LItemStack) {
LItemStack lisA = (LItemStack) a;
LItemStack lisB = (LItemStack) b;
ItemStack isA = lisA.getItemStack();
@@ -194,8 +195,7 @@ public interface ILabel {
public ILabel deserialize(NBTTagCompound nbt) {
String s = nbt.getString(KEY_IDENTIFIER);
ILabel e = idToData.get(s).apply(nbt.getCompoundTag(KEY_CONTENT));
if (e != ILabel.EMPTY) return e;
else throw new RuntimeException("Fail to deserialize label type: " + s);
return idToData.get(s).apply(nbt.getCompoundTag(KEY_CONTENT));
}
public NBTTagCompound serialize(ILabel label) {
@@ -259,4 +259,70 @@ public interface ILabel {
}
}
}
class LEmpty implements ILabel {
public static final String IDENTIFIER = "empty";
private LEmpty() {
}
@Override
public ILabel increaseAmount() {
return this;
}
@Override
public ILabel increaseAmountLarge() {
return this;
}
@Override
public ILabel decreaseAmount() {
return this;
}
@Override
public ILabel decreaseAmountLarge() {
return this;
}
@Override
public ILabel invertAmount() {
return this;
}
@Override
public String getAmountString() {
return "";
}
@Override
public String getDisplayName() {
return "";
}
@Override
public List<String> getToolTip(List<String> existing, boolean detailed) {
return new ArrayList<>();
}
@Override
public ILabel copy() {
return this;
}
@Override
public NBTTagCompound toNBTTagCompound() {
return new NBTTagCompound();
}
@Override
public String getIdentifier() {
return IDENTIFIER;
}
@Override
public void drawLabel(JecaGui gui) {
}
}
}