添加快艇的操控方式
This commit is contained in:
parent
1b8e2c03fd
commit
addf9d0ea3
11 changed files with 376 additions and 103 deletions
|
@ -137,6 +137,7 @@ public class ModUtils {
|
|||
addNetworkMessage(AdjustMortarAngleMessage.class, AdjustMortarAngleMessage::encode, AdjustMortarAngleMessage::decode, AdjustMortarAngleMessage::handler);
|
||||
addNetworkMessage(InteractMessage.class, InteractMessage::encode, InteractMessage::decode, InteractMessage::handler);
|
||||
addNetworkMessage(DroneMovementMessage.class, DroneMovementMessage::encode, DroneMovementMessage::decode, DroneMovementMessage::handler);
|
||||
addNetworkMessage(VehicleMovementMessage.class, VehicleMovementMessage::encode, VehicleMovementMessage::decode, VehicleMovementMessage::handler);
|
||||
addNetworkMessage(DroneFireMessage.class, DroneFireMessage::encode, DroneFireMessage::decode, DroneFireMessage::handler);
|
||||
addNetworkMessage(SimulationDistanceMessage.class, SimulationDistanceMessage::encode, SimulationDistanceMessage::decode, SimulationDistanceMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||
addNetworkMessage(GunReforgeMessage.class, GunReforgeMessage::encode, GunReforgeMessage::decode, GunReforgeMessage::handler);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.compat.CompatHolder;
|
|||
import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
|
||||
import com.atsuishio.superbwarfare.config.client.ReloadConfig;
|
||||
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
||||
import com.atsuishio.superbwarfare.entity.IVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.MortarEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
|
@ -355,6 +356,7 @@ public class ClickHandler {
|
|||
if (player == null) return;
|
||||
|
||||
handleDroneMove(key, state, player);
|
||||
handleVehicleMove(key, state, player);
|
||||
}
|
||||
|
||||
private static void handleDroneMove(int key, int state, Player player) {
|
||||
|
@ -380,6 +382,23 @@ public class ClickHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleVehicleMove(int key, int state, Player player) {
|
||||
if (player.getVehicle() != null && player.getVehicle() instanceof IVehicleEntity && player.getVehicle().getFirstPassenger() == player) {
|
||||
|
||||
var options = Minecraft.getInstance().options;
|
||||
|
||||
if (key == options.keyLeft.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(0, state == 1));
|
||||
} else if (key == options.keyRight.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(1, state == 1));
|
||||
} else if (key == options.keyUp.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(2, state == 1));
|
||||
} else if (key == options.keyDown.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(3, state == 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleDoubleJump(Player player) {
|
||||
Level level = player.level();
|
||||
double x = player.getX();
|
||||
|
|
|
@ -2,11 +2,19 @@ package com.atsuishio.superbwarfare.client.model.entity;
|
|||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||
import software.bernie.geckolib.core.animation.AnimationState;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.DELTA_ROT;
|
||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.POWER;
|
||||
|
||||
public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
||||
public static float lerpRotY = 0f;
|
||||
public static float rotorSpeed = 0f;
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(SpeedboatEntity entity) {
|
||||
|
@ -26,5 +34,17 @@ public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
|||
|
||||
@Override
|
||||
public void setCustomAnimations(SpeedboatEntity animatable, long instanceId, AnimationState<SpeedboatEntity> animationState) {
|
||||
float times = Minecraft.getInstance().getDeltaFrameTime();
|
||||
|
||||
CoreGeoBone rotor = getAnimationProcessor().getBone("Rotor");
|
||||
CoreGeoBone duo = getAnimationProcessor().getBone("duo");
|
||||
|
||||
rotorSpeed = Mth.lerp(0.1f * times, rotorSpeed, 10 * animatable.getEntityData().get(POWER));
|
||||
rotor.setRotZ(rotor.getRotZ() + rotorSpeed);
|
||||
|
||||
|
||||
lerpRotY = Mth.lerp(0.5f * times, lerpRotY, animatable.getEntityData().get(DELTA_ROT));
|
||||
|
||||
duo.setRotY(0.5f * lerpRotY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
|||
|
||||
public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntity> {
|
||||
|
||||
public static float lerpRotY = 0f;
|
||||
|
||||
public SpeedboatRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new SpeedboatModel());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
|||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
@ -28,6 +29,7 @@ import net.minecraft.world.entity.projectile.ThrownPotion;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
|
@ -40,9 +42,21 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, IVehicleEntity{
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ENERGY = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ROT_Y = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> POWER = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static final float MAX_HEALTH = CannonConfig.MK42_HP.get();
|
||||
|
||||
private boolean inputLeft;
|
||||
private boolean inputRight;
|
||||
private boolean inputUp;
|
||||
private boolean inputDown;
|
||||
private int lerpSteps;
|
||||
private double lerpX;
|
||||
private double lerpY;
|
||||
private double lerpZ;
|
||||
private double lerpYRot;
|
||||
private double lerpXRot;
|
||||
|
||||
public SpeedboatEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.SPEEDBOAT.get(), world);
|
||||
|
@ -56,6 +70,9 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
protected void defineSynchedData() {
|
||||
this.entityData.define(HEALTH, MAX_HEALTH);
|
||||
this.entityData.define(ENERGY, 0f);
|
||||
this.entityData.define(ROT_Y, 0f);
|
||||
this.entityData.define(DELTA_ROT, 0f);
|
||||
this.entityData.define(POWER, 0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,15 +90,23 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
this.entityData.set(HEALTH, MAX_HEALTH);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canCollideWith(Entity pEntity) {
|
||||
return canVehicleCollide(this, pEntity);
|
||||
}
|
||||
|
||||
//TODO 创飞碰到的碰撞箱小于该船的实体,且本体速度不会减少太多
|
||||
|
||||
public static boolean canVehicleCollide(Entity pVehicle, Entity pEntity) {
|
||||
return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !pVehicle.isPassengerOfSameVehicle(pEntity);
|
||||
}
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideWith(Entity pEntity) {
|
||||
return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !this.isPassengerOfSameVehicle(pEntity);
|
||||
public boolean isPushable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,11 +182,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Vec3 getDeltaMovement() {
|
||||
// return new Vec3(0, Math.min(super.getDeltaMovement().y, 0), 0);
|
||||
// }
|
||||
|
||||
public double getSubmergedHeight(Entity entity) {
|
||||
for (FluidType fluidType : ForgeRegistries.FLUID_TYPES.get().getValues()) {
|
||||
if (entity.level().getFluidState(entity.blockPosition()).getFluidType() == fluidType)
|
||||
|
@ -174,23 +194,39 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
|
||||
// if (this.getFirstPassenger() instanceof Player player) {
|
||||
// player.displayClientMessage(Component.literal("SubmergedHeight" + new java.text.DecimalFormat("##.##").format(getSubmergedHeight(this))), true);
|
||||
// player.displayClientMessage(Component.literal("Angle" + new java.text.DecimalFormat("##.##").format(Mth.abs(90 - (float)calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90)), true);
|
||||
// }
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
this.inputLeft = this.getPersistentData().getBoolean("left");
|
||||
this.inputRight = this.getPersistentData().getBoolean("right");
|
||||
this.inputUp = this.getPersistentData().getBoolean("forward");
|
||||
this.inputDown = this.getPersistentData().getBoolean("backward");
|
||||
|
||||
double fluidFloat;
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
|
||||
if (this.isInWater()) {
|
||||
fluidFloat = -0.025 + 0.05 * getSubmergedHeight(this);
|
||||
} else {
|
||||
fluidFloat = -0.04;
|
||||
}
|
||||
|
||||
float f = 0.85f + 0.09f * Mth.abs(90 - (float)calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
||||
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0));
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(1, 0.85, 1));
|
||||
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.04 * this.getDeltaMovement().length())));
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.85, f));
|
||||
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
this.entityData.set(ROT_Y, this.getYRot());
|
||||
}
|
||||
|
||||
handleClientSync();
|
||||
this.tickLerp();
|
||||
this.controlBoat();
|
||||
|
||||
if (this.entityData.get(HEALTH) <= 0) {
|
||||
this.ejectPassengers();
|
||||
destroy();
|
||||
|
@ -198,6 +234,136 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
private void controlBoat() {
|
||||
if (this.isVehicle()) {
|
||||
Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||
|
||||
float diffY = 0;
|
||||
|
||||
diffY = (float) Mth.lerp(0.1 * diffY, diffY, 0);
|
||||
|
||||
|
||||
if (this.inputUp) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) + 0.05f);
|
||||
}
|
||||
|
||||
if (this.inputDown) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) - 0.05f);
|
||||
if (this.inputLeft) {
|
||||
diffY = Mth.clamp(diffY + 1f, 0, 5);
|
||||
handleSetDiffY(diffY);
|
||||
} else if (this.inputRight) {
|
||||
diffY = Mth.clamp(diffY - 1f, -5, 0);
|
||||
handleSetDiffY(diffY);
|
||||
}
|
||||
} else {
|
||||
if (this.inputLeft) {
|
||||
diffY = Mth.clamp(diffY - 1f, -5, 0);
|
||||
handleSetDiffY(diffY);
|
||||
} else if (this.inputRight) {
|
||||
diffY = Mth.clamp(diffY + 1f, 0, 5);
|
||||
handleSetDiffY(diffY);
|
||||
}
|
||||
}
|
||||
|
||||
if (level().isClientSide) {
|
||||
level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.inputUp || this.inputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 0.7f), false);
|
||||
}
|
||||
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.3f);
|
||||
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.8f);
|
||||
|
||||
|
||||
this.setYRot(this.entityData.get(ROT_Y) + this.entityData.get(DELTA_ROT));
|
||||
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(Mth.sin(-this.entityData.get(ROT_Y) * 0.017453292F) * this.entityData.get(POWER), 0.0, Mth.cos(this.entityData.get(ROT_Y) * 0.017453292F) * this.entityData.get(POWER)));
|
||||
|
||||
// if (this.getFirstPassenger() instanceof Player player) {
|
||||
// player.displayClientMessage(Component.literal("Angle" + new java.text.DecimalFormat("##.##").format(this.entityData.get(DELTA_ROT))), false);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSetDiffY(float diffY) {
|
||||
this.entityData.set(DELTA_ROT, (float) (diffY * 1.3 * Math.max(3 * this.getDeltaMovement().length(), 0.3)));
|
||||
}
|
||||
|
||||
private void handleClientSync() {
|
||||
if (isControlledByLocalInstance()) {
|
||||
lerpSteps = 0;
|
||||
syncPacketPositionCodec(getX(), getY(), getZ());
|
||||
}
|
||||
if (lerpSteps <= 0) {
|
||||
return;
|
||||
}
|
||||
double interpolatedX = getX() + (lerpX - getX()) / (double) lerpSteps;
|
||||
double interpolatedY = getY() + (lerpY - getY()) / (double) lerpSteps;
|
||||
double interpolatedZ = getZ() + (lerpZ - getZ()) / (double) lerpSteps;
|
||||
double interpolatedYaw = Mth.wrapDegrees(lerpYRot - (double) getYRot());
|
||||
setYRot(getYRot() + (float) interpolatedYaw / (float) lerpSteps);
|
||||
setXRot(getXRot() + (float) (lerpXRot - (double) getXRot()) / (float) lerpSteps);
|
||||
|
||||
setPos(interpolatedX, interpolatedY, interpolatedZ);
|
||||
setRot(getYRot(), getXRot());
|
||||
|
||||
--lerpSteps;
|
||||
}
|
||||
|
||||
protected SoundEvent getEngineSound() {
|
||||
return ModSounds.BOAT_ENGINE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void positionRider(Entity pPassenger, MoveFunction pCallback) {
|
||||
super.positionRider(pPassenger, pCallback);
|
||||
if (this.hasPassenger(pPassenger)) {
|
||||
pPassenger.setYRot(pPassenger.getYRot() + 1.27f * this.entityData.get(DELTA_ROT));
|
||||
pPassenger.setYHeadRot(pPassenger.getYHeadRot() + 1.27f * this.entityData.get(DELTA_ROT));
|
||||
}
|
||||
}
|
||||
|
||||
public static double calculateAngle(Vec3 move, Vec3 view) {
|
||||
double startLength = move.length();
|
||||
double endLength = view.length();
|
||||
if (startLength > 0.0D && endLength > 0.0D) {
|
||||
return Math.toDegrees(Math.acos(move.dot(view) / (startLength * endLength)));
|
||||
} else {
|
||||
return 0.0D;
|
||||
}
|
||||
}
|
||||
|
||||
private void tickLerp() {
|
||||
if (this.isControlledByLocalInstance()) {
|
||||
this.lerpSteps = 0;
|
||||
this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
if (this.lerpSteps > 0) {
|
||||
double d0 = this.getX() + (this.lerpX - this.getX()) / (double)this.lerpSteps;
|
||||
double d1 = this.getY() + (this.lerpY - this.getY()) / (double)this.lerpSteps;
|
||||
double d2 = this.getZ() + (this.lerpZ - this.getZ()) / (double)this.lerpSteps;
|
||||
double d3 = Mth.wrapDegrees(this.lerpYRot - (double)this.getYRot());
|
||||
this.setYRot(this.getYRot() + (float)d3 / (float)this.lerpSteps);
|
||||
this.setXRot(this.getXRot() + (float)(this.lerpXRot - (double)this.getXRot()) / (float)this.lerpSteps);
|
||||
--this.lerpSteps;
|
||||
this.setPos(d0, d1, d2);
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lerpTo(double pX, double pY, double pZ, float pYaw, float pPitch, int pPosRotationIncrements, boolean pTeleport) {
|
||||
this.lerpX = pX;
|
||||
this.lerpY = pY;
|
||||
this.lerpZ = pZ;
|
||||
this.lerpYRot = pYaw;
|
||||
this.lerpXRot = pPitch;
|
||||
this.lerpSteps = 10;
|
||||
}
|
||||
|
||||
private void destroy() {
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this), 20f,
|
||||
|
|
|
@ -342,5 +342,7 @@ public class ModSounds {
|
|||
public static final RegistryObject<SoundEvent> ANNIHILATOR_FAR = REGISTRY.register("annihilator_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "annihilator_far")));
|
||||
public static final RegistryObject<SoundEvent> ANNIHILATOR_VERYFAR = REGISTRY.register("annihilator_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "annihilator_veryfar")));
|
||||
public static final RegistryObject<SoundEvent> ANNIHILATOR_RELOAD = REGISTRY.register("annihilator_reload", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "annihilator_reload")));
|
||||
|
||||
public static final RegistryObject<SoundEvent> BOAT_ENGINE = REGISTRY.register("boat_engine", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "boat_engine")));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.mixins;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.AnnihilatorEntity;
|
||||
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
||||
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
||||
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
||||
import com.atsuishio.superbwarfare.entity.*;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
|
@ -76,6 +73,10 @@ public abstract class CameraMixin {
|
|||
move(-getMaxZoom(16), 1.3, 0.0);
|
||||
return;
|
||||
}
|
||||
if (thirdPerson && entity.getVehicle() instanceof SpeedboatEntity) {
|
||||
move(-getMaxZoom(6), 1.3, 0.0);
|
||||
return;
|
||||
}
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||
move(-getMaxZoom(-2.9 * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos)), 0, -ClientEventHandler.cameraLocation * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.atsuishio.superbwarfare.network.message;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class VehicleMovementMessage {
|
||||
private final int direction;
|
||||
private final boolean clicked;
|
||||
|
||||
public VehicleMovementMessage(int direction, boolean clicked) {
|
||||
this.direction = direction;
|
||||
this.clicked = clicked;
|
||||
}
|
||||
|
||||
public static VehicleMovementMessage decode(FriendlyByteBuf buffer) {
|
||||
return new VehicleMovementMessage(buffer.readInt(), buffer.readBoolean());
|
||||
}
|
||||
|
||||
public static void encode(VehicleMovementMessage message, FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(message.direction);
|
||||
buffer.writeBoolean(message.clicked);
|
||||
}
|
||||
|
||||
public static void handler(VehicleMovementMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
if (context.getSender() != null) {
|
||||
Player player = context.getSender();
|
||||
|
||||
var vehicle = player.getVehicle();
|
||||
if (vehicle != null) {
|
||||
switch (message.direction) {
|
||||
case 0:
|
||||
vehicle.getPersistentData().putBoolean("left", message.clicked);
|
||||
break;
|
||||
case 1:
|
||||
vehicle.getPersistentData().putBoolean("right", message.clicked);
|
||||
break;
|
||||
case 2:
|
||||
vehicle.getPersistentData().putBoolean("forward", message.clicked);
|
||||
break;
|
||||
case 3:
|
||||
vehicle.getPersistentData().putBoolean("backward", message.clicked);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
}
|
|
@ -2773,8 +2773,8 @@
|
|||
"pivot": [20.4, 12, 49.2],
|
||||
"cubes": [
|
||||
{
|
||||
"origin": [27.50528, 10.8, 46.8],
|
||||
"size": [0.684, 1.2, 2.4],
|
||||
"origin": [27.50528, 10.8, 48.2],
|
||||
"size": [0.684, 1.2, 1],
|
||||
"pivot": [20.4, 12, 49.2],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2782,8 +2782,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [28.18928, 11.424, 46.8],
|
||||
"size": [0.36, 0.576, 2.4],
|
||||
"origin": [28.18928, 11.424, 48.2],
|
||||
"size": [0.36, 0.576, 1],
|
||||
"pivot": [20.4, 12, 49.2],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2791,8 +2791,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [16.91902, 11.424, 58.07027],
|
||||
"size": [0.36, 0.576, 2.4],
|
||||
"origin": [16.91902, 11.424, 59.47027],
|
||||
"size": [0.36, 0.576, 1],
|
||||
"pivot": [9.12973, 12, 60.47027],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2800,8 +2800,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [16.97324, 10.8, 57.33205],
|
||||
"size": [0.684, 1.2, 2.4],
|
||||
"origin": [16.97324, 10.8, 58.73205],
|
||||
"size": [0.684, 1.2, 1],
|
||||
"pivot": [9.86795, 12, 59.73205],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2809,8 +2809,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [15.69472, 7.2, 46.8],
|
||||
"size": [9.41056, 2.4, 2.4],
|
||||
"origin": [15.69472, 7.2, 48.2],
|
||||
"size": [9.41056, 2.4, 1],
|
||||
"pivot": [20.4, 12, 49.2],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2818,8 +2818,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [17.49472, 4.8, 46.8],
|
||||
"size": [5.81056, 2.4, 2.4],
|
||||
"origin": [17.49472, 4.8, 48.2],
|
||||
"size": [5.81056, 2.4, 1],
|
||||
"pivot": [20.4, 12, 49.2],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2827,8 +2827,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [18.69472, 1.8, 46.8],
|
||||
"size": [3.41056, 3, 2.4],
|
||||
"origin": [18.69472, 1.8, 48.2],
|
||||
"size": [3.41056, 3, 1],
|
||||
"pivot": [20.4, 12, 49.2],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2836,8 +2836,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [17.02934, -0.68866, 43.2],
|
||||
"size": [2.4, 14.184, 0],
|
||||
"origin": [17.02934, -0.68866, 42.2],
|
||||
"size": [2.4, 14.184, 1],
|
||||
"pivot": [19.42934, 5.02934, 43.2],
|
||||
"rotation": [0, 54.5, 45],
|
||||
"uv": {
|
||||
|
@ -2845,8 +2845,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [19.06934, 13.49534, 43.2],
|
||||
"size": [0.36, 0.72, 0],
|
||||
"origin": [19.06934, 13.49534, 42.2],
|
||||
"size": [0.36, 0.72, 1],
|
||||
"pivot": [19.42934, 5.02934, 43.2],
|
||||
"rotation": [0, 54.5, 45],
|
||||
"uv": {
|
||||
|
@ -2854,8 +2854,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [19.06934, 14.21534, 43.2],
|
||||
"size": [0.36, 0.672, 0],
|
||||
"origin": [19.06934, 14.21534, 42.2],
|
||||
"size": [0.36, 0.672, 1],
|
||||
"pivot": [19.42934, 5.02934, 43.2],
|
||||
"rotation": [0, 54.5, 45],
|
||||
"uv": {
|
||||
|
@ -2863,8 +2863,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [14.4, -1.11861, 46.80939],
|
||||
"size": [2.4, 14.22, 2.4],
|
||||
"origin": [14.4, -1.11861, 48.20939],
|
||||
"size": [2.4, 14.22, 1],
|
||||
"pivot": [14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, 24.24373, -26.76521],
|
||||
"uv": {
|
||||
|
@ -2872,8 +2872,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [14.4, -1.80261, 46.80939],
|
||||
"size": [1.212, 0.684, 2.4],
|
||||
"origin": [14.4, -1.80261, 48.20939],
|
||||
"size": [1.212, 0.684, 1],
|
||||
"pivot": [14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, 24.24373, -26.76521],
|
||||
"uv": {
|
||||
|
@ -2881,8 +2881,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [14.4, -2.48661, 46.80939],
|
||||
"size": [0.492, 0.684, 2.4],
|
||||
"origin": [14.4, -2.48661, 48.20939],
|
||||
"size": [0.492, 0.684, 1],
|
||||
"pivot": [14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, 24.24373, -26.76521],
|
||||
"uv": {
|
||||
|
@ -2890,8 +2890,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [14.892, -2.19861, 46.80939],
|
||||
"size": [0.684, 0.396, 2.4],
|
||||
"origin": [14.892, -2.19861, 48.20939],
|
||||
"size": [0.684, 0.396, 1],
|
||||
"pivot": [14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, 24.24373, -26.76521],
|
||||
"uv": {
|
||||
|
@ -2899,8 +2899,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [14.4, 13.10139, 46.80939],
|
||||
"size": [0.36, 0.72, 2.4],
|
||||
"origin": [14.4, 13.10139, 48.20939],
|
||||
"size": [0.36, 0.72, 1],
|
||||
"pivot": [14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, 24.24373, -26.76521],
|
||||
"uv": {
|
||||
|
@ -2908,8 +2908,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [14.4, 13.82139, 46.80939],
|
||||
"size": [0.36, 0.66, 2.4],
|
||||
"origin": [14.4, 13.82139, 48.20939],
|
||||
"size": [0.36, 0.66, 1],
|
||||
"pivot": [14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, 24.24373, -26.76521],
|
||||
"uv": {
|
||||
|
@ -2917,8 +2917,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [13.29472, 9.6, 46.8],
|
||||
"size": [14.21056, 2.4, 2.4],
|
||||
"origin": [13.29472, 9.6, 48.2],
|
||||
"size": [14.21056, 2.4, 1],
|
||||
"pivot": [20.4, 12, 49.2],
|
||||
"rotation": [-35.22, 45, 0],
|
||||
"uv": {
|
||||
|
@ -2933,156 +2933,156 @@
|
|||
"pivot": [-20.4, 12, 49.2],
|
||||
"cubes": [
|
||||
{
|
||||
"origin": [-28.18928, 10.8, 46.8],
|
||||
"size": [0.684, 1.2, 2.4],
|
||||
"origin": [-28.18928, 10.8, 48.2],
|
||||
"size": [0.684, 1.2, 1],
|
||||
"pivot": [-20.4, 12, 49.2],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 20], "uv_size": [1, 1]}
|
||||
"south": {"uv": [56, 14], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-28.54928, 11.424, 46.8],
|
||||
"size": [0.36, 0.576, 2.4],
|
||||
"origin": [-28.54928, 11.424, 48.2],
|
||||
"size": [0.36, 0.576, 1],
|
||||
"pivot": [-20.4, 12, 49.2],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 21], "uv_size": [1, 1]}
|
||||
"south": {"uv": [16, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-17.27902, 11.424, 58.07027],
|
||||
"size": [0.36, 0.576, 2.4],
|
||||
"origin": [-17.27902, 11.424, 59.47027],
|
||||
"size": [0.36, 0.576, 1],
|
||||
"pivot": [-9.12973, 12, 60.47027],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 22], "uv_size": [1, 1]}
|
||||
"south": {"uv": [18, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-17.65724, 10.8, 57.33205],
|
||||
"size": [0.684, 1.2, 2.4],
|
||||
"origin": [-17.65724, 10.8, 58.73205],
|
||||
"size": [0.684, 1.2, 1],
|
||||
"pivot": [-9.86795, 12, 59.73205],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 23], "uv_size": [1, 1]}
|
||||
"south": {"uv": [56, 16], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-25.10528, 7.2, 46.8],
|
||||
"size": [9.41056, 2.4, 2.4],
|
||||
"origin": [-25.10528, 7.2, 48.2],
|
||||
"size": [9.41056, 2.4, 1],
|
||||
"pivot": [-20.4, 12, 49.2],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [6, 53], "uv_size": [2, 1]}
|
||||
"south": {"uv": [17, 52], "uv_size": [-2, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-23.30528, 4.8, 46.8],
|
||||
"size": [5.81056, 2.4, 2.4],
|
||||
"origin": [-23.30528, 4.8, 48.2],
|
||||
"size": [5.81056, 2.4, 1],
|
||||
"pivot": [-20.4, 12, 49.2],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 24], "uv_size": [1, 1]}
|
||||
"south": {"uv": [14, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-22.10528, 1.8, 46.8],
|
||||
"size": [3.41056, 3, 2.4],
|
||||
"origin": [-22.10528, 1.8, 48.2],
|
||||
"size": [3.41056, 3, 1],
|
||||
"pivot": [-20.4, 12, 49.2],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 25], "uv_size": [1, 1]}
|
||||
"south": {"uv": [15, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-19.42934, -0.68866, 43.2],
|
||||
"size": [2.4, 14.184, 0],
|
||||
"origin": [-19.42934, -0.68866, 42.2],
|
||||
"size": [2.4, 14.184, 1],
|
||||
"pivot": [-19.42934, 5.02934, 43.2],
|
||||
"rotation": [0, -54.5, -45],
|
||||
"uv": {
|
||||
"south": {"uv": [17, 47], "uv_size": [1, 4]}
|
||||
"south": {"uv": [33, 42], "uv_size": [-1, 4]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-19.42934, 13.49534, 43.2],
|
||||
"size": [0.36, 0.72, 0],
|
||||
"origin": [-19.42934, 13.49534, 42.2],
|
||||
"size": [0.36, 0.72, 1],
|
||||
"pivot": [-19.42934, 5.02934, 43.2],
|
||||
"rotation": [0, -54.5, -45],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 26], "uv_size": [1, 1]}
|
||||
"south": {"uv": [56, 15], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-19.42934, 14.21534, 43.2],
|
||||
"size": [0.36, 0.672, 0],
|
||||
"origin": [-19.42934, 14.21534, 42.2],
|
||||
"size": [0.36, 0.672, 1],
|
||||
"pivot": [-19.42934, 5.02934, 43.2],
|
||||
"rotation": [0, -54.5, -45],
|
||||
"uv": {
|
||||
"south": {"uv": [27, 55], "uv_size": [1, 1]}
|
||||
"south": {"uv": [17, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-16.8, -1.11861, 46.80939],
|
||||
"size": [2.4, 14.22, 2.4],
|
||||
"origin": [-16.8, -1.11861, 48.20939],
|
||||
"size": [2.4, 14.22, 1],
|
||||
"pivot": [-14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, -24.24373, 26.76521],
|
||||
"uv": {
|
||||
"south": {"uv": [18, 47], "uv_size": [1, 4]}
|
||||
"south": {"uv": [48, 14], "uv_size": [-1, 4]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-15.612, -1.80261, 46.80939],
|
||||
"size": [1.212, 0.684, 2.4],
|
||||
"origin": [-15.612, -1.80261, 48.20939],
|
||||
"size": [1.212, 0.684, 1],
|
||||
"pivot": [-14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, -24.24373, 26.76521],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 27], "uv_size": [1, 1]}
|
||||
"south": {"uv": [20, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-14.892, -2.48661, 46.80939],
|
||||
"size": [0.492, 0.684, 2.4],
|
||||
"origin": [-14.892, -2.48661, 48.20939],
|
||||
"size": [0.492, 0.684, 1],
|
||||
"pivot": [-14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, -24.24373, 26.76521],
|
||||
"uv": {
|
||||
"south": {"uv": [28, 55], "uv_size": [1, 1]}
|
||||
"south": {"uv": [56, 19], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-15.576, -2.19861, 46.80939],
|
||||
"size": [0.684, 0.396, 2.4],
|
||||
"origin": [-15.576, -2.19861, 48.20939],
|
||||
"size": [0.684, 0.396, 1],
|
||||
"pivot": [-14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, -24.24373, 26.76521],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 28], "uv_size": [1, 1]}
|
||||
"south": {"uv": [21, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-14.76, 13.10139, 46.80939],
|
||||
"size": [0.36, 0.72, 2.4],
|
||||
"origin": [-14.76, 13.10139, 48.20939],
|
||||
"size": [0.36, 0.72, 1],
|
||||
"pivot": [-14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, -24.24373, 26.76521],
|
||||
"uv": {
|
||||
"south": {"uv": [29, 55], "uv_size": [1, 1]}
|
||||
"south": {"uv": [56, 17], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-14.76, 13.82139, 46.80939],
|
||||
"size": [0.36, 0.66, 2.4],
|
||||
"origin": [-14.76, 13.82139, 48.20939],
|
||||
"size": [0.36, 0.66, 1],
|
||||
"pivot": [-14.4, 6.00939, 49.20939],
|
||||
"rotation": [-50.85043, -24.24373, 26.76521],
|
||||
"uv": {
|
||||
"south": {"uv": [55, 29], "uv_size": [1, 1]}
|
||||
"south": {"uv": [19, 55], "uv_size": [-1, 1]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-27.50528, 9.6, 46.8],
|
||||
"size": [14.21056, 2.4, 2.4],
|
||||
"origin": [-27.50528, 9.6, 48.2],
|
||||
"size": [14.21056, 2.4, 1],
|
||||
"pivot": [-20.4, 12, 49.2],
|
||||
"rotation": [-35.22, -45, 0],
|
||||
"uv": {
|
||||
"south": {"uv": [47, 18], "uv_size": [4, 1]}
|
||||
"south": {"uv": [17, 47], "uv_size": [-4, 1]}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -2429,5 +2429,13 @@
|
|||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"boat_engine": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:speedboat/engine",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Add table
Reference in a new issue