fix #2136, rewrite statement icon code to remove StatementIconProvider

This commit is contained in:
asiekierka 2014-11-01 07:47:52 +01:00
parent 30f0b46f8b
commit fce0cfec44
16 changed files with 68 additions and 139 deletions

View file

@ -188,12 +188,12 @@ public class BuildCraftCore extends BuildCraftMod {
public static ITriggerExternal triggerFullFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Full);
public static ITriggerInternal triggerRedstoneActive = new TriggerRedstoneInput(true);
public static ITriggerInternal triggerRedstoneInactive = new TriggerRedstoneInput(false);
public static ITriggerExternal triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25);
public static ITriggerExternal triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50);
public static ITriggerExternal triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75);
public static ITriggerExternal triggerFluidContainerBelow25 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_25);
public static ITriggerExternal triggerFluidContainerBelow50 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_50);
public static ITriggerExternal triggerFluidContainerBelow75 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_75);
public static ITriggerExternal triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW25);
public static ITriggerExternal triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW50);
public static ITriggerExternal triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW75);
public static ITriggerExternal triggerFluidContainerBelow25 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW25);
public static ITriggerExternal triggerFluidContainerBelow50 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW50);
public static ITriggerExternal triggerFluidContainerBelow75 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW75);
public static IActionInternal actionRedstone = new ActionRedstoneOutput();
public static IActionExternal[] actionControl;

View file

@ -10,6 +10,9 @@ package buildcraft.core.statements;
import java.util.Locale;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.statements.IActionExternal;
@ -33,19 +36,6 @@ public class ActionMachineControl extends BCStatement implements IActionExternal
return StringUtils.localize("gate.action.machine." + mode.name().toLowerCase(Locale.ENGLISH));
}
@Override
public int getIconIndex() {
switch (mode) {
case On:
return StatementIconProvider.Action_MachineControl_On;
case Off:
return StatementIconProvider.Action_MachineControl_Off;
case Loop:
default:
return StatementIconProvider.Action_MachineControl_Loop;
}
}
@Override
public void actionActivate(TileEntity target, ForgeDirection side,
IStatementContainer source, IStatementParameter[] parameters) {
@ -53,4 +43,10 @@ public class ActionMachineControl extends BCStatement implements IActionExternal
((IControllable) target).setControlMode(mode);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/action_machinecontrol_" + mode.name().toLowerCase());
}
}

View file

@ -8,6 +8,9 @@
*/
package buildcraft.core.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
@ -23,11 +26,6 @@ public class ActionRedstoneOutput extends BCStatement implements IActionInternal
public String getDescription() {
return StringUtils.localize("gate.action.redstone.signal");
}
@Override
public int getIconIndex() {
return StatementIconProvider.Trigger_RedstoneInput_Active;
}
@Override
public IStatementParameter createParameter(int index) {
@ -50,4 +48,10 @@ public class ActionRedstoneOutput extends BCStatement implements IActionInternal
IStatementParameter[] parameters) {
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/action_redstoneoutput");
}
}

View file

@ -40,19 +40,11 @@ public abstract class BCStatement implements IStatement {
public String getUniqueTag() {
return uniqueTag;
}
public int getIconIndex() {
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
if (icon != null) {
return icon;
} else {
return StatementIconProvider.INSTANCE.getIcon(getIconIndex());
}
return icon;
}
@Override

View file

@ -31,7 +31,7 @@ public class StatementParameterRedstoneGateSideOnly implements
if (!isOn) {
return null;
} else {
return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.Action_Parameter_RedstoneGateSideOnly);
return icon;
}
}

View file

@ -82,19 +82,9 @@ public class TriggerEnergy extends BCStatement implements ITriggerInternal, ITri
return false;
}
@Override
public IIcon getIcon() {
if (high) {
return iconEnergyHigh;
} else {
return iconEnergyLow;
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
iconEnergyHigh = iconRegister.registerIcon("buildcraft:triggers/trigger_machine_energy_high");
iconEnergyLow = iconRegister.registerIcon("buildcraft:triggers/trigger_machine_energy_low");
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_machine_energy_" + (high ? "high" : "low"));
}
}

View file

@ -10,6 +10,7 @@ package buildcraft.core.statements;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -107,17 +108,8 @@ public class TriggerFluidContainer extends BCStatement implements ITriggerExtern
}
@Override
public int getIconIndex() {
switch (state) {
case Empty:
return StatementIconProvider.Trigger_FluidContainer_Empty;
case Contains:
return StatementIconProvider.Trigger_FluidContainer_Contains;
case Space:
return StatementIconProvider.Trigger_FluidContainer_Space;
default:
return StatementIconProvider.Trigger_FluidContainer_Full;
}
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_liquidcontainer_" + state.name().toLowerCase());
}
@Override

View file

@ -10,6 +10,7 @@ package buildcraft.core.statements;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -26,7 +27,7 @@ public class TriggerFluidContainerLevel extends BCStatement implements ITriggerE
public enum TriggerType {
BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F);
BELOW25(0.25F), BELOW50(0.5F), BELOW75(0.75F);
public final float level;
@ -90,17 +91,10 @@ public class TriggerFluidContainerLevel extends BCStatement implements ITriggerE
return false;
}
@Override
public int getIconIndex() {
switch (type) {
case BELOW_25:
return StatementIconProvider.Trigger_FluidContainer_Below25;
case BELOW_50:
return StatementIconProvider.Trigger_FluidContainer_Below50;
case BELOW_75:
default:
return StatementIconProvider.Trigger_FluidContainer_Below75;
}
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_liquidcontainer_" + type.name().toLowerCase());
}
@Override

View file

