#660: Add support to change block's lid state
By: jameslfc19 <jameslfc19@gmail.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.IBlockData;
|
||||
import net.minecraft.server.SoundEffects;
|
||||
import net.minecraft.server.TileEntityBarrel;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Barrel;
|
||||
@@ -30,4 +32,26 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
requirePlaced();
|
||||
if (!getTileEntity().opened) {
|
||||
IBlockData blockData = getTileEntity().getBlock();
|
||||
getTileEntity().a(blockData, true);
|
||||
getTileEntity().a(blockData, SoundEffects.BLOCK_BARREL_OPEN);
|
||||
}
|
||||
getTileEntity().opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
requirePlaced();
|
||||
if (getTileEntity().opened) {
|
||||
IBlockData blockData = getTileEntity().getBlock();
|
||||
getTileEntity().a(blockData, false);
|
||||
getTileEntity().a(blockData, SoundEffects.BLOCK_BARREL_CLOSE);
|
||||
}
|
||||
getTileEntity().opened = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.block;
|
||||
import net.minecraft.server.BlockChest;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ITileInventory;
|
||||
import net.minecraft.server.SoundEffects;
|
||||
import net.minecraft.server.TileEntityChest;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -54,4 +55,26 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
requirePlaced();
|
||||
if (!getTileEntity().opened) {
|
||||
net.minecraft.server.Block block = getTileEntity().getBlock().getBlock();
|
||||
getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, getTileEntity().viewingCount + 1);
|
||||
getTileEntity().a(SoundEffects.BLOCK_CHEST_OPEN);
|
||||
}
|
||||
getTileEntity().opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
requirePlaced();
|
||||
if (getTileEntity().opened) {
|
||||
net.minecraft.server.Block block = getTileEntity().getBlock().getBlock();
|
||||
getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, 0);
|
||||
getTileEntity().a(SoundEffects.BLOCK_CHEST_CLOSE);
|
||||
}
|
||||
getTileEntity().opened = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockShulkerBox;
|
||||
import net.minecraft.server.SoundCategory;
|
||||
import net.minecraft.server.SoundEffects;
|
||||
import net.minecraft.server.TileEntityShulkerBox;
|
||||
import net.minecraft.server.World;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -40,4 +43,26 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
|
||||
|
||||
return DyeColor.getByWoolData((byte) ((BlockShulkerBox) block).color.getColorIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
requirePlaced();
|
||||
if (!getTileEntity().opened) {
|
||||
World world = getTileEntity().getWorld();
|
||||
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 1);
|
||||
world.playSound(null, getPosition(), SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
getTileEntity().opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
requirePlaced();
|
||||
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);
|
||||
}
|
||||
getTileEntity().opened = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user