mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 03:32:46 +01:00
127 lines
6.1 KiB
Diff
127 lines
6.1 KiB
Diff
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/net/minecraft/world/level/block/entity/TileEntityEnderChest.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
|
|
index 2bc4213c70be47ca8bbc24898cc92e43f4228821..d03c4d100783b5d9f882c010a63dda3451db3c2e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
|
|
@@ -10,8 +10,9 @@ public class TileEntityEnderChest extends TileEntity { // Paper - Remove ITickab
|
|
|
|
public float a;
|
|
public float b;
|
|
- public int c;
|
|
+ public int c; public int getViewerCount() { return c; } // Paper - OBFHELPER
|
|
private int g;
|
|
+ public boolean opened; // Paper - More Lidded Block API
|
|
|
|
public TileEntityEnderChest() {
|
|
super(TileEntityTypes.ENDER_CHEST);
|
|
@@ -106,12 +107,14 @@ public class TileEntityEnderChest extends TileEntity { // Paper - Remove ITickab
|
|
|
|
public void d() {
|
|
++this.c;
|
|
+ if (opened) return; // Paper - More Lidded Block API
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c);
|
|
doOpenLogic(); // Paper
|
|
}
|
|
|
|
public void f() {
|
|
--this.c;
|
|
+ if (opened) return; // Paper - More Lidded Block API
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c);
|
|
doCloseLogic(); // Paper
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
|
|
index e27f5d689d689d4f65c285802bf327e96c113c46..f47fd41981bd89879627c2f0bb05d0ff70cc20fe 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
|
|
@@ -59,4 +59,11 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
|
|
}
|
|
getTileEntity().opened = false;
|
|
}
|
|
+
|
|
+ // Paper start - More Lidded Block API
|
|
+ @Override
|
|
+ public boolean isOpen() {
|
|
+ return getTileEntity().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 54eb170fd533b0e91572601268fcbc167ed9bb5c..374034e659f856895843f3e33cce750d5cca0244 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
|
@@ -78,4 +78,11 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest,
|
|
}
|
|
getTileEntity().opened = false;
|
|
}
|
|
+
|
|
+ // Paper start - More Lidded Block API
|
|
+ @Override
|
|
+ public boolean isOpen() {
|
|
+ return getTileEntity().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 3c0b28faa86fb2ebb6165ff9efb0e7e41230c5e4..01192a3a1354d36c1d5541ddcf4037e983fd3cf9 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
|
|
@@ -14,4 +14,33 @@ public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest>
|
|
public CraftEnderChest(final Material material, final TileEntityEnderChest te) {
|
|
super(material, te);
|
|
}
|
|
+
|
|
+ // Paper start - More Lidded Block API
|
|
+ @Override
|
|
+ public void open() {
|
|
+ requirePlaced();
|
|
+ if (!getTileEntity().opened) {
|
|
+ net.minecraft.world.level.World world = getTileEntity().getWorld();
|
|
+ world.playBlockAction(getTileEntity().getPosition(), getTileEntity().getBlock().getBlock(), 1, getTileEntity().getViewerCount() + 1);
|
|
+ world.playSound(null, getPosition(), net.minecraft.sounds.SoundEffects.BLOCK_ENDER_CHEST_OPEN, net.minecraft.sounds.SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
|
+ }
|
|
+ getTileEntity().opened = true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void close() {
|
|
+ requirePlaced();
|
|
+ if (getTileEntity().opened) {
|
|
+ net.minecraft.world.level.World world = getTileEntity().getWorld();
|
|
+ world.playBlockAction(getTileEntity().getPosition(), getTileEntity().getBlock().getBlock(), 1, 0);
|
|
+ world.playSound(null, getPosition(), net.minecraft.sounds.SoundEffects.BLOCK_ENDER_CHEST_CLOSE, net.minecraft.sounds.SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
|
+ }
|
|
+ getTileEntity().opened = false;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isOpen() {
|
|
+ return getTileEntity().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 fcf2a1810729fda56e4064702f5f3b4d2b3f1523..ffd10dfdaf348625e1653e2fd8add5e58f895bdd 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
|
|
@@ -62,8 +62,15 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
|
|
if (getTileEntity().opened) {
|
|
World world = getTileEntity().getWorld();
|
|
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 0);
|
|
- world.playSound(null, getPosition(), SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
|
+ world.playSound(null, getPosition(), SoundEffects.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.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
|
|
}
|