Skip to content

Instantly share code, notes, and snippets.

if(!world.isRemote){
if(world.getBlockState(pos).getBlock() instanceof BlockDoor) {
String sound;
if(world.getBlockState(pos).getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER){
world.setBlockState(pos.down(), world.getBlockState(pos.down()).withProperty(BlockDoor.OPEN, !world.getBlockState(pos.down()).getValue(BlockDoor.OPEN)));
sound = world.getBlockState(pos.down()).getValue(BlockDoor.OPEN) ? "random.door_close" : "random.door_open";
world.playSoundAtEntity(player, sound, 1.0f, 1.0f);
return true;
} else {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockDoor.OPEN, !world.getBlockState(pos).getValue(BlockDoor.OPEN)));