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

@@ -5,6 +5,7 @@ import net.minecraft.item.Item;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.core.Tags;
import binnie.core.gui.IBinnieGUID;
import binnie.core.network.BinniePacketHandler;
import binnie.core.proxy.IProxyCore;
@@ -32,7 +33,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@Mod(
modid = "ExtraTrees",
name = "Extra Trees",
version = BinnieCore.VERSION,
version = Tags.VERSION,
useMetadata = true,
dependencies = "after:BinnieCore")
public class ExtraTrees extends AbstractMod {
@@ -101,7 +102,7 @@ public class ExtraTrees extends AbstractMod {
}
@Override
public Class[] getConfigs() {
public Class<?>[] getConfigs() {
return new Class[] { ConfigurationMain.class };
}
@@ -20,7 +20,7 @@ import sun.misc.Unsafe;
public class FakeWorld extends World {
private static Unsafe unsafe;
private static final Unsafe unsafe;
static {
try {
@@ -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
@@ -38,7 +38,7 @@ public class BlockCarpentryPanel extends BlockCarpentry {
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
// ignored
}
@@ -55,28 +55,27 @@ public abstract class BlockDesign extends BlockMetadata implements IMultipassBlo
int x = event.x;
int y = event.y;
int z = event.z;
if (!(world.getBlock(x, y, z) instanceof BlockDesign)) {
if (!(world.getBlock(x, y, z) instanceof BlockDesign blockDesign)) {
return;
}
BlockDesign blockC = (BlockDesign) world.getBlock(x, y, z);
ItemStack item = player.getHeldItem();
if (item == null || !(item.getItem() instanceof IToolHammer)
|| !((IToolHammer) item.getItem()).isActive(item)) {
return;
}
DesignBlock block = blockC.getCarpentryBlock(world, x, y, z);
DesignBlock carpentryBlock = blockDesign.getCarpentryBlock(world, x, y, z);
TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
block.rotate(event.face, item, player, world, x, y, z);
int meta = block.getBlockMetadata(blockC.getDesignSystem());
carpentryBlock.rotate(event.face, item, player, world, x, y, z);
int meta = carpentryBlock.getBlockMetadata(blockDesign.getDesignSystem());
tile.setTileMetadata(meta, true);
}
public abstract ItemStack getCreativeStack(IDesign design);
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (IDesign design : CarpentryManager.carpentryInterface.getSortedDesigns()) {
list.add(getCreativeStack(design));
}
@@ -126,7 +125,7 @@ public abstract class BlockDesign extends BlockMetadata implements IMultipassBlo
}
@Override
public void addBlockTooltip(ItemStack stack, List tooltip) {
public void addBlockTooltip(ItemStack stack, List<String> tooltip) {
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
if (block.getPrimaryMaterial() != block.getSecondaryMaterial()) {
tooltip.add(
@@ -65,7 +65,7 @@ public class BlockStainedDesign extends BlockDesign {
}
@Override
public void addBlockTooltip(ItemStack stack, List tooltip) {
public void addBlockTooltip(ItemStack stack, List<String> tooltip) {
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
if (block.getPrimaryMaterial() != block.getSecondaryMaterial()) {
tooltip.add(
@@ -82,7 +82,7 @@ public class CarpentryInterface implements ICarpentryInterface {
public Collection<IDesignCategory> getAllDesignCategories() {
List<IDesignCategory> categories = new ArrayList<>();
for (IDesignCategory category : CarpentryInterface.designCategories.values()) {
if (category.getDesigns().size() > 0) {
if (!category.getDesigns().isEmpty()) {
categories.add(category);
}
}
@@ -119,31 +119,14 @@ public class DesignBlock {
adjustedDir = adjustedDir.getRotation(ForgeDirection.DOWN);
}
ILayout layout;
switch (adjustedDir) {
case EAST:
layout = getDesign().getEastPattern();
break;
case NORTH:
layout = getDesign().getNorthPattern();
break;
case SOUTH:
layout = getDesign().getSouthPattern();
break;
case WEST:
layout = getDesign().getWestPattern();
break;
case DOWN:
layout = getDesign().getBottomPattern();
break;
default:
layout = getDesign().getTopPattern();
}
ILayout layout = switch (adjustedDir) {
case EAST -> getDesign().getEastPattern();
case NORTH -> getDesign().getNorthPattern();
case SOUTH -> getDesign().getSouthPattern();
case WEST -> getDesign().getWestPattern();
case DOWN -> getDesign().getBottomPattern();
default -> getDesign().getTopPattern();
};
// TODO remove label
Label_1107: {
@@ -22,8 +22,8 @@ public enum DesignSystem implements IDesignSystem {
Wood,
Glass;
protected Map<Integer, IIcon> primary;
protected Map<Integer, IIcon> secondary;
private final Map<Integer, IIcon> primary;
private final Map<Integer, IIcon> secondary;
DesignSystem() {
primary = new HashMap<>();
@@ -33,85 +33,57 @@ public enum DesignSystem implements IDesignSystem {
@Override
public IDesignMaterial getDefaultMaterial() {
switch (this) {
case Glass:
return GlassType.get(0);
case Wood:
return PlankType.ExtraTreePlanks.Fir;
}
return null;
return switch (this) {
case Glass -> GlassType.get(0);
case Wood -> PlankType.ExtraTreePlanks.Fir;
};
}
@Override
public IDesignMaterial getDefaultMaterial2() {
switch (this) {
case Glass:
return GlassType.get(1);
case Wood:
return PlankType.ExtraTreePlanks.Whitebeam;
}
return null;
return switch (this) {
case Glass -> GlassType.get(1);
case Wood -> PlankType.ExtraTreePlanks.Whitebeam;
};
}
@Override
public IDesignMaterial getMaterial(int id) {
switch (this) {
case Glass:
return GlassType.get(id);
case Wood:
return CarpentryManager.carpentryInterface.getWoodMaterial(id);
}
return null;
return switch (this) {
case Glass -> GlassType.get(id);
case Wood -> CarpentryManager.carpentryInterface.getWoodMaterial(id);
};
}
@Override
public int getMaterialIndex(IDesignMaterial id) {
switch (this) {
case Glass:
return GlassType.getIndex(id);
case Wood:
return CarpentryManager.carpentryInterface.getCarpentryWoodIndex(id);
}
return 0;
return switch (this) {
case Glass -> GlassType.getIndex(id);
case Wood -> CarpentryManager.carpentryInterface.getCarpentryWoodIndex(id);
};
}
public String getTexturePath() {
switch (this) {
case Glass:
return "glass";
case Wood:
return "patterns";
}
return "";
return switch (this) {
case Glass -> "glass";
case Wood -> "patterns";
};
}
@Override
public IDesignMaterial getMaterial(ItemStack stack) {
switch (this) {
case Glass:
return GlassType.get(stack);
case Wood:
return CarpentryManager.carpentryInterface.getWoodMaterial(stack);
}
return null;
return switch (this) {
case Glass -> GlassType.get(stack);
case Wood -> CarpentryManager.carpentryInterface.getWoodMaterial(stack);
};
}
@Override
public ItemStack getAdhesive() {
switch (this) {
case Glass:
return ExtraTreeItems.GlassFitting.get(1);
case Wood:
return ExtraTreeItems.WoodWax.get(1);
}
return null;
return switch (this) {
case Glass -> ExtraTreeItems.GlassFitting.get(1);
case Wood -> ExtraTreeItems.WoodWax.get(1);
};
}
@Override
@@ -132,7 +104,7 @@ public enum DesignSystem implements IDesignSystem {
@Override
public void registerIcons(IIconRegister register) {
for (EnumPattern pattern : EnumPattern.values()) {
for (final EnumPattern pattern : EnumPattern.VALUES) {
primary.put(
pattern.ordinal(),
BinnieCore.proxy.getIcon(
@@ -311,13 +311,13 @@ public enum EnumDesign implements IDesign {
EnumDesign.OverlappedBarred.setTopPattern(EnumPattern.OverlappedBarred.layout());
}
protected String name;
protected ILayout topPattern;
protected ILayout bottomPattern;
protected ILayout northPattern;
protected ILayout southPattern;
protected ILayout eastPattern;
protected ILayout westPattern;
private String name;
private ILayout topPattern;
private ILayout bottomPattern;
private ILayout northPattern;
private ILayout southPattern;
private ILayout eastPattern;
private ILayout westPattern;
EnumDesign(String name) {
this.name = name;
@@ -17,8 +17,8 @@ public enum EnumDesignCategory implements IDesignCategory {
Letters("letters"),
Diagonal("diagonals");
protected String name;
protected List<IDesign> designs;
private final String name;
private final List<IDesign> designs;
EnumDesignCategory(String name) {
this.name = name;
@@ -406,8 +406,9 @@ public enum EnumPattern implements IPattern {
EnumPattern.OverlappedSplitBarred2.setLeftRotation(EnumPattern.OverlappedSplitBarred, false);
}
protected ILayout leftRotation;
protected ILayout horizontalFlip;
private ILayout leftRotation;
private ILayout horizontalFlip;
public static final EnumPattern[] VALUES = values();
EnumPattern() {
leftRotation = Layout.get(this, false);
@@ -506,7 +507,7 @@ public enum EnumPattern implements IPattern {
return horizontalFlip;
}
protected void setLeftRotation(EnumPattern pattern, boolean inverted) {
private void setLeftRotation(EnumPattern pattern, boolean inverted) {
leftRotation = Layout.get(pattern, inverted);
}
@@ -98,8 +98,8 @@ public class GlassType implements IDesignMaterial {
Red("Red", new Color(0x993333)),
Black("Black", new Color(0x191919));
protected String name;
protected int color;
private final String name;
private final int color;
StandardColor(String name, Color color) {
this.name = name;
@@ -11,18 +11,18 @@ public enum ExtraTreeTexture implements IBinnieTexture {
Gui(ResourceType.GUI, "gui"),
Nursery(ResourceType.Tile, "Nursery");
public static String carpenterTexture = "extratrees/carpenter_";
public static String panelerTexture = "extratrees/paneler_";
public static String tileworkerTexture = "extratrees/tileworker_";
public static String incubatorTexture = "extratrees/incubator_";
public static String lumbermillTexture = "extratrees/sawmill_";
public static String pressTexture = "extratrees/press_";
public static String distilleryTexture = "extratrees/distillery_";
public static String breweryTexture = "extratrees/brewery_";
public static String infuserTexture = "extratrees/infuser_";
public static final String carpenterTexture = "extratrees/carpenter_";
public static final String panelerTexture = "extratrees/paneler_";
public static final String tileworkerTexture = "extratrees/tileworker_";
public static final String incubatorTexture = "extratrees/incubator_";
public static final String lumbermillTexture = "extratrees/sawmill_";
public static final String pressTexture = "extratrees/press_";
public static final String distilleryTexture = "extratrees/distillery_";
public static final String breweryTexture = "extratrees/brewery_";
public static final String infuserTexture = "extratrees/infuser_";
protected String texture;
protected ResourceType type;
private final String texture;
private final ResourceType type;
ExtraTreeTexture(ResourceType base, String texture) {
this.texture = texture;
@@ -34,29 +34,15 @@ public enum ExtraTreesGUID implements IBinnieGUID {
if (tileEntity instanceof IInventory) {
object = (IInventory) tileEntity;
}
switch (this) {
case Database:
case DatabaseNEI:
window = WindowArboristDatabase.create(player, side, this != ExtraTreesGUID.Database);
break;
case Woodworker:
window = WindowWoodworker.create(player, object, side);
break;
case Lumbermill:
window = WindowLumbermill.create(player, object, side);
break;
case MothDatabase:
case MothDatabaseNEI:
window = WindowLepidopteristDatabase.create(player, side, this != ExtraTreesGUID.MothDatabase);
break;
case SetSquare:
window = WindowSetSquare.create(player, world, x, y, z, side);
break;
}
window = switch (this) {
case Database, DatabaseNEI -> WindowArboristDatabase.create(player, side, this != ExtraTreesGUID.Database);
case Woodworker -> WindowWoodworker.create(player, object, side);
case Lumbermill -> WindowLumbermill.create(player, object, side);
case MothDatabase, MothDatabaseNEI -> WindowLepidopteristDatabase
.create(player, side, this != ExtraTreesGUID.MothDatabase);
case SetSquare -> WindowSetSquare.create(player, world, x, y, z, side);
default -> window;
};
return window;
}
}
@@ -54,8 +54,7 @@ public class ModuleCore implements IInitializable {
Queue<ExtraTreeFruitGene> fruitQueue = new LinkedList<>();
Collections.addAll(fruitQueue, ExtraTreeFruitGene.values());
Queue<IDesign> designQueue = new LinkedList<>();
designQueue.addAll(CarpentryManager.carpentryInterface.getSortedDesigns());
Queue<IDesign> designQueue = new LinkedList<>(CarpentryManager.carpentryInterface.getSortedDesigns());
fruitQueue.remove(ExtraTreeFruitGene.Apple);
outputSpecies.println("<table style=\"width: 100%;\">");
@@ -31,7 +31,7 @@ public class ControlRecipeSlot extends ControlSlotBase {
@Override
public void onEvent(EventMouse.Down event) {
TileEntity tile = (TileEntity) Window.get(getWidget()).getInventory();
if (tile == null || !(tile instanceof TileEntityMachine)) {
if (!(tile instanceof TileEntityMachine)) {
return;
}
@@ -40,7 +40,6 @@ public class ControlSlotFluid extends Control implements ITooltip {
@Override
public void onRenderBackground() {
int size = (int) getSize().x();
CraftGUI.render.texture(CraftGUITexture.Slot, getArea());
if (getSuperParent().getMousedOverWidget() == this) {
CraftGUI.render.gradientRect(
@@ -13,7 +13,6 @@ public class ControlTankSlot extends ControlSlotFluid {
public ControlTankSlot(IWidget parent, int x, int y, int i) {
super(parent, x, y, null);
tankID = 0;
tankID = i;
addSelfEventHandler(new EventMouse.Down.Handler() {
@@ -156,7 +156,7 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
public void onRenderForeground() {
ItemStack image = ((WindowWoodworker) getSuperParent()).getDesignerType().getDisplayStack(getValue());
CraftGUI.render.item(new IPoint(1.0f, 1.0f), image);
if (((IControlValue) getParent()).getValue() == getValue()) {
if (((IControlValue<?>) getParent()).getValue() == getValue()) {
return;
}
@@ -43,17 +43,11 @@ public class PagePlanksOverview extends PageAbstract<ItemStack> {
ItemStack fence = WoodManager.getFence(type, new FenceType(0), 1);
ItemStack gate = WoodManager.getGate(type);
ItemStack door = WoodManager.getDoor(type, DoorType.STANDARD);
if (fence != null) {
new ControlItemDisplay(this, x, 48.0f).setItemStack(fence);
x += 22;
}
if (gate != null) {
new ControlItemDisplay(this, x, 48.0f).setItemStack(gate);
x += 22;
}
if (door != null) {
new ControlItemDisplay(this, x, 48.0f).setItemStack(door);
}
new ControlItemDisplay(this, x, 48.0f).setItemStack(fence);
x += 22;
new ControlItemDisplay(this, x, 48.0f).setItemStack(gate);
x += 22;
new ControlItemDisplay(this, x, 48.0f).setItemStack(door);
}
ControlText controlDescription = new ControlText(
@@ -71,22 +65,22 @@ public class PagePlanksOverview extends PageAbstract<ItemStack> {
desc = type.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.nodescription");
descBody.append(I18N.localise("binniecore.gui.database.nodescription"));
} 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(
@@ -58,14 +58,14 @@ public enum ButterflySpecies implements IAlleleButterflySpecies {
public IClassification branch;
protected String name;
protected String branchName;
protected String scientific;
protected BinnieResource texture;
protected int color;
private final String name;
final String branchName;
private final String scientific;
private final BinnieResource texture;
private final int color;
private Map<ItemStack, Float> butterflyLoot;
private Map<ItemStack, Float> caterpillarLoot;
private final Map<ItemStack, Float> butterflyLoot;
private final Map<ItemStack, Float> caterpillarLoot;
ButterflySpecies(String name, String scientific, Color color) {
this.name = name;
@@ -7,9 +7,9 @@ public enum ExtraTreeFruitFamily implements IFruitFamily {
Berry("Berries", "berry", "berri"),
Citrus("Citrus", "citrus", "citrus");
protected String name;
protected String uid;
protected String scientific;
private final String name;
private final String uid;
private final String scientific;
ExtraTreeFruitFamily(String name, String uid, String scientific) {
this.name = name;
@@ -95,17 +95,17 @@ public enum ExtraTreeFruitGene implements IAlleleFruit, IFruitProvider {
Gooseberry(8, 0xb99f50, 0xb9cf50, FruitSprite.Tiny),
GoldenRaspberry(8, 0xbeb03b, 0xf3b03b, FruitSprite.Tiny);
protected IFruitFamily family;
protected boolean isRipening;
protected int diffR;
protected int diffG;
protected int diffB;
protected FruitPod pod;
protected int ripeningPeriod;
protected int colorUnripe;
protected int color;
protected FruitSprite index;
protected HashMap<ItemStack, Float> products;
private IFruitFamily family;
private boolean isRipening;
private int diffR;
private int diffG;
private int diffB;
private final FruitPod pod;
private int ripeningPeriod;
private int colorUnripe;
private int color;
private FruitSprite index;
final HashMap<ItemStack, Float> products;
ExtraTreeFruitGene(int time, int unripe, int color, FruitSprite index) {
this.color = color;
@@ -24,10 +24,10 @@ public class ExtraTreeMutation implements ITreeMutation {
protected IAlleleTreeSpecies allele1;
protected IAllele[] template;
private float minTemperature;
private float maxTemperature;
private float minRainfall;
private float maxRainfall;
private final float minTemperature;
private final float maxTemperature;
private final float minRainfall;
private final float maxRainfall;
private float height;
public ExtraTreeMutation(IAllele allele0, IAllele allele1, IAllele result, int chance) {
@@ -89,7 +89,6 @@ import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.IGermlingIconProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenerator;
import forestry.api.arboriculture.ITreeRoot;
import forestry.api.arboriculture.TreeManager;
@@ -233,19 +232,19 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
DwarfHazel("Corylus", "americana", 0x9bb552, ILogType.ExtraTreeLog.Hazel, ExtraTreeFruitGene.Hazelnut,
WorldGenShrub.class);
public ILogType wood;
public final ILogType wood;
protected ArrayList<IFruitFamily> families;
protected int girth;
protected Class<? extends WorldGenerator> gen;
protected IAlleleFruit fruit;
protected IAllele[] template;
protected int color;
protected String binomial;
protected String uid;
protected String branchName;
protected IClassification branch;
protected int colorPollineted;
private final ArrayList<IFruitFamily> families;
private final int girth;
private Class<? extends WorldGenerator> gen;
private final IAlleleFruit fruit;
private IAllele[] template;
private final int color;
private final String binomial;
private final String uid;
final String branchName;
IClassification branch;
private final int colorPollineted;
private LeafType leafType;
private SaplingType saplingType;
@@ -816,7 +815,7 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
return new WorldGenDefault(tree);
}
protected ExtraTreeSpecies setLeafType(LeafType type) {
private ExtraTreeSpecies setLeafType(LeafType type) {
leafType = type;
if (leafType == LeafType.CONIFER) {
saplingType = SaplingType.CONIFER;
@@ -828,7 +827,7 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
return this;
}
protected ExtraTreeSpecies setSaplingType(SaplingType saplingType) {
private ExtraTreeSpecies setSaplingType(SaplingType saplingType) {
this.saplingType = saplingType;
return this;
}
@@ -886,7 +885,7 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
return this;
}
public int getLeafColor(ITree tree) {
public int getLeafColor() {
return color;
}
@@ -935,9 +934,8 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
return 0.0f;
}
if (template[EnumTreeChromosome.FRUITS.ordinal()] instanceof ExtraTreeFruitGene) {
ExtraTreeFruitGene fruit = (ExtraTreeFruitGene) template[EnumTreeChromosome.FRUITS.ordinal()];
for (ItemStack stack : fruit.products.keySet()) {
if (template[EnumTreeChromosome.FRUITS.ordinal()] instanceof ExtraTreeFruitGene fruitGene) {
for (ItemStack stack : fruitGene.products.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
@@ -971,7 +969,7 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
ItemStack research = null;
if (world.rand.nextFloat() < 10.0f / bountyLevel) {
Collection<? extends IMutation> combinations = getRoot().getCombinations(this);
if (combinations.size() > 0) {
if (!combinations.isEmpty()) {
IMutation[] candidates = combinations.toArray(new IMutation[0]);
research = AlleleManager.alleleRegistry
.getMutationNoteStack(researcher, candidates[world.rand.nextInt(candidates.length)]);
@@ -982,9 +980,8 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
bounty.add(research);
}
if (template[EnumTreeChromosome.FRUITS.ordinal()] instanceof ExtraTreeFruitGene) {
ExtraTreeFruitGene fruit = (ExtraTreeFruitGene) template[EnumTreeChromosome.FRUITS.ordinal()];
for (ItemStack stack : fruit.products.keySet()) {
if (template[EnumTreeChromosome.FRUITS.ordinal()] instanceof ExtraTreeFruitGene fruitGene) {
for (ItemStack stack : fruitGene.products.keySet()) {
ItemStack stack2 = stack.copy();
stack2.stackSize = world.rand.nextInt((int) (bountyLevel / 2.0f)) + 1;
bounty.add(stack2);
@@ -998,14 +995,14 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
public int getGermlingColour(EnumGermlingType type, int renderPass) {
if (type == EnumGermlingType.SAPLING) {
if (renderPass == 0) {
return getLeafColor(null);
return getLeafColor();
}
if (getLog() == null) {
return 0xffffff;
}
return getLog().getColour();
}
return getLeafColor(null);
return getLeafColor();
}
@Override
@@ -1033,7 +1030,7 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
highest = otherAdvance;
}
}
return own + ((highest < 0) ? 0 : highest);
return own + highest;
}
@Override
@@ -19,7 +19,7 @@ public enum FruitSprite implements IIconProvider {
Larger,
Pear;
protected BinnieIcon icon;
private BinnieIcon icon;
public short getIndex() {
return (short) (ordinal() + 4200);
@@ -9,10 +9,10 @@ public enum LeafType {
MAPLE((short) 30, (short) 31, (short) 32, "Maple"),
PALM((short) 35, (short) 36, (short) 37, "Palm");
public short fancyUID;
public short plainUID;
public short changedUID;
public String description;
public final short fancyUID;
public final short plainUID;
public final short changedUID;
public final String description;
LeafType(short fancyUID, short plainUID, short changedUID, String description) {
this.fancyUID = fancyUID;
@@ -88,7 +88,7 @@ public class ModuleGenetics implements IInitializable {
if (set2.contains(clss.getScientific().toLowerCase())) {
String nextLevel = "";
int index = set2.indexOf(clss.getScientific().toLowerCase()) + 1;
while (nextLevel.length() == 0) {
while (nextLevel.isEmpty()) {
try {
nextLevel = set2.get(index++);
} catch (IndexOutOfBoundsException ex) {
@@ -19,9 +19,9 @@ public enum ExtraTreeItems implements IItemMisc {
WoodWax("woodWax"),
GlassFitting("glassFitting");
protected String name;
protected String iconPath;
protected IIcon icon;
private final String name;
private final String iconPath;
private IIcon icon;
ExtraTreeItems(String name) {
this.name = name;
@@ -39,7 +39,7 @@ public enum ExtraTreeItems implements IItemMisc {
}
@Override
public void addInformation(List tooltip) {
public void addInformation(List<String> tooltip) {
// ignored
}
@@ -17,11 +17,11 @@ public enum ExtraTreeLiquid implements ILiquidType {
Latex("latex", 0xd8dbc9),
Turpentine("turpentine", 0x79533a);
public String name;
public final String name;
protected String ident;
protected IIcon icon;
protected int color;
private final String ident;
private IIcon icon;
private final int color;
ExtraTreeLiquid(String name, int color) {
this.name = name;
@@ -79,13 +79,9 @@ public enum Food implements IItemMisc {
Starfruit(2),
Candlenut(0);
protected IIcon icon;
protected int hunger;
private List<String> ores;
Food() {
this(0);
}
private IIcon icon;
private final int hunger;
private final List<String> ores;
Food(int hunger) {
ores = new ArrayList<>();
@@ -188,7 +184,7 @@ public enum Food implements IItemMisc {
}
@Override
public void addInformation(List tooltip) {
public void addInformation(List<String> tooltip) {
// ignored
}
@@ -42,16 +42,16 @@ public class ItemDictionary extends Item {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List toltip, boolean advanced) {
super.addInformation(stack, player, toltip, advanced);
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
if (stack.getItemDamage() > 0) {
toltip.add(I18N.localise("extratrees.item.database.tooltip"));
tooltip.add(I18N.localise("extratrees.item.database.tooltip"));
}
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
super.getSubItems(item, tab, list);
list.add(new ItemStack(item, 1, 1));
}
@@ -28,7 +28,7 @@ public class ItemFood extends net.minecraft.item.ItemFood {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (IItemMisc itemMisc : items) {
if (itemMisc.isActive()) {
list.add(getStack(itemMisc, 1));
@@ -46,7 +46,7 @@ public class ItemFood extends net.minecraft.item.ItemFood {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
IItemMisc item = getItem(stack.getItemDamage());
if (item != null) {
@@ -17,7 +17,6 @@ public class ItemHammer extends Item implements IToolHammer {
protected boolean isDurableHammer;
public ItemHammer(boolean durable) {
isDurableHammer = false;
isDurableHammer = durable;
setCreativeTab(CreativeTabs.tabTools);
setUnlocalizedName(durable ? "durableHammer" : "hammer");
@@ -42,7 +42,7 @@ public class ItemMothDatabase extends Item {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
if (stack.getItemDamage() > 0) {
tooltip.add(I18N.localise("extratrees.item.mothDatabase.tooltip"));
@@ -51,7 +51,7 @@ public class ItemMothDatabase extends Item {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
super.getSubItems(item, tab, list);
list.add(new ItemStack(item, 1, 1));
}
@@ -92,7 +92,7 @@ public enum ExtraTreeMachine implements IMachineType {
@Override
public void renderMachine(Machine machine, double x, double y, double z, float partialTick,
RenderBlocks renderer) {
MachineRendererForestry.renderMachine(textureName.getShortPath(), x, y, z, partialTick);
MachineRendererForestry.renderMachine(textureName.getShortPath(), x, y, z);
}
}
}
@@ -13,7 +13,7 @@ public class MachineRendererForestry {
static Map<String, Object> instances = new HashMap<>();
static Method renderMethod;
private static void loadMethod(String file, boolean waterTank, boolean productTank) {
private static void loadMethod(String file) {
try {
Class cls = Class.forName("forestry.core.render.RenderMachine");
Object instance = cls.getConstructor(String.class).newInstance(file);
@@ -32,9 +32,9 @@ public class MachineRendererForestry {
}
}
public static void renderMachine(String name, double x, double y, double z, float var8) {
public static void renderMachine(String name, double x, double y, double z) {
if (!MachineRendererForestry.instances.containsKey(name)) {
loadMethod(name, false, false);
loadMethod(name);
}
try {
@@ -8,7 +8,7 @@ import binnie.extratrees.machines.ExtraTreeMachine;
public abstract class CarpenterPackage extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
private DesignerType type;
private final DesignerType type;
public CarpenterPackage(DesignerType type) {
super(type.name, type.texture, false);
@@ -24,8 +24,8 @@ public enum DesignerType {
GLASSWORKER(ExtraTreeTexture.panelerTexture),
TILEWORKER(ExtraTreeTexture.tileworkerTexture);
public String name;
public String texture;
public final String name;
public final String texture;
DesignerType(String texture) {
this.name = name().toLowerCase(Locale.ENGLISH);
@@ -33,17 +33,11 @@ public enum DesignerType {
}
public IDesignSystem getSystem() {
switch (this) {
case GLASSWORKER: {
return DesignSystem.Glass;
}
case TILEWORKER: {
return CeramicDesignSystem.instance;
}
default: {
return DesignSystem.Wood;
}
}
return switch (this) {
case GLASSWORKER -> DesignSystem.Glass;
case TILEWORKER -> CeramicDesignSystem.instance;
default -> DesignSystem.Wood;
};
}
public ItemStack getBlock(IDesignMaterial type1, IDesignMaterial type2, IDesign design) {
@@ -59,17 +53,12 @@ public enum DesignerType {
}
private BlockDesign getBlock() {
switch (this) {
case GLASSWORKER:
return ExtraTrees.blockStained;
case PANELWORKER:
return ExtraTrees.blockPanel;
case TILEWORKER:
return Botany.ceramicTile;
}
return ExtraTrees.blockCarpentry;
return switch (this) {
case GLASSWORKER -> ExtraTrees.blockStained;
case PANELWORKER -> ExtraTrees.blockPanel;
case TILEWORKER -> Botany.ceramicTile;
default -> ExtraTrees.blockCarpentry;
};
}
public ItemStack getDisplayStack(IDesign design) {
@@ -77,19 +66,11 @@ public enum DesignerType {
}
public String getMaterialTooltip() {
switch (this) {
case GLASSWORKER:
return I18N.localise("extratrees.machine.glassworker.material");
case PANELWORKER:
return I18N.localise("extratrees.machine.panelworker.material");
case TILEWORKER:
return I18N.localise("extratrees.machine.tileworker.material");
case WOODWORKER:
return I18N.localise("extratrees.machine.woodworker.material");
}
return "";
return switch (this) {
case GLASSWORKER -> I18N.localise("extratrees.machine.glassworker.material");
case PANELWORKER -> I18N.localise("extratrees.machine.panelworker.material");
case TILEWORKER -> I18N.localise("extratrees.machine.tileworker.material");
case WOODWORKER -> I18N.localise("extratrees.machine.woodworker.material");
};
}
}
@@ -62,8 +62,7 @@ public class WoodworkerRecipeComponent extends ComponentRecipe
IDesignMaterial type1 = type.getSystem().getMaterial(plank1);
IDesignMaterial type2 = type.getSystem().getMaterial(plank2);
IDesign design = getDesign();
ItemStack stack = type.getBlock(type1, type2, design);
return stack;
return type.getBlock(type1, type2, design);
}
@Override
@@ -8,6 +8,7 @@ import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapelessOreRecipe;
@@ -53,39 +54,36 @@ public class Lumbermill {
private static Collection<ItemStack> getRecipeResult(ItemStack output) {
List<ItemStack> list = new ArrayList<>();
for (Object recipeO : CraftingManager.getInstance().getRecipeList()) {
if (recipeO instanceof ShapelessRecipes) {
ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
if (recipe.recipeItems.size() != 1 || !(recipe.recipeItems.get(0) instanceof ItemStack)) {
for (IRecipe iRecipe : CraftingManager.getInstance().getRecipeList()) {
if (iRecipe instanceof ShapelessRecipes shapeless) {
if (shapeless.recipeItems.size() != 1 || !(shapeless.recipeItems.get(0) instanceof ItemStack)) {
continue;
}
ItemStack input = (ItemStack) recipe.recipeItems.get(0);
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().isItemEqual(output)) {
ItemStack input = shapeless.recipeItems.get(0);
if (shapeless.getRecipeOutput() != null && shapeless.getRecipeOutput().isItemEqual(output)) {
list.add(input);
}
}
if (recipeO instanceof ShapedRecipes) {
ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
if (recipe2.recipeItems.length != 1) {
if (iRecipe instanceof ShapedRecipes shaped) {
if (shaped.recipeItems.length != 1) {
continue;
}
ItemStack input = recipe2.recipeItems[0];
if (recipe2.getRecipeOutput() != null && recipe2.getRecipeOutput().isItemEqual(output)) {
ItemStack input = shaped.recipeItems[0];
if (shaped.getRecipeOutput() != null && shaped.getRecipeOutput().isItemEqual(output)) {
list.add(input);
}
}
if (recipeO instanceof ShapelessOreRecipe) {
ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
if (recipe3.getInput().size() != 1 || !(recipe3.getInput().get(0) instanceof ItemStack)) {
if (iRecipe instanceof ShapelessOreRecipe shapelessOre) {
if (shapelessOre.getInput().size() != 1
|| !(shapelessOre.getInput().get(0) instanceof ItemStack input)) {
continue;
}
ItemStack input = (ItemStack) recipe3.getInput().get(0);
if (recipe3.getRecipeOutput() == null || !recipe3.getRecipeOutput().isItemEqual(output)) {
if (shapelessOre.getRecipeOutput() == null || !shapelessOre.getRecipeOutput().isItemEqual(output)) {
continue;
}
list.add(input);
@@ -1,10 +1,7 @@
package binnie.extratrees.machines.lumbermill;
import net.minecraft.tileentity.TileEntity;
import binnie.core.craftgui.minecraft.IMachineInformation;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.machines.inventory.ComponentInventorySlots;
import binnie.core.machines.inventory.ComponentTankContainer;
import binnie.core.machines.inventory.InventorySlot;
@@ -46,9 +43,4 @@ public class LumbermillPackage extends ExtraTreeMachine.PackageExtraTreeMachine
new ComponentPowerReceptor(machine);
new LumbermillComponentLogic(machine);
}
@Override
public TileEntity createTileEntity() {
return new TileEntityMachine(this);
}
}
@@ -12,13 +12,13 @@ public class IMCForNEI {
sendCatalyst("extratrees.lumbermill", "ExtraTrees:machine:0");
}
private static void sendHandler(String aName, String aBlock) {
private static void sendHandler(String name, String block) {
NBTTagCompound aNBT = new NBTTagCompound();
aNBT.setString("handler", aName);
aNBT.setString("handler", name);
aNBT.setString("modName", "Extra Trees");
aNBT.setString("modId", "ExtraTrees");
aNBT.setBoolean("modRequired", true);
aNBT.setString("itemName", aBlock);
aNBT.setString("itemName", block);
aNBT.setInteger("handlerHeight", 76);
aNBT.setInteger("handlerWidth", 166);
aNBT.setInteger("maxRecipesPerPage", 4);
@@ -26,15 +26,15 @@ public class IMCForNEI {
FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT);
}
private static void sendCatalyst(String aName, String aStack, int aPriority) {
private static void sendCatalyst(String name, String stack, int prio) {
NBTTagCompound aNBT = new NBTTagCompound();
aNBT.setString("handlerID", aName);
aNBT.setString("itemName", aStack);
aNBT.setInteger("priority", aPriority);
aNBT.setString("handlerID", name);
aNBT.setString("itemName", stack);
aNBT.setInteger("priority", prio);
FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT);
}
private static void sendCatalyst(String aName, String aStack) {
sendCatalyst(aName, aStack, 0);
private static void sendCatalyst(String name, String stack) {
sendCatalyst(name, stack, 0);
}
}
@@ -1,6 +1,6 @@
package binnie.extratrees.nei;
import binnie.core.BinnieCore;
import binnie.core.Tags;
import binnie.core.nei.RecipeHandlerBase;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
@@ -25,6 +25,6 @@ public class NEIExtraTreesConfig implements IConfigureNEI {
@Override
public String getVersion() {
return BinnieCore.VERSION;
return Tags.VERSION;
}
}
@@ -19,7 +19,7 @@ import forestry.plugins.PluginArboriculture;
public class DefaultTreeGenerator implements ITreeGenerator {
private ExtraTreeSpecies extraTreeSpecies;
private final ExtraTreeSpecies extraTreeSpecies;
public DefaultTreeGenerator(ExtraTreeSpecies extraTreeSpecies) {
this.extraTreeSpecies = extraTreeSpecies;
@@ -1,6 +1,5 @@
package binnie.extratrees.worldgen;
import binnie.extratrees.genetics.ExtraTreeSpecies;
import forestry.api.world.ITreeGenData;
public class WorldGenDefault extends WorldGenTree {
@@ -9,24 +8,9 @@ public class WorldGenDefault extends WorldGenTree {
super(tree);
}
@Override
public void generate() {
generateTreeTrunk(height, girth);
int leafSpawn = height + 1;
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), 1.0f, 1, leaf, false);
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), 1.5f, 1, leaf, false);
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), 2.9f, 1, leaf, false);
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), 2.9f, 1, leaf, false);
}
@Override
public void preGenerate() {
height = determineHeight(5, 2);
girth = determineGirth(treeGen.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockTypeLog(((ExtraTreeSpecies) treeGen.getGenome().getPrimary()).getLog());
}
}
@@ -23,7 +23,7 @@ public class WorldGenRedMaple extends WorldGenTree {
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), width - 0.4f, 1, leaf, false);
}
width += 0.6;
width += 0.6f;
while (leafSpawn > bottom) {
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), width, 1, leaf, false);
generateCylinder(new Vector(0.0f, leafSpawn--, 0.0f), width - 0.4f, 1, leaf, false);
@@ -3,6 +3,7 @@ package binnie.extratrees.worldgen;
import java.util.Random;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
@@ -73,7 +74,7 @@ public abstract class WorldGenTree extends WorldGenerator {
protected int determineHeight(int required, int variation) {
int determined = Math.round((required + rand.nextInt(variation)) * treeGen.getHeightModifier());
return (determined < minHeight) ? minHeight : ((determined > maxHeight) ? maxHeight : determined);
return MathHelper.clamp_int(determined, minHeight, maxHeight);
}
public BlockType getLeaf() {
@@ -142,7 +143,7 @@ public abstract class WorldGenTree extends WorldGenerator {
for (int y2 = minPodHeight; y2 < height; ++y2) {
for (int x2 = 0; x2 < girth; ++x2) {
for (int z = 0; z < girth; ++z) {
if (x2 <= 0 || x2 >= girth || z <= 0 || z >= girth) {
if (x2 <= 0 || x2 >= girth || z <= 0) {
treeGen.trySpawnFruitBlock(world, startX + x2 + 1, startY + y2, startZ + z);
treeGen.trySpawnFruitBlock(world, startX + x2 - 1, startY + y2, startZ + z);
treeGen.trySpawnFruitBlock(world, startX + x2, startY + y2, startZ + z + 1);
@@ -203,7 +204,7 @@ public abstract class WorldGenTree extends WorldGenerator {
}
}
static class Vector {
public static class Vector {
float x;
float y;