|
18 | 18 | import net.minecraft.server.level.*; |
19 | 19 | import net.minecraft.world.item.ItemStack; |
20 | 20 | import net.minecraft.world.item.Items; |
| 21 | +import net.minecraft.world.level.ChunkPos; |
21 | 22 | import net.minecraft.world.level.block.state.BlockState; |
| 23 | +import net.minecraft.world.level.chunk.ChunkAccess; |
| 24 | +import net.minecraft.world.level.chunk.ChunkStatus; |
22 | 25 | import net.minecraft.world.phys.AABB; |
23 | 26 | import org.jetbrains.annotations.Nullable; |
24 | 27 |
|
25 | 28 | import java.util.*; |
| 29 | +import java.util.concurrent.ExecutionException; |
26 | 30 |
|
27 | 31 | /** |
28 | 32 | * See {@link BlockEntityAbstractImpetus}, this is what's stored in it |
@@ -109,29 +113,31 @@ protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir, |
109 | 113 | var negativeBlock = new BlockPos.MutableBlockPos(); |
110 | 114 | var lastBlockPos = new BlockPos.MutableBlockPos(); |
111 | 115 | BlockPos firstBlock = null; |
112 | | - |
| 116 | + HashMap<ChunkPos, ChunkAccess> chunkSet = new HashMap<>(); |
113 | 117 | while (!todo.isEmpty()) { |
114 | | - /* |
115 | | - Sophia/Stickia here! |
116 | | - This block of code works well enough, it gets all the ICircleComponent that it can. However, |
117 | | - this tries to do all the calculating in a single tick, so it can get *really* laggy for larger circles. |
118 | | - So, this `while` would likely need to be moved into the #tick method, so it can be spread out over time during start up. |
119 | | - Why are these comments here? Likely so Sophia can remember this for after she gets sleep, or if anyone |
120 | | - else wants to take up the challenge. As for her system will work, but not be clean lmao |
121 | | -
|
122 | | - As brought up by Chloe, the slates *could* change during start up. |
123 | | - Meaning someone could just place/remove slate at the same rate of discovery, and have World Ambit for almost no slate |
124 | | - cost and generally cheating the system. What would be best would be (somehow) getting the block slate |
125 | | - without loading the chunk its self, meaning servers wont have to handle 1000s of chunks being loaded at once |
126 | | - and players not cheating the system. |
127 | | - But this is easier said than done. |
128 | | - */ |
129 | 118 |
|
130 | 119 | var pair = todo.pop(); |
131 | 120 | var enterDir = pair.getFirst(); |
132 | 121 | var herePos = pair.getSecond(); |
133 | 122 |
|
134 | | - BlockState hereBs = level.getLevel().getBlockState(herePos); //FUCK THIS LINE. THIS FUC- |
| 123 | + BlockState hereBs; |
| 124 | + var chunkPos = new ChunkPos(herePos); |
| 125 | + |
| 126 | + if (!chunkSet.containsKey(chunkPos)) { |
| 127 | + var z = level.getChunkSource().getChunkFuture(chunkPos.x,chunkPos.z, ChunkStatus.EMPTY,true); |
| 128 | + try { |
| 129 | + if (z.get().left().isPresent()){ |
| 130 | + chunkSet.put(chunkPos,z.get().left().get()); |
| 131 | + hereBs = z.get().left().get().getBlockState(herePos); |
| 132 | + } else { |
| 133 | + hereBs = level.getLevel().getBlockState(herePos); |
| 134 | + } |
| 135 | + } catch (InterruptedException | ExecutionException e) { |
| 136 | + hereBs = level.getLevel().getBlockState(herePos); |
| 137 | + } |
| 138 | + } else { |
| 139 | + hereBs = chunkSet.get(chunkPos).getBlockState(herePos); |
| 140 | + } |
135 | 141 | if (!(hereBs.getBlock() instanceof ICircleComponent cmp)) { |
136 | 142 | continue; |
137 | 143 | } |
|
0 commit comments