|
1 | 1 | package com.ferreusveritas.dynamictrees.systems; |
2 | 2 |
|
| 3 | +import com.ferreusveritas.dynamictrees.DynamicTrees; |
3 | 4 | import com.ferreusveritas.dynamictrees.tree.family.Family; |
4 | 5 | import com.ferreusveritas.dynamictrees.util.function.TetraFunction; |
5 | 6 | import net.minecraft.core.BlockPos; |
6 | 7 | import net.minecraft.core.Direction; |
| 8 | +import net.minecraft.resources.ResourceLocation; |
7 | 9 | import net.minecraft.world.level.BlockGetter; |
8 | 10 | import net.minecraft.world.level.block.Block; |
9 | 11 | import net.minecraft.world.level.block.state.BlockState; |
|
19 | 21 | */ |
20 | 22 | public class BranchConnectables { |
21 | 23 |
|
22 | | - private static final Map<Block, Map<Family, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer>>> connectablesMap = new HashMap<>(); |
| 24 | + private static final Map<Block, Map<ResourceLocation, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer>>> connectablesMap = new HashMap<>(); |
23 | 25 |
|
24 | 26 | //Direction can be null |
25 | | - public static void makeBlockConnectable(Block block, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer> radiusFunction, Family family) { |
| 27 | + public static void makeBlockConnectable(Block block, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer> radiusFunction, ResourceLocation family) { |
26 | 28 | var map = connectablesMap.computeIfAbsent(block, k -> new HashMap<>()); |
27 | 29 | map.putIfAbsent(family, radiusFunction); |
28 | 30 | } |
29 | 31 | public static void makeBlockConnectable(Block block, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer> radiusFunction) { |
30 | | - makeBlockConnectable(block, radiusFunction, Family.NULL_FAMILY); |
| 32 | + makeBlockConnectable(block, radiusFunction, DynamicTrees.location("null")); |
31 | 33 | } |
32 | | - public static void replaceBlockConnectable(Block block, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer> radiusFunction, Family family) { |
| 34 | + public static void replaceBlockConnectable(Block block, TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer> radiusFunction, ResourceLocation family) { |
33 | 35 | var map = connectablesMap.computeIfAbsent(block, k -> new HashMap<>()); |
34 | 36 | map.remove(family); |
35 | 37 | map.put(family, radiusFunction); |
@@ -57,9 +59,9 @@ public static int getConnectionRadiusForBlock(BlockState state, BlockGetter worl |
57 | 59 | private static TetraFunction<BlockState, BlockGetter, BlockPos, Direction, Integer> getFunctionForFamily(Block block, Family family){ |
58 | 60 | var familyMap = connectablesMap.get(block); |
59 | 61 | if (familyMap == null) return null; |
60 | | - var function = familyMap.get(family); |
| 62 | + var function = familyMap.get(family.getRegistryName()); |
61 | 63 | if (function == null){ |
62 | | - function = familyMap.get(Family.NULL_FAMILY); |
| 64 | + function = familyMap.get(DynamicTrees.location("null")); |
63 | 65 | } |
64 | 66 | return function; |
65 | 67 | } |
|
0 commit comments