#1209: Clean up various patches

By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
CraftBukkit/Spigot
2023-06-24 17:15:05 +10:00
parent 0f9e7a497e
commit b97cc9b99f
71 changed files with 662 additions and 719 deletions

View File

@@ -18,34 +18,3 @@
d1 = Double.MAX_VALUE;
CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a;
int k = acommandspreadplayers_a.length;
@@ -301,7 +301,7 @@
for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) {
blockposition_mutableblockposition.move(EnumDirection.DOWN);
- flag1 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir();
+ flag1 = getBlockState(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit
if (!flag1 && flag2 && flag) {
return blockposition_mutableblockposition.getY() + 1;
}
@@ -314,7 +314,7 @@
public boolean isSafe(IBlockAccess iblockaccess, int i) {
BlockPosition blockposition = BlockPosition.containing(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z);
- IBlockData iblockdata = iblockaccess.getBlockState(blockposition);
+ IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit
return blockposition.getY() < i && !iblockdata.liquid() && !iblockdata.is(TagsBlock.FIRE);
}
@@ -323,5 +323,12 @@
this.x = MathHelper.nextDouble(randomsource, d0, d2);
this.z = MathHelper.nextDouble(randomsource, d1, d3);
}
+
+ // CraftBukkit start - add a version of getBlockState which force loads chunks
+ private static IBlockData getBlockState(IBlockAccess iblockaccess, BlockPosition position) {
+ ((WorldServer) iblockaccess).getChunkSource().getChunk(position.getX() >> 4, position.getZ() >> 4, true);
+ return iblockaccess.getBlockState(position);
+ }
+ // CraftBukkit end
}
}

View File

@@ -113,22 +113,15 @@
if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
}
@@ -300,8 +339,14 @@
@@ -300,6 +339,7 @@
if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
}
+ ((EntityLiving) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
}
+ // CraftBukkit start - Fix for nonsensical head yaw
+ this.yHeadRotp = MathHelper.floor(this.entity.getYHeadRot() * 256.0F / 360.0F);
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp));
+ // CraftBukkit end
+
if (!this.entity.getPassengers().isEmpty()) {
consumer.accept(new PacketPlayOutMount(this.entity));
}
@@ -333,6 +378,11 @@
@@ -333,6 +373,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
if (!set.isEmpty()) {

View File

@@ -329,7 +329,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1);
@@ -342,17 +538,17 @@
@@ -342,7 +538,7 @@
}
}
@@ -338,18 +338,6 @@
ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
EnumInteractionResult enuminteractionresult1;
if (this.isCreative()) {
int i = itemstack.getCount();
- enuminteractionresult1 = itemstack.useOn(itemactioncontext);
+ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
itemstack.setCount(i);
} else {
- enuminteractionresult1 = itemstack.useOn(itemactioncontext);
+ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
}
if (enuminteractionresult1.consumesAction()) {
@@ -360,10 +556,10 @@
}

View File

@@ -1,6 +1,11 @@
--- a/net/minecraft/server/players/JsonList.java
+++ b/net/minecraft/server/players/JsonList.java
@@ -54,7 +54,7 @@
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.server.players;
import com.google.common.collect.Lists;
@@ -54,7 +55,7 @@
@Nullable
public V get(K k0) {
this.removeExpired();
@@ -9,20 +14,7 @@
}
public void remove(K k0) {
@@ -76,6 +76,12 @@
return (String[]) this.map.keySet().toArray(new String[0]);
}
+ // CraftBukkit start
+ public Collection<V> getValues() {
+ return this.map.values();
+ }
+ // CraftBukkit end
+
public boolean isEmpty() {
return this.map.size() < 1;
}
@@ -93,7 +99,7 @@
@@ -93,7 +94,7 @@
Iterator iterator = this.map.values().iterator();
while (iterator.hasNext()) {
@@ -31,7 +23,7 @@
if (v0.hasExpired()) {
list.add(v0.getUser());
@@ -103,7 +109,7 @@
@@ -103,7 +104,7 @@
iterator = list.iterator();
while (iterator.hasNext()) {
@@ -40,7 +32,7 @@
this.map.remove(this.getKeyForUser(k0));
}
@@ -118,7 +124,7 @@
@@ -118,7 +119,7 @@
public void save() throws IOException {
JsonArray jsonarray = new JsonArray();
@@ -49,7 +41,7 @@
JsonObject jsonobject = new JsonObject();
Objects.requireNonNull(jsonlistentry);
@@ -165,7 +171,7 @@
@@ -165,7 +166,7 @@
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
if (jsonlistentry.getUser() != null) {