Skip to content

Commit

Permalink
fix + more cleanup for PowerConduitEndergy (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilzinsel64 authored May 9, 2023
1 parent 3194ecf commit 63cbe6e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 35 deletions.
20 changes: 14 additions & 6 deletions src/main/java/crazypants/enderio/conduit/power/PowerConduit.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,21 @@ static ItemStack createItemStackForSubtype(int subtype) {
}

public static void initIcons() {
initIcons(POSTFIX, ICONS);
}

protected static void initIcons(String[] postfix, Map<String, IIcon> 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
Expand Down Expand Up @@ -119,6 +123,10 @@ public PowerConduit(int meta) {
this.subtype = meta;
}

protected int getSubtype() {
return subtype;
}

@Override
public boolean getConnectionsDirty() {
return connectionsDirty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 63cbe6e

Please sign in to comment.