use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project Magma by magmafoundation.
the class CraftNoteBlock method play.
@Override
public boolean play(byte instrument, byte 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, note);
return true;
} else {
return false;
}
}
use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project Magma by magmafoundation.
the class CraftDispenser method dispense.
@Override
public boolean dispense() {
Block block = getBlock();
if (block.getType() == Material.DISPENSER) {
CraftWorld world = (CraftWorld) this.getWorld();
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
dispense.dispense(world.getHandle(), new BlockPos(getX(), getY(), getZ()));
return true;
} else {
return false;
}
}
use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project BentoBox by BentoBoxWorld.
the class NMSHandler method setBlockInNativeChunk.
@Override
public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData, boolean applyPhysics) {
CraftBlockData craft = (CraftBlockData) blockData;
World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle();
Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ());
BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z);
// Setting the block to air before setting to another state prevents some console errors
nmsChunk.a(bp, AIR, applyPhysics);
nmsChunk.a(bp, craft.getState(), applyPhysics);
}
use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project RoyalGrenadier by BotulToxin.
the class ParsedBlockImpl method place.
@Override
public void place(World world, int x, int y, int z, boolean applyPhysics) {
// Configure the state we're setting
BlockState state = getState();
if (!getMaterial().isAir()) {
// If we're not setting it to air, make sure state has correct shape
state = net.minecraft.world.level.block.Block.updateFromNeighbourShapes(getState(), ((CraftWorld) world).getHandle(), new BlockPos(x, y, z));
}
// Set the block
Block b = world.getBlockAt(x, y, z);
b.setBlockData(state.createCraftBlockData(), applyPhysics);
// If we have NBT tags to set, set them
if (tags != null) {
BlockEntity entity = ((CraftWorld) world).getHandle().getBlockEntity(new BlockPos(x, y, z));
if (entity != null)
entity.load(tags);
}
}
use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project Magma-1.16.x by magmafoundation.
the class CraftPlayer method teleport.
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
Preconditions.checkArgument(location != null, "location");
Preconditions.checkArgument(location.getWorld() != null, "location.world");
location.checkFinite();
ServerPlayerEntity entity = getHandle();
if (getHealth() == 0 || entity.removed) {
return false;
}
if (entity.connection == null) {
return false;
}
if (entity.isVehicle()) {
return false;
}
// From = Players current Location
Location from = this.getLocation();
// To = Players new Location if Teleport is Successful
Location to = location;
// Create & Call the Teleport Event.
PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause);
server.getPluginManager().callEvent(event);
// Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
if (event.isCancelled()) {
return false;
}
// If this player is riding another entity, we must dismount before teleporting.
entity.stopRiding();
// SPIGOT-5509: Wakeup, similar to riding
if (this.isSleeping()) {
this.wakeup(false);
}
// Update the From Location
from = event.getFrom();
// Grab the new To Location dependent on whether the event was cancelled.
to = event.getTo();
// Grab the To and From World Handles.
ServerWorld fromWorld = ((CraftWorld) from.getWorld()).getHandle();
ServerWorld toWorld = ((CraftWorld) to.getWorld()).getHandle();
// Close any foreign inventory
if (getHandle().containerMenu != getHandle().inventoryMenu) {
getHandle().closeContainer();
}
if (fromWorld != toWorld)
entity.changeDimension(toWorld, new ITeleporter() {
});
entity.connection.teleport(to);
return true;
}
Aggregations