Some neoforge compatibility

Drop farm block mixin, doesn't appear to be fixing streams
anymore so it's not useful.

Also, implement the force ticks api and make it thread-safe.
This commit is contained in:
Spottedleaf
2024-08-07 02:05:21 -07:00
parent eada4f58bc
commit 5bc1ba2feb
5 changed files with 50 additions and 55 deletions

View File

@@ -105,6 +105,6 @@ abstract class StateHolderMixin<O, S> {
*/
@Overwrite
public <T extends Comparable<T>> boolean hasProperty(final Property<T> property) {
return this.optimisedTable.get(property) != null; // Paper - optimise state lookup
return this.optimisedTable.get(property) != null;
}
}

View File

@@ -16,7 +16,6 @@ import net.minecraft.server.level.TickingTracker;
import net.minecraft.util.SortedArraySet;
import net.minecraft.util.thread.ProcessorHandle;
import net.minecraft.world.level.ChunkPos;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@@ -62,7 +61,6 @@ abstract class DistanceManagerMixin implements ChunkSystemDistanceManager {
Executor mainThreadExecutor;
@Shadow
@Final
private DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter;
@Shadow

View File

@@ -1,49 +0,0 @@
package ca.spottedleaf.moonrise.mixin.farm_block;
import ca.spottedleaf.moonrise.patches.chunk_getblock.GetBlockChunk;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.material.FluidState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(FarmBlock.class)
abstract class FarmBlockMixin {
// TODO: NeoForge - APIs this method calls require a BlockPos, so is there much advantage to not using betweenClosed anymore?
/**
* @reason Avoid usage of betweenClosed, this can become very hot when
* there are significant numbers of farm blocks in the world
* @author Spottedleaf
*/
@Overwrite
public static boolean isNearWater(final LevelReader world, final BlockPos pos) {
final ChunkSource chunkCache = ((Level)world).getChunkSource();
final int xOff = pos.getX();
final int yOff = pos.getY();
final int zOff = pos.getZ();
for (int dz = -4; dz <= 4; ++dz) {
final int z = dz + zOff;
for (int dx = -4; dx <= 4; ++dx) {
final int x = xOff + dx;
final LevelChunk chunk = (LevelChunk)chunkCache.getChunk(x >> 4, z >> 4, ChunkStatus.FULL, true);
for (int dy = 0; dy <= 1; ++dy) {
final int y = dy + yOff;
final FluidState fluid = ((GetBlockChunk)chunk).moonrise$getBlock(x, y, z).getFluidState();
if (!fluid.isEmpty() && fluid.is(FluidTags.WATER)) {
return true;
}
}
}
}
return false;
}
}

View File

@@ -78,7 +78,6 @@
"entity_tracker.ChunkMapMixin",
"entity_tracker.EntityMixin",
"entity_tracker.TrackedEntityMixin",
"farm_block.FarmBlockMixin",
"fast_palette.CrudeIncrementalIntIdentityHashBiMapMixin",
"fast_palette.HashMapPaletteMixin",
"fast_palette.LinearPaletteMixin",