30 lines
1.2 KiB
Java
30 lines
1.2 KiB
Java
package carpet.mixins;
|
|
|
|
import net.minecraft.server.world.ServerWorld;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.util.math.ChunkPos;
|
|
import net.minecraft.util.profiler.Profiler;
|
|
import net.minecraft.world.chunk.WorldChunk;
|
|
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.CallbackInfo;
|
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
|
|
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
|
|
|
|
@Mixin(ServerWorld.class)
|
|
public class ServerWorld_scarpetEventMixin
|
|
{
|
|
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
|
value = "INVOKE",
|
|
target = "Lnet/minecraft/server/world/ServerWorld;addLightning(Lnet/minecraft/entity/LightningEntity;)V"
|
|
))
|
|
private void onNaturalLightinig(WorldChunk chunk, int randomTickSpeed, CallbackInfo ci,
|
|
ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2)
|
|
{
|
|
if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
|
|
}
|
|
|
|
}
|