From fec27be5b92300966dbf63ba051c2e73f0c0e28c Mon Sep 17 00:00:00 2001 From: Roadhog360 Date: Thu, 16 Nov 2023 12:42:32 -0600 Subject: [PATCH] Cache a few nussed `values()` calls, remove useless class The only way to make its inventory icon is setting the getSpriteNumber number, but I can't because it's not meta sensitive and there's no way to use only item icons for just the mangrove propagule. --- .../java/ganymedes01/etfuturum/ModBlocks.java | 4 +-- .../java/ganymedes01/etfuturum/ModItems.java | 2 +- .../itemblocks/ItemBlockModernSapling.java | 32 ------------------- .../etfuturum/core/utils/Rotation.java | 17 +++++----- .../core/utils/structurenbt/NBTStructure.java | 2 +- 5 files changed, 12 insertions(+), 45 deletions(-) delete mode 100644 src/main/java/ganymedes01/etfuturum/blocks/itemblocks/ItemBlockModernSapling.java diff --git a/src/main/java/ganymedes01/etfuturum/ModBlocks.java b/src/main/java/ganymedes01/etfuturum/ModBlocks.java index 6c3660179..d6901e2c9 100644 --- a/src/main/java/ganymedes01/etfuturum/ModBlocks.java +++ b/src/main/java/ganymedes01/etfuturum/ModBlocks.java @@ -279,7 +279,7 @@ public enum ModBlocks { WEEPING_VINES(ConfigBlocksItems.enableCrimsonBlocks, new BlockWeepingVines()), TWISTING_VINES(ConfigBlocksItems.enableWarpedBlocks, new BlockTwistingVines()), - SAPLING(ConfigBlocksItems.enableCherryBlocks && ConfigBlocksItems.enableMangroveBlocks, new BlockModernSapling(), ItemBlockModernSapling.class), + SAPLING(ConfigBlocksItems.enableCherryBlocks && ConfigBlocksItems.enableMangroveBlocks, new BlockModernSapling()), LEAVES(ConfigBlocksItems.enableCherryBlocks && ConfigBlocksItems.enableMangroveBlocks, new BlockModernLeaves()), WOOD_PLANKS(ConfigBlocksItems.woodVariants, new BlockModernWoodPlanks()), WOOD_SLAB(ConfigBlocksItems.woodVariants, new BlockModernWoodSlab(false)), @@ -494,7 +494,7 @@ public enum ModBlocks { public static final ModBlocks[] VALUES = values(); public static void init() { - for (ModBlocks block : values()) { + for (ModBlocks block : VALUES) { if (block.isEnabled()) { if (block.getItemBlock() != null || !block.getHasItemBlock()) { GameRegistry.registerBlock(block.get(), block.getItemBlock(), block.name().toLowerCase()); diff --git a/src/main/java/ganymedes01/etfuturum/ModItems.java b/src/main/java/ganymedes01/etfuturum/ModItems.java index f23ce999c..aa0dd0799 100644 --- a/src/main/java/ganymedes01/etfuturum/ModItems.java +++ b/src/main/java/ganymedes01/etfuturum/ModItems.java @@ -103,7 +103,7 @@ public enum ModItems { public static final ModItems[] VALUES = values(); public static void init() { - for (ModItems item : values()) { + for (ModItems item : VALUES) { if (item.isEnabled()) { //Honestly what do you think it's doing lmfao GameRegistry.registerItem(item.get(), item.name().toLowerCase()); } diff --git a/src/main/java/ganymedes01/etfuturum/blocks/itemblocks/ItemBlockModernSapling.java b/src/main/java/ganymedes01/etfuturum/blocks/itemblocks/ItemBlockModernSapling.java deleted file mode 100644 index 1c331977e..000000000 --- a/src/main/java/ganymedes01/etfuturum/blocks/itemblocks/ItemBlockModernSapling.java +++ /dev/null @@ -1,32 +0,0 @@ -package ganymedes01.etfuturum.blocks.itemblocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; - -public class ItemBlockModernSapling extends BaseItemBlock { - - private IIcon propaguleInvIcon; - - public ItemBlockModernSapling(Block block) { - super(block); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister p_94581_1_) { - propaguleInvIcon = p_94581_1_.registerIcon("mangrove_propagule"); - } - - /** - * Gets an icon index based on an item's damage value - */ - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int p_77617_1_) { - if (p_77617_1_ % 8 == 0) { - return propaguleInvIcon; - } - return super.getIconFromDamage(p_77617_1_); - } -} diff --git a/src/main/java/ganymedes01/etfuturum/core/utils/Rotation.java b/src/main/java/ganymedes01/etfuturum/core/utils/Rotation.java index fe17f565d..0f190ed41 100644 --- a/src/main/java/ganymedes01/etfuturum/core/utils/Rotation.java +++ b/src/main/java/ganymedes01/etfuturum/core/utils/Rotation.java @@ -10,8 +10,15 @@ public enum Rotation { COUNTERCLOCKWISE_90("rotate_270");//West private final String name; - private static final String[] ROTATION_NAMES = new String[values().length]; public static final Rotation[] VALUES = values(); + private static final String[] ROTATION_NAMES = new String[VALUES.length]; + + static { + int i = 0; + for (Rotation rotation : values()) { + ROTATION_NAMES[i++] = rotation.name; + } + } Rotation(String nameIn) { this.name = nameIn; @@ -141,12 +148,4 @@ public int rotate(int p_185833_1_, int p_185833_2_) { return p_185833_1_; } } - - static { - int i = 0; - - for (Rotation rotation : values()) { - ROTATION_NAMES[i++] = rotation.name; - } - } } diff --git a/src/main/java/ganymedes01/etfuturum/core/utils/structurenbt/NBTStructure.java b/src/main/java/ganymedes01/etfuturum/core/utils/structurenbt/NBTStructure.java index c60434ac2..f0749346e 100644 --- a/src/main/java/ganymedes01/etfuturum/core/utils/structurenbt/NBTStructure.java +++ b/src/main/java/ganymedes01/etfuturum/core/utils/structurenbt/NBTStructure.java @@ -394,7 +394,7 @@ public final ForgeDirection getFacingFromInt(int i) { if (i < 0 || i > 3) { throw new IllegalArgumentException("Facing int must be at least 0 and at most 3!"); } - return ForgeDirection.values()[i + 2]; + return ForgeDirection.VALID_DIRECTIONS[i + 2]; } public final int getIntFromFacing(ForgeDirection dir) {