Finished Trigger updates
This commit is contained in:
parent
a19470092e
commit
897eee58dc
11 changed files with 87 additions and 97 deletions
|
@ -157,8 +157,6 @@ public class BuildCraftCore {
|
|||
|
||||
public static final Logger bcLog = Logger.getLogger("Buildcraft");
|
||||
|
||||
public IIconProvider actionTriggerIconProvider = new ActionTriggerIconProvider();
|
||||
|
||||
@Instance("BuildCraft|Core")
|
||||
public static BuildCraftCore instance;
|
||||
|
||||
|
@ -314,7 +312,7 @@ public class BuildCraftCore {
|
|||
if (event.map.textureType == 1) {
|
||||
iconProvider = new CoreIconProvider();
|
||||
iconProvider.registerIcons(event.map);
|
||||
actionTriggerIconProvider.registerIcons(event.map);
|
||||
ActionTriggerIconProvider.INSTANCE.registerIcons(event.map);
|
||||
} else if (event.map.textureType == 0) {
|
||||
BuildCraftCore.redLaserTexture = event.map.registerIcon("buildcraft:blockRedLaser");
|
||||
BuildCraftCore.blueLaserTexture = event.map.registerIcon("buildcraft:blockBlueLaser");
|
||||
|
|
|
@ -65,9 +65,6 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
if(icons != null)
|
||||
return;
|
||||
|
||||
icons = new Icon[MAX];
|
||||
|
||||
icons[ActionTriggerIconProvider.Action_MachineControl_On] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_on");
|
||||
|
|
|
@ -48,7 +48,6 @@ public abstract class BCAction implements IAction {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
ActionTriggerIconProvider.INSTANCE.registerIcons(iconRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,7 +57,6 @@ public abstract class BCTrigger implements ITrigger {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
ActionTriggerIconProvider.INSTANCE.registerIcons(iconRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.core.triggers;
|
||||
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.inventory.ISpecialInventory;
|
||||
import buildcraft.core.inventory.InventoryWrapper;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -21,13 +20,13 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class TriggerInventory extends BCTrigger {
|
||||
|
||||
public enum State {
|
||||
|
||||
Empty, Contains, Space, Full
|
||||
};
|
||||
|
||||
public State state;
|
||||
|
||||
public TriggerInventory(int id, State state) {
|
||||
super(id);
|
||||
public TriggerInventory(int legacyId, State state) {
|
||||
super(legacyId, "buildcraft.inventory." + state.name().toLowerCase(Locale.ENGLISH));
|
||||
|
||||
this.state = state;
|
||||
}
|
||||
|
@ -43,14 +42,14 @@ public class TriggerInventory extends BCTrigger {
|
|||
@Override
|
||||
public String getDescription() {
|
||||
switch (state) {
|
||||
case Empty:
|
||||
return "Inventory Empty";
|
||||
case Contains:
|
||||
return "Items in Inventory";
|
||||
case Space:
|
||||
return "Space in Inventory";
|
||||
default:
|
||||
return "Inventory Full";
|
||||
case Empty:
|
||||
return "Inventory Empty";
|
||||
case Contains:
|
||||
return "Items in Inventory";
|
||||
case Space:
|
||||
return "Space in Inventory";
|
||||
default:
|
||||
return "Inventory Full";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,19 +65,19 @@ public class TriggerInventory extends BCTrigger {
|
|||
ISpecialInventory specialInventory = (ISpecialInventory) tile;
|
||||
ItemStack[] itemStacks;
|
||||
switch (state) {
|
||||
case Contains:
|
||||
itemStacks = specialInventory.extractItem(false, side, 1);
|
||||
return itemStacks != null && itemStacks.length > 0 && itemStacks[0] != null && itemStacks[0].stackSize > 0 && (searchedStack == null || itemStacks[0].isItemEqual(searchedStack));
|
||||
case Empty:
|
||||
itemStacks = specialInventory.extractItem(false, side, 1);
|
||||
return itemStacks == null || itemStacks.length == 0 || itemStacks[0] == null || itemStacks[0].stackSize == 0;
|
||||
case Full:
|
||||
break;
|
||||
case Space:
|
||||
if (searchedStack == null)
|
||||
case Contains:
|
||||
itemStacks = specialInventory.extractItem(false, side, 1);
|
||||
return itemStacks != null && itemStacks.length > 0 && itemStacks[0] != null && itemStacks[0].stackSize > 0 && (searchedStack == null || itemStacks[0].isItemEqual(searchedStack));
|
||||
case Empty:
|
||||
itemStacks = specialInventory.extractItem(false, side, 1);
|
||||
return itemStacks == null || itemStacks.length == 0 || itemStacks[0] == null || itemStacks[0].stackSize == 0;
|
||||
case Full:
|
||||
break;
|
||||
int added = specialInventory.addItem(searchedStack, false, side);
|
||||
return added > 0;
|
||||
case Space:
|
||||
if (searchedStack == null)
|
||||
break;
|
||||
int added = specialInventory.addItem(searchedStack, false, side);
|
||||
return added > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +112,14 @@ public class TriggerInventory extends BCTrigger {
|
|||
}
|
||||
|
||||
switch (state) {
|
||||
case Empty:
|
||||
return !foundItems;
|
||||
case Contains:
|
||||
return foundItems;
|
||||
case Space:
|
||||
return foundSpace;
|
||||
default:
|
||||
return !foundSpace;
|
||||
case Empty:
|
||||
return !foundItems;
|
||||
case Contains:
|
||||
return foundItems;
|
||||
case Space:
|
||||
return foundSpace;
|
||||
default:
|
||||
return !foundSpace;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,14 +129,14 @@ public class TriggerInventory extends BCTrigger {
|
|||
@Override
|
||||
public int getIconIndex() {
|
||||
switch (state) {
|
||||
case Empty:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Empty;
|
||||
case Contains:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Contains;
|
||||
case Space:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Space;
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Full;
|
||||
case Empty:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Empty;
|
||||
case Contains:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Contains;
|
||||
case Space:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Space;
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Full;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.core.triggers;
|
||||
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
|
@ -18,8 +16,8 @@ public class TriggerMachine extends BCTrigger {
|
|||
|
||||
boolean active;
|
||||
|
||||
public TriggerMachine(int id, boolean active) {
|
||||
super(id);
|
||||
public TriggerMachine(int legacyId, boolean active) {
|
||||
super(legacyId, "buildcraft.work." + (active ? "scheduled" : "done"));
|
||||
|
||||
this.active = active;
|
||||
}
|
||||
|
@ -53,4 +51,4 @@ public class TriggerMachine extends BCTrigger {
|
|||
else
|
||||
return ActionTriggerIconProvider.Trigger_Machine_Inactive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import buildcraft.core.triggers.BCAction;
|
|||
|
||||
public class ActionEnergyPulser extends BCAction {
|
||||
|
||||
public ActionEnergyPulser(int id) {
|
||||
super(id);
|
||||
public ActionEnergyPulser(int legacyId) {
|
||||
super(legacyId, "buildcraft.pulser.constant");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,13 +12,14 @@ package buildcraft.transport.triggers;
|
|||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.core.triggers.ActionTriggerIconProvider;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ActionSignalOutput extends BCAction {
|
||||
|
||||
public IPipe.WireColor color;
|
||||
|
||||
public ActionSignalOutput(int id, IPipe.WireColor color) {
|
||||
super(id);
|
||||
super(id, "buildcraft.pipe.wire.output." + color.name().toLowerCase(Locale.ENGLISH));
|
||||
|
||||
this.color = color;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import buildcraft.core.triggers.BCAction;
|
|||
|
||||
public class ActionSingleEnergyPulse extends BCAction {
|
||||
|
||||
public ActionSingleEnergyPulse(int id) {
|
||||
super(id);
|
||||
public ActionSingleEnergyPulse(int legacyId) {
|
||||
super(legacyId, "buildcraft.pulser.single");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.triggers;
|
||||
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.core.triggers.ActionTriggerIconProvider;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.transport.TileFilteredBuffer;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -21,13 +20,13 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
|
||||
|
||||
public enum State {
|
||||
|
||||
Below25, Below50, Below75
|
||||
};
|
||||
|
||||
public State state;
|
||||
|
||||
public TriggerFilteredBufferInventoryLevel(int id, State state) {
|
||||
super(id);
|
||||
public TriggerFilteredBufferInventoryLevel(int legacyId, State state) {
|
||||
super(legacyId, "buildcraft.filteredBuffer." + state.name().toLowerCase(Locale.ENGLISH));
|
||||
|
||||
this.state = state;
|
||||
}
|
||||
|
@ -40,12 +39,12 @@ public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
|
|||
@Override
|
||||
public String getDescription() {
|
||||
switch (state) {
|
||||
case Below25:
|
||||
return "Contains < 25%";
|
||||
case Below50:
|
||||
return "Contains < 50%";
|
||||
default:
|
||||
return "Contains < 75%";
|
||||
case Below25:
|
||||
return "Contains < 25%";
|
||||
case Below50:
|
||||
return "Contains < 50%";
|
||||
default:
|
||||
return "Contains < 75%";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +56,7 @@ public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
|
|||
if (parameter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile;
|
||||
ItemStack searchStack = parameter.getItem();
|
||||
|
||||
|
@ -65,23 +64,23 @@ public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
|
|||
int foundItemCount = 0;
|
||||
|
||||
IInventory filters = filteredBuffer.getFilters();
|
||||
|
||||
for (int i = 0 ; i < filters.getSizeInventory() ; i++) {
|
||||
|
||||
for (int i = 0; i < filters.getSizeInventory(); i++) {
|
||||
ItemStack filterStack = filters.getStackInSlot(i);
|
||||
|
||||
|
||||
if (filterStack != null && filterStack.isItemEqual(searchStack)) {
|
||||
ItemStack foundStack = filteredBuffer.getStackInSlot(i);
|
||||
|
||||
if(foundStack != null)
|
||||
|
||||
if (foundStack != null)
|
||||
foundItemCount += foundStack.stackSize;
|
||||
|
||||
|
||||
foundStackCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (foundStackCount > 0) {
|
||||
float percentage = (float)foundItemCount / ((float)foundStackCount * (float)searchStack.getMaxStackSize());
|
||||
|
||||
float percentage = (float) foundItemCount / ((float) foundStackCount * (float) searchStack.getMaxStackSize());
|
||||
|
||||
switch (state) {
|
||||
case Below25:
|
||||
return percentage < 0.25f;
|
||||
|
@ -92,19 +91,19 @@ public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconIndex() {
|
||||
switch (state) {
|
||||
case Below25:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below25;
|
||||
case Below50:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below50;
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below75;
|
||||
case Below25:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below25;
|
||||
case Below50:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below50;
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below75;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class TriggerPipeSignal extends BCTrigger implements ITriggerPipe {
|
|||
IPipe.WireColor color;
|
||||
|
||||
public TriggerPipeSignal(int legacyId, boolean active, IPipe.WireColor color) {
|
||||
super(legacyId, "buildcraft.pipe.wire." + color.name().toLowerCase(Locale.ENGLISH) + (active ? ".active" : ".inactive"));
|
||||
super(legacyId, "buildcraft.pipe.wire.input." + color.name().toLowerCase(Locale.ENGLISH) + (active ? ".active" : ".inactive"));
|
||||
|
||||
this.active = active;
|
||||
this.color = color;
|
||||
|
|
Loading…
Reference in a new issue