change: don't allow knocked players to place blocks
This commit is contained in:
parent
b182a35750
commit
f4d2174fba
1 changed files with 8 additions and 0 deletions
|
@ -2,11 +2,13 @@ package ru.octol1ttle.knockdowns.common.events;
|
||||||
|
|
||||||
import dev.architectury.event.CompoundEventResult;
|
import dev.architectury.event.CompoundEventResult;
|
||||||
import dev.architectury.event.EventResult;
|
import dev.architectury.event.EventResult;
|
||||||
|
import dev.architectury.event.events.common.BlockEvent;
|
||||||
import dev.architectury.event.events.common.EntityEvent;
|
import dev.architectury.event.events.common.EntityEvent;
|
||||||
import dev.architectury.event.events.common.InteractionEvent;
|
import dev.architectury.event.events.common.InteractionEvent;
|
||||||
import dev.architectury.event.events.common.PlayerEvent;
|
import dev.architectury.event.events.common.PlayerEvent;
|
||||||
import dev.architectury.event.events.common.TickEvent;
|
import dev.architectury.event.events.common.TickEvent;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -126,6 +128,12 @@ public class KnockdownsEvents {
|
||||||
}
|
}
|
||||||
return EventResult.pass();
|
return EventResult.pass();
|
||||||
});
|
});
|
||||||
|
BlockEvent.PLACE.register((level, pos, state, placer) -> {
|
||||||
|
if (placer instanceof PlayerEntity player && KnockdownsUtils.isKnockedOrReviving(player)) {
|
||||||
|
return EventResult.interruptFalse();
|
||||||
|
}
|
||||||
|
return EventResult.pass();
|
||||||
|
});
|
||||||
InteractionEvent.RIGHT_CLICK_ITEM.register((player, hand) -> {
|
InteractionEvent.RIGHT_CLICK_ITEM.register((player, hand) -> {
|
||||||
if (KnockdownsUtils.isKnockedOrReviving(player)) {
|
if (KnockdownsUtils.isKnockedOrReviving(player)) {
|
||||||
return CompoundEventResult.interruptFalse(hand == Hand.MAIN_HAND ? player.getMainHandStack() : player.getOffHandStack());
|
return CompoundEventResult.interruptFalse(hand == Hand.MAIN_HAND ? player.getMainHandStack() : player.getOffHandStack());
|
||||||
|
|
Loading…
Reference in a new issue