mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 15:33:12 +00:00
Minor cleanups (#50)
* Finalize, minor alloc reduction Also enable Jabel and generic injection * Update dependencies.gradle * Clean up Machine a bit * spotless more enhanced instanceof * Update ModuleMachine.java * More clen * WARN: Removed exception catching * Many, many tiny patches + birthday fix * Spotless * Spotless again * Fix getLow and clamp tolerance value * Revert event -> ignored on unused event parameters * Rename instanceof variables * Update Machine.java * Use StringBuilder * Cache getStack() * Oops, Jabel can't handle that * Spotless * Spotless again My IDE was fighting with it * Remove unused elements + scream test success
This commit is contained in:
1 parent
6b4f3eb1c7
commit
f0f14bb278
325 files changed
+1205
-1868
No files matched your search
@@ -39,13 +39,11 @@ public class Tooltip {
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return tooltip.size() > 0;
|
||||
return !tooltip.isEmpty();
|
||||
}
|
||||
|
||||
public void add(List list) {
|
||||
for (Object obj : list) {
|
||||
tooltip.add((String) obj);
|
||||
}
|
||||
public void add(List<String> list) {
|
||||
tooltip.addAll(list);
|
||||
}
|
||||
|
||||
public List<String> getList() {
|
||||
|
||||
@@ -19,17 +19,16 @@ public class Widget implements IWidget {
|
||||
protected int color;
|
||||
|
||||
private IWidget parent;
|
||||
private List<IWidget> subWidgets;
|
||||
private List<WidgetAttribute> attributes;
|
||||
private final List<IWidget> subWidgets;
|
||||
private final List<WidgetAttribute> attributes;
|
||||
private IPoint position;
|
||||
private IPoint size;
|
||||
private IPoint offset;
|
||||
private Collection<EventHandler> globalEventHandlers;
|
||||
private final Collection<EventHandler> globalEventHandlers;
|
||||
private boolean enabled;
|
||||
private boolean visible;
|
||||
|
||||
public Widget(IWidget parent) {
|
||||
this.parent = null;
|
||||
subWidgets = new ArrayList<>();
|
||||
attributes = new ArrayList<>();
|
||||
position = new IPoint(0.0f, 0.0f);
|
||||
@@ -91,7 +90,7 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public IWidget addWidget(IWidget widget) {
|
||||
if (subWidgets.size() != 0
|
||||
if (!subWidgets.isEmpty()
|
||||
&& subWidgets.get(subWidgets.size() - 1).hasAttribute(WidgetAttribute.ALWAYS_ON_TOP)) {
|
||||
subWidgets.add(subWidgets.size() - 1, widget);
|
||||
} else {
|
||||
|
||||
@@ -51,13 +51,13 @@ public class WindowFieldKit extends Window {
|
||||
private float glassOffsetY;
|
||||
private float glassVX;
|
||||
private float glassVY;
|
||||
private Random glassRand;
|
||||
private final Random glassRand;
|
||||
private Control GlassControl;
|
||||
private ControlChromosome chromo;
|
||||
private ControlText text;
|
||||
private float analyseProgress;
|
||||
private boolean isAnalysing;
|
||||
private Map<IChromosomeType, String> info;
|
||||
private final Map<IChromosomeType, String> info;
|
||||
|
||||
public WindowFieldKit(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(280.0f, 230.0f, player, inventory, side);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WindowGenesis extends Window {
|
||||
new Panel(this, one.outset(1), MinecraftGUI.PanelType.Black);
|
||||
new Panel(this, two.outset(1), MinecraftGUI.PanelType.Black);
|
||||
|
||||
geneList = new ControlListBox<Gene>(this, one.x(), one.y(), one.w(), one.h(), 10.0f) {
|
||||
geneList = new ControlListBox<>(this, one.x(), one.y(), one.w(), one.h(), 10.0f) {
|
||||
|
||||
@Override
|
||||
public IWidget createOption(Gene value, int y) {
|
||||
@@ -83,7 +83,7 @@ public class WindowGenesis extends Window {
|
||||
}
|
||||
};
|
||||
|
||||
geneOptions = new ControlListBox<Gene>(this, two.x(), two.y(), two.w(), two.h(), 10.0f) {
|
||||
geneOptions = new ControlListBox<>(this, two.x(), two.y(), two.w(), two.h(), 10.0f) {
|
||||
|
||||
@Override
|
||||
public IWidget createOption(Gene value, int y) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ControlButton extends Control {
|
||||
textWidget = new ControlText(this, getArea(), text, TextJustification.MIDDLE_CENTER);
|
||||
}
|
||||
|
||||
private EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
private final EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ControlCheckbox extends Control implements IControlValue<Boolean> {
|
||||
}
|
||||
|
||||
public ControlCheckbox(IWidget parent, float x, float y, float w, String text, boolean bool) {
|
||||
super(parent, x, y, (w > 16.0f) ? w : 16.0f, 16.0f);
|
||||
super(parent, x, y, Math.max(w, 16.0f), 16.0f);
|
||||
this.text = text;
|
||||
value = bool;
|
||||
if (w > 16.0f) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import binnie.core.craftgui.geometry.TextJustification;
|
||||
public class ControlText extends Control implements IControlValue<String> {
|
||||
|
||||
private String text;
|
||||
private TextJustification align;
|
||||
private final TextJustification align;
|
||||
|
||||
public ControlText(IWidget parent, IPoint pos, String text) {
|
||||
this(parent, new IArea(pos, new IPoint(500.0f, 0.0f)), text, TextJustification.TOP_LEFT);
|
||||
|
||||
@@ -69,11 +69,6 @@ public class ControlTextEdit extends Control implements IControlValue<String> {
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
protected void onTextEdit(String value) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@@ -38,11 +38,6 @@ public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public void addHelp(String string) {
|
||||
helpStrings.add(string);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ControlOption<T> extends Control implements IControlValue<T> {
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
private EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
private final EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ControlTextOption<T> extends ControlOption<T> {
|
||||
this(controlList, option, option.toString(), y);
|
||||
}
|
||||
|
||||
private EventWidget.ChangeColour.Handler mouseHandler = new EventWidget.ChangeColour.Handler() {
|
||||
private final EventWidget.ChangeColour.Handler mouseHandler = new EventWidget.ChangeColour.Handler() {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeColour event) {
|
||||
|
||||
@@ -15,8 +15,8 @@ public class ControlPage<T> extends Control implements IControlValue<T> {
|
||||
public ControlPage(IWidget parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
setValue(value);
|
||||
if (parent instanceof IControlValue && ((IControlValue) parent).getValue() == null) {
|
||||
((IControlValue) parent).setValue(value);
|
||||
if (parent instanceof IControlValue cv && ((IControlValue<?>) parent).getValue() == null) {
|
||||
cv.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ControlPages<T> extends Control implements IControlValues<T>, ICont
|
||||
public Collection<T> getValues() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (IWidget child : getWidgets()) {
|
||||
list.add((T) ((IControlValue) child).getValue());
|
||||
list.add((T) ((IControlValue<?>) child).getValue());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import binnie.core.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlScroll extends Control {
|
||||
|
||||
private IControlScrollable scrollWidget;
|
||||
private final IControlScrollable scrollWidget;
|
||||
|
||||
public ControlScroll(IWidget parent, float x, float y, float width, float height, IControlScrollable scrollWidget) {
|
||||
super(parent, x, y, width, height);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ControlScrollBar extends Control {
|
||||
addSelfEventHandler(mouseDownHandler);
|
||||
}
|
||||
|
||||
private EventMouse.Down.Handler mouseDownHandler = new EventMouse.Down.Handler() {
|
||||
private final EventMouse.Down.Handler mouseDownHandler = new EventMouse.Down.Handler() {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
@@ -50,11 +50,6 @@ public class ControlScrollBar extends Control {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
IArea renderArea = getRenderArea();
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ControlScrollableContent<T extends IWidget> extends Control impleme
|
||||
setPercentageIndex(getPercentageIndex());
|
||||
}
|
||||
|
||||
private EventMouse.Wheel.Handler mouseWheelHandler = new EventMouse.Wheel.Handler() {
|
||||
private final EventMouse.Wheel.Handler mouseWheelHandler = new EventMouse.Wheel.Handler() {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventMouse.Wheel event) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
|
||||
|
||||
protected T value;
|
||||
|
||||
private ControlTabBar<T> tabBar;
|
||||
private final ControlTabBar<T> tabBar;
|
||||
|
||||
public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
@@ -59,8 +59,7 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
|
||||
}
|
||||
|
||||
CraftGUI.render.texture(iTexture, area);
|
||||
if (this instanceof ControlTabIcon) {
|
||||
ControlTabIcon icon = (ControlTabIcon) this;
|
||||
if (this instanceof ControlTabIcon icon) {
|
||||
ControlItemDisplay item = (ControlItemDisplay) getWidgets().get(0);
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
item.setColor(0xaaaaaaaa);
|
||||
|
||||
@@ -13,9 +13,9 @@ import binnie.core.genetics.BreedingSystem;
|
||||
|
||||
class ControlBreedingProgress extends Control {
|
||||
|
||||
private static Texture Progress = new StandardTexture(80, 22, 4, 4, CraftGUITextureSheet.Controls2);
|
||||
private float percentage;
|
||||
private int colour;
|
||||
private static final Texture Progress = new StandardTexture(80, 22, 4, 4, CraftGUITextureSheet.Controls2);
|
||||
private final float percentage;
|
||||
private final int colour;
|
||||
|
||||
public ControlBreedingProgress(IWidget parent, int x, int y, int width, int height, BreedingSystem system,
|
||||
float percentage) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
|
||||
public class ControlItemStackOption extends ControlTextOption<ItemStack> {
|
||||
|
||||
private ControlItemDisplay controlBee;
|
||||
private final ControlItemDisplay controlBee;
|
||||
|
||||
public ControlItemStackOption(ControlList<ItemStack> controlList, ItemStack option, int y) {
|
||||
super(controlList, option, option.getDisplayName(), y);
|
||||
|
||||
@@ -11,7 +11,7 @@ import forestry.api.genetics.IMutation;
|
||||
|
||||
class ControlMutationBox extends ControlListBox<IMutation> {
|
||||
|
||||
private Type type;
|
||||
private final Type type;
|
||||
private IAlleleSpecies species;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,11 +17,11 @@ import forestry.api.genetics.IMutation;
|
||||
|
||||
class ControlMutationSymbol extends Control implements ITooltip {
|
||||
|
||||
private static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
private static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
private static final Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
private static final Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
private IMutation value;
|
||||
private boolean discovered;
|
||||
private int type;
|
||||
private final int type;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
class ControlSpeciesBoxOption extends ControlTextOption<IAlleleSpecies> {
|
||||
|
||||
private ControlDatabaseIndividualDisplay controlBee;
|
||||
private final ControlDatabaseIndividualDisplay controlBee;
|
||||
|
||||
public ControlSpeciesBoxOption(ControlList<IAlleleSpecies> controlList, IAlleleSpecies option, int y) {
|
||||
super(controlList, option, option.getName(), y);
|
||||
|
||||
@@ -7,8 +7,8 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class DatabaseTab implements ITooltipHelp {
|
||||
|
||||
private String mod;
|
||||
private String unloc;
|
||||
private final String mod;
|
||||
private final String unloc;
|
||||
|
||||
public DatabaseTab(AbstractMod mod, String unloc) {
|
||||
this.mod = mod.getModID();
|
||||
|
||||
@@ -14,10 +14,10 @@ import forestry.api.genetics.IClassification;
|
||||
|
||||
public class PageBranchOverview extends PageBranch {
|
||||
|
||||
private ControlText branchName;
|
||||
private ControlText branchScientific;
|
||||
private ControlText branchAuthority;
|
||||
private List<ControlText> branchDescription;
|
||||
private final ControlText branchName;
|
||||
private final ControlText branchScientific;
|
||||
private final ControlText branchAuthority;
|
||||
private final List<ControlText> branchDescription;
|
||||
|
||||
public PageBranchOverview(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -10,7 +10,7 @@ import forestry.api.genetics.IClassification;
|
||||
|
||||
public class PageBranchSpecies extends PageBranch {
|
||||
|
||||
private ControlSpeciesBox speciesList;
|
||||
private final ControlSpeciesBox speciesList;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onHandleEvent(EventValueChanged<IAlleleSpecies> event) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class PageBreeder extends ControlPage<DatabaseTab> {
|
||||
|
||||
private GameProfile player;
|
||||
private final GameProfile player;
|
||||
|
||||
public PageBreeder(IWidget parent, GameProfile player, DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
@@ -22,7 +22,7 @@ public class PageBreeder extends ControlPage<DatabaseTab> {
|
||||
}
|
||||
|
||||
public void onPageRefresh() {
|
||||
while (getWidgets().size() > 0) {
|
||||
while (!getWidgets().isEmpty()) {
|
||||
deleteChild(getWidgets().get(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import forestry.api.genetics.IClassification;
|
||||
|
||||
public class PageSpeciesClassification extends PageSpecies {
|
||||
|
||||
private Map<IClassification.EnumClassLevel, ControlText> levels;
|
||||
private ControlText genus;
|
||||
private final Map<IClassification.EnumClassLevel, ControlText> levels;
|
||||
private final ControlText genus;
|
||||
|
||||
public PageSpeciesClassification(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -7,7 +7,7 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public class PageSpeciesMutations extends PageSpecies {
|
||||
|
||||
private ControlMutationBox list;
|
||||
private final ControlMutationBox list;
|
||||
|
||||
public PageSpeciesMutations(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -14,14 +14,14 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public class PageSpeciesOverview extends PageSpecies {
|
||||
|
||||
private ControlText controlName;
|
||||
private ControlText controlScientific;
|
||||
private ControlText controlAuthority;
|
||||
private ControlText controlComplexity;
|
||||
private ControlText controlDescription;
|
||||
private ControlText controlSignature;
|
||||
private ControlDatabaseIndividualDisplay controlInd1;
|
||||
private ControlDatabaseIndividualDisplay controlInd2;
|
||||
private final ControlText controlName;
|
||||
private final ControlText controlScientific;
|
||||
private final ControlText controlAuthority;
|
||||
private final ControlText controlComplexity;
|
||||
private final ControlText controlDescription;
|
||||
private final ControlText controlSignature;
|
||||
private final ControlDatabaseIndividualDisplay controlInd1;
|
||||
private final ControlDatabaseIndividualDisplay controlInd2;
|
||||
|
||||
public PageSpeciesOverview(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
@@ -58,23 +58,23 @@ public class PageSpeciesOverview extends PageSpecies {
|
||||
+ EnumChatFormatting.RESET);
|
||||
controlComplexity.setValue(I18N.localise("extratrees.genetics.complexity", species.getComplexity()));
|
||||
String desc = species.getDescription();
|
||||
String descBody = EnumChatFormatting.ITALIC.toString();
|
||||
StringBuilder descBody = new StringBuilder(EnumChatFormatting.ITALIC.toString());
|
||||
String descSig = "";
|
||||
|
||||
if (desc == null || desc.isEmpty() || desc.matches("(\\w+\\.?)+")) {
|
||||
descBody += I18N.localise("binniecore.gui.database.species.noDesc");
|
||||
descBody.append(I18N.localise("binniecore.gui.database.species.noDesc"));
|
||||
} else {
|
||||
String[] descStrings = desc.split("\\|");
|
||||
descBody += descStrings[0];
|
||||
descBody.append(descStrings[0]);
|
||||
for (int i = 1; i < descStrings.length - 1; ++i) {
|
||||
descBody = descBody + " " + descStrings[i];
|
||||
descBody.append(" ").append(descStrings[i]);
|
||||
}
|
||||
if (descStrings.length > 1) {
|
||||
descSig += descStrings[descStrings.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
controlDescription.setValue(descBody + EnumChatFormatting.RESET);
|
||||
controlDescription.setValue(descBody.toString() + EnumChatFormatting.RESET);
|
||||
controlSignature.setValue(descSig + EnumChatFormatting.RESET);
|
||||
float descHeight = CraftGUI.render.textHeight(controlDescription.getValue(), controlDescription.getSize().x());
|
||||
controlSignature.setPosition(
|
||||
|
||||
@@ -7,7 +7,7 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public class PageSpeciesResultant extends PageSpecies {
|
||||
|
||||
private ControlMutationBox list;
|
||||
private final ControlMutationBox list;
|
||||
|
||||
public PageSpeciesResultant(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -40,8 +40,8 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
protected boolean isNEI;
|
||||
|
||||
private float selectionBoxWidth;
|
||||
private Map<IDatabaseMode, ModeWidgets> modes;
|
||||
private BreedingSystem system;
|
||||
private final Map<IDatabaseMode, ModeWidgets> modes;
|
||||
private final BreedingSystem system;
|
||||
private Panel panelInformation;
|
||||
private Panel panelSearch;
|
||||
private ControlPages<IDatabaseMode> modePages;
|
||||
@@ -88,13 +88,12 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (!(event.getOrigin().getParent() instanceof ControlPage)) {
|
||||
if (!(event.getOrigin().getParent() instanceof ControlPage parent)) {
|
||||
return;
|
||||
} else if ((event.getValue() instanceof DatabaseTab)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ControlPage parent = (ControlPage) event.getOrigin().getParent();
|
||||
if (!(parent.getValue() instanceof IDatabaseMode)) {
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +184,7 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
|
||||
@Override
|
||||
public ControlTab<IDatabaseMode> createTab(float x, float y, float w, float h, IDatabaseMode value) {
|
||||
return new ControlTab<IDatabaseMode>(this, x, y, w, h, value) {
|
||||
return new ControlTab<>(this, x, y, w, h, value) {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -199,7 +198,7 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
CraftGUIUtil.linkWidgets(tab, modePages);
|
||||
changeMode(Mode.Species);
|
||||
for (IDatabaseMode mode : modes.keySet()) {
|
||||
modes.get(mode).infoTabs = new ControlTabBar(
|
||||
modes.get(mode).infoTabs = new ControlTabBar<>(
|
||||
modes.get(mode).modePage,
|
||||
8.0f,
|
||||
24.0f,
|
||||
@@ -266,7 +265,7 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
public ControlPage<IDatabaseMode> modePage;
|
||||
public ControlListBox listBox;
|
||||
|
||||
private ControlPages<DatabaseTab> infoPages;
|
||||
private final ControlPages<DatabaseTab> infoPages;
|
||||
private ControlTabBar<DatabaseTab> infoTabs;
|
||||
|
||||
public ModeWidgets(IDatabaseMode mode, WindowAbstractDatabase database) {
|
||||
|
||||
@@ -33,20 +33,12 @@ public abstract class EventHandler<E extends Event> {
|
||||
DirectChild;
|
||||
|
||||
public boolean isOrigin(IWidget origin, IWidget test) {
|
||||
switch (this) {
|
||||
case Any:
|
||||
return true;
|
||||
|
||||
case DirectChild:
|
||||
return test.getWidgets().contains(origin);
|
||||
|
||||
case Parent:
|
||||
return test.getParent() == origin;
|
||||
|
||||
case Self:
|
||||
return test == origin;
|
||||
}
|
||||
return false;
|
||||
return switch (this) {
|
||||
case Any -> true;
|
||||
case DirectChild -> test.getWidgets().contains(origin);
|
||||
case Parent -> test.getParent() == origin;
|
||||
case Self -> test == origin;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ public enum Position {
|
||||
LEFT(-1, 0),
|
||||
RIGHT(1, 0);
|
||||
|
||||
protected int x;
|
||||
protected int y;
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
Position(int x, int y) {
|
||||
this.x = x;
|
||||
@@ -24,19 +24,11 @@ public enum Position {
|
||||
}
|
||||
|
||||
public Position opposite() {
|
||||
switch (this) {
|
||||
case BOTTOM:
|
||||
return Position.TOP;
|
||||
|
||||
case LEFT:
|
||||
return Position.RIGHT;
|
||||
|
||||
case RIGHT:
|
||||
return Position.LEFT;
|
||||
|
||||
case TOP:
|
||||
return Position.BOTTOM;
|
||||
}
|
||||
return null;
|
||||
return switch (this) {
|
||||
case BOTTOM -> Position.TOP;
|
||||
case LEFT -> Position.RIGHT;
|
||||
case RIGHT -> Position.LEFT;
|
||||
case TOP -> Position.BOTTOM;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ public enum TextJustification {
|
||||
BOTTOM_CENTER(0.5f, 1.0f),
|
||||
BOTTOM_RIGHT(1.0f, 1.0f);
|
||||
|
||||
protected float xOffset;
|
||||
protected float yOffset;
|
||||
final float xOffset;
|
||||
final float yOffset;
|
||||
|
||||
TextJustification(float xOffset, float yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
|
||||
@@ -36,10 +36,10 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ContainerCraftGUI extends Container {
|
||||
|
||||
private Window window;
|
||||
private Map<String, NBTTagCompound> syncedNBT;
|
||||
private Map<String, NBTTagCompound> sentNBT;
|
||||
private Map<Integer, TankInfo> syncedTanks;
|
||||
private final Window window;
|
||||
private final Map<String, NBTTagCompound> syncedNBT;
|
||||
private final Map<String, NBTTagCompound> sentNBT;
|
||||
private final Map<Integer, TankInfo> syncedTanks;
|
||||
private PowerInfo syncedPower;
|
||||
private ProcessInfo syncedProcess;
|
||||
private int errorType;
|
||||
@@ -61,8 +61,8 @@ public class ContainerCraftGUI extends Container {
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryItemStacks = new ListMap();
|
||||
inventorySlots = new ListMap();
|
||||
inventoryItemStacks = new ListMap<>();
|
||||
inventorySlots = new ListMap<>();
|
||||
if (machine == null) {
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class ContainerCraftGUI extends Container {
|
||||
if (index < 0 || index >= inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
return (Slot) inventorySlots.get(index);
|
||||
return inventorySlots.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,9 +145,9 @@ public class ContainerCraftGUI extends Container {
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
if (!crafters.contains(player)) {
|
||||
crafters.add(player);
|
||||
if (player instanceof EntityPlayerMP playerMP) {
|
||||
if (!crafters.contains(playerMP)) {
|
||||
crafters.add(playerMP);
|
||||
}
|
||||
sentNBT.clear();
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
ItemStack stack = request.transfer(true);
|
||||
Slot shiftClickedSlot = (Slot) inventorySlots.get(index);
|
||||
Slot shiftClickedSlot = inventorySlots.get(index);
|
||||
shiftClickedSlot.putStack(stack);
|
||||
shiftClickedSlot.onSlotChanged();
|
||||
return null;
|
||||
@@ -233,9 +233,8 @@ public class ContainerCraftGUI extends Container {
|
||||
int slotNumber = action.getShort("n");
|
||||
getOrCreateSlot(InventoryType.values()[type % 4], index, slotNumber);
|
||||
|
||||
for (Object crafterObject : crafters) {
|
||||
ICrafting crafter = (ICrafting) crafterObject;
|
||||
crafter.sendContainerAndContentsToPlayer(this, getInventory());
|
||||
for (ICrafting crafterObject : crafters) {
|
||||
crafterObject.sendContainerAndContentsToPlayer(this, getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,9 +298,8 @@ public class ContainerCraftGUI extends Container {
|
||||
|
||||
if (shouldSend) {
|
||||
for (Object crafter : crafters) {
|
||||
if (crafter instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) crafter;
|
||||
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), player);
|
||||
if (crafter instanceof EntityPlayerMP playerMP) {
|
||||
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), playerMP);
|
||||
}
|
||||
}
|
||||
sentThisTime.put(nbt.getKey(), nbt.getValue());
|
||||
|
||||
@@ -20,9 +20,9 @@ public enum EnumColor {
|
||||
Yellow("Yellow", 16777045, 'e'),
|
||||
White("White", 16777215, 'f');
|
||||
|
||||
protected int colour;
|
||||
protected String name;
|
||||
protected char code;
|
||||
private final int colour;
|
||||
private final String name;
|
||||
private final char code;
|
||||
|
||||
EnumColor(String name, int colour, char code) {
|
||||
this.name = name;
|
||||
@@ -35,7 +35,7 @@ public enum EnumColor {
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return "\u00a7" + code;
|
||||
return "§" + code;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ public enum GUIIcon {
|
||||
ArrowLeftDown("arrow-leftdown"),
|
||||
ArrowLeftUp("arrow-leftup");
|
||||
|
||||
String path;
|
||||
final String path;
|
||||
BinnieIcon icon;
|
||||
|
||||
GUIIcon(String path) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiCraftGUI extends GuiContainer {
|
||||
|
||||
private Window window;
|
||||
private final Window window;
|
||||
private ItemStack draggedItem;
|
||||
|
||||
public GuiCraftGUI(Window window) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Map;
|
||||
|
||||
class ListMap<T> implements List<T> {
|
||||
|
||||
private LinkedHashMap<Integer, T> map;
|
||||
private final LinkedHashMap<Integer, T> map;
|
||||
|
||||
ListMap() {
|
||||
map = new LinkedHashMap<>();
|
||||
|
||||
@@ -33,9 +33,9 @@ public class MinecraftTooltip extends Tooltip {
|
||||
USER(0x962433, EnumChatFormatting.RED, EnumChatFormatting.DARK_RED),
|
||||
POWER(0x896e00, EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD);
|
||||
|
||||
int outline;
|
||||
String mainText;
|
||||
String bodyText;
|
||||
final int outline;
|
||||
final String mainText;
|
||||
final String bodyText;
|
||||
|
||||
TypeColor(int outline, EnumChatFormatting mainText, EnumChatFormatting bodyText) {
|
||||
this.outline = outline;
|
||||
|
||||
@@ -53,15 +53,15 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
protected float titleButtonLeft;
|
||||
protected float titleButtonRight;
|
||||
private GuiCraftGUI gui;
|
||||
private ContainerCraftGUI container;
|
||||
private WindowInventory windowInventory;
|
||||
private final ContainerCraftGUI container;
|
||||
private final WindowInventory windowInventory;
|
||||
private ControlText title;
|
||||
private StandardTexture bgText1;
|
||||
private StandardTexture bgText2;
|
||||
private boolean hasBeenInitialised;
|
||||
private EntityPlayer player;
|
||||
private IInventory entityInventory;
|
||||
private Side side;
|
||||
private final Side side;
|
||||
|
||||
public Window(float width, float height, EntityPlayer player, IInventory inventory, Side side) {
|
||||
this.side = side;
|
||||
|
||||
@@ -13,10 +13,10 @@ import binnie.core.machines.inventory.SlotValidator;
|
||||
|
||||
public class WindowInventory implements IInventory {
|
||||
|
||||
private Window window;
|
||||
private Map<Integer, ItemStack> inventory;
|
||||
private Map<Integer, SlotValidator> validators;
|
||||
private List<Integer> disabledAutoDispenses;
|
||||
private final Window window;
|
||||
private final Map<Integer, ItemStack> inventory;
|
||||
private final Map<Integer, SlotValidator> validators;
|
||||
private final List<Integer> disabledAutoDispenses;
|
||||
|
||||
public WindowInventory(Window window) {
|
||||
inventory = new HashMap<>();
|
||||
@@ -27,7 +27,7 @@ public class WindowInventory implements IInventory {
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (inventory.size() == 0) {
|
||||
if (inventory.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ public class WindowInventory implements IInventory {
|
||||
amount = available;
|
||||
}
|
||||
|
||||
ItemStack itemStack = item;
|
||||
itemStack.stackSize -= amount;
|
||||
item.stackSize -= amount;
|
||||
output.stackSize = amount;
|
||||
if (item.stackSize == 0) {
|
||||
setInventorySlotContents(index, null);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ControlEnergyBar extends Control implements ITooltip {
|
||||
|
||||
public static boolean isError;
|
||||
|
||||
private Position direction;
|
||||
private final Position direction;
|
||||
|
||||
public ControlEnergyBar(IWidget parent, int x, int y, int width, int height, Position direction) {
|
||||
super(parent, x, y, width, height);
|
||||
@@ -42,8 +42,7 @@ public class ControlEnergyBar extends Control implements ITooltip {
|
||||
return null;
|
||||
}
|
||||
|
||||
IPoweredMachine clientPower = machine.getMachine().getInterface(IPoweredMachine.class);
|
||||
return clientPower;
|
||||
return machine.getMachine().getInterface(IPoweredMachine.class);
|
||||
}
|
||||
|
||||
public float getPercentage() {
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ControlErrorState extends Control implements ITooltip {
|
||||
}
|
||||
|
||||
tooltip.add(errorState.toString());
|
||||
if (errorState.getTooltip().length() > 0) {
|
||||
if (!errorState.getTooltip().isEmpty()) {
|
||||
tooltip.add(errorState.getTooltip());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import binnie.core.craftgui.geometry.IPoint;
|
||||
|
||||
public class ControlIconDisplay extends Control {
|
||||
|
||||
private IIcon icon;
|
||||
private final IIcon icon;
|
||||
|
||||
public ControlIconDisplay(IWidget parent, float x, float y, IIcon icon) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
|
||||
@@ -8,7 +8,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
|
||||
public class ControlImage extends Control {
|
||||
|
||||
private Object key;
|
||||
private final Object key;
|
||||
|
||||
public ControlImage(IWidget parent, float x, float y, Texture text) {
|
||||
super(parent, x, y, text.w(), text.h());
|
||||
|
||||
@@ -11,7 +11,7 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class ControlInfo extends Control implements ITooltip {
|
||||
|
||||
private String info;
|
||||
private final String info;
|
||||
|
||||
public ControlInfo(IWidget parent, float x, float y, String info) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
|
||||
public static List<Integer> tankError = new ArrayList<>();
|
||||
private int tankID;
|
||||
private boolean horizontal;
|
||||
private final boolean horizontal;
|
||||
|
||||
public ControlLiquidTank(IWidget parent, int x, int y) {
|
||||
this(parent, x, y, false);
|
||||
|
||||
@@ -9,7 +9,7 @@ import binnie.core.craftgui.minecraft.InventoryType;
|
||||
|
||||
public class ControlPlayerInventory extends Control {
|
||||
|
||||
private List<ControlSlot> slots;
|
||||
private final List<ControlSlot> slots;
|
||||
|
||||
public ControlPlayerInventory(IWidget parent, boolean wide) {
|
||||
super(
|
||||
@@ -77,8 +77,4 @@ public class ControlPlayerInventory extends Control {
|
||||
return slots.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class ControlPowerSystem extends Control implements ITooltip {
|
||||
|
||||
private PowerSystem system;
|
||||
private final PowerSystem system;
|
||||
|
||||
public ControlPowerSystem(IWidget parent, float x, float y, PowerSystem system) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
|
||||
@@ -7,9 +7,9 @@ import binnie.core.craftgui.resource.Texture;
|
||||
|
||||
public class ControlProgress extends ControlProgressBase {
|
||||
|
||||
private Texture progressBlank;
|
||||
private Texture progressBar;
|
||||
private Position direction;
|
||||
private final Texture progressBlank;
|
||||
private final Texture progressBar;
|
||||
private final Position direction;
|
||||
|
||||
public ControlProgress(IWidget parent, int x, int y, Texture progressBlank, Texture progressBar, Position dir) {
|
||||
super(
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ControlProgressBase extends Control {
|
||||
}
|
||||
|
||||
if (seconds > 0) {
|
||||
if (ts.length() > 0) {
|
||||
if (!ts.isEmpty()) {
|
||||
ts += " ";
|
||||
}
|
||||
if (seconds == 1) {
|
||||
|
||||
@@ -16,10 +16,10 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public class ControlSlide extends Control {
|
||||
|
||||
private IArea expanded;
|
||||
private IArea shrunk;
|
||||
private final IArea expanded;
|
||||
private final IArea shrunk;
|
||||
private boolean slideActive;
|
||||
private Position anchor;
|
||||
private final Position anchor;
|
||||
private String label;
|
||||
|
||||
public ControlSlide(IWidget parent, float x, float y, float w, float h, Position anchor2) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import binnie.core.craftgui.minecraft.InventoryType;
|
||||
|
||||
public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
|
||||
|
||||
private List<ControlSlot> slots;
|
||||
private final List<ControlSlot> slots;
|
||||
|
||||
public ControlSlotArray(IWidget parent, int x, int y, int columns, int rows) {
|
||||
super(parent, x, y, columns * 18, rows * 18);
|
||||
|
||||
@@ -17,7 +17,7 @@ import binnie.core.nei.NEIHook;
|
||||
|
||||
public abstract class ControlSlotBase extends Control implements ITooltip {
|
||||
|
||||
private ControlItemDisplay itemDisplay;
|
||||
private final ControlItemDisplay itemDisplay;
|
||||
|
||||
public ControlSlotBase(IWidget parent, float x, float y) {
|
||||
this(parent, x, y, 18);
|
||||
@@ -31,9 +31,7 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
|
||||
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeSize event) {
|
||||
if (itemDisplay != null) {
|
||||
itemDisplay.setSize(getSize().sub(new IPoint(2.0f, 2.0f)));
|
||||
}
|
||||
itemDisplay.setSize(getSize().sub(new IPoint(2.0f, 2.0f)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import binnie.core.machines.inventory.IChargedSlots;
|
||||
|
||||
public class ControlSlotCharge extends Control {
|
||||
|
||||
private int slot;
|
||||
private final int slot;
|
||||
|
||||
public ControlSlotCharge(IWidget parent, int x, int y, int slot) {
|
||||
super(parent, x, y, 4.0f, 18.0f);
|
||||
|
||||
@@ -9,7 +9,7 @@ import binnie.core.genetics.IItemStackRepresentative;
|
||||
|
||||
public class ControlTabIcon<T> extends ControlTab<T> {
|
||||
|
||||
private ControlItemDisplay item;
|
||||
private final ControlItemDisplay item;
|
||||
|
||||
public ControlTabIcon(ControlTabBar<T> parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h, value);
|
||||
@@ -28,7 +28,7 @@ public class ControlTabIcon<T> extends ControlTab<T> {
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
item.setItemStack(getItemStack());
|
||||
float x = ((ControlTabBar) getParent()).getDirection().x();
|
||||
float x = ((ControlTabBar<?>) getParent()).getDirection().x();
|
||||
item.setOffset(new IPoint((isCurrentSelection() || isMouseOver()) ? 0.0f : (-4.0f * x), 0.0f));
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ControlUser extends Control implements ITooltip {
|
||||
|
||||
protected String team;
|
||||
|
||||
private String username;
|
||||
private final String username;
|
||||
|
||||
public ControlUser(IWidget parent, float x, float y, String username) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
|
||||
@@ -11,19 +11,11 @@ public enum EnumHighlighting {
|
||||
SHIFT_CLICK;
|
||||
|
||||
int getColour() {
|
||||
switch (this) {
|
||||
case ERROR:
|
||||
return MinecraftTooltip.getOutline(MinecraftTooltip.Type.ERROR);
|
||||
|
||||
case HELP:
|
||||
return MinecraftTooltip.getOutline(Tooltip.Type.HELP);
|
||||
|
||||
case SHIFT_CLICK:
|
||||
return 0xffff00;
|
||||
|
||||
case WARNING:
|
||||
return MinecraftTooltip.getOutline(MinecraftTooltip.Type.WARNING);
|
||||
}
|
||||
return 0;
|
||||
return switch (this) {
|
||||
case ERROR -> MinecraftTooltip.getOutline(MinecraftTooltip.Type.ERROR);
|
||||
case HELP -> MinecraftTooltip.getOutline(Tooltip.Type.HELP);
|
||||
case SHIFT_CLICK -> 0xffff00;
|
||||
case WARNING -> MinecraftTooltip.getOutline(MinecraftTooltip.Type.WARNING);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CraftGUIResourceManager implements IResourceManagerReloadListener {
|
||||
|
||||
private Map<String, ParsedTextureSheet> textureSheets;
|
||||
private Map<String, Texture> textures;
|
||||
private final Map<String, ParsedTextureSheet> textureSheets;
|
||||
private final Map<String, Texture> textures;
|
||||
|
||||
public CraftGUIResourceManager() {
|
||||
textureSheets = new HashMap<>();
|
||||
@@ -53,8 +53,7 @@ public class CraftGUIResourceManager implements IResourceManagerReloadListener {
|
||||
bufferedreader = new BufferedReader(new InputStreamReader(res.getInputStream(), Charsets.UTF_8));
|
||||
jsonobject = new JsonParser().parse(bufferedreader).getAsJsonObject();
|
||||
for (JsonElement el : jsonobject.get("texture-sheets").getAsJsonArray()) {
|
||||
if (el instanceof JsonObject) {
|
||||
JsonObject sheet = (JsonObject) el;
|
||||
if (el instanceof JsonObject sheet) {
|
||||
String name = sheet.get("name").getAsString();
|
||||
String modid = sheet.get("modid").getAsString();
|
||||
String path = sheet.get("path").getAsString();
|
||||
@@ -63,8 +62,7 @@ public class CraftGUIResourceManager implements IResourceManagerReloadListener {
|
||||
}
|
||||
|
||||
for (JsonElement el : jsonobject.get("textures").getAsJsonArray()) {
|
||||
if (el instanceof JsonObject) {
|
||||
JsonObject sheet = (JsonObject) el;
|
||||
if (el instanceof JsonObject sheet) {
|
||||
String name = sheet.get("name").getAsString();
|
||||
IBinnieTexture textureSheet = getTextureSheet(sheet.get("sheet").getAsString());
|
||||
IArea uv = getArea(sheet.get("uv").getAsString());
|
||||
|
||||
@@ -45,7 +45,7 @@ public enum CraftGUITexture {
|
||||
CheckboxChecked("checkbox.checked"),
|
||||
CheckboxCheckedHighlighted("checkbox.checked.highlighted");
|
||||
|
||||
String name;
|
||||
final String name;
|
||||
|
||||
CraftGUITexture(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -11,7 +11,7 @@ public enum CraftGUITextureSheet implements IBinnieTexture {
|
||||
Panel2("panels"),
|
||||
Slots("slots");
|
||||
|
||||
String name;
|
||||
final String name;
|
||||
|
||||
CraftGUITextureSheet(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -6,9 +6,9 @@ import binnie.core.resource.ResourceType;
|
||||
|
||||
class ParsedTextureSheet implements IBinnieTexture {
|
||||
|
||||
private String name;
|
||||
private String modid;
|
||||
private String path;
|
||||
private final String name;
|
||||
private final String modid;
|
||||
private final String path;
|
||||
|
||||
public ParsedTextureSheet(String name, String modid, String path) {
|
||||
this.name = name;
|
||||
|
||||
Reference in new issue
Block a user