various fixes for gates

This commit is contained in:
SpaceToad 2014-07-05 13:29:09 +02:00
parent ffcd8188de
commit 57c338b9af
3 changed files with 28 additions and 33 deletions

View file

@ -69,7 +69,7 @@ public class TriggerInventoryLevel extends BCTrigger {
int stackSpace = 0;
int foundItems = 0;
for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side)) {
for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side.getOpposite())) {
if (slot.canPutStackInSlot(searchStack)) {
ItemStack stackInSlot = slot.getStackInSlot();
if (stackInSlot == null || StackHelper.canStacksMerge(stackInSlot, searchStack)) {

View file

@ -301,6 +301,8 @@ public final class Gate implements IGate {
int oldRedstoneOutput = redstoneOutput;
redstoneOutput = 0;
boolean wasActive = activeActions.size() > 0;
BitSet temp = prevBroadcastSignal;
temp.clear();
prevBroadcastSignal = broadcastSignal;
@ -311,7 +313,7 @@ public final class Gate implements IGate {
int [] actionGroups = new int [] {0, 1, 2, 3, 4, 5, 6, 7};
for (int i = 0; i < MAX_PARAMETERS; ++i) {
for (int i = 0; i < MAX_STATEMENTS; ++i) {
for (int j = i - 1; j >= 0; --j) {
if (actions[i] != null && actions[j] != null
&& actions[i].getUniqueTag().equals(actions[j].getUniqueTag())) {
@ -352,8 +354,8 @@ public final class Gate implements IGate {
activeActions = new ArrayList<ActionSlot>();
for (int it = 0; it < MAX_STATEMENTS; ++it) {
boolean andActivate = true;
boolean orActivate = false;
boolean allActive = true;
boolean oneActive = false;
if (actions[it] == null) {
continue;
@ -362,14 +364,14 @@ public final class Gate implements IGate {
for (int j = 0; j < MAX_STATEMENTS; ++j) {
if (actionGroups[j] == it) {
if (actionsState[j] != ActionActiveState.Partial) {
andActivate = false;
allActive = false;
} else {
orActivate = true;
oneActive = true;
}
}
}
if ((logic == GateLogic.AND && andActivate) || (logic == GateLogic.OR && orActivate)) {
if ((logic == GateLogic.AND && allActive && oneActive) || (logic == GateLogic.OR && oneActive)) {
if (logic == GateLogic.AND) {
for (int j = 0; j < MAX_STATEMENTS; ++j) {
if (actionGroups[j] == it) {
@ -420,16 +422,18 @@ public final class Gate implements IGate {
pipe.actionsActivated(activeActions);
if (oldRedstoneOutput != redstoneOutput) {
if (redstoneOutput == 0 ^ oldRedstoneOutput == 0) {
pipe.container.scheduleRenderUpdate();
}
pipe.updateNeighbors(true);
}
if (!prevBroadcastSignal.equals(broadcastSignal)) {
pipe.container.scheduleRenderUpdate();
pipe.updateSignalState();
}
boolean isActive = activeActions.size() > 0;
if (wasActive != isActive) {
pipe.container.scheduleRenderUpdate();
}
}
public boolean resolveAction(IAction action) {

View file

@ -293,7 +293,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
PipeType pipeType = pipe.getPipeType();
// do not use switch. we will be transitioning away from the enum
if (pipeType == PipeType.ITEM) {
if (pipeType == PipeType.ITEM) {
renderSolids(pipe.pipe, x, y, z);
} else if (pipeType == PipeType.FLUID) {
renderFluids(pipe.pipe, x, y, z);
@ -562,33 +562,24 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
zeroState[2][0] = min;
zeroState[2][1] = max;
if (shouldRenderNormalPipeSide(state, direction)) {
GL11.glPushMatrix();
GL11.glPushMatrix();
float xt = direction.offsetX * translateCenter,
yt = direction.offsetY * translateCenter,
zt = direction.offsetZ * translateCenter;
float xt = direction.offsetX * translateCenter, yt = direction.offsetY * translateCenter, zt = direction.offsetZ
* translateCenter;
GL11.glTranslatef(xt, yt, zt);
GL11.glTranslatef(xt, yt, zt);
float[][] rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, direction);
float[][] rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, direction);
if (layer != 0) {
renderBox.setRenderSingleSide(direction.ordinal());
}
renderBox.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
RenderEntityBlock.INSTANCE.renderBlock(renderBox, tile.getWorldObj(), 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true);
GL11.glPopMatrix();
if (layer != 0) {
renderBox.setRenderSingleSide(direction.ordinal());
}
}
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
return !state.pipeConnectionMatrix.isConnected(direction)
&& state.facadeMatrix.getFacadeBlock(direction) == null
&& !state.plugMatrix.isConnected(direction)
&& !state.robotStationMatrix.isConnected(direction)
&& !isOpenOrientation(state, direction);
renderBox.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
RenderEntityBlock.INSTANCE.renderBlock(renderBox, tile.getWorldObj(), 0, 0, 0, tile.xCoord, tile.yCoord,
tile.zCoord, true, true);
GL11.glPopMatrix();
}
public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) {