cleanup after enabling modern & generic. Primarily changing raw lists to their correct type, changing to pattern variable & enhanced switch and removing unused/unreachable code + ancient comments.

This commit is contained in:
Lyfts authored and Martin Robertz committed 2024-05-16 18:51:58 +02:00
1 parent e7dc1d9bd4
commit a5bec6c22b
52 files changed
+273 -489

No files matched your search

@@ -44,8 +44,7 @@ public class ChestSlot extends Slot {
@Override
public boolean isItemValid(ItemStack itemStack) {
if (inventory instanceof ISidedInventory) {
ISidedInventory sided = (ISidedInventory) inventory;
if (inventory instanceof ISidedInventory sided) {
return sided.canInsertItem(this.getSlotIndex(), itemStack, accessSide);
}
return inventory.isItemValidForSlot(this.getSlotIndex(), itemStack);
@@ -53,8 +52,7 @@ public class ChestSlot extends Slot {
@Override
public boolean canTakeStack(EntityPlayer player) {
if (inventory instanceof ISidedInventory) {
ISidedInventory sided = (ISidedInventory) inventory;
if (inventory instanceof ISidedInventory sided) {
return sided.canExtractItem(this.getSlotIndex(), this.getStack(), accessSide);
}
return super.canTakeStack(player);
@@ -126,9 +126,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
if (logic.chest != null) {
if (logic.chest.get() instanceof TileEntity) {
TileEntity te = (TileEntity) logic.chest.get();
if (te == null || te.getWorldObj().getTileEntity(te.xCoord, te.yCoord, te.zCoord) == null
if (logic.chest.get() instanceof TileEntity te) {
if (te.getWorldObj().getTileEntity(te.xCoord, te.yCoord, te.zCoord) == null
&& te.getWorldObj().isRemote) {
mc.thePlayer.closeScreen();
return;
@@ -344,8 +343,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
}
public boolean isMouseOverFullSlot(int mouseX, int mouseY) {
for (final Object slot : inventorySlots.inventorySlots) {
if (isMouseOverSlot((Slot) slot, mouseX, mouseY) && ((Slot) slot).getHasStack()) {
for (final Slot slot : inventorySlots.inventorySlots) {
if (isMouseOverSlot(slot, mouseX, mouseY) && slot.getHasStack()) {
return true;
}
}
@@ -365,8 +364,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
}
public boolean shouldDrawSlot(Slot slot) {
if (!(slot instanceof ChestSlot)) return true;
ChestSlot chestSlot = (ChestSlot) slot;
if (!(slot instanceof ChestSlot chestSlot)) return true;
// all visible
if (!slider.isEnabled()) return true;
@@ -481,9 +479,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
lastSlotId = Math.min(chestSlotCount, firstSlotId + getDisplayedRows() * logic.invColumns);
for (Object o : inventorySlots.inventorySlots) {
if (!(o instanceof ChestSlot)) continue;
final ChestSlot slot = (ChestSlot) o;
if (!(o instanceof ChestSlot slot)) continue;
if (shouldDrawSlot(slot)) {
slot.enable();
@@ -70,8 +70,7 @@ public final class ToolStationGuiHelper {
else if (item instanceof ToolCore || item instanceof ArmorCore) drawDurability(tags);
// tools
if (item instanceof ToolCore) {
ToolCore tool = (ToolCore) item;
if (item instanceof ToolCore tool) {
// DualHarvest tool?
if (categories.contains("dualharvest")) drawDualHarvestStats(tool, tags);
// or regular Harvest tool?
@@ -88,13 +87,11 @@ public final class ToolStationGuiHelper {
if (categories.contains("projectile")) drawProjectileStats(tags);
}
// armor
if (item instanceof ArmorCore) {
ArmorCore armor = (ArmorCore) item;
if (item instanceof ArmorCore armor) {
drawArmorStats(armor, tags, stack);
}
// Accessory
if (item instanceof AccessoryCore) {
AccessoryCore accessory = (AccessoryCore) item;
if (item instanceof AccessoryCore accessory) {
drawAccessoryStats(accessory, tags);
}