Skip to content

Commit 477fee6

Browse files
committed
Fix multi-layer offset issues
1 parent fcbfd1f commit 477fee6

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

src/main/java/com/robotgryphon/compactcrafting/core/Registration.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,18 @@ public class Registration {
105105
Collections.addAll(template, complexPattern);
106106

107107
rec.setLayers(new IRecipeLayer[]{
108-
new SingleComponentRecipeLayer("S", template)
109-
// new SingleComponentRecipeLayer("O", template),
110-
// new SingleComponentRecipeLayer("G", template)
108+
new SingleComponentRecipeLayer("O", template),
109+
new SingleComponentRecipeLayer("G", template)
110+
111111
});
112112

113-
rec.catalyst = Items.GLASS;
113+
rec.catalyst = Items.ANVIL;
114114
rec.outputs = new ItemStack[]{
115-
new ItemStack(Items.BELL, 1)
115+
new ItemStack(Items.CRYING_OBSIDIAN, 11)
116116
};
117117

118-
rec.addComponent("S", Blocks.STONE.getDefaultState());
119-
// rec.addComponent("O", Blocks.OBSIDIAN.getDefaultState());
120-
// rec.addComponent("G", Blocks.GLOWSTONE.getDefaultState());
118+
rec.addComponent("O", Blocks.OBSIDIAN.getDefaultState());
119+
rec.addComponent("G", Blocks.GLOWSTONE.getDefaultState());
121120

122121
return rec;
123122
});

src/main/java/com/robotgryphon/compactcrafting/recipes/MiniaturizationRecipe.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ private boolean checkRotation(IWorldReader world, Rotation rot, AxisAlignedBB fi
127127
Map<BlockPos, BlockPos> layerRotated = BlockSpaceUtil.rotatePositionsInPlace(layerFilled, rot);
128128

129129
// Check that the rotated positions are correct
130-
boolean layerMatches = areLayerPositionsCorrect(filledBounds, layerRotated.values().toArray(new BlockPos[0]));
130+
boolean layerMatches = areLayerPositionsCorrect(layer.get(), filledBounds, layerRotated.values().toArray(new BlockPos[0]));
131131
if (!layerMatches)
132132
return false;
133133

134134
// Check the states are correct
135135
for(BlockPos unrotatedPos : layerFilled) {
136136
BlockPos rotatedPos = layerRotated.get(unrotatedPos);
137-
BlockPos normalizedRotatedPos = BlockSpaceUtil.normalizeLayerPosition(filledBounds, rotatedPos);
137+
BlockPos normalizedRotatedPos = BlockSpaceUtil.normalizeLayerPosition(filledBounds, rotatedPos).down(offset);
138138

139139
BlockState actualState = world.getBlockState(unrotatedPos);
140140

@@ -194,19 +194,13 @@ public AxisAlignedBB getDimensions() {
194194
* @param filledPositions The filled positions on the layer to check.
195195
* @return
196196
*/
197-
public boolean areLayerPositionsCorrect(AxisAlignedBB fieldFilledBounds, BlockPos[] filledPositions) {
197+
public boolean areLayerPositionsCorrect(IRecipeLayer layer, AxisAlignedBB fieldFilledBounds, BlockPos[] filledPositions) {
198198
// Recipe layers using this method must define at least one filled space
199199
if (filledPositions.length == 0)
200200
return false;
201201

202-
Optional<IRecipeLayer> layer = getRecipeLayerFromPositions(fieldFilledBounds, filledPositions);
203-
if (!layer.isPresent())
204-
return false;
205-
206-
IRecipeLayer l = layer.get();
207-
208202
int totalFilled = filledPositions.length;
209-
int requiredFilled = l.getNumberFilledPositions();
203+
int requiredFilled = layer.getNumberFilledPositions();
210204

211205
// Early exit if we don't have the correct number of blocks in the layer
212206
if (totalFilled != requiredFilled)
@@ -226,7 +220,7 @@ public boolean areLayerPositionsCorrect(AxisAlignedBB fieldFilledBounds, BlockPo
226220

227221
return Arrays.stream(fieldNormalizedPositionsLayerOffset)
228222
.parallel()
229-
.allMatch(l::isPositionRequired);
223+
.allMatch(layer::isPositionRequired);
230224
}
231225

232226
private Optional<IRecipeLayer> getRecipeLayerFromPositions(AxisAlignedBB fieldFilledBounds, BlockPos[] filledPositions) {

0 commit comments

Comments
 (0)