aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0689-More-Lidded-Block-API.patch
blob: fec21741ed06e352b95d9dad3e6be0300f083766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: LemonCaramel <admin@caramel.moe>
Date: Sun, 23 May 2021 17:49:51 +0900
Subject: [PATCH] More Lidded Block API


diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
index 9d0c272b1d89a96b0b63603fa8e4649f11fb6c51..d5fdf4504a0ca76fb0483f4ae5861c93fb622b2d 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
@@ -58,4 +58,11 @@ public class CraftBarrel extends CraftLootable<BarrelBlockEntity> implements Bar
         }
         getTileEntity().openersCounter.opened = false;
     }
+
+    // Paper start - More Lidded Block API
+    @Override
+    public boolean isOpen() {
+        return getTileEntity().openersCounter.opened;
+    }
+    // Paper end - More Lidded Block API
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
index 6a1f47c58f1186f12fd112feedaf11da85b0bdcc..850a325cc98965c6f9f7ae8b48fdc3c8c8833fb9 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
@@ -75,4 +75,11 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
         }
         getTileEntity().openersCounter.opened = false;
     }
+
+    // Paper start - More Lidded Block API
+    @Override
+    public boolean isOpen() {
+        return getTileEntity().openersCounter.opened;
+    }
+    // Paper end - More Lidded Block API
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
index 950066001b23e7b9aec48b2369163d6196979640..c48d7ec19603962855962c6ae6e1275c1552c906 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
@@ -9,4 +9,33 @@ public class CraftEnderChest extends CraftBlockEntityState<EnderChestBlockEntity
     public CraftEnderChest(World world, EnderChestBlockEntity tileEntity) {
         super(world, tileEntity);
     }
+
+    // Paper start - More Lidded Block API
+    @Override
+    public void open() {
+        requirePlaced();
+        if (!getTileEntity().openersCounter.opened) {
+            net.minecraft.world.level.Level world = getTileEntity().getLevel();
+            world.blockEvent(getTileEntity().getBlockPos(), getTileEntity().getBlockState().getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1);
+            world.playSound(null, getPosition(), net.minecraft.sounds.SoundEvents.ENDER_CHEST_OPEN, net.minecraft.sounds.SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
+        }
+        getTileEntity().openersCounter.opened = true;
+    }
+
+    @Override
+    public void close() {
+        requirePlaced();
+        if (getTileEntity().openersCounter.opened) {
+            net.minecraft.world.level.Level world = getTileEntity().getLevel();
+            world.blockEvent(getTileEntity().getBlockPos(), getTileEntity().getBlockState().getBlock(), 1, 0);
+            world.playSound(null, getPosition(), net.minecraft.sounds.SoundEvents.ENDER_CHEST_CLOSE, net.minecraft.sounds.SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
+        }
+        getTileEntity().openersCounter.opened = false;
+    }
+
+    @Override
+    public boolean isOpen() {
+        return getTileEntity().openersCounter.opened;
+    }
+    // Paper end - More Lidded Block API
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
index 2d5205a9adfa66545f40a13bf0e37dc62ac0fdb9..72074b4c0feea8136e80589345538552ce28a2ea 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
@@ -55,8 +55,15 @@ public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implem
         if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.Level) {
             net.minecraft.world.level.Level world = getTileEntity().getLevel();
             world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0);
-            world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
+            world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); // Paper - More Lidded Block API (Wrong sound)
         }
         getTileEntity().opened = false;
     }
+
+    // Paper start - More Lidded Block API
+    @Override
+    public boolean isOpen() {
+        return getTileEntity().opened;
+    }
+    // Paper end - More Lidded Block API
 }