Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.ryanhcode.sable.mixin.stop_lightning;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import dev.ryanhcode.sable.api.sublevel.SubLevelContainer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

/**
* Prevents lightning or skeleton traps from spawning inside plots to avoid inflating spawn rates
*/
@Mixin(ServerLevel.class)
public class ServerLevelMixin {

@WrapOperation(method="tickChunk", at=@At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;isThundering()Z"))
private boolean sable$preventLightningInPlot(final ServerLevel instance, final Operation<Boolean> original, @Local(argsOnly = true) final LevelChunk chunk) {
final SubLevelContainer plotContainer = SubLevelContainer.getContainer((ServerLevel) (Object) this);
assert plotContainer != null;

if (plotContainer.getPlot(chunk.getPos()) != null) {
return false;
}
return original.call(instance);
}

}
1 change: 1 addition & 0 deletions common/src/main/resources/sable.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"sculk_vibrations.VibrationSystemListenerMixin",
"sculk_vibrations.VibrationSystemTickerMixin",
"sign_interaction.SignBlockEntityMixin",
"stop_lightning.ServerLevelMixin",
"tracking_points.EntityMixin",
"tracking_points.ServerPlayerMixin",
"udp.ConnectionMixin",
Expand Down