From 63cbe6e56250fff538d384a3679abe7e5668523b Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Tue, 9 May 2023 19:29:05 +0200 Subject: [PATCH] fix + more cleanup for PowerConduitEndergy (#122) --- .../enderio/conduit/power/PowerConduit.java | 20 +++++++--- .../power/endergy/PowerConduitEndergy.java | 37 ++++--------------- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/main/java/crazypants/enderio/conduit/power/PowerConduit.java b/src/main/java/crazypants/enderio/conduit/power/PowerConduit.java index 63e51c5607..9d1d0df94c 100644 --- a/src/main/java/crazypants/enderio/conduit/power/PowerConduit.java +++ b/src/main/java/crazypants/enderio/conduit/power/PowerConduit.java @@ -68,17 +68,21 @@ static ItemStack createItemStackForSubtype(int subtype) { } public static void initIcons() { + initIcons(POSTFIX, ICONS); + } + + protected static void initIcons(String[] postfix, Map icons) { IconUtil.addIconProvider(new IconUtil.IIconProvider() { @Override public void registerIcons(IIconRegister register) { - for (String pf : POSTFIX) { - ICONS.put(ICON_KEY + pf, register.registerIcon(ICON_KEY + pf)); - ICONS.put(ICON_KEY_INPUT + pf, register.registerIcon(ICON_KEY_INPUT)); - ICONS.put(ICON_KEY_OUTPUT + pf, register.registerIcon(ICON_KEY_OUTPUT)); - ICONS.put(ICON_CORE_KEY + pf, register.registerIcon(ICON_CORE_KEY + pf)); + for (String pf : postfix) { + icons.put(ICON_KEY + pf, register.registerIcon(ICON_KEY + pf)); + icons.put(ICON_KEY_INPUT + pf, register.registerIcon(ICON_KEY_INPUT)); + icons.put(ICON_KEY_OUTPUT + pf, register.registerIcon(ICON_KEY_OUTPUT)); + icons.put(ICON_CORE_KEY + pf, register.registerIcon(ICON_CORE_KEY + pf)); } - ICONS.put(ICON_TRANSMISSION_KEY, register.registerIcon(ICON_TRANSMISSION_KEY)); + icons.put(ICON_TRANSMISSION_KEY, register.registerIcon(ICON_TRANSMISSION_KEY)); } @Override @@ -119,6 +123,10 @@ public PowerConduit(int meta) { this.subtype = meta; } + protected int getSubtype() { + return subtype; + } + @Override public boolean getConnectionsDirty() { return connectionsDirty; diff --git a/src/main/java/crazypants/enderio/conduit/power/endergy/PowerConduitEndergy.java b/src/main/java/crazypants/enderio/conduit/power/endergy/PowerConduitEndergy.java index ab98997f2b..b274f06e12 100644 --- a/src/main/java/crazypants/enderio/conduit/power/endergy/PowerConduitEndergy.java +++ b/src/main/java/crazypants/enderio/conduit/power/endergy/PowerConduitEndergy.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.Map; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; @@ -46,71 +45,51 @@ static ItemStack createItemStackForSubtype(int subtype) { } public static void initIcons() { - IconUtil.addIconProvider(new IconUtil.IIconProvider() { - - @Override - public void registerIcons(IIconRegister register) { - for (String pf : POSTFIX) { - ICONS.put(ICON_KEY + pf, register.registerIcon(ICON_KEY + pf)); - ICONS.put(ICON_KEY_INPUT + pf, register.registerIcon(ICON_KEY_INPUT)); - ICONS.put(ICON_KEY_OUTPUT + pf, register.registerIcon(ICON_KEY_OUTPUT)); - ICONS.put(ICON_CORE_KEY + pf, register.registerIcon(ICON_CORE_KEY + pf)); - } - ICONS.put(ICON_TRANSMISSION_KEY, register.registerIcon(ICON_TRANSMISSION_KEY)); - } - - @Override - public int getTextureType() { - return 0; - } - }); + initIcons(POSTFIX, ICONS); } - private int subtype; - public PowerConduitEndergy() { super(); } public PowerConduitEndergy(int meta) { super(meta); - this.subtype = meta; } @Override public ICapacitor getCapacitor() { - return getCapacitors()[subtype]; + return getCapacitors()[getSubtype()]; } @Override public ItemStack createItem() { - return createItemStackForSubtype(subtype); + return createItemStackForSubtype(getSubtype()); } // Rendering @Override public IIcon getTextureForState(CollidableComponent component) { if (component.dir == ForgeDirection.UNKNOWN) { - return ICONS.get(ICON_CORE_KEY + POSTFIX[subtype]); + return ICONS.get(ICON_CORE_KEY + POSTFIX[getSubtype()]); } if (COLOR_CONTROLLER_ID.equals(component.data)) { return IconUtil.whiteTexture; } - return ICONS.get(ICON_KEY + POSTFIX[subtype]); + return ICONS.get(ICON_KEY + POSTFIX[getSubtype()]); } @Override public IIcon getTextureForInputMode() { - return ICONS.get(ICON_KEY_INPUT + POSTFIX[subtype]); + return ICONS.get(ICON_KEY_INPUT + POSTFIX[getSubtype()]); } @Override public IIcon getTextureForOutputMode() { - return ICONS.get(ICON_KEY_OUTPUT + POSTFIX[subtype]); + return ICONS.get(ICON_KEY_OUTPUT + POSTFIX[getSubtype()]); } @Override public int getMaxEnergyStored() { - return getCapacitors()[subtype].getMaxEnergyStored(); + return getCapacitors()[getSubtype()].getMaxEnergyStored(); } }