Skip to content

Commit

Permalink
fix(stunning)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvb-uy committed Aug 29, 2023
1 parent 9662934 commit 554bc9c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package elocindev.shield_overhaul.mixin;

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.CallbackInfoReturnable;

import elocindev.shield_overhaul.registry.EffectRegistry;
import net.minecraft.entity.LivingEntity;

@Mixin(LivingEntity.class)
public class LivingEntityMixin {

@Inject(method = "isImmobile", at = @At(value = "HEAD"), cancellable = true)
private void isStunned(CallbackInfoReturnable<Boolean> cir) {
LivingEntity entity = (LivingEntity)(Object)this;
if(entity.hasStatusEffect(EffectRegistry.STUN_EFFECT)) {
cir.setReturnValue(true);;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import elocindev.shield_overhaul.ShieldOverhaul;
import elocindev.shield_overhaul.config.ConfigEntries;
import elocindev.shield_overhaul.registry.EffectRegistry;
import elocindev.shield_overhaul.util.ShieldUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShieldItem;
Expand All @@ -21,6 +22,10 @@ public class ServerPlayerInteractionManagerMixin {

@Inject(method = "interactItem", at = @At("HEAD"), cancellable = true)
public void interactItem(ServerPlayerEntity player, World world, ItemStack stack, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
if (player.hasStatusEffect(EffectRegistry.STUN_EFFECT)) {
cir.setReturnValue(ActionResult.FAIL);
}

Hand shieldHand = player.getActiveHand();
ItemStack shield = player.getStackInHand(shieldHand);
ConfigEntries config = ShieldOverhaul.CONFIG;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public static Vec3d getLookingVec(PlayerEntity player, float speed) {

return new Vec3d(x*n/m, y*n/m * 0.5F, z*n/m);
}
}
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/shield_overhaul/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"effect.shield_overhaul.stun":"Stun",
"effect.shield_overhaul.stun.description":"Target is unable to move, use items or attack.",
"effect.shield_overhaul.stun_immunity":"Stun Immunity",
"effect.shield_overhaul.stun_immunity.description":"Target is immune to getting stunned."
}
2 changes: 1 addition & 1 deletion src/main/resources/shield_overhaul.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"package": "elocindev.shield_overhaul.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"ServerPlayerMixin",
"LivingEntityMixin",
"BackgroundRendererMixin",
"ClientPlayerEntityMixin",
"ServerPlayerInteractionManagerMixin"
Expand Down

0 comments on commit 554bc9c

Please sign in to comment.