mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 03:05:28 +01:00
fabric-1.18: add CustomServerChunkEvents.CHUNK_GENERATE
This commit is contained in:
parent
69a6bb2a2a
commit
32d618e99b
@ -0,0 +1,5 @@
|
|||||||
|
package org.dynmap.fabric_1_18.access;
|
||||||
|
|
||||||
|
public interface ProtoChunkAccessor {
|
||||||
|
boolean getTouchedByWorldGen();
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package org.dynmap.fabric_1_18.event;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.event.Event;
|
||||||
|
import net.fabricmc.fabric.api.event.EventFactory;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
public class CustomServerChunkEvents {
|
||||||
|
public static Event<ChunkGenerate> CHUNK_GENERATE = EventFactory.createArrayBacked(ChunkGenerate.class,
|
||||||
|
(listeners) -> (world, chunk) -> {
|
||||||
|
for (ChunkGenerate callback : listeners) {
|
||||||
|
callback.onChunkGenerate(world, chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ChunkGenerate {
|
||||||
|
void onChunkGenerate(ServerWorld world, Chunk chunk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package org.dynmap.fabric_1_18.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.ProtoChunk;
|
||||||
|
import org.dynmap.fabric_1_18.access.ProtoChunkAccessor;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ProtoChunk.class)
|
||||||
|
public class ProtoChunkMixin implements ProtoChunkAccessor {
|
||||||
|
private boolean touchedByWorldGen = false;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "setBlockState",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/world/chunk/ChunkSection;setBlockState(IIILnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
public void setBlockState(BlockPos pos, BlockState state, boolean moved, CallbackInfoReturnable<BlockState> info) {
|
||||||
|
touchedByWorldGen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getTouchedByWorldGen() {
|
||||||
|
return touchedByWorldGen;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
"BiomeEffectsAccessor",
|
"BiomeEffectsAccessor",
|
||||||
"MinecraftServerMixin",
|
"MinecraftServerMixin",
|
||||||
"PlayerManagerMixin",
|
"PlayerManagerMixin",
|
||||||
|
"ProtoChunkMixin",
|
||||||
"ServerPlayerEntityMixin",
|
"ServerPlayerEntityMixin",
|
||||||
"ServerPlayNetworkHandlerMixin",
|
"ServerPlayNetworkHandlerMixin",
|
||||||
"ThreadedAnvilChunkStorageAccessor",
|
"ThreadedAnvilChunkStorageAccessor",
|
||||||
|
Loading…
Reference in New Issue
Block a user