3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/patches/server-remapped/0747-More-Lidded-Block-API.patch

128 Zeilen
6.1 KiB
Diff

2021-06-11 14:02:28 +02:00
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/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<BarrelBlockEntity> 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<ChestBlockEntity> 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<EnderChestBlockEntity
public CraftEnderChest(final Material material, final EnderChestBlockEntity te) {
super(material, te);
}
+
+ // Paper start - More Lidded Block API
+ @Override
+ public void open() {
+ requirePlaced();
+ if (!getTileEntity().opened) {
+ net.minecraft.world.level.Level world = getTileEntity().getLevel();
+ world.blockEvent(getTileEntity().getBlockPos(), getTileEntity().getBlockState().getBlock(), 1, getTileEntity().getViewerCount() + 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().opened = true;
+ }
+
+ @Override
+ public void close() {
+ requirePlaced();
+ if (getTileEntity().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().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 60f2394547153b2d2553fb88470a00ff99ac2f2d..f3f95aaac02007b5f67ba64df1b5b9b7e82e3325 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
@@ -61,8 +61,15 @@ public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> 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
}