mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
SPIGOT-7043: EnderChest does not implement Lidded
By: md_5 <git@md-5.net>
This commit is contained in:
parent
29db051e6e
commit
d9d74754ba
4 changed files with 66 additions and 8 deletions
|
@ -8,7 +8,24 @@
|
|||
|
||||
public ContainerOpenersCounter() {}
|
||||
|
||||
@@ -25,8 +26,19 @@
|
||||
@@ -22,11 +23,36 @@
|
||||
|
||||
protected abstract void openerCountChanged(World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void onAPIOpen(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
+ onOpen(world, blockposition, iblockdata);
|
||||
+ }
|
||||
+
|
||||
+ public void onAPIClose(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
+ onClose(world, blockposition, iblockdata);
|
||||
+ }
|
||||
+
|
||||
+ public void openerAPICountChanged(World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j) {
|
||||
+ openerCountChanged(world, blockposition, iblockdata, i, j);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected abstract boolean isOwnContainer(EntityHuman entityhuman);
|
||||
|
||||
public void incrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
|
@ -28,7 +45,7 @@
|
|||
if (i == 0) {
|
||||
this.onOpen(world, blockposition, iblockdata);
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition);
|
||||
@@ -37,8 +49,19 @@
|
||||
@@ -37,8 +63,19 @@
|
||||
}
|
||||
|
||||
public void decrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
|
@ -48,7 +65,7 @@
|
|||
if (this.openCount == 0) {
|
||||
this.onClose(world, blockposition, iblockdata);
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition);
|
||||
@@ -59,6 +82,7 @@
|
||||
@@ -59,6 +96,7 @@
|
||||
|
||||
public void recheckOpeners(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
int i = this.getOpenCount(world, blockposition);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
--- a/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
|
||||
+++ b/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
|
||||
@@ -11,7 +11,7 @@
|
||||
public class TileEntityEnderChest extends TileEntity implements LidBlockEntity {
|
||||
|
||||
private final ChestLidController chestLidController = new ChestLidController();
|
||||
- private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
|
||||
+ public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
|
||||
@Override
|
||||
protected void onOpen(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
world.playSound((EntityHuman) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, SoundEffects.ENDER_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
|
@ -1,6 +1,5 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.sounds.SoundEffects;
|
||||
import net.minecraft.world.ITileInventory;
|
||||
import net.minecraft.world.level.block.BlockChest;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -58,8 +57,10 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
|
|||
requirePlaced();
|
||||
if (!getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
||||
IBlockData block = getTileEntity().getBlockState();
|
||||
getTileEntity().getLevel().blockEvent(getPosition(), block.getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1);
|
||||
TileEntityChest.playSound(getTileEntity().getLevel(), getPosition(), block, SoundEffects.CHEST_OPEN);
|
||||
int openCount = getTileEntity().openersCounter.getOpenerCount();
|
||||
|
||||
getTileEntity().openersCounter.onAPIOpen((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
|
||||
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, openCount + 1);
|
||||
}
|
||||
getTileEntity().openersCounter.opened = true;
|
||||
}
|
||||
|
@ -69,8 +70,10 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
|
|||
requirePlaced();
|
||||
if (getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
||||
IBlockData block = getTileEntity().getBlockState();
|
||||
getTileEntity().getLevel().blockEvent(getPosition(), block.getBlock(), 1, 0);
|
||||
TileEntityChest.playSound(getTileEntity().getLevel(), getPosition(), block, SoundEffects.CHEST_CLOSE);
|
||||
int openCount = getTileEntity().openersCounter.getOpenerCount();
|
||||
|
||||
getTileEntity().openersCounter.onAPIClose((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
|
||||
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, 0);
|
||||
}
|
||||
getTileEntity().openersCounter.opened = false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.EnderChest;
|
||||
|
||||
|
@ -9,4 +10,30 @@ public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest>
|
|||
public CraftEnderChest(World world, TileEntityEnderChest tileEntity) {
|
||||
super(world, tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
requirePlaced();
|
||||
if (!getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
||||
IBlockData block = getTileEntity().getBlockState();
|
||||
int openCount = getTileEntity().openersCounter.getOpenerCount();
|
||||
|
||||
getTileEntity().openersCounter.onAPIOpen((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
|
||||
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, openCount + 1);
|
||||
}
|
||||
getTileEntity().openersCounter.opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
requirePlaced();
|
||||
if (getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
||||
IBlockData block = getTileEntity().getBlockState();
|
||||
int openCount = getTileEntity().openersCounter.getOpenerCount();
|
||||
|
||||
getTileEntity().openersCounter.onAPIClose((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
|
||||
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, 0);
|
||||
}
|
||||
getTileEntity().openersCounter.opened = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue