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:
ah-OOG-ah authored and GitHub committed 2024-09-26 16:59:20 +02:00
1 parent 6b4f3eb1c7
commit f0f14bb278
325 files changed
+1205 -1868

No files matched your search

+3 -3
View File
@@ -47,7 +47,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
return new IBinnieGUID[0];
}
public Class[] getConfigs() {
public Class<?>[] getConfigs() {
return new Class[0];
}
@@ -68,7 +68,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
}
if (getConfigs() != null) {
for (Class cls : getConfigs()) {
for (Class<?> cls : getConfigs()) {
Binnie.Configuration.registerConfiguration(cls, this);
}
}
@@ -80,7 +80,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
// TODO what does it mean?
Collections.addAll(fields, getClass().getFields());
for (Class cls : getClass().getClasses()) {
for (Class<?> cls : getClass().getClasses()) {
Collections.addAll(fields, getClass().getFields());
}
for (IInitializable module : modules) {
+5 -6
View File
@@ -51,7 +51,7 @@ import forestry.plugins.PluginManager;
@Mod(
modid = "BinnieCore",
name = "Binnie Core",
version = BinnieCore.VERSION,
version = Tags.VERSION,
useMetadata = true,
dependencies = "after:Forestry@[4.2,),required-after:gtnhlib@[0.0.10,)")
public class BinnieCore extends AbstractMod {
@@ -63,14 +63,13 @@ public class BinnieCore extends AbstractMod {
public static BinnieProxy proxy;
public static int multipassRenderID;
private static List<AbstractMod> modList = new ArrayList<>();
private static final List<AbstractMod> modList = new ArrayList<>();
public static MachineGroup packageCompartment;
public static ItemGenesis genesis;
public static ItemFieldKit fieldKit;
public static final String VERSION = "GRADLETOKEN_VERSION";
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt) {
public void preInit(FMLPreInitializationEvent event) {
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
for (ManagerBase baseManager : Binnie.Managers) {
addModule(baseManager);
@@ -86,12 +85,12 @@ public class BinnieCore extends AbstractMod {
}
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
public void init(FMLInitializationEvent event) {
init();
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent evt) {
public void postInit(FMLPostInitializationEvent event) {
postInit();
}
+20 -20
View File
@@ -9,14 +9,15 @@ import cpw.mods.fml.common.registry.GameRegistry;
public class Mods {
public static Mod forestry;
public static Mod ic2;
public static Mod botania;
public static Mod extraBiomes;
public static final Mod forestry = new Mod("Forestry");
public static final Mod ic2 = new Mod("IC2");
public static final Mod botania = new Mod("Botania");
public static final Mod extraBiomes = new Mod("ExtrabiomesXL");
public static final Mod dreamcraft = new Mod("dreamcraft");
private static Item findItem(String modId, String name) {
Item stack = GameRegistry.findItem(modId, name);
if (stack == null && modId.equals("Forestry")) {
if (stack == null && forestry.matchID(modId)) {
throw new RuntimeException("Item not found: " + modId + ":" + name);
}
return stack;
@@ -24,7 +25,7 @@ public class Mods {
private static ItemStack findItemStack(String modId, String name, int stackSize) {
ItemStack stack = GameRegistry.findItemStack(modId, name, stackSize);
if (stack == null && modId.equals("Forestry")) {
if (stack == null && forestry.matchID(modId)) {
throw new RuntimeException("Stack not found: " + modId + ":" + name);
}
return stack;
@@ -32,37 +33,32 @@ public class Mods {
private static Block findBlock(String modId, String name) {
Block stack = GameRegistry.findBlock(modId, name);
if (stack == null && modId.equals("Forestry")) {
if (stack == null && forestry.matchID(modId)) {
throw new RuntimeException("Block not found: " + modId + ":" + name);
}
return stack;
}
static {
Mods.forestry = new Mod("Forestry");
Mods.ic2 = new Mod("IC2");
Mods.botania = new Mod("Botania");
Mods.extraBiomes = new Mod("ExtrabiomesXL");
}
public static class Mod {
private String id;
private final String modid;
private final boolean isLoaded;
private Mod(String id) {
this.id = id;
modid = id;
isLoaded = Loader.isModLoaded(id);
}
public Item item(String name) {
return findItem(id, name);
return findItem(modid, name);
}
public Block block(String name) {
return findBlock(id, name);
return findBlock(modid, name);
}
public ItemStack stack(String name, int stackSize) {
return findItemStack(id, name, stackSize);
return findItemStack(modid, name, stackSize);
}
public ItemStack stack(String name) {
@@ -74,7 +70,11 @@ public class Mods {
}
public boolean active() {
return Loader.isModLoaded(id);
return isLoaded;
}
public boolean matchID(final String id) {
return modid.equals(id);
}
}
}
@@ -62,7 +62,7 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
}
@Override
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
public void addBlockTooltip(ItemStack itemStack, List<String> tooltip) {
// ignored
}
@@ -97,7 +97,7 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
boolean hasBeenBroken = world.setBlockToAir(i, j, k);
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world)
&& drops.size() > 0
&& !drops.isEmpty()
&& (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
block.dropAsStack(world, i, j, k, drop);
@@ -15,7 +15,7 @@ public interface IBlockMetadata extends ITileEntityProvider {
String getBlockName(ItemStack itemStack);
void addBlockTooltip(ItemStack itemStack, List tooltip);
void addBlockTooltip(ItemStack itemStack, List<String> tooltip);
void dropAsStack(World world, int x, int y, int z, ItemStack itemStack);
}
@@ -19,11 +19,6 @@ public class ItemMetadata extends ItemBlock {
super(block);
}
@Override
public int getMetadata(int damage) {
return 0;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ, int metadata) {
@@ -56,7 +51,7 @@ public class ItemMetadata extends ItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) {
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> tooltip, boolean advanced) {
((IBlockMetadata) field_150939_a).addBlockTooltip(itemStack, tooltip);
}
@@ -34,14 +34,10 @@ public class MultipassItemRenderer implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
switch (type) {
case ENTITY:
case EQUIPPED:
case INVENTORY:
case EQUIPPED_FIRST_PERSON:
return true;
}
return false;
return switch (type) {
case ENTITY, EQUIPPED, INVENTORY, EQUIPPED_FIRST_PERSON -> true;
default -> false;
};
}
@Override
@@ -12,9 +12,9 @@ import forestry.api.circuits.ICircuitLayout;
public class BinnieCircuit implements ICircuit {
private String uid;
private int limit;
private List<String> tooltips;
private final String uid;
private final int limit;
private final List<String> tooltips;
public BinnieCircuit(String uid, int limit, ICircuitLayout layout, ItemStack itemStack) {
tooltips = new ArrayList<>();
@@ -9,8 +9,8 @@ import forestry.api.circuits.ICircuitSocketType;
public class BinnieCircuitLayout implements ICircuitLayout {
private String uid;
private AbstractMod mod;
private final String uid;
private final AbstractMod mod;
public BinnieCircuitLayout(AbstractMod mod, String uid) {
this.uid = uid;
@@ -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;
@@ -7,8 +7,8 @@ import java.util.Map;
public class BeeModifierLogic {
private Map<EnumBeeModifier, Float[]> modifiers;
private List<EnumBeeBooleanModifier> booleanModifiers;
private final Map<EnumBeeModifier, Float[]> modifiers;
private final List<EnumBeeBooleanModifier> booleanModifiers;
public BeeModifierLogic() {
modifiers = new HashMap<>();
@@ -131,6 +131,7 @@ public abstract class BreedingSystem implements IItemStackRepresentative {
for (IAlleleSpecies species2 : branch.getMemberSpecies()) {
if (allActiveSpecies.contains(species2)) {
possible = true;
break;
}
}
if (!possible) {
@@ -18,7 +18,7 @@ public class ForestryAllele {
Longest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.lifespan" + toString());
return AlleleManager.alleleRegistry.getAllele("forestry.lifespan" + this);
}
}
@@ -33,7 +33,7 @@ public class ForestryAllele {
Fastest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.speed" + toString());
return AlleleManager.alleleRegistry.getAllele("forestry.speed" + this);
}
}
@@ -45,7 +45,7 @@ public class ForestryAllele {
Maximum;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.fertility" + toString());
return AlleleManager.alleleRegistry.getAllele("forestry.fertility" + this);
}
}
@@ -57,7 +57,7 @@ public class ForestryAllele {
Largest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.territory" + toString());
return AlleleManager.alleleRegistry.getAllele("forestry.territory" + this);
}
}
@@ -72,7 +72,7 @@ public class ForestryAllele {
Largest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.size" + toString());
return AlleleManager.alleleRegistry.getAllele("forestry.size" + this);
}
}
@@ -82,7 +82,7 @@ public class ForestryAllele {
False;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.bool" + toString());
return AlleleManager.alleleRegistry.getAllele("forestry.bool" + this);
}
public static IAllele get(boolean bool) {
+2 -3
View File
@@ -95,12 +95,11 @@ public class Gene implements INBTTagable, IGene {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Gene)) {
if (!(obj instanceof Gene gene)) {
return false;
}
Gene g = (Gene) obj;
return allele == g.allele && chromosome.ordinal() == g.chromosome.ordinal() && root == g.root;
return allele == gene.allele && chromosome.ordinal() == gene.chromosome.ordinal() && root == gene.root;
}
public String getAlleleName() {
@@ -37,9 +37,9 @@ public class ManagerGenetics extends ManagerBase {
public BreedingSystem treeBreedingSystem;
public BreedingSystem mothBreedingSystem;
public BreedingSystem flowerBreedingSystem;
private Map<ISpeciesRoot, BreedingSystem> breedingSystems;
private List<IChromosomeType> invalidChromosomeTypes;
private Map<ISpeciesRoot, Map<IChromosomeType, List<IAllele>>> chromosomeArray;
private final Map<ISpeciesRoot, BreedingSystem> breedingSystems;
private final List<IChromosomeType> invalidChromosomeTypes;
private final Map<ISpeciesRoot, Map<IChromosomeType, List<IAllele>>> chromosomeArray;
public ManagerGenetics() {
breedingSystems = new LinkedHashMap<>();
@@ -178,11 +178,10 @@ public class ManagerGenetics extends ManagerBase {
}
system.addExtraAlleles(chromosome, alleles);
if (alleles.size() == 0) {
if (alleles.isEmpty()) {
invalidChromosomeTypes.add(chromosome);
} else {
List<IAllele> alleleList = new ArrayList<>();
alleleList.addAll(alleles);
List<IAllele> alleleList = new ArrayList<>(alleles);
chromosomeMap.put(chromosome, alleleList);
}
}
@@ -209,11 +208,11 @@ public class ManagerGenetics extends ManagerBase {
if (o1 == null || o2 == null) {
throw new NullPointerException("Allele is null!");
}
if (o1 instanceof IAlleleFloat && o2 instanceof IAlleleFloat) {
return Float.valueOf(((IAlleleFloat) o1).getValue()).compareTo(((IAlleleFloat) o2).getValue());
if (o1 instanceof IAlleleFloat af1 && o2 instanceof IAlleleFloat af2) {
return Float.compare(af1.getValue(), af2.getValue());
}
if (o1 instanceof IAlleleInteger && o2 instanceof IAlleleInteger && !(o1 instanceof AlleleColor)) {
return Integer.valueOf(((IAlleleInteger) o1).getValue()).compareTo(((IAlleleInteger) o2).getValue());
if (o1 instanceof IAlleleInteger ai1 && o2 instanceof IAlleleInteger ai2 && !(o1 instanceof AlleleColor)) {
return Integer.compare(ai1.getValue(), ai2.getValue());
}
// if (o1.getName() != null && o2.getName() != null) {
// return o1.getName().compareTo(o2.getName());
@@ -1,5 +1,7 @@
package binnie.core.genetics;
import net.minecraft.util.MathHelper;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
@@ -23,14 +25,15 @@ public enum Tolerance {
Down4(-4, 0),
Down5(-5, 0);
private int[] bounds;
private final int[] bounds;
private static final Tolerance[] VALUES = values();
Tolerance(int a, int b) {
bounds = new int[] { a, b };
}
public String getUID() {
return "forestry.tolerance" + toString();
return "forestry.tolerance" + this;
}
public int[] getBounds() {
@@ -38,7 +41,40 @@ public enum Tolerance {
}
public static Tolerance get(EnumTolerance tol) {
return values()[tol.ordinal()];
return VALUES[tol.ordinal()];
}
public static Tolerance getHigh(int i) {
return switch (MathHelper.clamp_int(i, 0, 5)) {
case 0 -> None;
case 1 -> Up1;
case 2 -> Up2;
case 3 -> Up3;
case 4 -> Up4;
default -> Up5;
};
}
public static Tolerance getLow(int i) {
return switch (MathHelper.clamp_int(i, -5, 0)) {
case -0 -> None;
case -1 -> Down1;
case -2 -> Down2;
case -3 -> Down3;
case -4 -> Down4;
default -> Down5;
};
}
public static Tolerance getBoth(int i) {
return switch (MathHelper.clamp_int(i, 0, 5)) {
case 0 -> None;
case 1 -> Both1;
case 2 -> Both2;
case 3 -> Both3;
case 4 -> Both4;
default -> Both5;
};
}
public IAllele getAllele() {
@@ -52,8 +52,8 @@ public class TreeBreedingSystem extends BreedingSystem {
public UniqueItemStackSet allFruits = new UniqueItemStackSet();
public UniqueItemStackSet allWoods = new UniqueItemStackSet();
private UniqueItemStackSet discoveredFruits = new UniqueItemStackSet();
private UniqueItemStackSet discoveredWoods = new UniqueItemStackSet();
private final UniqueItemStackSet discoveredFruits = new UniqueItemStackSet();
private final UniqueItemStackSet discoveredWoods = new UniqueItemStackSet();
public TreeBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredTree");
@@ -142,7 +142,6 @@ public class TreeBreedingSystem extends BreedingSystem {
// this.discoveredWoods.add(wood);
// }
discoveredFruits.addAll(Arrays.asList(genome.getFruitProvider().getProducts()));
for (ItemStack wood2 : discoveredWoods) {}
}
}
@@ -24,7 +24,7 @@ import forestry.core.access.FakeAccessHandler;
public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IBeeModifier {
ArrayList<IBeeModifier> beeModifier = new ArrayList<>();
private InventoryBeeHousing beeInventory;
private final InventoryBeeHousing beeInventory;
public VirtualBeeHousing(EntityPlayer player) {
super(player);
@@ -70,11 +70,6 @@ public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IB
return true;
}
@Override
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
public void wearOutEquipment(int amount) {}
public void onQueenChange(ItemStack queen) {}
@@ -17,7 +17,7 @@ import forestry.api.genetics.IHousing;
class VirtualHousing implements IHousing {
private EntityPlayer player;
private final EntityPlayer player;
public VirtualHousing(EntityPlayer player) {
this.player = player;
@@ -18,17 +18,11 @@ public enum BinnieCoreGUI implements IBinnieGUID {
Genesis;
public Window getWindow(EntityPlayer player, IInventory object, Side side) throws Exception {
switch (this) {
case Compartment:
return new WindowCompartment(player, object, side);
case FieldKit:
return new WindowFieldKit(player, null, side);
case Genesis:
return new WindowGenesis(player, null, side);
}
return null;
return switch (this) {
case Compartment -> new WindowCompartment(player, object, side);
case FieldKit -> new WindowFieldKit(player, null, side);
case Genesis -> new WindowGenesis(player, null, side);
};
}
@Override
@@ -11,7 +11,7 @@ import cpw.mods.fml.relauncher.Side;
public class BinnieGUIHandler implements IGuiHandler {
private AbstractMod mod;
private final AbstractMod mod;
public BinnieGUIHandler(AbstractMod mod) {
this.mod = mod;
@@ -16,5 +16,5 @@ public interface IItemMisc extends IItemEnum {
@SideOnly(Side.CLIENT)
void registerIcons(IIconRegister register);
void addInformation(List data);
void addInformation(List<String> data);
}
+3 -3
View File
@@ -14,7 +14,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemMisc extends Item {
private IItemMisc[] items;
private final IItemMisc[] items;
protected ItemMisc(CreativeTabs tab, IItemMisc[] items2) {
setCreativeTab(tab);
@@ -25,7 +25,7 @@ public class ItemMisc extends Item {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs tab, List list) {
public void getSubItems(Item par1, CreativeTabs tab, List<ItemStack> list) {
for (IItemMisc item : items) {
if (item.isActive()) {
list.add(getStack(item, 1));
@@ -46,7 +46,7 @@ public class ItemMisc extends Item {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) {
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(itemStack, player, tooltip, advanced);
IItemMisc item = getItem(itemStack.getItemDamage());
if (item != null) {
@@ -60,11 +60,10 @@ public class ModuleItems implements IInitializable {
&& player.getHeldItem().getItem() == BinnieCore.fieldKit
&& player.isSneaking()) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (!(tile instanceof TileEntityFlower)) {
if (!(tile instanceof TileEntityFlower tileFlower)) {
return;
}
TileEntityFlower tileFlower = (TileEntityFlower) tile;
IFlower flower = tileFlower.getFlower();
if (flower == null) {
return;
@@ -3,11 +3,11 @@ package binnie.core.liquid;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
class BinnieFluid extends Fluid {
public class BinnieFluid extends Fluid {
protected IFluidType fluidType;
private String name;
private final String name;
@Override
public String getLocalizedName(FluidStack stack) {
@@ -22,9 +22,9 @@ public enum FluidContainer {
Glass,
Cylinder;
protected IIcon bottle;
protected IIcon contents;
protected ItemFluidContainer item;
private IIcon bottle;
private IIcon contents;
ItemFluidContainer item;
public int getMaxStackSize() {
return (this == FluidContainer.Bucket) ? 1 : 16;
@@ -65,26 +65,14 @@ public enum FluidContainer {
}
public ItemStack getEmpty() {
switch (this) {
case Bucket:
return new ItemStack(Items.bucket, 1, 0);
case Can:
return Mods.forestry.stack("canEmpty");
case Capsule:
return Mods.forestry.stack("waxCapsule");
case Glass:
return new ItemStack(Items.glass_bottle, 1, 0);
case Refractory:
return Mods.forestry.stack("refractoryEmpty");
case Cylinder:
return GeneticsItems.Cylinder.get(1);
}
return null;
return switch (this) {
case Bucket -> new ItemStack(Items.bucket, 1, 0);
case Can -> Mods.forestry.stack("canEmpty");
case Capsule -> Mods.forestry.stack("waxCapsule");
case Glass -> new ItemStack(Items.glass_bottle, 1, 0);
case Refractory -> Mods.forestry.stack("refractoryEmpty");
case Cylinder -> GeneticsItems.Cylinder.get(1);
};
}
public void registerContainerData(IFluidType fluid) {
@@ -18,7 +18,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemFluidContainer extends Item {
private FluidContainer container;
private final FluidContainer container;
public static int LiquidExtraBee = 64;
public static int LiquidExtraTree = 128;
public static int LiquidJuice = 256;
@@ -27,8 +27,8 @@ public class ItemFluidContainer extends Item {
public static int LiquidLiqueuer = 640;
public static int LiquidGenetics = 768;
private static Map<Integer, String> idToFluid = new HashMap<>();
private static Map<String, Integer> fluidToID = new HashMap<>();
private static final Map<Integer, String> idToFluid = new HashMap<>();
private static final Map<String, Integer> fluidToID = new HashMap<>();
public static void registerFluid(IFluidType fluid, int id) {
ItemFluidContainer.idToFluid.put(id, fluid.getIdentifier().toLowerCase());
@@ -69,7 +69,7 @@ public class ItemFluidContainer extends Item {
}
@Override
public void getSubItems(Item item, CreativeTabs tab, List itemList) {
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> itemList) {
for (IFluidType liquid : Binnie.Liquid.fluids.values()) {
if (!liquid.canPlaceIn(container) || !liquid.showInCreative(container)) {
continue;
@@ -53,11 +53,6 @@ public class ManagerLiquid extends ManagerBase {
}
}
@Override
public void init() {
// ignored
}
@Override
public void postInit() {
for (IFluidType fluid : fluids.values()) {
@@ -25,9 +25,9 @@ import binnie.core.machines.component.IRender;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
class BlockMachine extends BlockContainer implements IBlockMachine {
public class BlockMachine extends BlockContainer implements IBlockMachine {
private MachineGroup group;
private final MachineGroup group;
public BlockMachine(MachineGroup group, String blockName) {
super(Material.iron);
@@ -37,7 +37,7 @@ class BlockMachine extends BlockContainer implements IBlockMachine {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List itemList) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> itemList) {
for (MachinePackage pack : group.getPackages()) {
if (pack.isActive()) {
itemList.add(new ItemStack(this, 1, pack.getMetadata()));
@@ -134,12 +134,11 @@ class BlockMachine extends BlockContainer implements IBlockMachine {
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileEntityMachine)) {
if (!(tileentity instanceof TileEntityMachine machine)) {
return;
}
TileEntityMachine entity = (TileEntityMachine) tileentity;
entity.onBlockDestroy();
machine.onBlockDestroy();
super.breakBlock(world, x, y, z, block, meta);
}
@@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
public class ItemMachine extends ItemBlock {
private IBlockMachine associatedBlock;
private final IBlockMachine associatedBlock;
public ItemMachine(Block block) {
super(block);
+19 -28
View File
@@ -2,7 +2,7 @@ package binnie.core.machines;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,20 +29,15 @@ import forestry.api.core.INBTTagable;
public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePacketSync, IMachine, INetwork.GuiNBT {
private MachinePackage machinePackage;
private Map<Class, List<MachineComponent>> componentInterfaceMap;
private Map<Class<? extends MachineComponent>, MachineComponent> componentMap;
private TileEntity tile;
private boolean queuedInventoryUpdate;
private int nextProgressBarID;
private final MachinePackage machinePackage;
private final Map<Class<?>, List<MachineComponent>> componentInterfaceMap = new HashMap<>();
private final Map<Class<? extends MachineComponent>, MachineComponent> componentMap = new HashMap<>();
private final TileEntity tile;
private boolean queuedInventoryUpdate = false;
private GameProfile owner;
private final MachineUtil machineUtil = new MachineUtil(this);
public Machine(MachinePackage pack, TileEntity tile) {
componentInterfaceMap = new LinkedHashMap<>();
componentMap = new LinkedHashMap<>();
queuedInventoryUpdate = false;
nextProgressBarID = 0;
owner = null;
this.tile = tile;
pack.createMachine(this);
machinePackage = pack;
@@ -55,7 +50,7 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
}
component.setMachine(this);
componentMap.put(component.getClass(), component);
for (Class inter : component.getComponentInterfaces()) {
for (Class<?> inter : component.getComponentInterfaces()) {
if (!componentInterfaceMap.containsKey(inter)) {
componentInterfaceMap.put(inter, new ArrayList<>());
}
@@ -123,8 +118,8 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
@Override
public void writeToPacket(PacketPayload payload) {
for (MachineComponent component : getComponents()) {
if (component instanceof INetworkedEntity) {
((INetworkedEntity) component).writeToPacket(payload);
if (component instanceof INetworkedEntity ne) {
ne.writeToPacket(payload);
}
}
}
@@ -132,8 +127,8 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
@Override
public void readFromPacket(PacketPayload payload) {
for (MachineComponent component : getComponents()) {
if (component instanceof INetworkedEntity) {
((INetworkedEntity) component).readFromPacket(payload);
if (component instanceof INetworkedEntity ne) {
ne.readFromPacket(payload);
}
}
}
@@ -205,14 +200,14 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
}
public static IMachine getMachine(Object inventory) {
if (inventory != null && inventory instanceof IMachine) {
return (IMachine) inventory;
if (inventory instanceof IMachine m) {
return m;
}
if (inventory != null && inventory instanceof TileEntityMachine) {
return ((TileEntityMachine) inventory).getMachine();
if (inventory instanceof TileEntityMachine tem) {
return tem.getMachine();
}
if (inventory != null && inventory instanceof MachineComponent) {
return ((MachineComponent) inventory).getMachine();
if (inventory instanceof MachineComponent mc) {
return mc.getMachine();
}
return null;
}
@@ -230,7 +225,7 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
@Override
public MachineUtil getMachineUtil() {
return new MachineUtil(this);
return machineUtil;
}
@Override
@@ -244,10 +239,6 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
}
}
public int getUniqueProgressBarID() {
return nextProgressBarID++;
}
@Override
public GameProfile getOwner() {
return owner;
@@ -38,7 +38,7 @@ public class MachineComponent implements INBTTagable {
// ignored
}
public Class[] getComponentInterfaces() {
public Class<?>[] getComponentInterfaces() {
return Binnie.Machine.getComponentInterfaces(getClass());
}
@@ -12,12 +12,12 @@ import cpw.mods.fml.common.registry.GameRegistry;
public class MachineGroup {
private AbstractMod mod;
private String blockName;
private String uid;
private Map<String, MachinePackage> packages;
private Map<Integer, MachinePackage> packagesID;
private BlockMachine block;
private final AbstractMod mod;
private final String blockName;
private final String uid;
private final Map<String, MachinePackage> packages;
private final Map<Integer, MachinePackage> packagesID;
private final BlockMachine block;
public boolean customRenderer;
private boolean renderedTileEntity;
@@ -7,7 +7,7 @@ import binnie.core.util.I18N;
public abstract class MachinePackage {
private String uid;
private final String uid;
private boolean active;
boolean powered;
private int metadata;
@@ -12,7 +12,7 @@ public class MachineRendererBlock {
public static MachineRendererBlock instance = new MachineRendererBlock();
private BinnieResource texture;
private ModelBlock model;
private final ModelBlock model;
public MachineRendererBlock() {
model = new ModelBlock();
@@ -21,7 +21,8 @@ import binnie.core.util.ItemStackSet;
public class MachineUtil {
private IMachine machine;
private final IMachine machine;
private final Random random = new Random();
public MachineUtil(IMachine machine) {
this.machine = machine;
@@ -48,7 +49,7 @@ public class MachineUtil {
}
public boolean spaceInTank(int id, int amount) {
IFluidTank tank = getTank(id);
final IFluidTank tank = getTank(id);
int space = tank.getCapacity() - tank.getFluidAmount();
return amount <= space;
}
@@ -70,7 +71,7 @@ public class MachineUtil {
}
public void fillTank(int id, FluidStack liquidStack) {
IFluidTank tank = getTank(id);
final IFluidTank tank = getTank(id);
tank.fill(liquidStack, true);
}
@@ -78,10 +79,9 @@ public class MachineUtil {
if (isSlotEmpty(slot)) {
setStack(slot, addition);
} else {
ItemStack merge = getStack(slot);
final ItemStack merge = getStack(slot);
if (merge.isItemEqual(addition) && merge.stackSize + addition.stackSize <= merge.getMaxStackSize()) {
ItemStack itemStack = merge;
itemStack.stackSize += addition.stackSize;
merge.stackSize += addition.stackSize;
setStack(slot, merge);
}
}
@@ -97,7 +97,7 @@ public class MachineUtil {
}
public void damageItem(int slot, int damage) {
ItemStack item = getStack(slot);
final ItemStack item = getStack(slot);
if (damage < 0) {
item.setItemDamage(Math.max(0, item.getItemDamage() + damage));
} else if (item.attemptDamageItem(damage, new Random())) {
@@ -154,7 +154,7 @@ public class MachineUtil {
}
public Random getRandom() {
return new Random();
return random;
}
public void refreshBlock() {
@@ -14,20 +14,14 @@ import forestry.api.core.INBTTagable;
public class ManagerMachine extends ManagerBase {
private Map<Class<?>, Class<?>[]> componentInterfaceMap;
private Map<String, MachineGroup> machineGroups;
private Map<Integer, Class<?>> networkIDToComponent;
private Map<Class<?>, Integer> componentToNetworkID;
private int nextNetworkID;
private final Map<Class<?>, Class<?>[]> componentInterfaceMap = new HashMap<>();
private final Map<String, MachineGroup> machineGroups = new HashMap<>();
private final Map<Integer, Class<?>> networkIDToComponent = new HashMap<>();
private final Map<Class<?>, Integer> componentToNetworkID = new HashMap<>();
private int nextNetworkID = 0;
private int machineRenderID;
public ManagerMachine() {
componentInterfaceMap = new HashMap<>();
machineGroups = new HashMap<>();
networkIDToComponent = new HashMap<>();
componentToNetworkID = new HashMap<>();
nextNetworkID = 0;
}
public ManagerMachine() {}
public void registerMachineGroup(MachineGroup group) {
machineGroups.put(group.getUID(), group);
@@ -5,7 +5,7 @@ import net.minecraft.client.model.ModelRenderer;
class ModelBlock extends ModelBase {
private ModelRenderer block;
private final ModelRenderer block;
public ModelBlock() {
textureWidth = 64;
Loaded 100 of 325 files, more files were not shown because too many files have changed in this diff. Show more