Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/ By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import net.minecraft.server.TileEntityBanner;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftBanner extends CraftBlockState implements Banner {
|
||||
|
||||
private final TileEntityBanner banner;
|
||||
private DyeColor base;
|
||||
private List<Pattern> patterns = new ArrayList<Pattern>();
|
||||
|
||||
public CraftBanner(final Block block) {
|
||||
super(block);
|
||||
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
banner = (TileEntityBanner) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
|
||||
base = DyeColor.getByDyeData((byte) banner.color);
|
||||
|
||||
if (banner.patterns != null) {
|
||||
for (int i = 0; i < banner.patterns.size(); i++) {
|
||||
NBTTagCompound p = (NBTTagCompound) banner.patterns.get(i);
|
||||
patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInt("Color")), PatternType.getByIdentifier(p.getString("Pattern"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getBaseColor() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseColor(DyeColor color) {
|
||||
this.base = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pattern> getPatterns() {
|
||||
return new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPatterns(List<Pattern> patterns) {
|
||||
this.patterns = new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPattern(Pattern pattern) {
|
||||
this.patterns.add(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern getPattern(int i) {
|
||||
return this.patterns.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern removePattern(int i) {
|
||||
return this.patterns.remove(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPattern(int i, Pattern pattern) {
|
||||
this.patterns.set(i, pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numberOfPatterns() {
|
||||
return patterns.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
banner.color = base.getDyeData();
|
||||
|
||||
NBTTagList newPatterns = new NBTTagList();
|
||||
|
||||
for (Pattern p : patterns) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInt("Color", p.getColor().getDyeData());
|
||||
compound.setString("Pattern", p.getPattern().getIdentifier());
|
||||
newPatterns.add(compound);
|
||||
}
|
||||
|
||||
banner.patterns = newPatterns;
|
||||
|
||||
banner.update();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.BlockCocoa;
|
||||
import net.minecraft.server.BlockRedstoneWire;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.EnumSkyBlock;
|
||||
import net.minecraft.server.GameProfileSerializer;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.TileEntitySkull;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@@ -97,19 +89,27 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public void setData(final byte data) {
|
||||
chunk.getHandle().world.setData(x, y, z, data, 3);
|
||||
setData(data, 3);
|
||||
}
|
||||
|
||||
public void setData(final byte data, boolean applyPhysics) {
|
||||
if (applyPhysics) {
|
||||
chunk.getHandle().world.setData(x, y, z, data, 3);
|
||||
setData(data, 3);
|
||||
} else {
|
||||
chunk.getHandle().world.setData(x, y, z, data, 2);
|
||||
setData(data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void setData(final byte data, int flag) {
|
||||
net.minecraft.server.World world = chunk.getHandle().getWorld();
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
IBlockData blockData = world.getType(position);
|
||||
world.setTypeAndData(position, blockData.getBlock().fromLegacyData(data), flag);
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return (byte) chunk.getHandle().getData(this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
IBlockData blockData = chunk.getHandle().getBlockData(new BlockPosition(x, y, z));
|
||||
return (byte) blockData.getBlock().toLegacyData(blockData);
|
||||
}
|
||||
|
||||
public void setType(final Material type) {
|
||||
@@ -125,12 +125,14 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
|
||||
IBlockData blockData = getNMSBlock(type).fromLegacyData(data);
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
if (applyPhysics) {
|
||||
return chunk.getHandle().world.setTypeAndData(x, y, z, getNMSBlock(type), data, 3);
|
||||
return chunk.getHandle().getWorld().setTypeAndData(position, blockData, 3);
|
||||
} else {
|
||||
boolean success = chunk.getHandle().world.setTypeAndData(x, y, z, getNMSBlock(type), data, 2);
|
||||
boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 2);
|
||||
if (success) {
|
||||
chunk.getHandle().world.notify(x, y, z);
|
||||
chunk.getHandle().getWorld().notify(position);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -143,19 +145,19 @@ public class CraftBlock implements Block {
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getTypeId() {
|
||||
return CraftMagicNumbers.getId(chunk.getHandle().getType(this.x & 0xF, this.y & 0xFF, this.z & 0xF));
|
||||
return CraftMagicNumbers.getId(chunk.getHandle().getType(new BlockPosition(this.x, this.y, this.z)));
|
||||
}
|
||||
|
||||
public byte getLightLevel() {
|
||||
return (byte) chunk.getHandle().world.getLightLevel(this.x, this.y, this.z);
|
||||
return (byte) chunk.getHandle().getWorld().getLightLevel(new BlockPosition(this.x, this.y, this.z));
|
||||
}
|
||||
|
||||
public byte getLightFromSky() {
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.SKY, this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.SKY, new BlockPosition(this.x, this.y, this.z));
|
||||
}
|
||||
|
||||
public byte getLightFromBlocks() {
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.BLOCK, this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.BLOCK, new BlockPosition(this.x, this.y, this.z));
|
||||
}
|
||||
|
||||
|
||||
@@ -199,47 +201,42 @@ public class CraftBlock implements Block {
|
||||
return "CraftBlock{" + "chunk=" + chunk + ",x=" + x + ",y=" + y + ",z=" + z + ",type=" + getType() + ",data=" + getData() + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notch uses a 0-5 to mean DOWN, UP, NORTH, SOUTH, WEST, EAST
|
||||
* in that order all over. This method is convenience to convert for us.
|
||||
*
|
||||
* @return BlockFace the BlockFace represented by this number
|
||||
*/
|
||||
public static BlockFace notchToBlockFace(int notch) {
|
||||
public static BlockFace notchToBlockFace(EnumDirection notch) {
|
||||
if (notch == null) return BlockFace.SELF;
|
||||
switch (notch) {
|
||||
case 0:
|
||||
case DOWN:
|
||||
return BlockFace.DOWN;
|
||||
case 1:
|
||||
case UP:
|
||||
return BlockFace.UP;
|
||||
case 2:
|
||||
case NORTH:
|
||||
return BlockFace.NORTH;
|
||||
case 3:
|
||||
case SOUTH:
|
||||
return BlockFace.SOUTH;
|
||||
case 4:
|
||||
case WEST:
|
||||
return BlockFace.WEST;
|
||||
case 5:
|
||||
case EAST:
|
||||
return BlockFace.EAST;
|
||||
default:
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
}
|
||||
|
||||
public static int blockFaceToNotch(BlockFace face) {
|
||||
public static EnumDirection blockFaceToNotch(BlockFace face) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
return 0;
|
||||
return EnumDirection.DOWN;
|
||||
case UP:
|
||||
return 1;
|
||||
return EnumDirection.UP;
|
||||
case NORTH:
|
||||
return 2;
|
||||
return EnumDirection.NORTH;
|
||||
case SOUTH:
|
||||
return 3;
|
||||
return EnumDirection.SOUTH;
|
||||
case WEST:
|
||||
return 4;
|
||||
return EnumDirection.WEST;
|
||||
case EAST:
|
||||
return 5;
|
||||
return EnumDirection.EAST;
|
||||
default:
|
||||
return 7; // Good as anything here, but technically invalid
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +274,9 @@ public class CraftBlock implements Block {
|
||||
return new CraftCommandBlock(this);
|
||||
case BEACON:
|
||||
return new CraftBeacon(this);
|
||||
case BANNER:
|
||||
case WALL_BANNER:
|
||||
return new CraftBanner(this);
|
||||
default:
|
||||
return new CraftBlockState(this);
|
||||
}
|
||||
@@ -314,11 +314,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public boolean isBlockPowered() {
|
||||
return chunk.getHandle().world.getBlockPower(x, y, z) > 0;
|
||||
return chunk.getHandle().getWorld().getBlockPower(new BlockPosition(x, y, z)) > 0;
|
||||
}
|
||||
|
||||
public boolean isBlockIndirectlyPowered() {
|
||||
return chunk.getHandle().world.isBlockIndirectlyPowered(x, y, z);
|
||||
return chunk.getHandle().getWorld().isBlockIndirectlyPowered(new BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,11 +336,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public boolean isBlockFacePowered(BlockFace face) {
|
||||
return chunk.getHandle().world.isBlockFacePowered(x, y, z, blockFaceToNotch(face));
|
||||
return chunk.getHandle().getWorld().isBlockFacePowered(new BlockPosition(x, y, z), blockFaceToNotch(face));
|
||||
}
|
||||
|
||||
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
|
||||
int power = chunk.getHandle().world.getBlockFacePower(x, y, z, blockFaceToNotch(face));
|
||||
int power = chunk.getHandle().getWorld().getBlockFacePower(new BlockPosition(x, y, z), blockFaceToNotch(face));
|
||||
|
||||
Block relative = getRelative(face);
|
||||
if (relative.getType() == Material.REDSTONE_WIRE) {
|
||||
@@ -353,13 +353,13 @@ public class CraftBlock implements Block {
|
||||
public int getBlockPower(BlockFace face) {
|
||||
int power = 0;
|
||||
BlockRedstoneWire wire = Blocks.REDSTONE_WIRE;
|
||||
net.minecraft.server.World world = chunk.getHandle().world;
|
||||
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(x, y - 1, z, 0)) power = wire.getPower(world, x, y - 1, z, power);
|
||||
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(x, y + 1, z, 1)) power = wire.getPower(world, x, y + 1, z, power);
|
||||
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(x + 1, y, z, 2)) power = wire.getPower(world, x + 1, y, z, power);
|
||||
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(x - 1, y, z, 3)) power = wire.getPower(world, x - 1, y, z, power);
|
||||
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z - 1, 4)) power = wire.getPower(world, x, y, z - 1, power);
|
||||
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z + 1, 5)) power = wire.getPower(world, x, y, z - 1, power);
|
||||
net.minecraft.server.World world = chunk.getHandle().getWorld();
|
||||
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = wire.getPower(world, new BlockPosition(x, y - 1, z), power);
|
||||
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(world, new BlockPosition(x, y + 1, z), power);
|
||||
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(world, new BlockPosition(x + 1, y, z), power);
|
||||
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = wire.getPower(world, new BlockPosition(x - 1, y, z), power);
|
||||
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = wire.getPower(world, new BlockPosition(x, y, z - 1), power);
|
||||
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = wire.getPower(world, new BlockPosition(x, y, z - 1), power);
|
||||
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ public class CraftBlock implements Block {
|
||||
boolean result = false;
|
||||
|
||||
if (block != null && block != Blocks.AIR) {
|
||||
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
|
||||
block.dropNaturally(chunk.getHandle().getWorld(), new BlockPosition(x, y, z), block.fromLegacyData(data), 1.0F, 0);
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -415,14 +415,14 @@ public class CraftBlock implements Block {
|
||||
if (block != Blocks.AIR) {
|
||||
byte data = getData();
|
||||
// based on nms.Block.dropNaturally
|
||||
int count = block.getDropCount(0, chunk.getHandle().world.random);
|
||||
int count = block.getDropCount(0, chunk.getHandle().getWorld().random);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
Item item = block.getDropType(data, chunk.getHandle().world.random, 0);
|
||||
Item item = block.getDropType(block.fromLegacyData(data), chunk.getHandle().getWorld().random, 0);
|
||||
if (item != null) {
|
||||
// Skulls are special, their data is based on the tile entity
|
||||
if (Blocks.SKULL == block) {
|
||||
net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z));
|
||||
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z);
|
||||
net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().getWorld(), new BlockPosition(x, y, z)));
|
||||
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPosition(x, y, z));
|
||||
|
||||
if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
|
||||
nmsStack.setTag(new NBTTagCompound());
|
||||
@@ -435,12 +435,13 @@ public class CraftBlock implements Block {
|
||||
drops.add(CraftItemStack.asBukkitCopy(nmsStack));
|
||||
// We don't want to drop cocoa blocks, we want to drop cocoa beans.
|
||||
} else if (Blocks.COCOA == block) {
|
||||
int dropAmount = (BlockCocoa.c(data) >= 2 ? 3 : 1);
|
||||
int age = (Integer) block.fromLegacyData(data).get(BlockCocoa.AGE);
|
||||
int dropAmount = (age >= 2 ? 3 : 1);
|
||||
for (int j = 0; j < dropAmount; ++j) {
|
||||
drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
|
||||
}
|
||||
} else {
|
||||
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
|
||||
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(block.fromLegacyData(data))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -147,7 +148,7 @@ public class CraftBlockState implements BlockState {
|
||||
}
|
||||
|
||||
block.setData(getRawData(), applyPhysics);
|
||||
world.getHandle().notify(x, y, z);
|
||||
world.getHandle().notify(new BlockPosition(x, y, z));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.TileEntityChest;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@@ -41,19 +42,19 @@ public class CraftChest extends CraftBlockState implements Chest {
|
||||
}
|
||||
|
||||
if (world.getBlockTypeIdAt(x - 1, y, z) == id) {
|
||||
CraftInventory left = new CraftInventory((TileEntityChest)world.getHandle().getTileEntity(x - 1, y, z));
|
||||
CraftInventory left = new CraftInventory((TileEntityChest)world.getHandle().getTileEntity(new BlockPosition(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(x + 1, y, z));
|
||||
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(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(x, y, z - 1));
|
||||
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(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(x, y, z + 1));
|
||||
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z + 1)));
|
||||
inventory = new CraftInventoryDoubleChest(inventory, right);
|
||||
}
|
||||
return inventory;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDispenser;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDispenser;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
if (block.getType() == Material.DISPENSER) {
|
||||
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
|
||||
|
||||
dispense.dispense(world.getHandle(), getX(), getY(), getZ());
|
||||
dispense.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDropper;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDropper;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class CraftDropper extends CraftBlockState implements Dropper {
|
||||
if (block.getType() == Material.DROPPER) {
|
||||
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
|
||||
|
||||
drop.dispense(world.getHandle(), getX(), getY(), getZ());
|
||||
drop.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockJukeBox;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.TileEntityRecordPlayer;
|
||||
import net.minecraft.server.*;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -41,9 +38,13 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
}
|
||||
jukebox.update();
|
||||
if (record == Material.AIR) {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 0, 3);
|
||||
world.getHandle().setTypeAndData(new BlockPosition(getX(), getY(), getZ()),
|
||||
Blocks.JUKEBOX.getBlockData()
|
||||
.set(BlockJukeBox.HAS_RECORD, false), 3);
|
||||
} else {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 1, 3);
|
||||
world.getHandle().setTypeAndData(new BlockPosition(getX(), getY(), getZ()),
|
||||
Blocks.JUKEBOX.getBlockData()
|
||||
.set(BlockJukeBox.HAS_RECORD, true), 3);
|
||||
}
|
||||
world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
|
||||
}
|
||||
@@ -54,7 +55,7 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
|
||||
public boolean eject() {
|
||||
boolean result = isPlaying();
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ());
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPosition(getX(), getY(), getZ()), null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.TileEntityNote;
|
||||
|
||||
import org.bukkit.Instrument;
|
||||
@@ -41,7 +42,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
note.play(world.getHandle(), getX(), getY(), getZ());
|
||||
note.play(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -53,7 +54,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
world.getHandle().playBlockAction(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument, note);
|
||||
world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument, note);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -65,7 +66,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
world.getHandle().playBlockAction(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
|
||||
world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
import net.minecraft.server.TileEntitySign;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftSign extends CraftBlockState implements Sign {
|
||||
private final TileEntitySign sign;
|
||||
@@ -15,7 +18,7 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
lines = new String[sign.lines.length];
|
||||
System.arraycopy(sign.lines, 0, lines, 0, lines.length);
|
||||
System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length);
|
||||
}
|
||||
|
||||
public String[] getLines() {
|
||||
@@ -35,24 +38,37 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
sign.lines = sanitizeLines(lines);
|
||||
IChatBaseComponent[] newLines = sanitizeLines(lines);
|
||||
System.arraycopy(newLines, 0, sign.lines, 0, 4);
|
||||
sign.update();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String[] sanitizeLines(String[] lines) {
|
||||
String[] astring = new String[4];
|
||||
public static IChatBaseComponent[] sanitizeLines(String[] lines) {
|
||||
IChatBaseComponent[] components = new IChatBaseComponent[4];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < lines.length && lines[i] != null) {
|
||||
astring[i] = lines[i];
|
||||
components[i] = CraftChatMessage.fromString(lines[i])[0];
|
||||
} else {
|
||||
astring[i] = "";
|
||||
components[i] = new ChatComponentText("");
|
||||
}
|
||||
}
|
||||
|
||||
return TileEntitySign.sanitizeLines(astring);
|
||||
return components;
|
||||
}
|
||||
|
||||
public static String[] revertComponents(IChatBaseComponent[] components) {
|
||||
String[] lines = new String[components.length];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
lines[i] = revertComponent(components[i]);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static String revertComponent(IChatBaseComponent component) {
|
||||
return CraftChatMessage.fromComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.TileEntitySkull;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -24,7 +24,7 @@ public class CraftSkull extends CraftBlockState implements Skull {
|
||||
skull = (TileEntitySkull) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
profile = skull.getGameProfile();
|
||||
skullType = getSkullType(skull.getSkullType());
|
||||
rotation = (byte) skull.getRotation();
|
||||
rotation = (byte) skull.rotation;
|
||||
}
|
||||
|
||||
static SkullType getSkullType(int id) {
|
||||
|
||||
Reference in New Issue
Block a user