Add BlockFailedDispenseEvent
This commit is contained in:
@@ -17,7 +17,16 @@
|
|||||||
|
|
||||||
if (tileentitydispenser == null) {
|
if (tileentitydispenser == null) {
|
||||||
DispenserBlock.LOGGER.warn("Ignoring dispensing attempt for Dispenser without matching block entity at {}", pos);
|
DispenserBlock.LOGGER.warn("Ignoring dispensing attempt for Dispenser without matching block entity at {}", pos);
|
||||||
@@ -104,6 +105,7 @@
|
@@ -97,13 +98,16 @@
|
||||||
|
int i = tileentitydispenser.getRandomSlot(world.random);
|
||||||
|
|
||||||
|
if (i < 0) {
|
||||||
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) { // Paper - Add BlockFailedDispenseEvent
|
||||||
|
world.levelEvent(1001, pos, 0);
|
||||||
|
world.gameEvent((Holder) GameEvent.BLOCK_ACTIVATE, pos, GameEvent.Context.of(tileentitydispenser.getBlockState()));
|
||||||
|
+ } // Paper - Add BlockFailedDispenseEvent
|
||||||
|
} else {
|
||||||
|
ItemStack itemstack = tileentitydispenser.getItem(i);
|
||||||
DispenseItemBehavior idispensebehavior = this.getDispenseMethod(world, itemstack);
|
DispenseItemBehavior idispensebehavior = this.getDispenseMethod(world, itemstack);
|
||||||
|
|
||||||
if (idispensebehavior != DispenseItemBehavior.NOOP) {
|
if (idispensebehavior != DispenseItemBehavior.NOOP) {
|
||||||
|
|||||||
@@ -34,7 +34,15 @@
|
|||||||
|
|
||||||
if (tileentitydispenser == null) {
|
if (tileentitydispenser == null) {
|
||||||
DropperBlock.LOGGER.warn("Ignoring dispensing attempt for Dropper without matching block entity at {}", pos);
|
DropperBlock.LOGGER.warn("Ignoring dispensing attempt for Dropper without matching block entity at {}", pos);
|
||||||
@@ -68,8 +72,25 @@
|
@@ -56,6 +60,7 @@
|
||||||
|
int i = tileentitydispenser.getRandomSlot(world.random);
|
||||||
|
|
||||||
|
if (i < 0) {
|
||||||
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) // Paper - Add BlockFailedDispenseEvent
|
||||||
|
world.levelEvent(1001, pos, 0);
|
||||||
|
} else {
|
||||||
|
ItemStack itemstack = tileentitydispenser.getItem(i);
|
||||||
|
@@ -68,8 +73,25 @@
|
||||||
if (iinventory == null) {
|
if (iinventory == null) {
|
||||||
itemstack1 = DropperBlock.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
|
itemstack1 = DropperBlock.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2125,4 +2125,12 @@ public class CraftEventFactory {
|
|||||||
return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion());
|
return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion());
|
||||||
}
|
}
|
||||||
// Paper end - WitchReadyPotionEvent
|
// Paper end - WitchReadyPotionEvent
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
public static boolean handleBlockFailedDispenseEvent(ServerLevel serverLevel, BlockPos pos) {
|
||||||
|
org.bukkit.block.Block block = CraftBlock.at(serverLevel, pos);
|
||||||
|
io.papermc.paper.event.block.BlockFailedDispenseEvent event = new io.papermc.paper.event.block.BlockFailedDispenseEvent(block);
|
||||||
|
return event.callEvent();
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user