Fixed Icon API for Actions/Triggers

This commit is contained in:
Krapht 2013-04-11 19:28:34 +02:00
parent 08f0216be7
commit b624b5dd9f
17 changed files with 79 additions and 142 deletions

View file

@ -1,6 +1,5 @@
package buildcraft.api.gates;
import net.minecraft.util.Icon;
import buildcraft.api.core.IIconProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -9,8 +8,7 @@ public interface IAction {
int getId();
@SideOnly(Side.CLIENT)
Icon getTexture();
int getIconIndex();
@SideOnly(Side.CLIENT)
IIconProvider getIconProvider();

View file

@ -1,21 +1,16 @@
package buildcraft.api.gates;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.IIconProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.ForgeDirection;
public interface ITrigger {
public abstract int getId();
/**
* Return the texture file for this trigger icon
*/
@SideOnly(Side.CLIENT)
public Icon getTextureIcon();
public int getIconIndex();
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider();

View file

@ -1,8 +1,5 @@
package buildcraft.core.triggers;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ActionMachineControl extends BCAction {
@ -31,20 +28,17 @@ public class ActionMachineControl extends BCAction {
return "";
}
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
public int getIconIndex() {
switch (mode) {
case On:
return getIconProvider().getIcon(ActionTriggerIconProvider.Action_MachineControl_On);
return ActionTriggerIconProvider.Action_MachineControl_On;
case Off:
return getIconProvider().getIcon(ActionTriggerIconProvider.Action_MachineControl_Off);
return ActionTriggerIconProvider.Action_MachineControl_Off;
case Loop:
return getIconProvider().getIcon(ActionTriggerIconProvider.Action_MachineControl_Loop);
default:
return null;
}
return ActionTriggerIconProvider.Action_MachineControl_Loop;
}
}
}

View file

@ -9,9 +9,6 @@
package buildcraft.core.triggers;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ActionRedstoneOutput extends BCAction {
@ -25,8 +22,7 @@ public class ActionRedstoneOutput extends BCAction {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_RedstoneInput_Active);
public int getIconIndex() {
return ActionTriggerIconProvider.Trigger_RedstoneInput_Active;
}
}

View file

@ -9,7 +9,6 @@
package buildcraft.core.triggers;
import net.minecraft.util.Icon;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager;
@ -32,8 +31,7 @@ public abstract class BCAction implements IAction {
}
@Override
@SideOnly(Side.CLIENT)
public abstract Icon getTexture();
public abstract int getIconIndex();
@Override
public boolean hasParameter() {

View file

@ -10,7 +10,7 @@
package buildcraft.core.triggers;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager;
@ -19,7 +19,6 @@ import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.gates.TriggerParameter;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.ForgeDirection;
/**
* This class has to be implemented to create new triggers kinds to BuildCraft gates. There is an instance per kind, which will get called wherever the trigger
@ -39,15 +38,14 @@ public abstract class BCTrigger implements ITrigger {
return this.id;
}
@Override
@SideOnly(Side.CLIENT)
public abstract Icon getTextureIcon();
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return BuildCraftCore.instance.actionTriggerIconProvider;
}
@Override
public abstract int getIconIndex();
@Override
public boolean hasParameter() {

View file

@ -12,14 +12,11 @@ package buildcraft.core.triggers;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.utils.SidedInventoryAdapter;
import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TriggerInventory extends BCTrigger {
@ -115,17 +112,16 @@ public class TriggerInventory extends BCTrigger {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
switch (state) {
case Empty:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Inventory_Empty);
return ActionTriggerIconProvider.Trigger_Inventory_Empty;
case Contains:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Inventory_Contains);
return ActionTriggerIconProvider.Trigger_Inventory_Contains;
case Space:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Inventory_Space);
return ActionTriggerIconProvider.Trigger_Inventory_Space;
default:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Inventory_Full);
return ActionTriggerIconProvider.Trigger_Inventory_Full;
}
}
}

View file

@ -10,15 +10,12 @@
package buildcraft.core.triggers;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import buildcraft.api.gates.ITriggerParameter;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TriggerLiquidContainer extends BCTrigger {
@ -124,17 +121,16 @@ public class TriggerLiquidContainer extends BCTrigger {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
switch (state) {
case Empty:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_LiquidContainer_Empty);
return ActionTriggerIconProvider.Trigger_LiquidContainer_Empty;
case Contains:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_LiquidContainer_Contains);
return ActionTriggerIconProvider.Trigger_LiquidContainer_Contains;
case Space:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_LiquidContainer_Space);
return ActionTriggerIconProvider.Trigger_LiquidContainer_Space;
default:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_LiquidContainer_Full);
return ActionTriggerIconProvider.Trigger_LiquidContainer_Full;
}
}
}

View file

@ -10,12 +10,9 @@
package buildcraft.core.triggers;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.IMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.ForgeDirection;
public class TriggerMachine extends BCTrigger {
@ -50,11 +47,10 @@ public class TriggerMachine extends BCTrigger {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
if (active)
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Machine_Active);
return ActionTriggerIconProvider.Trigger_Machine_Active;
else
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Machine_Inactive);
return ActionTriggerIconProvider.Trigger_Machine_Inactive;
}
}
}

View file

@ -10,13 +10,10 @@
package buildcraft.energy;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCTrigger;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.ForgeDirection;
public class TriggerEngineHeat extends BCTrigger {
@ -54,17 +51,16 @@ public class TriggerEngineHeat extends BCTrigger {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
switch (stage) {
case Blue:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_EngineHeat_Blue);
return ActionTriggerIconProvider.Trigger_EngineHeat_Blue;
case Green:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_EngineHeat_Green);
return ActionTriggerIconProvider.Trigger_EngineHeat_Green;
case Yellow:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_EngineHeat_Yellow);
return ActionTriggerIconProvider.Trigger_EngineHeat_Yellow;
default:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_EngineHeat_Red);
return ActionTriggerIconProvider.Trigger_EngineHeat_Red;
}
}
}

View file

@ -61,7 +61,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
public Icon getTexture() {
ITrigger trigger = pipe.getTrigger(slot);
if (trigger != null)
return trigger.getTextureIcon();
return trigger.getIconProvider().getIcon(trigger.getIconIndex());
else
return null;
}
@ -102,7 +102,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
public Icon getTexture() {
IAction action = pipe.getAction(slot);
if (action != null)
return action.getTexture();
return action.getIconProvider().getIcon(action.getIconIndex());
else
return null;
}

View file

@ -1,10 +1,7 @@
package buildcraft.transport.triggers;
import net.minecraft.util.Icon;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCAction;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ActionEnergyPulser extends BCAction {
@ -13,11 +10,10 @@ public class ActionEnergyPulser extends BCAction {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Machine_Active);
public int getIconIndex() {
return ActionTriggerIconProvider.Trigger_Machine_Active;
}
@Override
public String getDescription() {
return "Energy Pulser";

View file

@ -9,12 +9,9 @@
package buildcraft.transport.triggers;
import net.minecraft.util.Icon;
import buildcraft.api.transport.IPipe;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCAction;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ActionSignalOutput extends BCAction {
@ -43,19 +40,17 @@ public class ActionSignalOutput extends BCAction {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
public int getIconIndex() {
switch (color) {
case Red:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active;
case Blue:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active;
case Green:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Green_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Green_Active;
case Yellow:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active);
default:
return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active;
}
return null;
}
}

View file

@ -1,10 +1,7 @@
package buildcraft.transport.triggers;
import net.minecraft.util.Icon;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCAction;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ActionSingleEnergyPulse extends BCAction {
@ -12,15 +9,13 @@ public class ActionSingleEnergyPulse extends BCAction {
super(id);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_Machine_Active);
}
@Override
public int getIconIndex() {
return ActionTriggerIconProvider.Trigger_Machine_Active;
}
@Override
public String getDescription() {
return "Single Energy Pulse";
}
}

View file

@ -9,7 +9,6 @@
package buildcraft.transport.triggers;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.LiquidContainerRegistry;
@ -23,8 +22,6 @@ import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.PipeTransportLiquids;
import buildcraft.transport.PipeTransportPower;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
@ -127,18 +124,18 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
switch (kind) {
case Empty:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeContents_Empty);
case ContainsItems:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeContents_ContainsItems);
case ContainsLiquids:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeContents_ContainsLiquid);
case ContainsEnergy:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeContents_ContainsEnergy);
case Empty:
return ActionTriggerIconProvider.Trigger_PipeContents_Empty;
case ContainsItems:
return ActionTriggerIconProvider.Trigger_PipeContents_ContainsItems;
case ContainsLiquids:
return ActionTriggerIconProvider.Trigger_PipeContents_ContainsLiquid;
case ContainsEnergy:
default:
return ActionTriggerIconProvider.Trigger_PipeContents_ContainsEnergy;
}
return null;
}
}

View file

@ -9,15 +9,12 @@
package buildcraft.transport.triggers;
import net.minecraft.util.Icon;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.transport.ITriggerPipe;
import buildcraft.transport.Pipe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TriggerPipeSignal extends BCTrigger implements ITriggerPipe {
@ -72,34 +69,32 @@ public class TriggerPipeSignal extends BCTrigger implements ITriggerPipe {
else
return pipe.signalStrength[color.ordinal()] == 0;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
if (active) {
switch (color) {
case Red:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active;
case Blue:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active;
case Green:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Green_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Green_Active;
case Yellow:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active);
return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active;
}
} else {
switch (color) {
case Red:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Red_Inactive);
return ActionTriggerIconProvider.Trigger_PipeSignal_Red_Inactive;
case Blue:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Inactive);
return ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Inactive;
case Green:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Green_Inactive);
return ActionTriggerIconProvider.Trigger_PipeSignal_Green_Inactive;
case Yellow:
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Inactive);
return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Inactive;
}
}
return null;
return -1;
}
}

View file

@ -9,14 +9,11 @@
package buildcraft.transport.triggers;
import net.minecraft.util.Icon;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.transport.ITriggerPipe;
import buildcraft.transport.Pipe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TriggerRedstoneInput extends BCTrigger implements ITriggerPipe {
@ -43,13 +40,12 @@ public class TriggerRedstoneInput extends BCTrigger implements ITriggerPipe {
else
return !pipe.worldObj.isBlockIndirectlyGettingPowered(pipe.xCoord, pipe.yCoord, pipe.zCoord);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getTextureIcon() {
public int getIconIndex() {
if (active)
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_RedstoneInput_Active);
return ActionTriggerIconProvider.Trigger_RedstoneInput_Active;
else
return getIconProvider().getIcon(ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive);
return ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive;
}
}