Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void tick(MovementContext context) {
context.data.putInt("OpenTicks", ticksOpen);
if (ticksOpen > 20) {
BlockPos pos = context.localPos;
int oldLightMode = context.state.getValue(HeadTailLightBlockBase.LIGHT_MODE);
if (context.contraption.entity instanceof CarriageContraptionEntity cce && context.contraption instanceof CarriageContraption cc) {
Direction assemblyDirection = cc.getAssemblyDirection();
if (assemblyDirection == Direction.UP || assemblyDirection == Direction.DOWN) {
Expand Down Expand Up @@ -80,80 +79,77 @@ public void tick(MovementContext context) {
value = globalP.subtract(globalN);
}

if (direction == Direction.NORTH) {
if (value.z > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
} else if (direction == Direction.EAST) {
if (value.x > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
} else if (direction == Direction.SOUTH) {
if (value.z > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
} else if (direction == Direction.WEST) {
if (value.x > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
}

if (locked) {
if (context.state.getValue(HeadTailLightBlockBase.LIGHT_MODE) != oldLightMode) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, oldLightMode);
context.state = context.state .setValue(HeadTailLightBlockBase.LIT, false);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
else {
context.state = context.state .setValue(HeadTailLightBlockBase.LIT, true);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
context.state = context.state .setValue(HeadTailLightBlockBase.LIT, true);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else {
tickLightMode(context, value, direction, localXZ, pos, structureBlockInfo);
}
}
context.data.putInt("OpenTicks", 0);
}
}

private void tickLightMode(MovementContext context, Vec3 value, Direction direction, int localXZ, BlockPos pos, StructureTemplate.StructureBlockInfo structureBlockInfo) {
if (direction == Direction.NORTH) {
if (value.z > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
} else if (direction == Direction.EAST) {
if (value.x > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
} else if (direction == Direction.SOUTH) {
if (value.z > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.z < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
} else if (direction == Direction.WEST) {
if (value.x > 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x > 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ > 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 0);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
} else if (value.x < 0 && localXZ < 0) {
context.state = context.state .setValue(HeadTailLightBlockBase.LIGHT_MODE, 1);
context.contraption.entity.setBlock(pos, new StructureTemplate.StructureBlockInfo(pos, context.state, structureBlockInfo.nbt()));
}
}
}

protected void tickLIT(MovementContext context, boolean currentlyOpen) {
boolean shouldLIT = shouldLIT(context);
if (!shouldUpdate(context, shouldLIT))
Expand Down