Skip to content

Commit

Permalink
Remove CC, small internal change on pulse trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
KorewaLidesu committed Sep 20, 2023
1 parent b82ae3c commit 7696db8
Showing 1 changed file with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import logisticspipes.pipes.basic.CoreRoutedPipe;
import logisticspipes.proxy.MainProxy;
import logisticspipes.proxy.SimpleServiceLocator;
import logisticspipes.proxy.computers.interfaces.CCCommand;
import logisticspipes.proxy.computers.interfaces.CCType;
import logisticspipes.request.*;
import logisticspipes.request.resources.DictResource;
import logisticspipes.request.resources.IResource;
Expand Down Expand Up @@ -72,19 +70,17 @@
import network.rs485.logisticspipes.pipes.IChassisPipe;
import network.rs485.logisticspipes.property.SlottedModule;

@CCType(name = "TestBridge:CraftingManager")
public class PipeCraftingManager extends CoreRoutedPipe implements ICraftItems, ISimpleInventoryEventHandler,
ISendRoutedItem, IChassisPipe, IChangeListener, ISendQueueContentRecieiver {

private boolean initial = false;
private final TB_ModuleCM moduleCM;
private final ItemIdentifierInventory _moduleInventory;
private final NonNullList<ModuleUpgradeManager> slotUpgradeManagers = NonNullList.create();
private boolean isRedstone = false;
private boolean isPoweredRedstone = false;
public final PlayerCollectionList localModeWatchers = new PlayerCollectionList();
@Nullable private SingleAdjacent pointedAdjacent = null;

@CCCommand(description = "Returns the size of this container pipe")
public int getChassisSize() {
return 27;
}
Expand All @@ -93,7 +89,6 @@ public PipeCraftingManager(Item item) {
super(item);
_moduleInventory = new ItemIdentifierInventory(getChassisSize(), "Crafting Manager", 1);
_moduleInventory.addListener(this);
assert slotUpgradeManagers.size() == 0; // starting at index 0
for (int i = 0; i < getChassisSize(); i++) {
addModuleUpgradeManager();
}
Expand Down Expand Up @@ -136,7 +131,7 @@ public void writeToNBT(@Nonnull NBTTagCompound nbttagcompound) {
pointedAdjacent == null ? -1
: pointedAdjacent.getDir()
.ordinal());
nbttagcompound.setBoolean("isRedstone", isRedstone);
nbttagcompound.setBoolean("isPoweredRedstone", isPoweredRedstone);
for (int i = 0; i < getChassisSize(); i++) {
slotUpgradeManagers.get(i)
.writeToNBT(nbttagcompound, Integer.toString(i));
Expand All @@ -152,7 +147,7 @@ public void readFromNBT(@Nonnull NBTTagCompound nbttagcompound) {
if (tmp != -1) {
setPointedOrientation(EnumFacingUtil.getOrientation(tmp % 6));
}
isRedstone = nbttagcompound.getBoolean("isRedstone");
isPoweredRedstone = nbttagcompound.getBoolean("isPoweredRedstone");
for (int i = 0; i < getChassisSize(); i++) {
final ItemIdentifierStack idStack = _moduleInventory.getIDStackInSlot(i);
if (idStack != null && !moduleCM.hasModule(i)) {
Expand Down Expand Up @@ -187,17 +182,18 @@ public void onNeighborBlockChange() {

boolean isPulse = false;

// Check if redstone pulse
if (!isRedstone) {
if (getWorld().isBlockPowered(getPos())) {
isPulse = isRedstone = getWorld().isBlockPowered(getPos());
}
// Check if pulse
if (!isPoweredRedstone) {
isPulse = isPoweredRedstone != getWorld().isBlockPowered(getPos());
}

isRedstone = getWorld().isBlockPowered(getPos());
// Reset powered state
isPoweredRedstone = getWorld().isBlockPowered(getPos());

if (!this.getWorld().isRemote && moduleCM.blockingMode.getValue()
.equals(TB_ModuleCM.BlockingMode.REDSTONE_PULSE) && moduleCM.hasItemsToCraft() && isPulse) {
if (!this.getWorld().isRemote && moduleCM.hasItemsToCraft()
&& moduleCM.blockingMode
.getValue().equals(TB_ModuleCM.BlockingMode.REDSTONE_PULSE)
&& isPulse) {
moduleCM.startCrafting();
}
}
Expand Down

0 comments on commit 7696db8

Please sign in to comment.