Search in sources :

Example 71 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R2.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;
    }
}
Also used : Block(org.bukkit.block.Block) NoteBlock(org.bukkit.block.NoteBlock) BlockPos(net.minecraft.util.math.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 72 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R2.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;
    }
}
Also used : Block(org.bukkit.block.Block) BlockPos(net.minecraft.util.math.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) BlockDispenser(net.minecraft.block.BlockDispenser)

Example 73 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R2.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);
}
Also used : CraftBlockData(org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) Chunk(net.minecraft.world.level.chunk.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 74 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R2.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);
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) ParsedBlock(net.forthecrown.grenadier.types.block.ParsedBlock) BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 75 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R2.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;
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) ITeleporter(net.minecraftforge.common.util.ITeleporter) PlayerTeleportEvent(org.bukkit.event.player.PlayerTeleportEvent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Location(org.bukkit.Location) ResourceLocation(net.minecraft.util.ResourceLocation)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)147 Location (org.bukkit.Location)131 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)111 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)103 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)95 BlockPos (net.minecraft.core.BlockPos)83 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)74 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)66 ItemStack (org.bukkit.inventory.ItemStack)61 Block (org.bukkit.block.Block)57 LivingEntity (org.bukkit.entity.LivingEntity)54 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)53 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)47 ArrayList (java.util.ArrayList)43 World (org.bukkit.World)41 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)39 Entity (org.bukkit.entity.Entity)39 Level (net.minecraft.world.level.Level)38 List (java.util.List)34 GameProfile (com.mojang.authlib.GameProfile)32