fix and cleanup loot table patches (#10100)

* fix and cleanup loot table patches

* fixes
This commit is contained in:
Jake Potrebic
2024-05-26 12:51:15 -07:00
parent fff2347845
commit dd6b67a80a
11 changed files with 554 additions and 444 deletions

View File

@@ -11,14 +11,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
*/
public void setLeftHanded(boolean leftHanded);
// Paper end
// Paper end - left-handed API
+
+ // Paper start
+ // Paper start - mob xp reward API
+ /**
+ * Gets the amount of experience the mob will possibly drop. This value is randomized and it can give different results
+ *
+ * @return the amount of experience the mob will possibly drop
+ */
+ public int getPossibleExperienceReward();
+ // Paper end
+ // Paper end - mob xp reward API
}

View File

@@ -11,9 +11,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
*/
void setAggressive(boolean aggressive);
// Paper end
// Paper end - Missing Entity API
+
+ // Paper start
+ // Paper start - left-handed API
+ /**
+ * Check if Mob is left-handed
+ *
@@ -27,5 +27,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param leftHanded True if left-handed
+ */
+ public void setLeftHanded(boolean leftHanded);
+ // Paper end
+ // Paper end - left-handed API
}

View File

@@ -101,8 +101,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param player The player to check
+ * @return Whether or not this player has looted this block
+ */
+ default boolean hasPlayerLooted(@NotNull Player player) {
+ return hasPlayerLooted(player.getUniqueId());
+ default boolean hasPlayerLooted(final @NotNull Player player) {
+ return this.hasPlayerLooted(player.getUniqueId());
+ }
+
+ /**
@@ -127,9 +127,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param player The player to check
+ * @return Timestamp last looted, or null if player has not looted this object
+ */
+ @Nullable
+ default Long getLastLooted(@NotNull Player player) {
+ return getLastLooted(player.getUniqueId());
+ default @Nullable Long getLastLooted(final @NotNull Player player) {
+ return this.getLastLooted(player.getUniqueId());
+ }
+
+ /**
@@ -147,8 +146,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param looted true to add player to looted list, false to remove
+ * @return The previous state of whether the player had looted this or not
+ */
+ default boolean setHasPlayerLooted(@NotNull Player player, boolean looted) {
+ return setHasPlayerLooted(player.getUniqueId(), looted);
+ default boolean setHasPlayerLooted(final @NotNull Player player, final boolean looted) {
+ return this.setHasPlayerLooted(player.getUniqueId(), looted);
+ }
+
+ /**
@@ -271,6 +270,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
* Gets the inventory of the chest block represented by this block state.
diff --git a/src/main/java/org/bukkit/block/Crafter.java b/src/main/java/org/bukkit/block/Crafter.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/block/Crafter.java
+++ b/src/main/java/org/bukkit/block/Crafter.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.ApiStatus;
*/
@ApiStatus.Experimental
@MinecraftExperimental(Requires.UPDATE_1_21)
-public interface Crafter extends Container, Lootable {
+public interface Crafter extends Container, com.destroystokyo.paper.loottable.LootableBlockInventory { // Paper - LootTable API
/**
* Gets the number of ticks which this block will remain in the crafting
diff --git a/src/main/java/org/bukkit/block/Dispenser.java b/src/main/java/org/bukkit/block/Dispenser.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/block/Dispenser.java
@@ -355,6 +367,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
-public interface ChestBoat extends Boat, InventoryHolder, Lootable {
+public interface ChestBoat extends Boat, InventoryHolder, com.destroystokyo.paper.loottable.LootableEntityInventory { // Paper
}
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Mob.java
+++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
*/
@Nullable
public Sound getAmbientSound();
+
+ // Paper start - LootTable API
+ @Override
+ default void setLootTable(final @Nullable org.bukkit.loot.LootTable table, final long seed) {
+ this.setLootTable(table);
+ this.setSeed(seed);
+ }
+ // Paper end - LootTable API
}
diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java
@@ -408,24 +437,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param table the Loot Table this {@link org.bukkit.block.Container} or {@link org.bukkit.entity.Mob} will have.
+ * @param seed the seed to used to generate loot. Default is 0.
+ */
+ default void setLootTable(@Nullable LootTable table, long seed) {
+ setLootTable(table);
+ setSeed(seed);
+ }
+ void setLootTable(final @Nullable LootTable table, final long seed);
+
+ /**
+ * Returns whether or not this object has a Loot Table
+ * @return Has a loot table
+ */
+ default boolean hasLootTable() {
+ return getLootTable() != null;
+ return this.getLootTable() != null;
+ }
+
+ /**
+ * Clears the associated Loot Table to this object
+ */
+ default void clearLootTable() {
+ setLootTable(null);
+ this.setLootTable(null);
+ }
+ // Paper end
+

View File

@@ -742,11 +742,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/entity/Mob.java
+++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
*/
@Nullable
public Sound getAmbientSound();
this.setSeed(seed);
}
// Paper end - LootTable API
+
+ // Paper start
+ // Paper start - Missing Entity API
+ /**
+ * Some mobs will raise their arm(s) when aggressive:
+ * <ul>
@@ -778,7 +778,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @see #isAggressive()
+ */
+ void setAggressive(boolean aggressive);
+ // Paper end
+ // Paper end - Missing Entity API
}
diff --git a/src/main/java/org/bukkit/entity/Panda.java b/src/main/java/org/bukkit/entity/Panda.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644