fix cache misses

This commit is contained in:
dfsek
2021-05-03 19:43:52 -07:00
parent 457729b832
commit f21069ab2e
2 changed files with 29 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.ServerWorldAccess;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
@@ -80,4 +81,17 @@ public abstract class ChunkRegionMixin {
public int hashCode() {
return world.hashCode();
}
/**
* Overridden in the same manner as {@link #hashCode()}
*
* @param other Another object
* @return Whether this world is the same as other.
* @see #hashCode()
*/
@Override
public boolean equals(Object other) {
if(!(other instanceof ServerWorldAccess)) return false;
return world.equals(((ServerWorldAccess) other).toServerWorld());
}
}

View File

@@ -13,6 +13,7 @@ import com.dfsek.terra.fabric.world.block.FabricBlock;
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ServerWorldAccess;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin;
@@ -58,4 +59,18 @@ public abstract class ServerWorldMixin {
public TerraChunkGenerator terra$getTerraGenerator() {
return ((FabricChunkGeneratorWrapper) terra$getGenerator()).getHandle();
}
/**
* Overridden in the same manner as {@link ChunkRegionMixin#hashCode()}
*
* @param other Another object
* @return Whether this world is the same as other.
* @see ChunkRegionMixin#hashCode()
*/
@SuppressWarnings("ConstantConditions")
@Override
public boolean equals(Object other) {
if(!(other instanceof ServerWorldAccess)) return false;
return (ServerWorldAccess) this == (((ServerWorldAccess) other).toServerWorld());
}
}