@ -10,6 +10,7 @@ package buildcraft.core.statements;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -98,18 +99,10 @@ public class TriggerInventory extends BCStatement implements ITriggerExternal {
return false;
}
@Override
public int getIconIndex() {
switch (state) {
case Empty:
return StatementIconProvider.Trigger_Inventory_Empty;
case Contains:
return StatementIconProvider.Trigger_Inventory_Contains;
case Space:
return StatementIconProvider.Trigger_Inventory_Space;
default:
return StatementIconProvider.Trigger_Inventory_Full;
}
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_inventory_" + state.name().toLowerCase());
}
@Override

View file

@ -10,6 +10,7 @@ package buildcraft.core.statements;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -27,7 +28,7 @@ public class TriggerInventoryLevel extends BCStatement implements ITriggerExtern
public enum TriggerType {
BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F);
BELOW25(0.25F), BELOW50(0.5F), BELOW75(0.75F);
public final float level;
private TriggerType(float level) {
@ -95,15 +96,8 @@ public class TriggerInventoryLevel extends BCStatement implements ITriggerExtern
}
@Override
public int getIconIndex() {
switch (type) {
case BELOW_25:
return StatementIconProvider.Trigger_Inventory_Below25;
case BELOW_50:
return StatementIconProvider.Trigger_Inventory_Below50;
default:
return StatementIconProvider.Trigger_Inventory_Below75;
}
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_inventory_" + type.name().toLowerCase());
}
@Override

View file

@ -8,6 +8,7 @@
*/
package buildcraft.core.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.statements.IStatementContainer;
@ -47,11 +48,7 @@ public class TriggerMachine extends BCStatement implements ITriggerExternal {
}
@Override
public int getIconIndex() {
if (active) {
return StatementIconProvider.Trigger_Machine_Active;
} else {
return StatementIconProvider.Trigger_Machine_Inactive;
}
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_machine_" + (active ? "active" : "inactive"));
}
}

View file

@ -8,6 +8,7 @@
*/
package buildcraft.core.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import buildcraft.api.gates.IGate;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
@ -62,7 +63,7 @@ public class TriggerRedstoneInput extends BCStatement implements ITriggerInterna
}
@Override
public int getIconIndex() {
return active ? StatementIconProvider.Trigger_RedstoneInput_Active : StatementIconProvider.Trigger_RedstoneInput_Inactive;
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_redstoneinput_" + (active ? "active" : "inactive"));
}
}

View file

@ -36,7 +36,7 @@ public class ActionParameterSignal implements IStatementParameter {
if (color == null) {
return null;
} else {
return icons[color.ordinal() & 3];
return icons[color.ordinal()];
}
}
@ -78,6 +78,9 @@ public class ActionParameterSignal implements IStatementParameter {
@Override
public String getDescription() {
if (color == null) {
return null;
}
return String.format(StringUtils.localize("gate.action.pipe.wire"), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH)));
}

View file

@ -10,6 +10,7 @@ package buildcraft.transport.statements;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
@ -34,21 +35,6 @@ public class ActionSignalOutput extends BCStatement implements IActionInternal {
return String.format(StringUtils.localize("gate.action.pipe.wire"), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH)));
}
@Override
public int getIconIndex() {
switch (color) {
case RED:
return StatementIconProvider.Trigger_PipeSignal_Red_Active;
case BLUE:
return StatementIconProvider.Trigger_PipeSignal_Blue_Active;
case GREEN:
return StatementIconProvider.Trigger_PipeSignal_Green_Active;
case YELLOW:
default:
return StatementIconProvider.Trigger_PipeSignal_Yellow_Active;
}
}
@Override
public int maxParameters() {
return 3;
@ -75,4 +61,9 @@ public class ActionSignalOutput extends BCStatement implements IActionInternal {
}
}
}
@Override
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_pipesignal_" + color.name().toLowerCase() + "_active");
}
}

View file

@ -20,6 +20,8 @@ import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.transport.PipeWire;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.Gate;
import buildcraft.transport.Pipe;
public class TriggerParameterSignal implements IStatementParameter {
@ -101,6 +103,9 @@ public class TriggerParameterSignal implements IStatementParameter {
@Override
public String getDescription() {
if (color == null) {
return null;
}
return String.format(StringUtils.localize("gate.trigger.pipe.wire." + (active ? "active" : "inactive")), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH)));
}

View file

@ -10,6 +10,7 @@ package buildcraft.transport.statements;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import buildcraft.api.gates.IGate;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
@ -83,32 +84,8 @@ public class TriggerPipeSignal extends BCStatement implements ITriggerInternal {
}
@Override
public int getIconIndex() {
if (active) {
switch (color) {
case RED:
return StatementIconProvider.Trigger_PipeSignal_Red_Active;
case BLUE:
return StatementIconProvider.Trigger_PipeSignal_Blue_Active;
case GREEN:
return StatementIconProvider.Trigger_PipeSignal_Green_Active;
case YELLOW:
return StatementIconProvider.Trigger_PipeSignal_Yellow_Active;
}
} else {
switch (color) {
case RED:
return StatementIconProvider.Trigger_PipeSignal_Red_Inactive;
case BLUE:
return StatementIconProvider.Trigger_PipeSignal_Blue_Inactive;
case GREEN:
return StatementIconProvider.Trigger_PipeSignal_Green_Inactive;
case YELLOW:
return StatementIconProvider.Trigger_PipeSignal_Yellow_Inactive;
}
}
return -1;
public void registerIcons(IIconRegister register) {
icon = register.registerIcon("buildcraft:triggers/trigger_pipesignal_" + color.name().toLowerCase() + "_" + (active ? "active" : "inactive"));
}
@Override