mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +01:00
de04cbced5
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: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
157 lines
7.5 KiB
Diff
157 lines
7.5 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 9ea6c0b250c361949a7f2d2c6b5fb2eeac7c650a..58fdbdcc5de9f93230669d93778c4c1392e0a4cf 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -261,6 +261,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
|
|
|
|
@Override
|
|
public float getBukkitYaw() {
|
|
@@ -716,7 +717,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
public boolean shouldDiscardFriction() {
|
|
- return this.discardFriction;
|
|
+ return !this.frictionState.toBooleanOrElse(!this.discardFriction); // Paper
|
|
}
|
|
|
|
public void setDiscardFriction(boolean noDrag) {
|
|
@@ -760,6 +761,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
@Override
|
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
|
+ // Paper start
|
|
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
|
|
+ nbt.putString("Paper.FrictionState", this.frictionState.toString());
|
|
+ }
|
|
+ // Paper end
|
|
nbt.putFloat("Health", this.getHealth());
|
|
nbt.putShort("HurtTime", (short) this.hurtTime);
|
|
nbt.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp);
|
|
@@ -802,6 +808,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
absorptionAmount = 0;
|
|
}
|
|
this.internalSetAbsorptionAmount(absorptionAmount);
|
|
+
|
|
+ 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
|
|
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 6b18f23b57c7000dce9726df98a509ee9477f6d2..a39db702063887cf530f272deaf4f334047cc7d4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -57,6 +57,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
|
public boolean canMobPickup = true; // Paper
|
|
private int despawnRate = -1; // Paper
|
|
+ public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper
|
|
|
|
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
|
|
super(type, world);
|
|
@@ -178,7 +179,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
|
float f1 = 0.98F;
|
|
|
|
- if (this.onGround()) {
|
|
+ // Paper start
|
|
+ if (frictionState == net.kyori.adventure.util.TriState.FALSE) {
|
|
+ f1 = 1F;
|
|
+ } else if (this.onGround()) {
|
|
+ // Paper end
|
|
f1 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
|
|
}
|
|
|
|
@@ -387,6 +392,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
|
|
@Override
|
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
|
+ // Paper start
|
|
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
|
|
+ nbt.putString("Paper.FrictionState", this.frictionState.toString());
|
|
+ }
|
|
+ // Paper end
|
|
nbt.putShort("Health", (short) this.health);
|
|
nbt.putShort("Age", (short) this.age);
|
|
nbt.putShort("PickupDelay", (short) this.pickupDelay);
|
|
@@ -421,6 +431,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
this.cachedThrower = null;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ 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
|
|
+
|
|
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
|
|
|
|
this.setItem(ItemStack.of(nbttagcompound1));
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
|
index b1bbab951ef9a3d2bd98cc54665ba824263542eb..81498941748d646ebe6495f4a7ce6953532144c6 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 1af42e8f5161a24e908bf6bf5b29e0163e18082c..94f65fdc4e5657cc765bf63710621c2d24b7b27b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -1084,6 +1084,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
});
|
|
}
|
|
|
|
+ @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 void knockback(double strength, double directionX, double directionZ) {
|
|
Preconditions.checkArgument(strength > 0, "Knockback strength must be > 0");
|