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

@@ -40,7 +40,7 @@ public class BlockETDoor extends BlockDoor implements IBlockMetadata {
public static DoorType getDoorType(int tileMeta) {
int type = (tileMeta & 0xF00) >> 8;
if (type >= 0 && type < DoorType.values().length) {
if (type < DoorType.values().length) {
return DoorType.values()[type];
}
return DoorType.STANDARD;
@@ -226,7 +226,7 @@ public class BlockETDoor extends BlockDoor implements IBlockMetadata {
}
@Override
public void addBlockTooltip(ItemStack stack, List tooltip) {
public void addBlockTooltip(ItemStack stack, List<String> tooltip) {
// ignored
}
@@ -236,7 +236,7 @@ public class BlockETDoor extends BlockDoor implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List itemList) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> itemList) {
for (IPlankType type : PlankType.ExtraTreePlanks.values()) {
itemList.add(WoodManager.getDoor(type, DoorType.STANDARD));
}
@@ -36,7 +36,7 @@ public class BlockETLog extends BlockLog implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i < ILogType.ExtraTreeLog.values().length; ++i) {
list.add(TileEntityMetadata.getItemStack(this, i));
}
@@ -85,11 +85,6 @@ public class BlockETLog extends BlockLog implements IBlockMetadata {
ILogType.ExtraTreeLog.registerIcons(register);
}
@Override
public int getRenderType() {
return 31;
}
@Override
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
dropBlockAsItem(world, x, y, z, itemStack);
@@ -138,15 +133,10 @@ public class BlockETLog extends BlockLog implements IBlockMetadata {
}
@Override
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
public void addBlockTooltip(ItemStack itemStack, List<String> tooltip) {
// ignored
}
@Override
public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) {
return true;
}
@Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack);
@@ -154,24 +144,11 @@ public class BlockETLog extends BlockLog implements IBlockMetadata {
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float par6, float par7, float par8, int meta) {
byte b0 = 0;
switch (side) {
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
break;
}
return b0;
return switch (side) {
case 2, 3 -> 8;
case 4, 5 -> 4;
default -> 0;
};
}
@Override
@@ -180,11 +157,6 @@ public class BlockETLog extends BlockLog implements IBlockMetadata {
world.removeTileEntity(x, y, z);
}
@Override
public boolean isWood(IBlockAccess world, int x, int y, int z) {
return true;
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 20;
@@ -79,7 +79,7 @@ public class BlockETPlanks extends BlockWood implements IBlockMetadata {
}
@Override
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
public void addBlockTooltip(ItemStack itemStack, List<String> tooltip) {
// ignored
}
@@ -89,7 +89,7 @@ public class BlockETPlanks extends BlockWood implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i < PlankType.ExtraTreePlanks.values().length; ++i) {
list.add(TileEntityMetadata.getItemStack(this, i));
}
@@ -44,8 +44,8 @@ public class BlockETSlab extends BlockWoodSlab implements IBlockMetadata {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
drops.addAll(BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
ArrayList<ItemStack> drops = new ArrayList<>(
BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
if (field_150004_a) {
drops.addAll(
BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
@@ -92,7 +92,7 @@ public class BlockETSlab extends BlockWoodSlab implements IBlockMetadata {
}
@Override
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
public void addBlockTooltip(ItemStack itemStack, List<String> tooltip) {
// ignored
}
@@ -102,7 +102,7 @@ public class BlockETSlab extends BlockWoodSlab implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
if (field_150004_a) {
return;
}
@@ -42,7 +42,7 @@ public class BlockETStairs extends BlockStairs implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
public void getSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> list) {
for (int i = 0; i < PlankType.ExtraTreePlanks.values().length; ++i) {
list.add(new ItemStack(this, 1, i));
}
@@ -11,12 +11,12 @@ public enum DoorType {
DOUBLE("double"),
FULL("full");
protected String id;
protected IIcon iconDoorLower;
protected IIcon iconDoorUpper;
protected IIcon iconDoorLowerFlip;
protected IIcon iconDoorUpperFlip;
protected IIcon iconItem;
final String id;
IIcon iconDoorLower;
IIcon iconDoorUpper;
IIcon iconDoorLowerFlip;
IIcon iconDoorUpperFlip;
IIcon iconItem;
DoorType(String id) {
this.id = id;
@@ -18,8 +18,8 @@ public enum FruitPod implements IIconProvider {
RedBanana,
Papayimar;
protected short[] textures;
protected IIcon[] icons;
private final short[] textures;
private final IIcon[] icons;
FruitPod() {
textures = new short[] { BinnieCore.proxy.getUniqueTextureUID(), BinnieCore.proxy.getUniqueTextureUID(),
@@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL11;
public class GateItemRenderer implements IItemRenderer {
private void renderStairBlock(RenderBlocks renderBlocks, ItemStack item, float f, float g, float h) {
private void renderStairBlock(RenderBlocks renderBlocks, ItemStack item) {
Tessellator tessellator = Tessellator.instance;
Block block = ((ItemBlock) item.getItem()).field_150939_a;
for (int k = 0; k < 3; ++k) {
@@ -22,7 +22,6 @@ public class GateItemRenderer implements IItemRenderer {
if (k == 1) {
renderBlocks.setRenderBounds(0.5f - f2, 0.30000001192092896, 1.0f - f2 * 2.0f, 0.5f + f2, 1.0, 1.0);
}
f2 = 0.0625f;
if (k == 2) {
renderBlocks.setRenderBounds(0.5f - f2, 0.5, 0.0, 0.5f + f2, 1.0f - f2, 1.0);
}
@@ -87,13 +86,10 @@ public class GateItemRenderer implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
switch (type) {
case ENTITY:
case EQUIPPED:
case INVENTORY:
return true;
}
return false;
return switch (type) {
case ENTITY, EQUIPPED, INVENTORY -> true;
default -> false;
};
}
@Override
@@ -106,15 +102,15 @@ public class GateItemRenderer implements IItemRenderer {
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
case ENTITY:
renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
renderStairBlock((RenderBlocks) data[0], item);
break;
case EQUIPPED:
renderStairBlock((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
renderStairBlock((RenderBlocks) data[0], item);
break;
case INVENTORY:
renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
renderStairBlock((RenderBlocks) data[0], item);
break;
}
}
@@ -67,11 +67,11 @@ public interface ILogType {
Cinnamon("cinnamon", 0x86583c, PlankType.VanillaPlanks.JUNGLE),
PinkIvory("pinkivory", 0x7f6554, PlankType.ExtraTreePlanks.PinkIvory);
protected String name;
protected int color;
protected IDesignMaterial plank;
protected IIcon trunk;
protected IIcon bark;
private final String name;
private final int color;
private final IDesignMaterial plank;
private IIcon trunk;
private IIcon bark;
ExtraTreeLog(String name, int color) {
this.name = name;
@@ -161,9 +161,9 @@ public interface ILogType {
MAPLE(6, 2, 9078657),
CITRUS(6, 3, 5983033);
protected int block;
protected int metadata;
protected int colour;
private final int block;
private final int metadata;
private final int colour;
ForestryLog(int blockOffset, int meta, int colour) {
block = blockOffset;
@@ -197,7 +197,7 @@ public interface ILogType {
Birch(6376752),
Jungle(5456154);
protected int colour;
private final int colour;
VanillaLog(int colour) {
this.colour = colour;
@@ -46,10 +46,7 @@ public class ItemETDoor extends ItemMetadata {
+ (world.isBlockNormalCubeDefault(x + b0, y + 1, z + b2, false) ? 1 : 0);
boolean flag = world.getBlock(x - b0, y, z - b2) == block || world.getBlock(x - b0, y + 1, z - b2) == block;
boolean flag2 = world.getBlock(x + b0, y, z + b2) == block || world.getBlock(x + b0, y + 1, z + b2) == block;
boolean flag3 = false;
if (flag && !flag2 || j1 > i1) {
flag3 = true;
}
boolean flag3 = flag && !flag2 || j1 > i1;
world.setBlock(x, y, z, block, meta, 2);
world.setBlock(x, y + 1, z, block, 0x8 | (flag3 ? 1 : 0), 2);
@@ -13,9 +13,9 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemETSlab extends ItemMetadata {
private boolean isFullBlock;
private BlockETSlab theHalfSlab;
private BlockETSlab doubleSlab;
private final boolean isFullBlock;
private final BlockETSlab theHalfSlab;
private final BlockETSlab doubleSlab;
public ItemETSlab(Block block) {
super(block);
@@ -54,11 +54,11 @@ public class ItemETSlab extends ItemMetadata {
}
return true;
}
return func_77888_a(stack, player, world, x, y, z, meta)
return func_77888_a(stack, world, x, y, z, meta)
|| super.onItemUse(stack, player, world, x, y, z, meta, hitX, hitY, hitZ);
}
private boolean func_77888_a(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) {
private boolean func_77888_a(ItemStack stack, World world, int x, int y, int z, int side) {
if (side == 0) {
y--;
} else if (side == 1) {
@@ -125,9 +125,6 @@ public class ModuleBlocks implements IInitializable {
ItemStack doorSplit = WoodManager.getDoor(plank2, DoorType.DOUBLE);
ItemStack doorFull = WoodManager.getDoor(plank2, DoorType.FULL);
if (planks2 != null) {
if (gate == null) {
continue;
}
gate.stackSize = 1;
GameRegistry.addRecipe(gate.copy(), "fpf", 'f', fenceNormal.copy(), 'p', planks2.copy());
fenceNormal.stackSize = 4;
@@ -70,8 +70,8 @@ public class PlankType {
Gingko(0xf4e7ba),
PinkIvory(0xec8ca0);
protected int color;
protected IIcon icon;
private final int color;
private IIcon icon;
ExtraTreePlanks(int color) {
this.color = color;
@@ -121,7 +121,7 @@ public class PlankType {
ACACIA(0xba6337),
DARKOAK(0x462d15);
protected int color;
private final int color;
VanillaPlanks(int color) {
this.color = color;
@@ -192,7 +192,7 @@ public class PlankType {
COCOBOLO(0x731302),
ZEBRAWOOD(0xa6824e);
protected int color;
private final int color;
ForestryPlanks(int color) {
this.color = color;
@@ -221,12 +221,10 @@ public class PlankType {
@Override
public IIcon getIcon() {
if (getStack() != null) {
int meta = getStack().getItemDamage();
Block block = ((ItemBlock) getStack().getItem()).field_150939_a;
return block.getIcon(2, meta);
}
return null;
final ItemStack stack = getStack();
final int meta = stack.getItemDamage();
final Block block = ((ItemBlock) stack.getItem()).field_150939_a;
return block.getIcon(2, meta);
}
@Override
@@ -243,7 +241,7 @@ public class PlankType {
Fir(0x7e774a),
Acacia(0xbfaa7e);
protected int color;
private final int color;
ExtraBiomesPlank(int color) {
this.color = color;
@@ -274,9 +272,10 @@ public class PlankType {
@Override
public IIcon getIcon() {
if (getStack() != null) {
int meta = getStack().getItemDamage();
Block block = ((ItemBlock) getStack().getItem()).field_150939_a;
final ItemStack stack = getStack();
if (stack != null) {
int meta = stack.getItemDamage();
Block block = ((ItemBlock) stack.getItem()).field_150939_a;
return block.getIcon(2, meta);
}
return null;
@@ -56,13 +56,10 @@ public class StairItemRenderer implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
switch (type) {
case ENTITY:
case EQUIPPED:
case INVENTORY:
return true;
}
return false;
return switch (type) {
case ENTITY, EQUIPPED, INVENTORY -> true;
default -> false;
};
}
@Override
@@ -30,7 +30,7 @@ public class WoodManager {
public static int getPlankTypeIndex(IPlankType type) {
int index = CarpentryManager.carpentryInterface.getCarpentryWoodIndex(type);
return (index < 0) ? 0 : index;
return Math.max(index, 0);
}
public static FenceType getFenceType(ItemStack stack) {
@@ -41,7 +41,7 @@ public class BlockFence extends net.minecraft.block.BlockFence implements IBlock
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (IFenceProvider type : PlankType.ExtraTreePlanks.values()) {
list.add(type.getFence());
}
@@ -36,12 +36,10 @@ public class BlockGate extends BlockFenceGate implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List itemList) {
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack> itemList) {
for (IPlankType type : WoodManager.getAllPlankTypes()) {
ItemStack gate = WoodManager.getGate(type);
if (gate != null) {
itemList.add(gate);
}
itemList.add(gate);
}
}
@@ -41,7 +41,7 @@ public class BlockHedge extends Block implements IBlockFence {
}
@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) {
boolean connectNegZ = canConnectFenceTo(world, x, y, z - 1);
boolean connectPosZ = canConnectFenceTo(world, x, y, z + 1);
@@ -166,7 +166,7 @@ public class BlockHedge extends Block implements IBlockFence {
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i < 6; ++i) {
for (int f = 0; f < 2; ++f) {
list.add(new ItemStack(item, 1, i + f * 8));
@@ -21,7 +21,7 @@ public class BlockMultiFence extends BlockFence implements IBlockMetadata {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (FenceType type : FenceType.values()) {
list.add(WoodManager.getFence(PlankType.VanillaPlanks.SPRUCE, PlankType.VanillaPlanks.BIRCH, type, 1));
}
@@ -145,8 +145,8 @@ public class FenceRenderer implements ISimpleBlockRenderingHandler {
float i = 0.0625f;
FenceType fenceType = new FenceType(0);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileEntityMetadata && block instanceof BlockMultiFence) {
fenceType = WoodManager.getFenceType(((TileEntityMetadata) tile).getTileMetadata());
if (tile instanceof TileEntityMetadata tileMeta && block instanceof BlockMultiFence) {
fenceType = WoodManager.getFenceType(tileMeta.getTileMetadata());
}
boolean rendered;
@@ -203,13 +203,11 @@ public class FenceRenderer implements ISimpleBlockRenderingHandler {
if (connectAnyX) {
renderer.setRenderBounds(minX, barMinY, minPostPos, maxX, barMaxY, maxPostPos);
renderer.renderStandardBlock(blockFence, x, y, z);
rendered = true;
}
if (connectAnyZ) {
renderer.setRenderBounds(minPostPos, barMinY, minZ, maxPostPos, barMaxY, maxZ);
renderer.renderStandardBlock(blockFence, x, y, z);
rendered = true;
}
if (renderBottom) {
@@ -221,12 +219,10 @@ public class FenceRenderer implements ISimpleBlockRenderingHandler {
if (connectAnyX) {
renderer.setRenderBounds(minX, barMinY, minPostPos, maxX, barMaxY, maxPostPos);
renderer.renderStandardBlock(blockFence, x, y, z);
rendered = true;
}
if (connectAnyZ) {
renderer.setRenderBounds(minPostPos, barMinY, minZ, maxPostPos, barMaxY, maxZ);
renderer.renderStandardBlock(blockFence, x, y, z);
rendered = true;
}
}
@@ -237,12 +233,10 @@ public class FenceRenderer implements ISimpleBlockRenderingHandler {
if (connectAnyX) {
renderer.setRenderBounds(minX, barMinY, minPostPos, maxX, barMaxY, maxPostPos);
renderer.renderStandardBlock(blockFence, x, y, z);
rendered = true;
}
if (connectAnyZ) {
renderer.setRenderBounds(minPostPos, barMinY, minZ, maxPostPos, barMaxY, maxZ);
renderer.renderStandardBlock(blockFence, x, y, z);
rendered = true;
}
}
@@ -26,7 +26,7 @@ public class MultiFenceRecipeEmbedded implements IRecipe {
type = WoodManager.getFenceType(a);
FenceType type2 = WoodManager.getFenceType(c);
if (type == null || type2 == null || !type.equals(type2)) {
if (type == null || !type.equals(type2)) {
continue;
}
@@ -26,7 +26,7 @@ public class MultiFenceRecipeSolid implements IRecipe {
type = WoodManager.getFenceType(a);
FenceType type2 = WoodManager.getFenceType(b);
FenceType type3 = WoodManager.getFenceType(c);
if (type == null || type2 == null || type3 == null || !type.equals(type2) || !type.equals(type3)) {
if (type == null || !type.equals(type2) || !type.equals(type3)) {
continue;
}
@@ -7,7 +7,6 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class NBTShapedRecipe implements IRecipe {
@@ -15,11 +14,10 @@ public class NBTShapedRecipe implements IRecipe {
public int recipeWidth;
public int recipeHeight;
public ItemStack[] recipeItems;
private ItemStack recipeOutput;
private boolean field_92101_f;
private final ItemStack recipeOutput;
public NBTShapedRecipe(ItemStack stack, Object... p_92103_2_) {
String s = "";
StringBuilder s = new StringBuilder();
int i = 0;
int j = 0;
int k = 0;
@@ -29,18 +27,18 @@ public class NBTShapedRecipe implements IRecipe {
for (String s2 : astring) {
k++;
j = s2.length();
s += s2;
s.append(s2);
}
} else {
while (p_92103_2_[i] instanceof String) {
String s3 = (String) p_92103_2_[i++];
++k;
j = s3.length();
s += s3;
s.append(s3);
}
}
HashMap hashmap = new HashMap();
HashMap<Character, ItemStack> hashmap = new HashMap<>();
while (i < p_92103_2_.length) {
Character character = (Character) p_92103_2_[i];
ItemStack itemstack1 = null;
@@ -130,17 +128,7 @@ public class NBTShapedRecipe implements IRecipe {
@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
ItemStack itemstack = getRecipeOutput().copy();
// todo unused code?
if (field_92101_f) {
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
ItemStack itemstack2 = crafting.getStackInSlot(i);
if (itemstack2 != null && itemstack2.hasTagCompound()) {
itemstack.setTagCompound((NBTTagCompound) itemstack2.stackTagCompound.copy());
}
}
}
return itemstack;
return getRecipeOutput().copy();
}
@Override