2020-08-30 20:26:15 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Eearslya Sleiarion <eearslya@gmail.com>
|
|
|
|
Date: Sun, 23 Aug 2020 13:04:02 +0200
|
|
|
|
Subject: [PATCH] Add BellRingEvent
|
|
|
|
|
|
|
|
Add a new event, BellRingEvent, to trigger whenever a player rings a
|
|
|
|
village bell. Passes along the bell block and the player who rang it.
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockBell.java b/src/main/java/net/minecraft/world/level/block/BlockBell.java
|
2020-08-30 20:26:15 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockBell.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockBell.java
|
2020-08-30 20:26:15 +02:00
|
|
|
@@ -0,0 +0,0 @@
|
2021-03-16 08:19:45 +01:00
|
|
|
package net.minecraft.world.level.block;
|
2020-08-30 20:26:15 +02:00
|
|
|
|
|
|
|
+import io.papermc.paper.event.block.BellRingEvent;
|
|
|
|
+
|
|
|
|
import javax.annotation.Nullable;
|
2021-03-16 08:19:45 +01:00
|
|
|
import net.minecraft.core.BlockPosition;
|
|
|
|
import net.minecraft.core.EnumDirection;
|
2021-03-16 16:50:45 +01:00
|
|
|
+import net.minecraft.server.MCUtil;
|
|
|
|
import net.minecraft.sounds.SoundCategory;
|
|
|
|
import net.minecraft.sounds.SoundEffects;
|
|
|
|
import net.minecraft.stats.StatisticList;
|
2020-08-30 20:26:15 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class BlockBell extends BlockTileEntity {
|
|
|
|
boolean flag1 = !flag || this.a(iblockdata, enumdirection, movingobjectpositionblock.getPos().y - (double) blockposition.getY());
|
|
|
|
|
|
|
|
if (flag1) {
|
|
|
|
- boolean flag2 = this.a(world, blockposition, enumdirection);
|
|
|
|
+ boolean flag2 = this.handleBellRing(world, blockposition, enumdirection, entityhuman); // Paper
|
|
|
|
|
|
|
|
if (flag2 && entityhuman != null) {
|
|
|
|
entityhuman.a(StatisticList.BELL_RING);
|
|
|
|
@@ -0,0 +0,0 @@ public class BlockBell extends BlockTileEntity {
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(World world, BlockPosition blockposition, @Nullable EnumDirection enumdirection) {
|
|
|
|
+ // Paper start - add ringer param
|
|
|
|
+ return this.handleBellRing(world, blockposition, enumdirection, null);
|
|
|
|
+ }
|
|
|
|
+ public boolean handleBellRing(World world, BlockPosition blockposition, @Nullable EnumDirection enumdirection, @Nullable Entity ringer) {
|
|
|
|
+ // Paper end
|
|
|
|
TileEntity tileentity = world.getTileEntity(blockposition);
|
|
|
|
|
|
|
|
if (!world.isClientSide && tileentity instanceof TileEntityBell) {
|
|
|
|
@@ -0,0 +0,0 @@ public class BlockBell extends BlockTileEntity {
|
|
|
|
enumdirection = (EnumDirection) world.getType(blockposition).get(BlockBell.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (!new BellRingEvent(world.getWorld().getBlockAt(MCUtil.toLocation(world, blockposition)), ringer == null ? null : ringer.getBukkitEntity()).callEvent()) return false; // Paper - BellRingEvent
|
|
|
|
((TileEntityBell) tileentity).a(enumdirection);
|
|
|
|
world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BELL_USE, SoundCategory.BLOCKS, 2.0F, 1.0F);
|
|
|
|
return true;
|