mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Add More Lidded Block API (#5707)
This commit is contained in:
parent
8c6fe5ca93
commit
0f48f0150a
3 changed files with 162 additions and 0 deletions
|
@ -48,4 +48,5 @@ Camotoy <20743703+Camotoy@users.noreply.github.com>
|
|||
Bjarne Koll <git@lynxplay.dev>
|
||||
MeFisto94 <MeFisto94@users.noreply.github.com>
|
||||
Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
LemonCaramel <admin@caramel.moe>
|
||||
```
|
||||
|
|
34
Spigot-API-Patches/More-Lidded-Block-API.patch
Normal file
34
Spigot-API-Patches/More-Lidded-Block-API.patch
Normal file
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: LemonCaramel <admin@caramel.moe>
|
||||
Date: Sun, 23 May 2021 17:49:31 +0900
|
||||
Subject: [PATCH] More Lidded Block API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/EnderChest.java b/src/main/java/org/bukkit/block/EnderChest.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/EnderChest.java
|
||||
+++ b/src/main/java/org/bukkit/block/EnderChest.java
|
||||
@@ -0,0 +0,0 @@ package org.bukkit.block;
|
||||
/**
|
||||
* Represents a captured state of an ender chest.
|
||||
*/
|
||||
-public interface EnderChest extends TileState { }
|
||||
+public interface EnderChest extends TileState, Lidded { } // Paper - More Lidded Block API
|
||||
diff --git a/src/main/java/org/bukkit/block/Lidded.java b/src/main/java/org/bukkit/block/Lidded.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/Lidded.java
|
||||
+++ b/src/main/java/org/bukkit/block/Lidded.java
|
||||
@@ -0,0 +0,0 @@ public interface Lidded {
|
||||
* viewing this block.
|
||||
*/
|
||||
void close();
|
||||
+
|
||||
+ // Paper start - More Lidded Block API
|
||||
+ /**
|
||||
+ * Checks if the block's animation state.
|
||||
+ *
|
||||
+ * @return true if the block's animation state is set to open.
|
||||
+ */
|
||||
+ boolean isOpen();
|
||||
+ // Paper end - More Lidded Block API
|
||||
}
|
127
Spigot-Server-Patches/More-Lidded-Block-API.patch
Normal file
127
Spigot-Server-Patches/More-Lidded-Block-API.patch
Normal file
|
@ -0,0 +1,127 @@
|
|||
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
|
||||
}
|
Loading…
Reference in a new issue