回滚阻止外部stopriding方法
This commit is contained in:
parent
4286f907e7
commit
247ddb30c3
6 changed files with 2 additions and 91 deletions
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.compat.CompatHolder;
|
||||||
import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
|
import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
|
||||||
import com.atsuishio.superbwarfare.config.client.ReloadConfig;
|
import com.atsuishio.superbwarfare.config.client.ReloadConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.MortarEntity;
|
import com.atsuishio.superbwarfare.entity.MortarEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.mixin.CustomStopRiding;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
|
@ -469,8 +468,5 @@ public class ClickHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PacketDistributor.sendToServer(new PlayerStopRidingMessage(0));
|
PacketDistributor.sendToServer(new PlayerStopRidingMessage(0));
|
||||||
|
|
||||||
CustomStopRiding customStopRiding = CustomStopRiding.getInstance(player);
|
|
||||||
customStopRiding.superbwarfare$stopRiding();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
package com.atsuishio.superbwarfare.entity.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
|
|
||||||
public interface CustomStopRiding {
|
|
||||||
|
|
||||||
static CustomStopRiding getInstance(Entity entity) {
|
|
||||||
return (CustomStopRiding) entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void superbwarfare$stopRiding();
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.entity.vehicle.base;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.mixin.CustomStopRiding;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
||||||
|
@ -719,14 +718,6 @@ public abstract class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
this.getPassengers().forEach(p -> {
|
|
||||||
if (p instanceof Player player) {
|
|
||||||
CustomStopRiding customStopRiding = CustomStopRiding.getInstance(player);
|
|
||||||
customStopRiding.superbwarfare$stopRiding();
|
|
||||||
} else {
|
|
||||||
p.stopRiding();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -980,34 +971,6 @@ public abstract class VehicleEntity extends Entity {
|
||||||
return getEyePosition();
|
return getEyePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ejectPassengers() {
|
|
||||||
for(int i = this.passengers.size() - 1; i >= 0; --i) {
|
|
||||||
var passenger = this.passengers.get(i);
|
|
||||||
if (passenger instanceof Player player) {
|
|
||||||
CustomStopRiding stopRiding = CustomStopRiding.getInstance(player);
|
|
||||||
stopRiding.superbwarfare$stopRiding();
|
|
||||||
} else {
|
|
||||||
passenger.stopRiding();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void remove(RemovalReason pReason) {
|
|
||||||
// if (this.getRemovalReason() == null) {
|
|
||||||
// this.removalReason = pReason;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (this.getRemovalReason().shouldDestroy()) {
|
|
||||||
// this.stopRiding();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.getPassengers().forEach(Entity::stopRiding);
|
|
||||||
// this.levelCallback.onRemove(pReason);
|
|
||||||
// this.invalidateCaps();
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染载具的第一人称UI
|
* 渲染载具的第一人称UI
|
||||||
* 务必标记 @OnlyIn(Dist.CLIENT) !
|
* 务必标记 @OnlyIn(Dist.CLIENT) !
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.mixins;
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.mixin.ICustomKnockback;
|
import com.atsuishio.superbwarfare.entity.mixin.ICustomKnockback;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -41,13 +39,4 @@ public class LivingEntityMixin implements ICustomKnockback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "stopRiding()V", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void stopRiding(CallbackInfo ci) {
|
|
||||||
var living = ((LivingEntity) (Object) this);
|
|
||||||
Entity entity = living.getVehicle();
|
|
||||||
if (entity instanceof VehicleEntity && living instanceof Player) {
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,14 +1,11 @@
|
||||||
package com.atsuishio.superbwarfare.mixins;
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.mixin.CustomStopRiding;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import net.minecraft.tags.BlockTags;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.Pose;
|
import net.minecraft.world.entity.Pose;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
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;
|
||||||
|
@ -16,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(value = Player.class, priority = 1145)
|
@Mixin(value = Player.class, priority = 1145)
|
||||||
public abstract class PlayerMixin extends Entity implements CustomStopRiding {
|
public abstract class PlayerMixin extends Entity {
|
||||||
|
|
||||||
public PlayerMixin(EntityType<?> type, Level world) {
|
public PlayerMixin(EntityType<?> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
@ -38,23 +35,4 @@ public abstract class PlayerMixin extends Entity implements CustomStopRiding {
|
||||||
this.setPose(Pose.STANDING);
|
this.setPose(Pose.STANDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void superbwarfare$stopRiding() {
|
|
||||||
Entity entity = this.getVehicle();
|
|
||||||
this.removeVehicle();
|
|
||||||
if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) {
|
|
||||||
Vec3 vec3;
|
|
||||||
if (this.isRemoved()) {
|
|
||||||
vec3 = this.position();
|
|
||||||
} else if (!entity.isRemoved() && !this.level().getBlockState(entity.blockPosition()).is(BlockTags.PORTALS)) {
|
|
||||||
vec3 = entity.getDismountLocationForPassenger((Player) (Object) this);
|
|
||||||
} else {
|
|
||||||
double d0 = Math.max(this.getY(), entity.getY());
|
|
||||||
vec3 = new Vec3(this.getX(), d0, this.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dismountTo(vec3.x, vec3.y, vec3.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.network.message.send;
|
package com.atsuishio.superbwarfare.network.message.send;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.entity.mixin.CustomStopRiding;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
@ -25,9 +24,7 @@ public record PlayerStopRidingMessage(int msgType) implements CustomPacketPayloa
|
||||||
var vehicle = player.getVehicle();
|
var vehicle = player.getVehicle();
|
||||||
if (!(vehicle instanceof VehicleEntity)) return;
|
if (!(vehicle instanceof VehicleEntity)) return;
|
||||||
|
|
||||||
CustomStopRiding customStopRiding = CustomStopRiding.getInstance(player);
|
player.stopRiding();
|
||||||
customStopRiding.superbwarfare$stopRiding();
|
|
||||||
|
|
||||||
player.setJumping(false);
|
player.setJumping(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue