增强BEAST效果
This commit is contained in:
parent
24d77c71ba
commit
f48b8f5892
4 changed files with 62 additions and 1 deletions
|
@ -0,0 +1,12 @@
|
||||||
|
package com.atsuishio.superbwarfare.entity.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
public interface BeastEntityKiller {
|
||||||
|
|
||||||
|
static BeastEntityKiller getInstance(LivingEntity entity) {
|
||||||
|
return (BeastEntityKiller) entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sbw$kill();
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.item;
|
||||||
import com.atsuishio.superbwarfare.config.server.MiscConfig;
|
import com.atsuishio.superbwarfare.config.server.MiscConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity;
|
import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.TargetEntity;
|
import com.atsuishio.superbwarfare.entity.TargetEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.mixin.BeastEntityKiller;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModEnumExtensions;
|
import com.atsuishio.superbwarfare.init.ModEnumExtensions;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
@ -99,6 +100,7 @@ public class Beast extends SwordItem {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (target instanceof LivingEntity living) {
|
if (target instanceof LivingEntity living) {
|
||||||
|
BeastEntityKiller.getInstance(living).sbw$kill();
|
||||||
living.setHealth(0);
|
living.setHealth(0);
|
||||||
}
|
}
|
||||||
target.level().broadcastEntityEvent(target, (byte) 60);
|
target.level().broadcastEntityEvent(target, (byte) 60);
|
||||||
|
@ -129,7 +131,7 @@ public class Beast extends SwordItem {
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public boolean onEntitySwing(ItemStack stack, LivingEntity entity, InteractionHand hand) {
|
public boolean onEntitySwing(ItemStack stack, LivingEntity entity, InteractionHand hand) {
|
||||||
var target = TraceTool.findMeleeEntity(entity, 50);
|
var target = TraceTool.findMeleeEntity(entity, 51.4);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
beastKill(entity, target);
|
beastKill(entity, target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.entity.mixin.BeastEntityKiller;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(LivingEntity.class)
|
||||||
|
public abstract class BeastMixin implements BeastEntityKiller {
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
public boolean sbw$beastKilled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sbw$kill() {
|
||||||
|
this.sbw$beastKilled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isDeadOrDying", at = @At("HEAD"), cancellable = true, order = Integer.MAX_VALUE)
|
||||||
|
public void isDeadOrDying(CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (this.sbw$beastKilled) {
|
||||||
|
cir.cancel();
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getHealth", at = @At("HEAD"), cancellable = true, order = Integer.MAX_VALUE)
|
||||||
|
public void getHealth(CallbackInfoReturnable<Float> cir) {
|
||||||
|
if (this.sbw$beastKilled) {
|
||||||
|
cir.cancel();
|
||||||
|
cir.setReturnValue(0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "remove", at = @At("RETURN"), order = Integer.MAX_VALUE)
|
||||||
|
public void onRemove(Entity.RemovalReason reason, CallbackInfo ci) {
|
||||||
|
if (this.sbw$beastKilled) {
|
||||||
|
((LivingEntity) (Object) this).setRemoved(reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"refmap": "mixins.superbwarfare.refmap.json",
|
"refmap": "mixins.superbwarfare.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"BeastMixin",
|
||||||
"ClientboundSetPassengersPacketMixin",
|
"ClientboundSetPassengersPacketMixin",
|
||||||
"EntityMixin",
|
"EntityMixin",
|
||||||
"FishingHookMixin",
|
"FishingHookMixin",
|
||||||
|
|
Loading…
Add table
Reference in a new issue