mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
There a lot of performance improvements related to events. No more InheritableEvent for abstract events that you shouldn't add listeners to anyway, like EntityEvent. Use their sub-events. Made a lot more events records and interfaces. Mostly just a binary break, but has better performance. Mod bus posting methods are now static, no more ModLoader.get() for those. ObjectHolder was removed, use RegistryObject. Changed RuntimeEnumExtender to only target Minecraft classes. If you want other modders to interact with your API, use an Interface instead of Enum. Moved some abstract event methods to only the relevant sub-events now, e.g. can no longer check the side of a ClientTickEvent, because it'll always be client Rendering has changed a lot, they now batch most things together so that the game will render faster. RenderHighlightEvent changed a lot See https://github.com/MinecraftForge/MinecraftForge-Experimental/tree/1.21.9-dev for unsquashed commits. Co-authored-by: Paint_Ninja <[email protected]>
89 lines
4.3 KiB
Diff
89 lines
4.3 KiB
Diff
--- a/net/minecraft/client/player/LocalPlayer.java
|
|
+++ b/net/minecraft/client/player/LocalPlayer.java
|
|
@@ -295,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();
|
|
@@ -482,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 == null || event.getSound() == null) return;
|
|
+ this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), event.getSound().get(), event.getSource(), event.getNewVolume(), event.getNewPitch(), false);
|
|
+
|
|
}
|
|
|
|
@Override
|
|
@@ -720,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) {
|
|
@@ -792,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)) {
|
|
@@ -859,7 +_,7 @@
|
|
}
|
|
|
|
private boolean shouldStopSwimSprinting() {
|
|
- return !this.isSprintingPossible(true) || !this.isInWater() || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift();
|
|
+ return !this.isSprintingPossible(true) || !this.isInWaterOrSwimmable() || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift();
|
|
}
|
|
|
|
public Portal.Transition getActivePortalLocalTransition() {
|
|
@@ -902,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(
|
|
@@ -1079,7 +_,7 @@
|
|
&& this.isSprintingPossible(this.getAbilities().flying)
|
|
&& !this.isUsingItem()
|
|
&& (!this.isFallFlying() || this.isUnderWater())
|
|
- && (!this.isMovingSlowly() || this.isUnderWater());
|
|
+ && (!this.isMovingSlowly() || this.isUnderWater() || this.canStartSwimming());
|
|
}
|
|
|
|
private boolean vehicleCanSprint(Entity p_265184_) {
|
|
@@ -1158,6 +_,17 @@
|
|
@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.wasSprinting = old.wasSprinting;
|
|
+ this.positionReminder = old.positionReminder;
|
|
}
|
|
|
|
@Override
|