mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
hopefully finally caused the game to not hang?????????????
This commit is contained in:
parent
81c6034c21
commit
25d3550e0a
3 changed files with 11 additions and 7 deletions
|
@ -25,9 +25,11 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
@ -94,7 +96,12 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk getLoadedChunk(IWorld world, int x, int z) {
|
public static Chunk getLoadedChunk(IWorld world, int x, int z) {
|
||||||
return world.getChunkProvider().getChunk(x, z, false);
|
// DO NOT EDIT PLEASE FOR THE LOVE OF GOD
|
||||||
|
// This is very finicky and easily causes the game to hang for some reason
|
||||||
|
AbstractChunkProvider provider = world.getChunkProvider();
|
||||||
|
if (provider.isChunkLoaded(new ChunkPos(x, z)))
|
||||||
|
return provider.getChunk(x, z, false);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int blendColors(int c1, int c2, float ratio) {
|
public static int blendColors(int c1, int c2, float ratio) {
|
||||||
|
|
|
@ -143,8 +143,6 @@ public class AuraChunk implements IAuraChunk {
|
||||||
public void update() {
|
public void update() {
|
||||||
World world = this.chunk.getWorld();
|
World world = this.chunk.getWorld();
|
||||||
|
|
||||||
if (this.drainSpots.size() > 0)
|
|
||||||
System.out.println("Updating with " + this.drainSpots.size());
|
|
||||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||||
BlockPos pos = entry.getKey();
|
BlockPos pos = entry.getKey();
|
||||||
MutableInt amount = entry.getValue();
|
MutableInt amount = entry.getValue();
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class CommonEvents {
|
public class CommonEvents {
|
||||||
|
|
||||||
|
@ -48,10 +47,10 @@ public class CommonEvents {
|
||||||
ChunkManager manager = ((ServerChunkProvider) event.world.getChunkProvider()).chunkManager;
|
ChunkManager manager = ((ServerChunkProvider) event.world.getChunkProvider()).chunkManager;
|
||||||
Iterable<ChunkHolder> chunks = (Iterable<ChunkHolder>) GET_LOADED_CHUNKS_METHOD.invoke(manager);
|
Iterable<ChunkHolder> chunks = (Iterable<ChunkHolder>) GET_LOADED_CHUNKS_METHOD.invoke(manager);
|
||||||
for (ChunkHolder holder : chunks) {
|
for (ChunkHolder holder : chunks) {
|
||||||
Optional<Chunk> chunkQuestionmark = holder.func_219296_a().getNow(ChunkHolder.UNLOADED_CHUNK).left();
|
Chunk chunk = holder.func_219298_c();
|
||||||
if (!chunkQuestionmark.isPresent())
|
if (chunk == null)
|
||||||
continue;
|
continue;
|
||||||
AuraChunk auraChunk = (AuraChunk) chunkQuestionmark.get().getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||||
if (auraChunk != null)
|
if (auraChunk != null)
|
||||||
auraChunk.update();
|
auraChunk.update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue