Skip to content

Commit

Permalink
Merge pull request #7 from cerus/feat/player-ramming
Browse files Browse the repository at this point in the history
Make players affected as well
  • Loading branch information
ix0rai authored Oct 6, 2024
2 parents 6f87b35 + b2ea4c9 commit 1f15540
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/io/ix0rai/ramel/mixin/CamelEntityMixin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,8 +19,6 @@
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();
Expand Down Expand Up @@ -53,6 +54,10 @@ protected CamelEntityMixin(EntityType<? extends CamelEntity> 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));
}
});
}
}

0 comments on commit 1f15540

Please sign in to comment.