Paper/Spigot-Server-Patches/More-Lidded-Block-API.patch
2021-05-26 03:05:03 +09:00

128 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
@@ -0,0 +0,0 @@ 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);
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
@@ -0,0 +0,0 @@ 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
}