本文整理汇总了Java中net.minecraft.command.server.CommandBlockLogic.setCommand方法的典型用法代码示例。如果您正苦于以下问题:Java CommandBlockLogic.setCommand方法的具体用法?Java CommandBlockLogic.setCommand怎么用?Java CommandBlockLogic.setCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.command.server.CommandBlockLogic
的用法示例。
在下文中一共展示了CommandBlockLogic.setCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTick
import net.minecraft.command.server.CommandBlockLogic; //导入方法依赖的package包/类
@Override
public void updateTick(World w, BlockPos ps,IBlockState state, Random r)
{
//this fires on redstone power
TileEntity tileentity = w.getTileEntity(ps);
if (tileentity == null ) {return;}
if(!(tileentity instanceof TileEntityCommandBlock)) {return;}
int d = 2;
String command = null; //set the command of the block as a string, just as a player would type it
switch(type)
{
case Teleport:
EntityPlayer p = w.getClosestPlayer(ps.getX(), ps.getY(), ps.getZ(), 6);
if(p==null){return;}
//boolean inWall = true;
//Block current;
int _x = (int) p.posX;//w.getWorldInfo().getSpawnX();
int _y = (int) p.posY + dist;//w.getWorldInfo().getSpawnY();
int _z = (int) p.posZ;//w.getWorldInfo().getSpawnZ();
/*
while(inWall)
{
current = w.getBlock(_x, _y, _z);
if(current == Blocks.air)
{
inWall = false;
}
else
{
_y++;
}
//either we are out in open air, or we have moved up one block so loop again
}
*/
command = "tp @p " + _x + " "+_y+" "+_z;
break;
case Gamerule:
String lastVal = w.getGameRules().getGameRuleStringValue(rule);
//toggle it based on previous value
lastVal = (lastVal.equals("false")) ? "true" : "false";
//Chat.addMessage(w, rule+" = "+lastVal);
command = "gamerule "+ rule +" "+lastVal;
break;
case Weather:
command = "toggledownfall";
break;
}
//in 1.8 snapshot, we will use execute possibly?
// commandblocklogic.func_145752_a("/execute @p "+x+" "+y+" "+z+" toggledownfall");
if(command != null)
{
command = "/"+command;
CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).getCommandBlockLogic();//func_145993_a();
commandblocklogic.setCommand(command);//.func_145752_a(command); //set current command into this CommandClock
//execute my current command in the World
commandblocklogic.trigger(w);//.func_145755_a(w);
w.notifyBlockOfStateChange(ps, this);//.func_147453_f(x, y, z, this);
w.markBlockForUpdate(ps);
}
}
开发者ID:LothrazarMinecraftMods,项目名称:SurvivalCommandBlocks,代码行数:79,代码来源:BlockCommandBlockCraftable.java