mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
98 lines
4.8 KiB
Diff
98 lines
4.8 KiB
Diff
--- a/net/minecraft/client/player/LocalPlayer.java
|
|
+++ b/net/minecraft/client/player/LocalPlayer.java
|
|
@@ -303,6 +_,7 @@
|
|
ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_
|
|
? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS
|
|
: ServerboundPlayerActionPacket.Action.DROP_ITEM;
|
|
+ if (isUsingItem() && getUsedItemHand() == InteractionHand.MAIN_HAND && (p_108701_ || getUseItem().getCount() == 1)) stopUsingItem(); // Forge: fix MC-231097 on the clientside
|
|
ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_);
|
|
this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN));
|
|
return !itemstack.isEmpty();
|
|
@@ -483,7 +_,11 @@
|
|
|
|
@Override
|
|
public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) {
|
|
- this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), p_108651_, this.getSoundSource(), p_108652_, p_108653_, false);
|
|
+ var holder = net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(p_108651_);
|
|
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this.level(), this, holder, this.getSoundSource(), p_108652_, p_108653_);
|
|
+ if (event.isCanceled() || event.getSound() == null) return;
|
|
+ this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), event.getSound().get(), event.getSource(), event.getNewVolume(), event.getNewPitch(), false);
|
|
+
|
|
}
|
|
|
|
@Override
|
|
@@ -716,6 +_,7 @@
|
|
&& this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)
|
|
&& (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING));
|
|
this.input.tick();
|
|
+ net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.input);
|
|
this.minecraft.getTutorial().onInput(this.input);
|
|
boolean flag3 = false;
|
|
if (this.autoJumpTime > 0) {
|
|
@@ -788,8 +_,9 @@
|
|
}
|
|
|
|
this.wasFallFlying = this.isFallFlying();
|
|
- if (this.isInWater() && this.input.keyPresses.shift() && this.isAffectedByFluids()) {
|
|
- this.goDownInWater();
|
|
+ var fluidType = this.getMaxHeightFluidType();
|
|
+ if ((this.isInWater() || (!fluidType.isAir() && this.canSwimInFluidType(fluidType))) && this.input.keyPresses.shift() && this.isAffectedByFluids()) {
|
|
+ this.sinkInFluid(this.isInWater() ? net.minecraftforge.common.ForgeMod.WATER_TYPE.get() : fluidType);
|
|
}
|
|
|
|
if (this.isEyeInFluid(FluidTags.WATER)) {
|
|
@@ -856,13 +_,14 @@
|
|
|| !this.input.hasForwardImpulse()
|
|
|| !this.hasEnoughFoodToSprint()
|
|
|| this.horizontalCollision && !this.minorHorizontalCollision
|
|
- || this.isInWater() && !this.isUnderWater();
|
|
+ || this.isInWater() && !this.isUnderWater()
|
|
+ || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming();
|
|
}
|
|
|
|
private boolean shouldStopSwimSprinting() {
|
|
return this.hasBlindness()
|
|
|| this.isPassenger() && !this.vehicleCanSprint(this.getVehicle())
|
|
- || !this.isInWater()
|
|
+ || !this.isInWaterOrSwimmable()
|
|
|| !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift()
|
|
|| !this.hasEnoughFoodToSprint();
|
|
}
|
|
@@ -914,6 +_,8 @@
|
|
@Override
|
|
public void rideTick() {
|
|
super.rideTick();
|
|
+ if (this.wantsToStopRiding() && this.isPassenger())
|
|
+ this.input.keyPresses = this.input.keyPresses.jump(false);
|
|
this.handsBusy = false;
|
|
if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) {
|
|
abstractboat.setInput(
|
|
@@ -1090,7 +_,7 @@
|
|
&& (!this.isPassenger() || this.vehicleCanSprint(this.getVehicle()))
|
|
&& (!this.isFallFlying() || this.isUnderWater())
|
|
&& (!this.isMovingSlowly() || this.isUnderWater())
|
|
- && (!this.isInWater() || this.isUnderWater());
|
|
+ && (!this.isInWater() || this.isUnderWater() || this.canStartSwimming());
|
|
}
|
|
|
|
private boolean vehicleCanSprint(Entity p_265184_) {
|
|
@@ -1169,6 +_,18 @@
|
|
@Override
|
|
public float getVisualRotationYInDegrees() {
|
|
return this.getYRot();
|
|
+ }
|
|
+
|
|
+ public void updateSyncFields(LocalPlayer old) {
|
|
+ this.xLast = old.xLast;
|
|
+ this.yLast = old.yLast;
|
|
+ this.zLast = old.zLast;
|
|
+ this.yRotLast = old.yRotLast;
|
|
+ this.xRotLast = old.xRotLast;
|
|
+ this.lastOnGround = old.lastOnGround;
|
|
+ this.wasShiftKeyDown = old.wasShiftKeyDown;
|
|
+ this.wasSprinting = old.wasSprinting;
|
|
+ this.positionReminder = old.positionReminder;
|
|
}
|
|
|
|
@Override
|