Compare commits
5 commits
13c8c95b3c
...
92ce91d05d
Author | SHA1 | Date | |
---|---|---|---|
92ce91d05d | |||
2e288d0738 | |||
f4d2174fba | |||
b182a35750 | |||
a3471e7a39 |
7 changed files with 21 additions and 29 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());
|
||||||
|
|
|
@ -2,8 +2,12 @@ package ru.octol1ttle.knockdowns.common.mixin;
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import ru.octol1ttle.knockdowns.common.KnockdownsUtils;
|
||||||
import ru.octol1ttle.knockdowns.common.api.IKnockableDown;
|
import ru.octol1ttle.knockdowns.common.api.IKnockableDown;
|
||||||
|
|
||||||
@Mixin(LivingEntity.class)
|
@Mixin(LivingEntity.class)
|
||||||
|
@ -12,4 +16,12 @@ public abstract class LivingEntityMixin {
|
||||||
private boolean dontTargetKnockedPlayers(boolean original, LivingEntity target) {
|
private boolean dontTargetKnockedPlayers(boolean original, LivingEntity target) {
|
||||||
return original && !(target instanceof IKnockableDown knockable && knockable.is_KnockedDown());
|
return original && !(target instanceof IKnockableDown knockable && knockable.is_KnockedDown());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tryUseTotem", at = @At("RETURN"))
|
||||||
|
private void resetKnockedDownOnTotemUse(DamageSource source, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
LivingEntity $this = (LivingEntity) (Object) this;
|
||||||
|
if (cir.getReturnValue() && $this instanceof IKnockableDown knockable && knockable.is_KnockedDown()) {
|
||||||
|
KnockdownsUtils.resetKnockedState(knockable);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"knockdowns.mixins.json",
|
|
||||||
"knockdowns-common.mixins.json"
|
"knockdowns-common.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "ru.octol1ttle.knockdowns.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_17",
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"client": [
|
|
||||||
],
|
|
||||||
"mixins": [
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ loom {
|
||||||
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
|
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
|
||||||
|
|
||||||
mixinConfig "knockdowns-common.mixins.json"
|
mixinConfig "knockdowns-common.mixins.json"
|
||||||
mixinConfig "knockdowns.mixins.json"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "ru.octol1ttle.knockdowns.forge.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_17",
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"client": [
|
|
||||||
],
|
|
||||||
"mixins": [
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ minecraft_version=1.19.2
|
||||||
enabled_platforms=fabric,forge
|
enabled_platforms=fabric,forge
|
||||||
|
|
||||||
archives_base_name=knockdowns
|
archives_base_name=knockdowns
|
||||||
mod_version=2.2.0
|
mod_version=2.2.2
|
||||||
maven_group=ru.octol1ttle.knockdowns
|
maven_group=ru.octol1ttle.knockdowns
|
||||||
|
|
||||||
architectury_version=6.5.85
|
architectury_version=6.5.85
|
||||||
|
|
Loading…
Add table
Reference in a new issue