本文整理汇总了Java中net.minecraft.command.server.CommandBlockLogic类的典型用法代码示例。如果您正苦于以下问题:Java CommandBlockLogic类的具体用法?Java CommandBlockLogic怎么用?Java CommandBlockLogic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandBlockLogic类属于net.minecraft.command.server包,在下文中一共展示了CommandBlockLogic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlacedBy
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityCommandBlock)
{
CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).getCommandBlockLogic();
if (stack.hasDisplayName())
{
commandblocklogic.setName(stack.getDisplayName());
}
if (!worldIn.isRemote)
{
commandblocklogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback"));
}
}
}
示例2: handleCommandExecution
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
private int handleCommandExecution(ICommandManager commandManager, CommandBlockLogic commandBlockLogic, String commandStored) {
final String[] args = commandStored.split(" ");
String commandName = args[0];
if (commandName.startsWith("/")) {
commandName = commandName.substring(1);
}
CommandBlockCommandHook commandHook = (CommandBlockCommandHook) new CommandBlockCommandHook(
(net.canarymod.api.CommandBlockLogic) commandBlockLogic, args).call();
if (!commandHook.isCanceled()
&& (Configuration.getServerConfig().isCommandBlockOpped()
|| ((net.canarymod.api.CommandBlockLogic) commandBlockLogic).hasPermission("canary.command." + commandName))) {
int result = commandManager.executeCommand(commandBlockLogic, commandStored);
if (result == 0) {
// Minecraft found no command, now its our turn
Canary.getServer().consoleCommand(commandStored, (net.canarymod.api.CommandBlockLogic) commandBlockLogic);
}
return result;
}
return 0;
}
示例3: fireCommand
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
public static int fireCommand(ICommandSender sender, String input){
CommandSender wrapped = null;
if(sender instanceof EntityPlayerMP){
wrapped = NailedPlatform.instance().getPlayer(((EntityPlayerMP) sender).getGameProfile().getId());
}else if(sender instanceof CommandBlockLogic){
wrapped = new CommandBlockCommandSender(((CommandBlockLogic) sender)); //TODO: replace this with our own api
}else if(sender instanceof RConConsoleSource){
//wrapped = new RConCommandSender(((RConConsoleSource) sender));
}else if(sender instanceof MinecraftServer){
wrapped = serverCommandSender;
}
if(wrapped == null){
return -1;
}
return NailedCommandManager.fireCommand((wrapped instanceof Player) ? input.substring(1) : input, wrapped, sender);
}
示例4: fireTabCompletion
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
public static List<String> fireTabCompletion(ICommandSender sender, String input){
CommandSender wrapped = null;
if(sender instanceof EntityPlayerMP){
wrapped = NailedPlatform.instance().getPlayer(((EntityPlayerMP) sender).getGameProfile().getId());
}else if(sender instanceof CommandBlockLogic){
wrapped = new CommandBlockCommandSender(((CommandBlockLogic) sender)); //TODO: replace this with our own api
}else if(sender instanceof RConConsoleSource){
//wrapped = new RConCommandSender(((RConConsoleSource) sender));
}else if(sender instanceof MinecraftServer){
wrapped = serverCommandSender;
}
if(wrapped == null){
return null;
}
return NailedCommandManager.fireAutocompletion(input, wrapped, sender);
}
示例5: load
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
/**
* Load command data from NBT tag
* @param commandBlock Target command block
* @param tag tag to load
* @param seed Loading seed
*/
private static void load(TileEntityCommandBlock commandBlock, NBTTagCompound tag, long seed) {
if (tag == null) {
return;
}
Random random = new Random(seed);
CommandBlockLogic logic = commandBlock.func_145993_a();
logic.func_145759_b(tag);
}
示例6: getReceiverType
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
@Override
public ReceiverType getReceiverType() {
if (this instanceof Player) {
return ReceiverType.PLAYER;
} else if (this instanceof net.canarymod.api.CommandBlockLogic) {
return ReceiverType.COMMANDBLOCK;
} else {
return ReceiverType.SERVER;
}
}
示例7: asCommandBlock
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
@Override
public net.canarymod.api.CommandBlockLogic asCommandBlock() {
if (this instanceof net.canarymod.api.CommandBlockLogic) {
return (net.canarymod.api.CommandBlockLogic) this;
}
throw new InvalidInstanceException("This is not a MessageReceiver of the type: COMMANDBLOCK");
}
示例8: updateTick
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
TileEntity var6 = p_149674_1_.getTileEntity(p_149674_2_, p_149674_3_, p_149674_4_);
if (var6 != null && var6 instanceof TileEntityCommandBlock)
{
CommandBlockLogic var7 = ((TileEntityCommandBlock)var6).func_145993_a();
var7.func_145755_a(p_149674_1_);
p_149674_1_.func_147453_f(p_149674_2_, p_149674_3_, p_149674_4_, this);
}
}
示例9: notifyAdmins
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
/**
* Sends a message to the admins of the server from a given CommandSender with the given resource string and given
* extra srings. If the int par2 is even or zero, the original sender is also notified.
*/
public void notifyAdmins(ICommandSender par1ICommandSender, int par2, String par3Str, Object ... par4ArrayOfObj)
{
boolean var5 = true;
if (par1ICommandSender instanceof CommandBlockLogic && !MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput"))
{
var5 = false;
}
ChatComponentTranslation var6 = new ChatComponentTranslation("chat.type.admin", new Object[] {par1ICommandSender.getCommandSenderName(), new ChatComponentTranslation(par3Str, par4ArrayOfObj)});
var6.getChatStyle().setColor(EnumChatFormatting.GRAY);
var6.getChatStyle().setItalic(Boolean.valueOf(true));
if (var5)
{
Iterator var7 = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
while (var7.hasNext())
{
EntityPlayerMP var8 = (EntityPlayerMP)var7.next();
if (var8 != par1ICommandSender && MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(var8.getCommandSenderName()))
{
var8.addChatMessage(var6);
}
}
}
if (par1ICommandSender != MinecraftServer.getServer())
{
MinecraftServer.getServer().addChatMessage(var6);
}
if ((par2 & 1) != 1)
{
par1ICommandSender.addChatMessage(new ChatComponentTranslation(par3Str, par4ArrayOfObj));
}
}
示例10: notifyOperators
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
/**
* @author jamierocks - 1st September 2016
* @reason Log command feedback
*/
@Overwrite
public void notifyOperators(ICommandSender sender, ICommand command, int flags, String msgFormat, Object... msgParams) {
final MinecraftServer server = MinecraftServer.getServer();
final IChatComponent feedback =
new ChatComponentTranslation("chat.type.admin", sender.getName(), new ChatComponentTranslation(msgFormat, msgParams));
feedback.getChatStyle().setColor(EnumChatFormatting.GRAY);
feedback.getChatStyle().setItalic(true);
if (sender.sendCommandFeedback()) {
for (final EntityPlayer player : server.getConfigurationManager().getPlayerList()) {
if (player != sender && server.getConfigurationManager().canSendCommands(player.getGameProfile()) && command
.canCommandSenderUseCommand(sender)) {
final boolean broadcastConsoleToOps = sender instanceof MinecraftServer &&
MinecraftServer.getServer().shouldBroadcastConsoleToOps();
final boolean broadcastRconToOps = sender instanceof RConConsoleSource &&
MinecraftServer.getServer().shouldBroadcastRconToOps();
if (broadcastConsoleToOps || broadcastRconToOps || !(sender instanceof RConConsoleSource) && !(sender instanceof MinecraftServer)) {
player.addChatMessage(feedback);
}
}
}
}
// Neptune - Always log command feedback
//if (sender != server && server.worldServers[0].getGameRules().getBoolean("logAdminCommands")) {
server.addChatMessage(feedback);
//}
// Neptune - end
final boolean shouldSendCommandFeedback = sender instanceof CommandBlockLogic ?
((CommandBlockLogic) sender).shouldTrackOutput() :
server.worldServers[0].getGameRules().getBoolean("sendCommandFeedback");
if ((flags & 1) != 1 && shouldSendCommandFeedback || sender instanceof MinecraftServer) {
sender.addChatMessage(new ChatComponentTranslation(msgFormat, msgParams));
}
}
示例11: trigger
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
/**
* @author jamierocks - 3rd September 2016
* @reason Support Canary commands
*/
@Overwrite
public void trigger(net.minecraft.world.World worldIn) {
if (worldIn.isRemote) {
this.successCount = 0;
}
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && minecraftserver.isCommandBlockEnabled()) {
ICommandManager icommandmanager = minecraftserver.getCommandManager();
try {
this.lastOutput = null;
// Neptune - Canary commands
this.successCount = this.handleCommandExecution(icommandmanager, (CommandBlockLogic) (Object) this, this.commandStored);
// Neptune - end
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Executing command block");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed");
crashreportcategory.addCrashSectionCallable("Command", this::getCommand);
crashreportcategory.addCrashSectionCallable("Name", this::getName);
throw new ReportedException(crashreport);
}
} else {
this.successCount = 0;
}
}
示例12: processCommand
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
@Override
public void processCommand(ICommandSender sender, String[] args)
{
if (!(sender instanceof CommandBlockLogic) && !sender.canCommandSenderUseCommand(3, this.getCommandName())) {
throw new CommandException("Could not execute command: Permission Denied");
}
if (args.length < 1) {
throw new CommandException("Could not execute command");
}
String filename = args[0];
double x = sender.getPlayerCoordinates().posX;
double y = sender.getPlayerCoordinates().posY;
double z = sender.getPlayerCoordinates().posZ;
if (args.length > 3) {
x = func_110666_a(sender, x, args[1]);
y = func_110666_a(sender, y, args[2]);
z = func_110666_a(sender, z, args[3]);
}
SchematicLoader loader = new SchematicLoader();
if (!filename.endsWith(".schematic")) {
filename += ".schematic";
}
ResourceLocation schematicLocation = loader.loadSchematic(new File(TheMod.proxy.getDataDirectory(), "/Schematics/" + filename));
loader.renderSchematicInOneShot(schematicLocation, sender.getEntityWorld(), (int) x, (int) y, (int) z, ForgeDirection.NORTH, false);
sender.addChatMessage(new ChatComponentText("Rendered schematic " + filename));
}
示例13: SchematicLoader
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
public SchematicLoader()
{
tileEntityLoadedEventListeners.add(new ITileEntityLoadedEvent()
{
@Override
public boolean onTileEntityAdded(TileEntity tileEntity)
{
if (tileEntity instanceof TileEntityCommandBlock)
{
_logger.info("Activating command Block");
final GameRules gameRules = MinecraftServer.getServer().worldServers[0].getGameRules();
Boolean commandBlockOutputSetting = gameRules.getGameRuleBooleanValue("commandBlockOutput");
gameRules.setOrCreateGameRule("commandBlockOutput", "false");
final World worldObj = tileEntity.getWorldObj();
TileEntityCommandBlock commandBlock = (TileEntityCommandBlock) tileEntity;
Block block = worldObj.getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
CommandBlockLogic commandblocklogic = commandBlock.func_145993_a();
commandblocklogic.func_145755_a(worldObj);
worldObj.func_147453_f(commandBlock.xCoord, commandBlock.yCoord, commandBlock.zCoord, block);
if (worldObj.getTileEntity(commandBlock.xCoord, commandBlock.yCoord, commandBlock.zCoord) instanceof TileEntityCommandBlock)
{
worldObj.setBlock(commandBlock.xCoord, commandBlock.yCoord, commandBlock.zCoord, Blocks.air, 0, 3);
}
gameRules.setOrCreateGameRule("commandBlockOutput", commandBlockOutputSetting.toString());
return true;
}
return false;
}
});
}
示例14: updateTick
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
TileEntity tileentity = p_149674_1_.getTileEntity(p_149674_2_, p_149674_3_, p_149674_4_);
if (tileentity != null && tileentity instanceof TileEntityCommandBlock)
{
CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).func_145993_a();
commandblocklogic.func_145755_a(p_149674_1_);
p_149674_1_.func_147453_f(p_149674_2_, p_149674_3_, p_149674_4_, this);
}
}
示例15: func_152372_a
import net.minecraft.command.server.CommandBlockLogic; //导入依赖的package包/类
public void func_152372_a(ICommandSender p_152372_1_, ICommand p_152372_2_, int p_152372_3_, String p_152372_4_, Object ... p_152372_5_)
{
boolean flag = true;
if (p_152372_1_ instanceof CommandBlockLogic && !MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput"))
{
flag = false;
}
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.type.admin", new Object[] {p_152372_1_.getCommandSenderName(), new ChatComponentTranslation(p_152372_4_, p_152372_5_)});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY);
chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true));
if (flag)
{
Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
while (iterator.hasNext())
{
EntityPlayer entityplayer = (EntityPlayer)iterator.next();
if (entityplayer != p_152372_1_ && MinecraftServer.getServer().getConfigurationManager().func_152596_g(entityplayer.getGameProfile()) && p_152372_2_.canCommandSenderUseCommand(entityplayer) && (!(p_152372_1_ instanceof RConConsoleSource) || MinecraftServer.getServer().func_152363_m()))
{
entityplayer.addChatMessage(chatcomponenttranslation);
}
}
}
if (p_152372_1_ != MinecraftServer.getServer())
{
MinecraftServer.getServer().addChatMessage(chatcomponenttranslation);
}
if ((p_152372_3_ & 1) != 1)
{
p_152372_1_.addChatMessage(new ChatComponentTranslation(p_152372_4_, p_152372_5_));
}
}