mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Replace Redirect for VelocityFromFluidEvent with WrapWithCondition
Fixes #924
This commit is contained in:
parent
adf0058b63
commit
a6ee72159e
@ -11,10 +11,11 @@ import org.objectweb.asm.Opcodes;
|
|||||||
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.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.command.CommandOutput;
|
import net.minecraft.server.command.CommandOutput;
|
||||||
@ -29,19 +30,16 @@ import net.wurstclient.events.VelocityFromFluidListener.VelocityFromFluidEvent;
|
|||||||
@Mixin(Entity.class)
|
@Mixin(Entity.class)
|
||||||
public abstract class EntityMixin implements Nameable, EntityLike, CommandOutput
|
public abstract class EntityMixin implements Nameable, EntityLike, CommandOutput
|
||||||
{
|
{
|
||||||
@Redirect(at = @At(value = "INVOKE",
|
@WrapWithCondition(at = @At(value = "INVOKE",
|
||||||
target = "Lnet/minecraft/entity/Entity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V",
|
target = "Lnet/minecraft/entity/Entity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V",
|
||||||
opcode = Opcodes.INVOKEVIRTUAL,
|
opcode = Opcodes.INVOKEVIRTUAL,
|
||||||
ordinal = 0),
|
ordinal = 0),
|
||||||
method = "updateMovementInFluid(Lnet/minecraft/registry/tag/TagKey;D)Z")
|
method = "updateMovementInFluid(Lnet/minecraft/registry/tag/TagKey;D)Z")
|
||||||
private void setVelocityFromFluid(Entity entity, Vec3d velocity)
|
private boolean shouldSetVelocity(Entity instance, Vec3d velocity)
|
||||||
{
|
{
|
||||||
VelocityFromFluidEvent event =
|
VelocityFromFluidEvent event = new VelocityFromFluidEvent(instance);
|
||||||
new VelocityFromFluidEvent((Entity)(Object)this);
|
|
||||||
EventManager.fire(event);
|
EventManager.fire(event);
|
||||||
|
return !event.isCancelled();
|
||||||
if(!event.isCancelled())
|
|
||||||
entity.setVelocity(velocity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"),
|
@Inject(at = @At("HEAD"),
|
||||||
|
Loading…
Reference in New Issue
Block a user