BuildCraft|Core

BuildCraft|Core

7M Downloads

Gates created twice

SpaceToad opened this issue ยท 3 comments

commented

@Prototik - this seems like one for you, following changes in multi-side gates. This is directly linked to #1895. The problematic call stack is the following:

ItemGate$GatePluggable.onAttachedPipe(IPipeTile, ForgeDirection) line: 130
TileGenericPipe.setPluggable(ForgeDirection, IPipePluggable) line: 856
TileGenericPipe.addGate(ForgeDirection, Gate) line: 827
BlockGenericPipe.addGate(EntityPlayer, Pipe<?>, ForgeDirection) line: 864

in addGate, we have:

if (stack != null && stack.getItem() instanceof ItemGate && pipe.container.addGate(side, GateFactory.makeGate(pipe, stack, side))) {

so one gate is created. But later down the stack, in the onAttachedPipe, we get:

pipeReal.pipe.gates[direction.ordinal()] = GateFactory.makeGate(pipeReal.pipe, material, logic, direction);

So a gate is created again, passing through a IPluggable in between. There clearly should not be two gates created. This causes further problem when looking at gate extensions.

Let me know if you can take over this one. I'll resume work on #1895 after that if needed.

commented

Indeed, working...

commented

Shouldn't the addGate() function in TileGenericPipe set the pipe.gates[direction.ordinal()] to the gate passed to it, like the legacy method setGate does?
Then, because the pipe.gates[direction.ordinal()] would be set to the gate, and the check would return false, the gate would not be created twice.

Unless the gates array in Pipe is also legacy and it's all done through IPluggables now, which would mean the GatePluggable method onAttachedPipe should be changed to check the pluggable array, right?

I'm not sure which of those is the case, so I don't want to submit a PR so it doesn't turn out to be wrong.

commented

I'm doing this blind. @SpaceToad - it seems to fix all gate expansion bugs, but I do NOT promise that this was the right idea!