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

@@ -54,22 +54,14 @@ public class BattlesignBlock extends EquipBlock {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int newMeta = 0;
int newMeta = switch (i3) {
case 3 -> 0;
case 0 -> 3;
case 1 -> 1;
case 2 -> 2;
default -> 0;
};
switch (i3) {
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
}
@@ -92,7 +84,7 @@ public class BattlesignBlock extends EquipBlock {
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list,
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List<AxisAlignedBB> list,
Entity entity) {
setBlockBoundsBasedOnState(world, x, y, z);
@@ -89,43 +89,30 @@ public class CraftingSlab extends InventorySlab {
@Override
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata % 8) {
case 0:
return new CraftingStationLogic();
case 1:
return new ToolStationLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new StencilTableLogic();
case 4:
return new PatternChestLogic();
case 5:
return new ToolForgeLogic();
default:
return null;
}
return switch (metadata % 8) {
case 0 -> new CraftingStationLogic();
case 1 -> new ToolStationLogic();
case 2 -> new PartBuilderLogic();
case 3 -> new StencilTableLogic();
case 4 -> new PatternChestLogic();
case 5 -> new ToolForgeLogic();
default -> null;
};
}
@Override
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
int meta = world.getBlockMetadata(x, y, z) % 8;
switch (meta) {
case 0:
return ToolProxyCommon.craftingStationID;
case 1:
return ToolProxyCommon.toolStationID;
case 2:
return ToolProxyCommon.partBuilderID;
case 3:
return ToolProxyCommon.stencilTableID;
case 4:
return ToolProxyCommon.patternChestID;
case 5:
return ToolProxyCommon.toolForgeID;
}
return switch (meta) {
case 0 -> ToolProxyCommon.craftingStationID;
case 1 -> ToolProxyCommon.toolStationID;
case 2 -> ToolProxyCommon.partBuilderID;
case 3 -> ToolProxyCommon.stencilTableID;
case 4 -> ToolProxyCommon.patternChestID;
case 5 -> ToolProxyCommon.toolForgeID;
default -> -1;
};
return -1;
}
@Override
@@ -134,7 +121,7 @@ public class CraftingSlab extends InventorySlab {
}
@Override
public void getSubBlocks(Item b, CreativeTabs tab, List list) {
public void getSubBlocks(Item b, CreativeTabs tab, List<ItemStack> list) {
for (int iter = 0; iter < 6; iter++) {
list.add(new ItemStack(b, 1, iter));
}
@@ -146,8 +133,7 @@ public class CraftingSlab extends InventorySlab {
if (stack.hasTagCompound()) {
NBTTagCompound inventory = stack.getTagCompound().getCompoundTag("Inventory");
TileEntity te = world.getTileEntity(x, y, z);
if (inventory != null && te instanceof PatternChestLogic) {
PatternChestLogic logic = (PatternChestLogic) te;
if (inventory != null && te instanceof PatternChestLogic logic) {
logic.readInventoryFromNBT(inventory);
logic.xCoord = x;
logic.yCoord = y;
@@ -170,22 +156,15 @@ public class CraftingSlab extends InventorySlab {
@Override
public TileEntity createNewTileEntity(World var1, int metadata) {
switch (metadata % 8) {
case 0:
return new CraftingStationLogic();
case 1:
return new ToolStationLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new StencilTableLogic();
case 4:
return new PatternChestLogic();
case 5:
return new ToolForgeLogic();
default:
return null;
}
return switch (metadata % 8) {
case 0 -> new CraftingStationLogic();
case 1 -> new ToolStationLogic();
case 2 -> new PartBuilderLogic();
case 3 -> new StencilTableLogic();
case 4 -> new PatternChestLogic();
case 5 -> new ToolForgeLogic();
default -> null;
};
}
/* Keep pattern chest inventory */
@@ -88,7 +88,7 @@ public class CraftingStationBlock extends InventoryBlock {
}
@Override
public void getSubBlocks(Item id, CreativeTabs tab, List list) {
public void getSubBlocks(Item id, CreativeTabs tab, List<ItemStack> list) {
for (int iter = 0; iter < 1; iter++) {
list.add(new ItemStack(id, 1, iter));
}
@@ -103,22 +103,14 @@ public class EquipBlock extends InventoryBlock {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int newMeta = 0;
int newMeta = switch (i3) {
case 3 -> 0;
case 0 -> 3;
case 1 -> 1;
case 2 -> 2;
default -> 0;
};
switch (i3) {
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
}
@@ -126,8 +118,7 @@ public class EquipBlock extends InventoryBlock {
public void breakBlock(World par1World, int x, int y, int z, Block par5, int meta) {
TileEntity te = par1World.getTileEntity(x, y, z);
if (te instanceof EquipLogic) {
EquipLogic logic = (EquipLogic) te;
if (te instanceof EquipLogic logic) {
for (int iter = 0; iter < logic.getSizeInventory(); ++iter) {
ItemStack stack = iter == 0 ? logic.getEquipmentItem() : logic.getStackInSlot(iter);
@@ -188,8 +179,7 @@ public class EquipBlock extends InventoryBlock {
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) {
TileEntity te = blockAccess.getTileEntity(x, y, z);
if (te instanceof EquipLogic) {
EquipLogic logic = (EquipLogic) te;
if (te instanceof EquipLogic logic) {
ItemStack stack = logic.getEquipmentItem();
if (stack != null && stack.hasTagCompound() && stack.getTagCompound().hasKey("InfiTool")) {
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("InfiTool");
@@ -26,82 +26,52 @@ public class MultiBrick extends TConstructBlock {
@Override
public float getBlockHardness(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta) {
case 0:
case 13:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 3:
return Blocks.stone.getBlockHardness(world, x, y, z);
case 4:
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
return switch (meta) {
case 0, 13 -> Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1 -> Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2 -> Blocks.netherrack.getBlockHardness(world, x, y, z);
case 3 -> Blocks.stone.getBlockHardness(world, x, y, z);
case 4 -> Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5 -> Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6 -> Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7 -> Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8 -> Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9 -> 1.0F;
case 10, 11 -> 1.5F;
case 12 -> Blocks.end_stone.getBlockHardness(world, x, y, z);
default -> blockHardness;
};
}
@Override
public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX,
double explosionY, double explosionZ) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta) {
case 0:
case 13:
return Blocks.obsidian
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
return Blocks.sandstone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
return Blocks.netherrack
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
return Blocks.stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
return Blocks.iron_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
return Blocks.gold_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
return Blocks.lapis_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
return Blocks.diamond_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
return Blocks.redstone_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
case 11:
return 1.5F;
case 12:
return Blocks.end_stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
}
return switch (meta) {
case 0, 13 -> Blocks.obsidian
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1 -> Blocks.sandstone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2 -> Blocks.netherrack
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3 -> Blocks.stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4 -> Blocks.iron_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5 -> Blocks.gold_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6 -> Blocks.lapis_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7 -> Blocks.diamond_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8 -> Blocks.redstone_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9 -> 1.0F;
case 10, 11 -> 1.5F;
case 12 -> Blocks.end_stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default -> getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
};
}
@Override
@@ -28,86 +28,52 @@ public class MultiBrickFancy extends TConstructBlock {
@Override
public float getBlockHardness(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta) {
case 0:
case 13:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 4:
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getBlockHardness(world, x, y, z);
case 3:
case 14:
case 15:
return Blocks.stone.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
return switch (meta) {
case 0, 13 -> Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1 -> Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2 -> Blocks.netherrack.getBlockHardness(world, x, y, z);
case 4 -> Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5 -> Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6 -> Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7 -> Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8 -> Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9 -> 1.0F;
case 10, 11 -> 1.5F;
case 12 -> Blocks.end_stone.getBlockHardness(world, x, y, z);
case 3, 14, 15 -> Blocks.stone.getBlockHardness(world, x, y, z);
default -> blockHardness;
};
}
@Override
public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX,
double explosionY, double explosionZ) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta) {
case 0:
case 13:
return Blocks.obsidian
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
return Blocks.sandstone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
return Blocks.netherrack
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
return Blocks.iron_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
return Blocks.gold_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
return Blocks.lapis_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
return Blocks.diamond_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
return Blocks.redstone_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
case 11:
return 1.5F;
case 12:
return Blocks.end_stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
case 14:
case 15:
return Blocks.stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
}
return switch (meta) {
case 0, 13 -> Blocks.obsidian
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1 -> Blocks.sandstone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2 -> Blocks.netherrack
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4 -> Blocks.iron_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5 -> Blocks.gold_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6 -> Blocks.lapis_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7 -> Blocks.diamond_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8 -> Blocks.redstone_block
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9 -> 1.0F;
case 10, 11 -> 1.5F;
case 12 -> Blocks.end_stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3, 14, 15 -> Blocks.stone
.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default -> getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
};
}
// TODO onEntityCollidedWithBlock
@@ -65,18 +65,13 @@ public class ToolForgeBlock extends InventoryBlock {
return textureTop;
}
if (side == 0) {
switch (meta) {
case 0:
return Blocks.iron_block.getIcon(side, 0);
case 1:
return Blocks.gold_block.getIcon(side, 0);
case 2:
return Blocks.diamond_block.getIcon(side, 0);
case 3:
return Blocks.emerald_block.getIcon(side, 0);
default:
return TinkerWorld.metalBlock.getIcon(side, meta - 4);
}
return switch (meta) {
case 0 -> Blocks.iron_block.getIcon(side, 0);
case 1 -> Blocks.gold_block.getIcon(side, 0);
case 2 -> Blocks.diamond_block.getIcon(side, 0);
case 3 -> Blocks.emerald_block.getIcon(side, 0);
default -> TinkerWorld.metalBlock.getIcon(side, meta - 4);
};
}
return this.icons[meta];
@@ -123,7 +118,7 @@ public class ToolForgeBlock extends InventoryBlock {
}
@Override
public void getSubBlocks(Item b, CreativeTabs tab, List list) {
public void getSubBlocks(Item b, CreativeTabs tab, List<ItemStack> list) {
for (int iter = 0; iter < textureNames.length; iter++) {
list.add(new ItemStack(b, 1, iter));
}
@@ -121,31 +121,13 @@ public class ToolStationBlock extends InventoryBlock {
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
switch (metadata) {
case 0:
return new ToolStationLogic();
case 1:
case 3:
case 2:
case 4:
return new PartBuilderLogic();
case 5:
case 9:
case 8:
case 7:
case 6:
return new PatternChestLogic();
case 10:
case 13:
case 12:
case 11:
return new StencilTableLogic();
/*
* case 14: return new CastingTableLogic();
*/
default:
return null;
}
return switch (metadata) {
case 0 -> new ToolStationLogic();
case 1, 3, 2, 4 -> new PartBuilderLogic();
case 5, 9, 8, 7, 6 -> new PatternChestLogic();
case 10, 13, 12, 11 -> new StencilTableLogic();
default -> null;
};
}
@Override
@@ -165,7 +147,7 @@ public class ToolStationBlock extends InventoryBlock {
}
@Override
public void getSubBlocks(Item id, CreativeTabs tab, List list) {
public void getSubBlocks(Item id, CreativeTabs tab, List<ItemStack> list) {
for (int iter = 0; iter < 6; iter++) {
list.add(new ItemStack(id, 1, iter));
}
@@ -241,8 +223,7 @@ public class ToolStationBlock extends InventoryBlock {
if (stack.hasTagCompound()) {
NBTTagCompound inventory = stack.getTagCompound().getCompoundTag("Inventory");
TileEntity te = world.getTileEntity(x, y, z);
if (inventory != null && te instanceof PatternChestLogic) {
PatternChestLogic logic = (PatternChestLogic) te;
if (inventory != null && te instanceof PatternChestLogic logic) {
logic.readInventoryFromNBT(inventory);
logic.xCoord = x;
logic.yCoord = y;
@@ -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);
}
@@ -41,8 +41,7 @@ public class FrypanContainer extends Container {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Object crafter : crafters) {
ICrafting icrafting = (ICrafting) crafter;
for (ICrafting icrafting : crafters) {
if (progress != logic.progress) {
icrafting.sendProgressBarUpdate(this, 0, logic.progress);
}
@@ -54,8 +54,7 @@ public class FurnaceContainer extends Container {
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Object crafter : this.crafters) {
ICrafting icrafting = (ICrafting) crafter;
for (ICrafting icrafting : this.crafters) {
if (this.lastCookTime != this.furnace.progress) {
icrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
@@ -24,7 +24,7 @@ public class MultiBrickFancyItem extends MultiItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
switch (stack.getItemDamage()) {
case 5:
case 6:
@@ -25,7 +25,7 @@ public class MultiBrickItem extends MultiItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
switch (stack.getItemDamage()) {
case 5:
case 6:
@@ -29,7 +29,7 @@ public class CreativeModifier extends Item {
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
@Override
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack> par3List) {
par3List.add(new ItemStack(par1, 1, 0));
for (ToolRecipe recipe : ToolBuilder.instance.combos) {
@@ -50,23 +50,18 @@ public class Manual extends CraftingItem {
}
private static String getBookName(int bookItemDamage) {
switch (bookItemDamage) {
case 0:
return "tconstruct.manual.beginner";
case 1:
return "tconstruct.manual.toolstation";
case 2:
return "tconstruct.manual.smeltery";
case 4:
return "tconstruct.manual.weaponry";
default:
return "tconstruct.manual.diary";
}
return switch (bookItemDamage) {
case 0 -> "tconstruct.manual.beginner";
case 1 -> "tconstruct.manual.toolstation";
case 2 -> "tconstruct.manual.smeltery";
case 4 -> "tconstruct.manual.weaponry";
default -> "tconstruct.manual.diary";
};
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
switch (stack.getItemDamage()) {
case 0:
list.add("\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"));
@@ -46,7 +46,7 @@ public class MaterialItem extends CraftingItem {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
switch (stack.getItemDamage()) {
case 6:
list.add(
@@ -100,7 +100,7 @@ public class Pattern extends CraftingItem implements IPattern {
/* Tags and information about the pattern */
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
float cost = getPatternCost(stack) / 2f;
if (cost > 0) {
if (cost - (int) cost < 0.1) list.add(StatCollector.translateToLocal("pattern1.tooltip") + (int) cost);
@@ -83,7 +83,7 @@ public class TitleIcon extends Item {
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack) {
String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
String s = (StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
String s1 = mobNames[par1ItemStack.getItemDamage()];
if (s1 != null) {
@@ -94,7 +94,7 @@ public class TitleIcon extends Item {
}
@Override
public void getSubItems(Item b, CreativeTabs tab, List list) {
public void getSubItems(Item b, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i < mobNames.length; i++) list.add(new ItemStack(b, 1, i));
}
@@ -68,12 +68,10 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
for (final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
final int xPos = x + dir.offsetX, yPos = y + dir.offsetY, zPos = z + dir.offsetZ;
final TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
if (!(tile instanceof IInventory) || (tile instanceof CraftingStationLogic)
if (!(tile instanceof IInventory inv) || (tile instanceof CraftingStationLogic)
|| isBlacklisted(tile.getClass()))
continue;
final IInventory inv = (IInventory) tile;
if (patternChest == null && tile instanceof PatternChestLogic) {
patternChest = new WeakReference<>(inv);
continue;
@@ -85,16 +83,16 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
continue;
}
if (tile instanceof ISidedInventory
&& ((ISidedInventory) tile).getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length == 0)
if (tile instanceof ISidedInventory sidedIvn
&& sidedIvn.getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length == 0)
continue;
if (chest == null && inv.isUseableByPlayer(inventoryplayer.player)) {
chest = new WeakReference<>(inv);
chestDirection = dir;
invColumns = 6;
chestSize = tile instanceof ISidedInventory
? ((ISidedInventory) tile).getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length
chestSize = tile instanceof ISidedInventory sidedIvn
? sidedIvn.getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length
: inv.getSizeInventory();
if (tile instanceof TileEntityChest) {