9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00

move some sources patches to features; add some new api patches

This commit is contained in:
NONPLAYT
2025-03-23 16:57:48 +03:00
parent f4e79b8427
commit 95522311db
16 changed files with 503 additions and 90 deletions

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Mar 2025 16:52:42 +0300
Subject: [PATCH] Paper PR: Player standing on position API
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 82117a1b258d43f68ff803c4c1af0a33c99065a8..cb8232faed9423dd570e3a6b0ea664182074a1ac 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -1197,6 +1197,33 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
void broadcastHurtAnimation(@NotNull java.util.Collection<Player> players);
// Paper end - broadcast hurt animation
+ // Paper start - Player standing on position API
+ /**
+ * Gets the block that is currently being used to calculate movement effects (i.e. friction) on the entity.
+ * <p>
+ * Examples:
+ * - When standing on a slab under an ice block, this will return the position of the ice block.
+ * - When flying on top of a flower placed on a grass block, this will return the position of the grass block (although this technically will not affect your movement).
+ *
+ * @return block used for movement effects
+ */
+ @NotNull
+ org.bukkit.block.Block getMovementAffectingBlock();
+
+ /**
+ * Gets the block that is currently supporting the entity.
+ * This takes into account the collisions of blocks under the entity.
+ * <p>
+ * Examples:
+ * - When standing on a slab under an ice block, this will return the position of the slab.
+ * - When flying on top of a flower placed on a grass block, this will return null, as no block is supporting the entity.
+ *
+ * @return block currently supporting the entity, or null if no block is currently supporting the entity
+ */
+ @Nullable
+ org.bukkit.block.Block getSupportingBlock();
+ // Paper end - Player standing on position API
+
// Purpur start - Ridables
/**
* Get the riding player

View File

@@ -0,0 +1,78 @@
package io.papermc.paper.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.inventory.ItemStack;
import org.jspecify.annotations.NullMarked;
/**
* Called when a {@link org.bukkit.block.Dispenser} fills up a bottle.
*/
@NullMarked
public class BlockFillBottleEvent extends BlockEvent implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final ItemStack bottle;
private ItemStack resultItem;
private boolean cancelled;
public BlockFillBottleEvent(Block block, ItemStack bottle, ItemStack resultItem) {
super(block);
this.bottle = bottle;
this.resultItem = resultItem;
}
/**
* Gets the bottle item that's being filled.
*
* @return the bottle item
*/
public ItemStack getBottle() {
return this.bottle;
}
/**
* Gets the result of the glass bottle that's being filled.
*
* @return the result of the filling
*/
public ItemStack getResultItem() {
return this.resultItem;
}
/**
* Sets the result of the glass bottle being filled.
*
* @param resultItem the result of the filling
*/
public void setResultItem(ItemStack resultItem) {
this.resultItem = resultItem;
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
/**
* {@inheritDoc}
* <p>
* Cancelling this event will prevent {@link #getBottle()} from being
* replaced/consumed.
*/
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}

View File

@@ -0,0 +1,87 @@
package io.papermc.paper.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jspecify.annotations.NullMarked;
@NullMarked
public class PlayerFillBottleEvent extends PlayerEvent implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final EquipmentSlot hand;
private final ItemStack bottle;
private ItemStack resultItem;
private boolean cancelled;
public PlayerFillBottleEvent(Player player, EquipmentSlot hand, ItemStack bottle, ItemStack resultItem) {
super(player);
this.hand = hand;
this.bottle = bottle;
this.resultItem = resultItem;
}
/**
* The hand used to fill the bottle.
*
* @return the hand
*/
public EquipmentSlot getHand() {
return this.hand;
}
/**
* Gets the bottle item that's being filled.
*
* @return the bottle item
*/
public ItemStack getBottle() {
return this.bottle;
}
/**
* Gets the result of the bottle that's being filled.
*
* @return the result of the filling
*/
public ItemStack getResultItem() {
return this.resultItem;
}
/**
* Sets the result of the bottle being filled.
*
* @param resultItem the result of the filling
*/
public void setResultItem(ItemStack resultItem) {
this.resultItem = resultItem;
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
/**
* {@inheritDoc}
* <p>
* Cancelling this event will prevent {@link #getBottle()} from being
* replaced/consumed.
*/
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}