mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 08:19:26 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@7fbb827 Finish API patches PaperMC/Paper@8a37f93 62 PaperMC/Paper@2055809 117 PaperMC/Paper@0b75522 194 PaperMC/Paper@ec05cb8 279 PaperMC/Paper@0bc9aee 385 PaperMC/Paper@27e29cc 487/1053 PaperMC/Paper@083bd9e 531/1053 PaperMC/Paper@ed2ea45 538 PaperMC/Paper@ba163e1 585/1053 PaperMC/Paper@8731266 650/1053 PaperMC/Paper@52b49fb 788/1053 PaperMC/Paper@33b36cd update some patches PaperMC/Paper@14c0336 922 PaperMC/Paper@a399f23 956 PaperMC/Paper@4140de2 960 PaperMC/Paper@6d4e235 988 PaperMC/Paper@6a34750 Move unapplied patches to the back PaperMC/Paper@3c04f9f Fix a few compile errors PaperMC/Paper@0d3ce2d Fix more compile issues PaperMC/Paper@a308c7c Fix more compile issues PaperMC/Paper@69d1d0a Pretend to fix compile errors PaperMC/Paper@547f09d Some work on the ItemMend events PaperMC/Paper@184a943 Adopt previous commit changes in API PaperMC/Paper@5442bff Make it compile PaperMC/Paper@038f8d9 Fixup and deprecate player profiles in ping event PaperMC/Paper@66f7b67 Fix body equipmentslot and effect enum PaperMC/Paper@38b3182 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@df633e5 DataConverter 1.21 PaperMC/Paper@f569389 Update ConcurrentUtil PaperMC/Paper@5fca3ae update generated API PaperMC/Paper@188cff2 remove old vanilla goals PaperMC/Paper@ffe310a remove api that was scheduled for removal PaperMC/Paper@730882f Chunk System and Starlight WIP PaperMC/Paper@512fd08 Update Gradle Wrapper to v8.8 PaperMC/Paper@097284d Bump tiny-remapper to 0.10.3 PaperMC/Paper@ee9b820 Update more optimization patches PaperMC/Paper@5d834b1 rebuild patches PaperMC/Paper@4bc15f1 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@0b6701d Revert DamageSource#getCausingEntity to vanilla PaperMC/Paper@5bd7f4e Update AbstractArrow item method implementations for 1.20.6 (#10885) PaperMC/Paper@fb511c6 Fix Player#sendBlockState (#10855) PaperMC/Paper@b420038 Fix ItemMeta#removeEnchantments (#10886) PaperMC/Paper@a835ad1 Merge remote-tracking branch 'origin/dev/1.21' into dev/1.21 PaperMC/Paper@04dad71 Improve enchantWithLevels logic PaperMC/Paper@0008fa1 Add back more optimization patches PaperMC/Paper@56b5b7d Fix max chunk status checks PaperMC/Paper@c1aefee correctly change enchantment registry to a 'delayed' version PaperMC/Paper@d41636f Add back RecipeIterator fixes patch (#10887) PaperMC/Paper@7df4725 Configurable damage tick when blocking with shield (#10877) PaperMC/Paper@3555a77 Properly forward DispenseEvent #getItem to saddle PaperMC/Paper@e339ec2 Deprecate BlockData#getDestroySpeed for removal PaperMC/Paper@b090c65 Remove unnecessary changes from chunk status fix PaperMC/Paper@5e7cd07 add some generated typed/tag keys PaperMC/Paper@5a5412c Owen fixing stuff!!! PaperMC/Paper@7240d9d Restore functionality to sand dupe setting PaperMC/Paper@f873bce Fix NPE in V3808 PaperMC/Paper@1f8e7a7 address compile and test issue (#10890) PaperMC/Paper@60f3bd8 De-deprecate BlockData#getDestroySpeed PaperMC/Paper@752f957 Add back more patches PaperMC/Paper@dc684c6 Remove bad server.scheduleOnMain disconnect calls from old patches PaperMC/Paper@c84a3b5 Remove fully dropped patches PaperMC/Paper@d8c2980 Add Adventure API to ServerLinks (#10891) PaperMC/Paper@ec4c712 update 'improve mass craft perf' patch PaperMC/Paper@e1c0033 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@fbc2a55 Update Wither#canTravelThroughPortals PaperMC/Paper@167961e call EntityDamageItemEvent for thorns PaperMC/Paper@106dbae Fix getAddress connection check PaperMC/Paper@d9111cc Registry Modification API (#10893) PaperMC/Paper@f8ee0a0 Fix implementations of ChunkHolder#getChunkIfPresent PaperMC/Paper@61b85e4 Fix legacy cb version in remapper PaperMC/Paper@de8220c Update ChunkMap#distanceManager mapping patch PaperMC/Paper@8dfb85c Enchantment and GameEvent Registry builders (#10889) PaperMC/Paper@fb762cf remove remaining reference to 'pgive' PaperMC/Paper@a7f6633 make EntityPortalReadyEvent#setTargetWorld work again PaperMC/Paper@152f4fe Add back improved watchdog support patch PaperMC/Paper@13992b1 Make chunk system loggers calm down a bit PaperMC/Paper@bf8552f Delegate ItemStack (#10852) PaperMC/Paper@b3e072a Fix `hasFiredAsync` parameter when `AsyncPlayerSendCommandsEvent` is called (#10896) PaperMC/Paper@21c9a7c Rebuild patches PaperMC/Paper@b9f7098 [ci skip] Fix javadoc mistake in EnchantmentRegistryEntry.Builder (#10898) PaperMC/Paper@b4b8208 Fix NPE for Jukebox#setRecord PaperMC/Paper@4514f41 Correct duplicate attribute check (#10901) PaperMC/Paper@090775e Use ItemStack.empty() when air is passed into constructor PaperMC/Paper@7bbe682 Fix CraftWorld#isChunkGenerated PaperMC/Paper@126f6d7 Remove getUnloadingChunkHolder check PaperMC/Paper@d23825a Add missing null check to getFullChunkIfLoaded PaperMC/Paper@3b1c85b Execute chunk tasks while waiting for chunk load in isChunkGenerated PaperMC/Paper@4ea696f Add ticket for chunk load in isChunkGenerated PaperMC/Paper@250e78c Re-add fixlight command PaperMC/Paper@c0268ca Copy missing diff from old chunk system patch PaperMC/Paper@38428c0 Cleanup MCUtils patch for chunk system PaperMC/Paper@f4ddd4a Fix ChunkHolder#getFullChunkNow returning non-null when it should not PaperMC/Paper@e0d9d60 Add debug for chunk system unload crash PaperMC/Paper@2df432f Re-add chunk system debug commands PaperMC/Paper@cf60574 Fix jukebox playable component not being applied on item meta (#10922) PaperMC/Paper@666bc4d Experimental annotation changes (#10914) PaperMC/Paper@bab07e0 Validate speed for tool component rule (#10923) PaperMC/Paper@2118196 Fixes exception log messages getting dropped during bootstrap (#10935) PaperMC/Paper@8b1d26d Fix diff in sprint interruption option (Closes #10939) PaperMC/Paper@0a1b133 Revert "Fixes exception log messages getting dropped during bootstrap (#10935)" (Closes #10945) PaperMC/Paper@a0fad76 Fix base damage for trident (#10948) PaperMC/Paper@d64be7e Fix NPE of AbstractArrow#getWeapon (#10933) PaperMC/Paper@081146c Validate using_converts_to for food component (#10931) PaperMC/Paper@0409a68 deprecate and update some entity tags (#10932) PaperMC/Paper@9cd0201 Preserve velocity for fireball (#10934) PaperMC/Paper@19105a9 Fix unload queue storing chunks in wrong sections PaperMC/Paper@77c763b Fix PlayerShearBlockEvent drops ignored for Pumpkin (#10956) PaperMC/Paper@76c2f16 Fix wrong diff applying delta twice (#10959) PaperMC/Paper@812701d Do not crash when an exp orb attempts to mend an unrepairable item PaperMC/Paper@19eefe9 Fix SoundEffects only to players diff (#10966) PaperMC/Paper@95aa440 Add missing effect cause and deprecate PATROL_CAPTAIN cause (#10958) PaperMC/Paper@b2e5587 Expose LivingEntity#canUseSlot (#10930) PaperMC/Paper@97afc9a Fix StackOverflowError for new dispenser interaction (#10949) PaperMC/Paper@5ae4758 Fix speed for launched trident using api (#10936) PaperMC/Paper@897ece4 Call EntityPortalEnterEvent on endgateways and make cancellable (#10892) PaperMC/Paper@1d3fc0e Bump reflection-rewriter to 0.0.2 (#10927) PaperMC/Paper@b99d071 Swap some nullable annotations (#10960) PaperMC/Paper@dd31654 bump reflection-rewriter to 0.0.3 (#10969) PaperMC/Paper@dd49fba Fix NPE when retrieving an entity with a null UUID
239 lines
10 KiB
Diff
239 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Wed, 6 Oct 2021 11:03:01 -0500
|
|
Subject: [PATCH] (Slice) Packet obfuscation and reduction
|
|
|
|
Minecraft is overzealous about packet updates for Entities. In Loka's case, we want to reduce as many unnecessary
|
|
packet updates as possible. This patch is likely to be updated over and over in terms of reducing packet sends.
|
|
|
|
In summary, this patch creates the concept of a "foreignValue" of a packet's data. We treat packets in two ways:
|
|
1) The packet sent to the player itself (the normal way). This always has all of the values as usual.
|
|
2) The packet data as seen by any other (foreign) players.
|
|
|
|
This patch adds the ability to set a "foreignValue" for an entity value so as to obfuscate data received by other players.
|
|
The current packets modified/obfuscated are the following:
|
|
|
|
# This reduces the amount of health packet updates as well which is great for players in combat.
|
|
|
|
# Air level packets are sent PER-TICK, and as such a player with any change in air level will only spam themselves
|
|
# with packets instead of every single player within tracking distance
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
|
|
index 0f99733660f91280e4c6262cf75b3c9cae86f65a..ba9f8fe6fafc54bbdfb104de28af4b392feb4483 100644
|
|
--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
|
|
+++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
|
|
@@ -22,6 +22,7 @@ public class SynchedEntityData {
|
|
private final SyncedDataHolder entity;
|
|
private final SynchedEntityData.DataItem<?>[] itemsById;
|
|
private boolean isDirty;
|
|
+ private boolean isForeignDirty; // Slice
|
|
|
|
SynchedEntityData(SyncedDataHolder trackedEntity, SynchedEntityData.DataItem<?>[] entries) {
|
|
this.entity = trackedEntity;
|
|
@@ -63,6 +64,16 @@ public class SynchedEntityData {
|
|
}
|
|
|
|
public <T> void set(EntityDataAccessor<T> key, T value, boolean force) {
|
|
+ // Slice start
|
|
+ this.set(key, value, null, force);
|
|
+ }
|
|
+
|
|
+ public <T> void set(EntityDataAccessor<T> key, T value, T foreignValue) {
|
|
+ this.set(key, value, foreignValue, false);
|
|
+ }
|
|
+
|
|
+ public <T> void set(EntityDataAccessor<T> key, T value, T foreignValue, boolean force) {
|
|
+ // Slice end
|
|
SynchedEntityData.DataItem<T> datawatcher_item = this.getItem(key);
|
|
|
|
if (force || ObjectUtils.notEqual(value, datawatcher_item.getValue())) {
|
|
@@ -72,6 +83,12 @@ public class SynchedEntityData {
|
|
this.isDirty = true;
|
|
}
|
|
|
|
+ // Slice start
|
|
+ if (foreignValue != null && ObjectUtils.notEqual(foreignValue, datawatcher_item.getForeignValue())) {
|
|
+ datawatcher_item.setForeignValue(foreignValue);
|
|
+ this.isForeignDirty = true;
|
|
+ }
|
|
+ // Slice end
|
|
}
|
|
|
|
// CraftBukkit start - add method from above
|
|
@@ -81,6 +98,12 @@ public class SynchedEntityData {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ // Slice start
|
|
+ public boolean isForeignDirty() {
|
|
+ return this.isForeignDirty;
|
|
+ }
|
|
+ // Slice end
|
|
+
|
|
public boolean isDirty() {
|
|
return this.isDirty;
|
|
}
|
|
@@ -108,6 +131,29 @@ public class SynchedEntityData {
|
|
}
|
|
}
|
|
|
|
+ // Slice start
|
|
+ @Nullable
|
|
+ public List<SynchedEntityData.DataValue<?>> packForeignDirty(List<DataValue<?>> unpackedData) {
|
|
+ List<SynchedEntityData.DataValue<?>> list = null;
|
|
+
|
|
+ for (DataValue<?> dataItem : unpackedData) {
|
|
+ DataItem<?> item = this.itemsById[dataItem.id()];
|
|
+ if (item.isDirty(true)) {
|
|
+ item.setForeignDirty(false);
|
|
+
|
|
+ if (list == null) {
|
|
+ list = new ArrayList<>();
|
|
+ }
|
|
+
|
|
+ list.add(item.copy(true));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.isForeignDirty = false;
|
|
+ return list;
|
|
+ }
|
|
+ // Slice end
|
|
+
|
|
@Nullable
|
|
public List<SynchedEntityData.DataValue<?>> getNonDefaultValues() {
|
|
List<SynchedEntityData.DataValue<?>> list = null;
|
|
@@ -171,11 +217,14 @@ public class SynchedEntityData {
|
|
T value;
|
|
private final T initialValue;
|
|
private boolean dirty;
|
|
+ @Nullable T foreignValue = null; // Slice
|
|
+ private boolean foreignDirty; // Slice
|
|
|
|
public DataItem(EntityDataAccessor<T> data, T value) {
|
|
this.accessor = data;
|
|
this.initialValue = value;
|
|
this.value = value;
|
|
+ this.foreignDirty = true; // Slice
|
|
}
|
|
|
|
public EntityDataAccessor<T> getAccessor() {
|
|
@@ -202,6 +251,35 @@ public class SynchedEntityData {
|
|
return this.initialValue.equals(this.value);
|
|
}
|
|
|
|
+ // Slice start
|
|
+ public void setForeignValue(T foreignValue) {
|
|
+ this.foreignValue = foreignValue;
|
|
+ this.foreignDirty = true;
|
|
+ }
|
|
+
|
|
+ public @Nullable T getForeignValue() {
|
|
+ return this.foreignValue;
|
|
+ }
|
|
+
|
|
+ public boolean isDirty(boolean foreign) {
|
|
+ if (foreign) {
|
|
+ //There must be a foreign value in order for this to be dirty, otherwise we consider this a normal
|
|
+ //value and check the normal dirty flag.
|
|
+ return this.foreignValue == null || this.foreignDirty;
|
|
+ }
|
|
+
|
|
+ return this.dirty;
|
|
+ }
|
|
+
|
|
+ public void setForeignDirty(boolean dirty) {
|
|
+ this.foreignDirty = dirty;
|
|
+ }
|
|
+
|
|
+ public SynchedEntityData.DataValue<T> copy(boolean foreign) {
|
|
+ return SynchedEntityData.DataValue.create(this.accessor, this.accessor.serializer().copy((foreign && this.foreignValue != null ? this.foreignValue : this.value)));
|
|
+ }
|
|
+ // Slice end
|
|
+
|
|
public SynchedEntityData.DataValue<T> value() {
|
|
return SynchedEntityData.DataValue.create(this.accessor, this.value);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index 1d849ce4e2c85f149af25318b8ffb6dcef6c6788..055e8691467e18ee3a70c857f0972f34a5a58e58 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -140,7 +140,7 @@ public class ServerEntity {
|
|
}
|
|
}
|
|
|
|
- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) {
|
|
+ if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isForeignDirty()) { // Slice
|
|
int i;
|
|
int j;
|
|
|
|
@@ -398,7 +398,15 @@ public class ServerEntity {
|
|
|
|
if (list != null) {
|
|
this.trackedDataValues = datawatcher.getNonDefaultValues();
|
|
- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
|
|
+ // Slice start
|
|
+ if (!(this.entity instanceof ServerPlayer)) {
|
|
+ list = datawatcher.packForeignDirty(list);
|
|
+ }
|
|
+
|
|
+ if (list != null) {
|
|
+ this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
|
|
+ }
|
|
+ // Slice end
|
|
}
|
|
|
|
if (this.entity instanceof LivingEntity) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 117f36743e1fa8a468528d44f0e16e6f7283880e..71e8a4f30afac822cc0da9620b904a02c201e452 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -3545,7 +3545,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
|
|
return;
|
|
}
|
|
- this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount());
|
|
+ this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount(), getMaxAirSupply()); // Slice
|
|
// CraftBukkit end
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
index 3feffddfb537451d88e316f39ee28a6fa22921aa..79c2ea81444c0ac9598f7fe334055326958a4f30 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -115,7 +115,7 @@ public class FallingBlockEntity extends Entity {
|
|
}
|
|
|
|
public void setStartPos(BlockPos pos) {
|
|
- this.entityData.set(FallingBlockEntity.DATA_START_POS, pos);
|
|
+ this.entityData.set(FallingBlockEntity.DATA_START_POS, pos, BlockPos.ZERO); // Slice
|
|
}
|
|
|
|
public BlockPos getStartPos() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index bcee8b6254618dc7f444992ec8cdfe53b12458a7..ac9781762a987b4d0121f69b9e873d169dfc24a0 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -203,7 +203,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
}
|
|
|
|
public void setFuse(int fuse) {
|
|
- this.entityData.set(PrimedTnt.DATA_FUSE_ID, fuse);
|
|
+ this.entityData.set(PrimedTnt.DATA_FUSE_ID, fuse, (fuse / 10) * 10); // Slice
|
|
}
|
|
|
|
public int getFuse() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 54ba25632c2a9e1c93a5b3a0b92e5280864c49d6..b352a8d299a13026d8e2c8e3405eb7f40b289d38 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -649,7 +649,7 @@ public abstract class Player extends LivingEntity {
|
|
public void increaseScore(int score) {
|
|
int j = this.getScore();
|
|
|
|
- this.entityData.set(Player.DATA_SCORE_ID, j + score);
|
|
+ this.entityData.set(Player.DATA_SCORE_ID, j + score, 0); // Slice
|
|
}
|
|
|
|
public void startAutoSpinAttack(int riptideTicks, float riptideAttackDamage, ItemStack stack) {
|