|
1 | 1 | package dev.compactmods.crafting.recipes.blocks; |
2 | 2 |
|
3 | | -import java.util.ArrayList; |
| 3 | +import java.util.Arrays; |
4 | 4 | import java.util.List; |
| 5 | +import java.util.stream.Collectors; |
5 | 6 | import com.google.common.collect.ImmutableList; |
6 | 7 | import com.mojang.datafixers.util.Pair; |
7 | 8 | import com.mojang.serialization.Codec; |
|
12 | 13 | import dev.compactmods.crafting.recipes.RecipeHelper; |
13 | 14 | import dev.compactmods.crafting.util.BlockSpaceUtil; |
14 | 15 | import net.minecraft.util.math.AxisAlignedBB; |
| 16 | +import net.minecraft.util.math.BlockPos; |
15 | 17 |
|
16 | 18 | public class ComponentPositionLookupCodec implements PrimitiveCodec<ComponentPositionLookup> { |
17 | 19 | @Override |
@@ -50,13 +52,11 @@ public <T> T write(DynamicOps<T> ops, ComponentPositionLookup lookup) { |
50 | 52 | BlockSpaceUtil.getBlocksIn(boundsForBlocks) |
51 | 53 | .map(pos -> Pair.of(pos.immutable(), lookup.getRequiredComponentKeyForPosition(pos).orElse("-"))) |
52 | 54 | .forEach(pair -> { |
53 | | - map[pair.getFirst().getZ()][pair.getFirst().getX()] = pair.getSecond(); |
| 55 | + final BlockPos p = pair.getFirst(); |
| 56 | + map[p.getX()][p.getZ()] = pair.getSecond(); |
54 | 57 | }); |
55 | 58 |
|
56 | | - List<List<String>> fin = new ArrayList<>(map.length); |
57 | | - for(int x = 0; x < boundsForBlocks.getXsize(); x++) { |
58 | | - fin.add(ImmutableList.copyOf(map[x])); |
59 | | - } |
| 59 | + List<List<String>> fin = Arrays.stream(map).map(ImmutableList::copyOf).collect(Collectors.toList()); |
60 | 60 |
|
61 | 61 | DataResult<T> encoded = Codec.STRING.listOf().listOf().encode(fin, ops, ops.empty()); |
62 | 62 |
|
|
0 commit comments