From b421fc6e72f2469bc752b1a6032a3c403914634a Mon Sep 17 00:00:00 2001 From: Cerus Date: Wed, 2 Oct 2024 22:42:46 +0200 Subject: [PATCH 1/2] feat: make players affected as well --- .../io/ix0rai/ramel/mixin/CamelEntityMixin.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java b/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java index 25baab1..bb75af3 100644 --- a/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java +++ b/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java @@ -1,12 +1,15 @@ package io.ix0rai.ramel.mixin; import io.ix0rai.ramel.Config; +import java.util.Objects; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.passive.CamelEntity; +import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; @@ -16,11 +19,11 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Objects; - @Mixin(CamelEntity.class) public abstract class CamelEntityMixin extends LivingEntity { - @Shadow public abstract boolean isDashing(); + + @Shadow + public abstract boolean isDashing(); protected CamelEntityMixin(EntityType entityType, World world) { super(entityType, world); @@ -53,6 +56,10 @@ protected CamelEntityMixin(EntityType entityType, World w entity.takeKnockback(blockedImpact * speedAdjustedImpact * knockBackMultiplier, MathHelper.sin(this.getPitch() * ((float) Math.PI / 180)), -MathHelper.cos(this.getPitch() * ((float) Math.PI / 180))); + if (entity instanceof ServerPlayerEntity player) { + // The player won't feel any effects if we don't update the velocity + player.networkHandler.send(new EntityVelocityUpdateS2CPacket(player)); + } }); } } From b2ea4c94a1148f6f1bf37d590bbcc68ffa1654f8 Mon Sep 17 00:00:00 2001 From: Cerus Date: Wed, 2 Oct 2024 22:44:33 +0200 Subject: [PATCH 2/2] style: revert style --- src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java b/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java index bb75af3..e979b5d 100644 --- a/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java +++ b/src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java @@ -21,9 +21,7 @@ @Mixin(CamelEntity.class) public abstract class CamelEntityMixin extends LivingEntity { - - @Shadow - public abstract boolean isDashing(); + @Shadow public abstract boolean isDashing(); protected CamelEntityMixin(EntityType entityType, World world) { super(entityType, world);