mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 21:19:00 +01:00
BlockState for Command Blocks. Adds BUKKIT-3805.
This commit is contained in:
parent
e639690e45
commit
dc19d3788f
@ -9,7 +9,7 @@ import com.google.common.base.Joiner;
|
|||||||
public class TileEntityCommand extends TileEntity implements ICommandListener {
|
public class TileEntityCommand extends TileEntity implements ICommandListener {
|
||||||
|
|
||||||
private int a = 0;
|
private int a = 0;
|
||||||
private String b = "";
|
public String b = ""; // CraftBukkit - private -> public
|
||||||
private String c = "@";
|
private String c = "@";
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
private final org.bukkit.command.BlockCommandSender sender;
|
private final org.bukkit.command.BlockCommandSender sender;
|
||||||
|
@ -261,6 +261,8 @@ public class CraftBlock implements Block {
|
|||||||
return new CraftBrewingStand(this);
|
return new CraftBrewingStand(this);
|
||||||
case SKULL:
|
case SKULL:
|
||||||
return new CraftSkull(this);
|
return new CraftSkull(this);
|
||||||
|
case COMMAND:
|
||||||
|
return new CraftCommandBlock(this);
|
||||||
default:
|
default:
|
||||||
return new CraftBlockState(this);
|
return new CraftBlockState(this);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntityCommand;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.CommandBlock;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
|
public class CraftCommandBlock extends CraftBlockState implements CommandBlock {
|
||||||
|
private final TileEntityCommand commandBlock;
|
||||||
|
private String command;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public CraftCommandBlock(Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
CraftWorld world = (CraftWorld) block.getWorld();
|
||||||
|
commandBlock = (TileEntityCommand) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
command = commandBlock.b;
|
||||||
|
name = commandBlock.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommand() {
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommand(String command) {
|
||||||
|
this.command = command != null ? command : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name != null ? name : "@";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean update(boolean forced) {
|
||||||
|
boolean result = super.update(forced);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
commandBlock.b(command);
|
||||||
|
commandBlock.c(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user