@@ -416,13 +416,10 @@ public class CraftWorld implements World {
|
||||
world.captureTreeGeneration = false;
|
||||
if (grownTree) { // Copy block data to delegate
|
||||
for (BlockState blockstate : world.capturedBlockStates) {
|
||||
int x = blockstate.getX();
|
||||
int y = blockstate.getY();
|
||||
int z = blockstate.getZ();
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
BlockPosition position = ((CraftBlockState) blockstate).getPosition();
|
||||
net.minecraft.server.IBlockData oldBlock = world.getType(position);
|
||||
int flag = ((CraftBlockState) blockstate).getFlag();
|
||||
delegate.setBlockData(x, y, z, blockstate.getBlockData());
|
||||
delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData());
|
||||
net.minecraft.server.IBlockData newBlock = world.getType(position);
|
||||
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag);
|
||||
}
|
||||
@@ -434,10 +431,6 @@ public class CraftWorld implements World {
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntity getTileEntityAt(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(new BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return world.worldData.getName();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
||||
|
||||
// get tile entity from block:
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
this.tileEntity = tileEntityClass.cast(world.getTileEntityAt(this.getX(), this.getY(), this.getZ()));
|
||||
this.tileEntity = tileEntityClass.cast(world.getHandle().getTileEntity(this.getPosition()));
|
||||
|
||||
// copy tile entity data:
|
||||
this.snapshot = this.createSnapshot(tileEntity, world.getHandle());
|
||||
@@ -74,7 +74,7 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
||||
protected TileEntity getTileEntityFromWorld() {
|
||||
requirePlaced();
|
||||
|
||||
return ((CraftWorld) this.getWorld()).getTileEntityAt(this.getX(), this.getY(), this.getZ());
|
||||
return ((CraftWorld) this.getWorld()).getHandle().getTileEntity(this.getPosition());
|
||||
}
|
||||
|
||||
// gets the NBT data of the TileEntity represented by this block state
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.server.IBlockData;
|
||||
public class CraftBlockState implements BlockState {
|
||||
private final CraftWorld world;
|
||||
private final CraftChunk chunk;
|
||||
protected final BlockPosition position;
|
||||
private final BlockPosition position;
|
||||
protected IBlockData data;
|
||||
protected int flag;
|
||||
|
||||
@@ -83,6 +83,10 @@ public class CraftBlockState implements BlockState {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public BlockPosition getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public IBlockData getHandle() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockChest;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ITileInventory;
|
||||
import net.minecraft.server.InventoryLargeChest;
|
||||
@@ -50,7 +49,7 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
|
||||
BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST);
|
||||
ITileInventory nms = blockChest.getInventory(data, world.getHandle(), position, true);
|
||||
ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition(), true);
|
||||
|
||||
if (nms instanceof InventoryLargeChest) {
|
||||
inventory = new CraftInventoryDoubleChest((InventoryLargeChest) nms);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CraftDispenser extends CraftLootable<TileEntityDispenser> implement
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
|
||||
|
||||
dispense.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
dispense.dispense(world.getHandle(), this.getPosition());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dr
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
|
||||
|
||||
drop.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
drop.dispense(world.getHandle(), this.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
Material record = this.getPlaying();
|
||||
if (record == Material.AIR) {
|
||||
world.getHandle().setTypeAndData(position, Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, false), 3);
|
||||
world.getHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, false), 3);
|
||||
} else {
|
||||
world.getHandle().setTypeAndData(position, Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, true), 3);
|
||||
world.getHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, true), 3);
|
||||
}
|
||||
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
|
||||
boolean result = !jukebox.getRecord().isEmpty();
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), position);
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getPosition());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user