use of org.bukkit.craftbukkit.v1_16_R2.CraftWorld in project Magma by magmafoundation.
the class CraftItemFrame method update.
private void update() {
EntityItemFrame old = this.getHandle();
WorldServer world = ((CraftWorld) getWorld()).getHandle();
BlockPos position = old.getPosition();
EnumFacing direction = old.getHorizontalFacing();
ItemStack item = old.getDisplayedItem() != null ? old.getDisplayedItem().copy() : null;
old.setDead();
EntityItemFrame frame = new EntityItemFrame(world, position, direction);
frame.setDisplayedItem(item);
world.spawnEntity(frame);
this.entity = frame;
}
use of org.bukkit.craftbukkit.v1_16_R2.CraftWorld in project Magma by magmafoundation.
the class CraftChest method getInventory.
@Override
public Inventory getInventory() {
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
if (!isPlaced()) {
return inventory;
}
// The logic here is basically identical to the logic in BlockChest.interact
int x = this.getX();
int y = this.getY();
int z = this.getZ();
CraftWorld world = (CraftWorld) this.getWorld();
int id;
if (world.getBlockTypeIdAt(x, y, z) == Material.CHEST.getId()) {
id = Material.CHEST.getId();
} else if (world.getBlockTypeIdAt(x, y, z) == Material.TRAPPED_CHEST.getId()) {
id = Material.TRAPPED_CHEST.getId();
} else {
throw new IllegalStateException("CraftChest is not a chest but is instead " + world.getBlockAt(x, y, z));
}
if (world.getBlockTypeIdAt(x - 1, y, z) == id) {
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPos(x - 1, y, z)));
inventory = new CraftInventoryDoubleChest(left, inventory);
}
if (world.getBlockTypeIdAt(x + 1, y, z) == id) {
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPos(x + 1, y, z)));
inventory = new CraftInventoryDoubleChest(inventory, right);
}
if (world.getBlockTypeIdAt(x, y, z - 1) == id) {
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPos(x, y, z - 1)));
inventory = new CraftInventoryDoubleChest(left, inventory);
}
if (world.getBlockTypeIdAt(x, y, z + 1) == id) {
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPos(x, y, z + 1)));
inventory = new CraftInventoryDoubleChest(inventory, right);
}
return inventory;
}
use of org.bukkit.craftbukkit.v1_16_R2.CraftWorld in project Magma by magmafoundation.
the class CraftJukebox method update.
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
CraftWorld world = (CraftWorld) this.getWorld();
Material record = this.getPlaying();
if (record == Material.AIR) {
world.getHandle().setBlockState(new BlockPos(this.getX(), this.getY(), this.getZ()), Blocks.JUKEBOX.getDefaultState().withProperty(BlockJukebox.HAS_RECORD, false), 3);
} else {
world.getHandle().setBlockState(new BlockPos(this.getX(), this.getY(), this.getZ()), Blocks.JUKEBOX.getDefaultState().withProperty(BlockJukebox.HAS_RECORD, true), 3);
}
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record.getId());
}
return result;
}
use of org.bukkit.craftbukkit.v1_16_R2.CraftWorld in project Magma by magmafoundation.
the class CraftNoteBlock method play.
@Override
public boolean play() {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
TileEntityNote note = (TileEntityNote) this.getTileEntityFromWorld();
CraftWorld world = (CraftWorld) this.getWorld();
note.triggerNote(world.getHandle(), new BlockPos(getX(), getY(), getZ()));
return true;
} else {
return false;
}
}
use of org.bukkit.craftbukkit.v1_16_R2.CraftWorld in project Magma by magmafoundation.
the class CraftNoteBlock method play.
@Override
public boolean play(Instrument instrument, Note note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
CraftWorld world = (CraftWorld) this.getWorld();
world.getHandle().addBlockEvent(new BlockPos(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
return true;
} else {
return false;
}
}
Aggregations