Skip to content

Instantly share code, notes, and snippets.

@Wehavecookies56
Created January 21, 2016 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wehavecookies56/5a118cdec49aca781e6c to your computer and use it in GitHub Desktop.
Save Wehavecookies56/5a118cdec49aca781e6c to your computer and use it in GitHub Desktop.
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)));
sound = world.getBlockState(pos).getValue(BlockDoor.OPEN) ? "random.door_close" : "random.door_open";
world.playSoundAtEntity(player, sound, 1.0f, 1.0f);
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment