mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 20:16:19 +01:00
d1a72eac31
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 1fc1020a PR-1049: Add MenuType API 8ae2e3be PR-1055: Expand riptiding API cac68bfb SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor 7004fcf2 SPIGOT-7886: Fix mistake in AttributeModifier UUID shim 1ac7f950 PR-1054: Add FireworkMeta#hasPower 4cfb565f SPIGOT-7873: Add powered state for skulls CraftBukkit Changes: bbb30e7a8 SPIGOT-7894: NPE when sending tile entity update ba21e9472 SPIGOT-7895: PlayerItemBreakEvent not firing 0fb24bbe0 SPIGOT-7875: Fix PlayerItemConsumeEvent cancellation causing client-side desync 815066449 SPIGOT-7891: Can't remove second ingredient of MerchantRecipe 45c206f2c PR-1458: Add MenuType API 19c8ef9ae SPIGOT-7867: Merchant instanceof AbstractVillager always returns false 4e006d28f PR-1468: Expand riptiding API bd8aded7d Ignore checks in CraftPlayerProfile for ResolvableProfile used in profile components 8679620b5 SPIGOT-7889: Fix tool component deserialisation without speed and/or correct-for-drops 8d5222691 SPIGOT-7882, PR-1467: Fix conversion of name in Profile Component to empty if it is missing 63f91669a SPIGOT-7887: Remove duplicate ProjectileHitEvent for fireballs 7070de8c8 SPIGOT-7878: Server#getLootTable does not return null on invalid loot table 060ee6cae SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies 7ccb86cc0 PR-1465: Add FireworkMeta#hasPower 804ad6491 SPIGOT-7873: Add powered state for skulls f9610cdcb Improve minecart movement Spigot Changes: a759b629 Rebuild patches Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
157 lines
7.8 KiB
Diff
157 lines
7.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Noah van der Aa <ndvdaa@gmail.com>
|
|
Date: Wed, 15 Sep 2021 20:44:22 +0200
|
|
Subject: [PATCH] Friction API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index f662a791e8cb045903a0de29778e5f30892fb766..2bb61084b628582ded44926d7697ee26d0bb1e8e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -285,6 +285,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
public boolean bukkitPickUpLoot;
|
|
public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper
|
|
public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event
|
|
+ public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
|
|
|
|
@Override
|
|
public float getBukkitYaw() {
|
|
@@ -706,7 +707,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
public boolean shouldDiscardFriction() {
|
|
- return this.discardFriction;
|
|
+ return !this.frictionState.toBooleanOrElse(!this.discardFriction); // Paper - Friction API
|
|
}
|
|
|
|
public void setDiscardFriction(boolean noDrag) {
|
|
@@ -774,6 +775,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
@Override
|
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
|
+ // Paper start - Friction API
|
|
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
|
|
+ nbt.putString("Paper.FrictionState", this.frictionState.toString());
|
|
+ }
|
|
+ // Paper end - Friction API
|
|
nbt.putFloat("Health", this.getHealth());
|
|
nbt.putShort("HurtTime", (short) this.hurtTime);
|
|
nbt.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp);
|
|
@@ -817,6 +823,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
this.internalSetAbsorptionAmount(absorptionAmount);
|
|
// Paper end - Check for NaN
|
|
+ // Paper start - Friction API
|
|
+ if (nbt.contains("Paper.FrictionState")) {
|
|
+ String fs = nbt.getString("Paper.FrictionState");
|
|
+ try {
|
|
+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs);
|
|
+ } catch (Exception ignored) {
|
|
+ LOGGER.error("Unknown friction state " + fs + " for " + this);
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Friction API
|
|
if (nbt.contains("attributes", 9) && this.level() != null && !this.level().isClientSide) {
|
|
this.getAttributes().load(nbt.getList("attributes", 10));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
index 30056568a9701fcb664682f329175d3bfee79b60..ea0d9335446b20073b9aafb9de453097355db79c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -63,6 +63,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
|
public boolean canMobPickup = true; // Paper - Item#canEntityPickup
|
|
private int despawnRate = -1; // Paper - Alternative item-despawn-rate
|
|
+ public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
|
|
|
|
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
|
|
super(type, world);
|
|
@@ -186,7 +187,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
|
float f = 0.98F;
|
|
|
|
- if (this.onGround()) {
|
|
+ // Paper start - Friction API
|
|
+ if (frictionState == net.kyori.adventure.util.TriState.FALSE) {
|
|
+ f = 1F;
|
|
+ } else if (this.onGround()) {
|
|
+ // Paper end - Friction API
|
|
f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
|
|
}
|
|
|
|
@@ -395,6 +400,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
|
|
@Override
|
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
|
+ // Paper start - Friction API
|
|
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
|
|
+ nbt.putString("Paper.FrictionState", this.frictionState.toString());
|
|
+ }
|
|
+ // Paper end - Friction API
|
|
nbt.putShort("Health", (short) this.health);
|
|
nbt.putShort("Age", (short) this.age);
|
|
nbt.putShort("PickupDelay", (short) this.pickupDelay);
|
|
@@ -437,6 +447,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
this.setItem(ItemStack.EMPTY);
|
|
}
|
|
|
|
+ // Paper start - Friction API
|
|
+ if (nbt.contains("Paper.FrictionState")) {
|
|
+ String fs = nbt.getString("Paper.FrictionState");
|
|
+ try {
|
|
+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs);
|
|
+ } catch (Exception ignored) {
|
|
+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state " + fs + " for " + this);
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Friction API
|
|
+
|
|
if (this.getItem().isEmpty()) {
|
|
this.discard(null); // CraftBukkit - add Bukkit remove cause
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
|
index 1a291dd8a287db30e71dcb315599fc4b038764c4..30d62ee4d5cd2ddacb8783b5bbbf475d592b3e02 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
|
@@ -99,6 +99,18 @@ public class CraftItem extends CraftEntity implements Item {
|
|
this.getHandle().age = willAge ? 0 : NO_AGE_TIME;
|
|
}
|
|
|
|
+ @org.jetbrains.annotations.NotNull
|
|
+ @Override
|
|
+ public net.kyori.adventure.util.TriState getFrictionState() {
|
|
+ return this.getHandle().frictionState;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setFrictionState(@org.jetbrains.annotations.NotNull net.kyori.adventure.util.TriState state) {
|
|
+ java.util.Objects.requireNonNull(state, "state may not be null");
|
|
+ this.getHandle().frictionState = state;
|
|
+ }
|
|
+
|
|
@Override
|
|
public int getHealth() {
|
|
return this.getHandle().health;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
index 9134ce983f5c798e2925348ac9d3b8570965d415..89b66fd33cdeab03a6b208f9c59df767787a42bf 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -1155,4 +1155,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
nmsStack.hurtAndBreak(amount, this.getHandle(), slot, true);
|
|
}
|
|
// Paper end - ItemStack damage API
|
|
+ // Paper start - friction API
|
|
+ @org.jetbrains.annotations.NotNull
|
|
+ @Override
|
|
+ public net.kyori.adventure.util.TriState getFrictionState() {
|
|
+ return this.getHandle().frictionState;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setFrictionState(@org.jetbrains.annotations.NotNull net.kyori.adventure.util.TriState state) {
|
|
+ java.util.Objects.requireNonNull(state, "state may not be null");
|
|
+ this.getHandle().frictionState = state;
|
|
+ }
|
|
+ // Paper end - friction API
|
|
}
|