From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: LemonCaramel 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/EnderChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java index 8f0477d9620ef71e10855bbca07f9b6984d5d794..70ca456fad052ca6eeaf8c4242c78d15d81084a5 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java @@ -10,8 +10,9 @@ public class EnderChestBlockEntity extends BlockEntity { // Paper - Remove ITick public float openness; public float oOpenness; - public int openCount; + public int openCount; public int getViewerCount() { return openCount; } // Paper - OBFHELPER private int tickInterval; + public boolean opened; // Paper - More Lidded Block API public EnderChestBlockEntity() { super(BlockEntityType.ENDER_CHEST); @@ -106,12 +107,14 @@ public class EnderChestBlockEntity extends BlockEntity { // Paper - Remove ITick public void startOpen() { ++this.openCount; + if (opened) return; // Paper - More Lidded Block API this.level.blockEvent(this.worldPosition, Blocks.ENDER_CHEST, 1, this.openCount); doOpenLogic(); // Paper } public void stopOpen() { --this.openCount; + if (opened) return; // Paper - More Lidded Block API this.level.blockEvent(this.worldPosition, Blocks.ENDER_CHEST, 1, this.openCount); 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 a0eadcbcb2575eb18f7b4951ae9eadfbc2e8af6f..fc4397a48425a23d64e0a679ace9e58fbf9b770b 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 implements Bar } 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 a821df3e13e2ddc479dc5f55540671f43563cdac..9d7af8717085ba5c170a998aa863686d72840a40 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 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 25add8bee6ea35beeb205dd828759304346e4f48..fabcb2b8dc950fd074d65fed95d6b371dcfbf842 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 implem if (getTileEntity().opened) { 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 }