mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 23:46:05 +00:00
Remove redundant casts, unnecessary object creation, and string ==
This commit is contained in:
1 parent
100784b51b
commit
a4cd13282a
57 files changed
+180
-156
No files matched your search
@@ -120,7 +120,7 @@ public class WindowGenesis extends Window {
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
final Map<IChromosomeType, List<IAllele>> map = Binnie.Genetics.getChromosomeMap(WindowGenesis.this.root);
|
||||
final List<Gene> opts = new ArrayList<>();
|
||||
final IChromosomeType chromo = ((Gene) event.value) != null ? ((Gene) event.value).getChromosome() : null;
|
||||
final IChromosomeType chromo = event.value != null ? ((Gene) event.value).getChromosome() : null;
|
||||
if (chromo != null)// fix NPE
|
||||
for (final IAllele allele : map.get(chromo)) {
|
||||
opts.add(new Gene(allele, chromo, WindowGenesis.this.root));
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ControlColourMixBox extends ControlListBox<IColourMix> {
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IColourMix value, final int y) {
|
||||
return new ControlColourMixItem(((ControlScrollableContent<ControlList<IColourMix>>) this).getContent(), value, y);
|
||||
return new ControlColourMixItem(this.getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlColourMixBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColourOption(((ControlScrollableContent<ControlList<IFlowerColour>>) this).getContent(), value, y);
|
||||
return new ControlColourOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = new ArrayList<>();
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ControlTileSelect extends Control implements IControlValue<IDesign>, IControlScrollable {
|
||||
IDesign value;
|
||||
@@ -74,7 +75,7 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
|
||||
for (final IDesignCategory category : CarpentryManager.carpentryInterface.getAllDesignCategories()) {
|
||||
designs.put(category, new ArrayList<>());
|
||||
for (final IDesign tile : category.getDesigns()) {
|
||||
if (filterText == "" || tile.getName().toLowerCase().contains(filterText)) {
|
||||
if (Objects.equals(filterText, "") || tile.getName().toLowerCase().contains(filterText)) {
|
||||
designs.get(category).add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PageSpeciesTreeGenome extends PageSpecies {
|
||||
try {
|
||||
//TODO RENDERING
|
||||
//fruit = ForestryAPI.textureManager.getIcon(genome.getFruitProvider().getIconIndex(genome, (IBlockAccess) null, 0, 0, 0, 100, false));
|
||||
fruitColour = genome.getFruitProvider().getColour(genome, (IBlockAccess) null, new BlockPos(0, 0, 0), 100);
|
||||
fruitColour = genome.getFruitProvider().getColour(genome, null, new BlockPos(0, 0, 0), 100);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase {
|
||||
(this.listBox = new ControlListBox<ItemStack>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final ItemStack value, final int y) {
|
||||
return new ControlItemStackOption(((ControlScrollableContent<ControlList<ItemStack>>) this).getContent(), value, y);
|
||||
return new ControlItemStackOption(this.getContent(), value, y);
|
||||
}
|
||||
}).setOptions(((TreeBreedingSystem) WindowArboristDatabase.this.getBreedingSystem()).allFruits);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase {
|
||||
(this.listBox = new ControlListBox<ItemStack>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final ItemStack value, final int y) {
|
||||
return new ControlItemStackOption(((ControlScrollableContent<ControlList<ItemStack>>) this).getContent(), value, y);
|
||||
return new ControlItemStackOption(this.getContent(), value, y);
|
||||
}
|
||||
}).setOptions(((TreeBreedingSystem) WindowArboristDatabase.this.getBreedingSystem()).allWoods);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase {
|
||||
this.listBox = new ControlListBox<ItemStack>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final ItemStack value, final int y) {
|
||||
return new ControlItemStackOption(((ControlScrollableContent<ControlList<ItemStack>>) this).getContent(), value, y);
|
||||
return new ControlItemStackOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class WindowPress extends Window {
|
||||
logic.alterProgress(2.0f);
|
||||
} else if (side == Side.SERVER && name.equals("clear-fruit")) {
|
||||
logic.setProgress(0.0f);
|
||||
this.getInventory().setInventorySlotContents(Press.slotCurrent, (ItemStack) null);
|
||||
this.getInventory().setInventorySlotContents(Press.slotCurrent, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ContainerCraftGUI extends Container {
|
||||
if (par1 < 0 || par1 >= this.inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
return (Slot) this.inventorySlots.get(par1);
|
||||
return this.inventorySlots.get(par1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +150,7 @@ public class ContainerCraftGUI extends Container {
|
||||
return null;
|
||||
}
|
||||
final ItemStack itemstack = request.transfer(true);
|
||||
final Slot shiftClickedSlot = (Slot) this.inventorySlots.get(slotnumber);
|
||||
final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
|
||||
shiftClickedSlot.putStack(itemstack);
|
||||
shiftClickedSlot.onSlotChanged();
|
||||
return null;
|
||||
@@ -270,7 +270,7 @@ public class ContainerCraftGUI extends Container {
|
||||
//TODO INVENTORY
|
||||
this.crafters.stream().filter(Objects::nonNull).forEach(entityPlayer -> {
|
||||
System.out.println("send to:" + entityPlayer.getDisplayName().getUnformattedText());
|
||||
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), (EntityPlayerMP) entityPlayer);
|
||||
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), entityPlayer);
|
||||
});
|
||||
sentThisTime.put(nbt.getKey(), nbt.getValue());
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CustomSlot extends Slot {
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
//TODO modifier==mouseButton2?
|
||||
if (stack == null || modifier == ClickType.PICKUP_ALL) {
|
||||
this.putStack((ItemStack) null);
|
||||
this.putStack(null);
|
||||
} else {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
|
||||
@@ -404,7 +404,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
}
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(item, (int) pos.x(), (int) pos.y());
|
||||
GL11.glPopMatrix();
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(font, item, (int) pos.x(), (int) pos.y(), (String) null);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(font, item, (int) pos.x(), (int) pos.y(), null);
|
||||
}
|
||||
GL11.glClear(256);
|
||||
GL11.glEnable(3042);
|
||||
|
||||
@@ -104,8 +104,9 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
}
|
||||
|
||||
public String showInfoButton() {
|
||||
if (Machine.getInterface(IMachineInformation.class, this.getInventory()) != null) {
|
||||
return Machine.getInterface(IMachineInformation.class, this.getInventory()).getInformation();
|
||||
IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory());
|
||||
if (machineInformation != null) {
|
||||
return machineInformation.getInformation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.core.*;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ControlUser extends Control implements ITooltip {
|
||||
private String username;
|
||||
String team;
|
||||
@@ -25,7 +27,7 @@ public class ControlUser extends Control implements ITooltip {
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.setType(Tooltip.Type.User);
|
||||
tooltip.add("Owner");
|
||||
if (this.username != "") {
|
||||
if (!Objects.equals(this.username, "")) {
|
||||
tooltip.add(this.username);
|
||||
}
|
||||
tooltip.setMaxWidth(200);
|
||||
|
||||
@@ -9,7 +9,7 @@ import forestry.api.genetics.IClassification;
|
||||
class ControlBranchBox extends ControlListBox<IClassification> {
|
||||
@Override
|
||||
public IWidget createOption(final IClassification value, final int y) {
|
||||
return new ControlBranchBoxOption(((ControlScrollableContent<ControlList<IClassification>>) this).getContent(), value, y);
|
||||
return new ControlBranchBoxOption(this.getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlBranchBox(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
|
||||
@@ -18,7 +18,7 @@ class ControlMutationBox extends ControlListBox<IMutation> {
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IMutation value, final int y) {
|
||||
return new ControlMutationItem(((ControlScrollableContent<ControlList<IMutation>>) this).getContent(), value, this.species, y);
|
||||
return new ControlMutationItem(this.getContent(), value, this.species, y);
|
||||
}
|
||||
|
||||
public ControlMutationBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ControlSpeciesBox extends ControlListBox<IAlleleSpecies> {
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IAlleleSpecies value, final int y) {
|
||||
return new ControlSpeciexBoxOption(((ControlScrollableContent<ControlList<IAlleleSpecies>>) this).getContent(), value, y);
|
||||
return new ControlSpeciexBoxOption(this.getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlSpeciesBox(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import forestry.api.genetics.IClassification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PageBranchOverview extends PageBranch {
|
||||
private ControlText pageBranchOverview_branchName;
|
||||
@@ -33,7 +34,7 @@ public class PageBranchOverview extends PageBranch {
|
||||
}
|
||||
this.pageBranchOverview_branchDescription.clear();
|
||||
String desc = branch.getDescription();
|
||||
if (desc == null || desc == "") {
|
||||
if (desc == null || Objects.equals(desc, "")) {
|
||||
desc = "No Description Provided.";
|
||||
}
|
||||
String line = "";
|
||||
|
||||
@@ -9,6 +9,8 @@ import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PageSpeciesOverview extends PageSpecies {
|
||||
private ControlText controlName;
|
||||
private ControlText controlScientific;
|
||||
@@ -44,7 +46,7 @@ public class PageSpeciesOverview extends PageSpecies {
|
||||
final String desc = species.getDescription();
|
||||
String descBody = "§o";
|
||||
String descSig = "";
|
||||
if (desc == null || desc == "") {
|
||||
if (desc == null || Objects.equals(desc, "")) {
|
||||
descBody += "No Description Provided.";
|
||||
} else {
|
||||
final String[] descStrings = desc.split("\\|");
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class WindowAbstractDatabase extends Window {
|
||||
private float selectionBoxWidth;
|
||||
@@ -120,7 +121,7 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
widgets.listBox.setValidator(new IValidator<IWidget>() {
|
||||
@Override
|
||||
public boolean isValid(final IWidget object) {
|
||||
return event.getValue() == "" || ((ControlTextOption) object).getText().toLowerCase().contains(event.getValue().toLowerCase());
|
||||
return Objects.equals(event.getValue(), "") || ((ControlTextOption) object).getText().toLowerCase().contains(event.getValue().toLowerCase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user