当前位置: 首页>>代码示例>>Java>>正文


Java GameRules.hasRule方法代码示例

本文整理汇总了Java中net.minecraft.world.GameRules.hasRule方法的典型用法代码示例。如果您正苦于以下问题:Java GameRules.hasRule方法的具体用法?Java GameRules.hasRule怎么用?Java GameRules.hasRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.world.GameRules的用法示例。


在下文中一共展示了GameRules.hasRule方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSelectedRule

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
public void setSelectedRule(String rule) {
	if (!rules.contains(rule)) {
		rule = rules.get(0);
	}
	this.selectedRule = rule;
	String unlocalizedName = "gui.commandEditor.gamerule.rule." + rule;
	if (SmartTranslationRegistry.getLanguageMapInstance().isKeyTranslated(unlocalizedName)) {
		this.label.setText(I18n.format(unlocalizedName));
	} else {
		this.label.setText(rule);
	}
	this.label.setColor(Colors.itemName.color);

	GameRules gameRules = Minecraft.getMinecraft().world.getGameRules();
	boolean isBooleanRule = false;
	if (gameRules.hasRule(rule)) {
		if (gameRules.areSameType(rule, GameRules.ValueType.BOOLEAN_VALUE)) {
			isBooleanRule = true;
		}
	}
	if (isBooleanRule) {
		SyntaxGamerule.this.value.setChild(valueCheckbox);
	} else {
		SyntaxGamerule.this.value.setChild((IGuiCommandSlot) valueTextField);
	}
}
 
开发者ID:Earthcomputer,项目名称:Easy-Editors,代码行数:27,代码来源:SyntaxGamerule.java

示例2: processCommand

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    GameRules gamerules = this.getGameRules();
    String s = args.length > 0 ? args[0] : "";
    String s1 = args.length > 1 ? buildString(args, 1) : "";

    switch (args.length)
    {
        case 0:
            sender.addChatMessage(new ChatComponentText(joinNiceString(gamerules.getRules())));
            break;

        case 1:
            if (!gamerules.hasRule(s))
            {
                throw new CommandException("commands.gamerule.norule", new Object[] {s});
            }

            String s2 = gamerules.getString(s);
            sender.addChatMessage((new ChatComponentText(s)).appendText(" = ").appendText(s2));
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, gamerules.getInt(s));
            break;

        default:
            if (gamerules.areSameType(s, GameRules.ValueType.BOOLEAN_VALUE) && !"true".equals(s1) && !"false".equals(s1))
            {
                throw new CommandException("commands.generic.boolean.invalid", new Object[] {s1});
            }

            gamerules.setOrCreateGameRule(s, s1);
            func_175773_a(gamerules, s);
            notifyOperators(sender, this, "commands.gamerule.success", new Object[0]);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:CommandGameRule.java

示例3: execute

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    GameRules gamerules = this.getOverWorldGameRules(server);
    String s = args.length > 0 ? args[0] : "";
    String s1 = args.length > 1 ? buildString(args, 1) : "";

    switch (args.length)
    {
        case 0:
            sender.addChatMessage(new TextComponentString(joinNiceString(gamerules.getRules())));
            break;

        case 1:
            if (!gamerules.hasRule(s))
            {
                throw new CommandException("commands.gamerule.norule", new Object[] {s});
            }

            String s2 = gamerules.getString(s);
            sender.addChatMessage((new TextComponentString(s)).appendText(" = ").appendText(s2));
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, gamerules.getInt(s));
            break;

        default:
            if (gamerules.areSameType(s, GameRules.ValueType.BOOLEAN_VALUE) && !"true".equals(s1) && !"false".equals(s1))
            {
                throw new CommandException("commands.generic.boolean.invalid", new Object[] {s1});
            }

            gamerules.setOrCreateGameRule(s, s1);
            notifyGameRuleChange(gamerules, s, server);
            notifyCommandListener(sender, this, "commands.gamerule.success", new Object[] {s, s1});
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:38,代码来源:CommandGameRule.java

示例4: execute

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    GameRules gamerules = this.getOverWorldGameRules(server);
    String s = args.length > 0 ? args[0] : "";
    String s1 = args.length > 1 ? buildString(args, 1) : "";

    switch (args.length)
    {
        case 0:
            sender.addChatMessage(new TextComponentString(joinNiceString(gamerules.getRules())));
            break;
        case 1:

            if (!gamerules.hasRule(s))
            {
                throw new CommandException("commands.gamerule.norule", new Object[] {s});
            }

            String s2 = gamerules.getString(s);
            sender.addChatMessage((new TextComponentString(s)).appendText(" = ").appendText(s2));
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, gamerules.getInt(s));
            break;
        default:

            if (gamerules.areSameType(s, GameRules.ValueType.BOOLEAN_VALUE) && !"true".equals(s1) && !"false".equals(s1))
            {
                throw new CommandException("commands.generic.boolean.invalid", new Object[] {s1});
            }

            gamerules.setOrCreateGameRule(s, s1);
            notifyGameRuleChange(gamerules, s, server);
            notifyCommandListener(sender, this, "commands.gamerule.success", new Object[] {s, s1});
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:38,代码来源:CommandGameRule.java

示例5: createGameruleIfAbsent

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
private boolean createGameruleIfAbsent(GameRules gameRule, String gameruleName, boolean value) {
    boolean added = false;
    if (!gameRule.hasRule(gameruleName)) {
        gameRule.addGameRule(gameruleName, Boolean.toString(value));
        added = true;
    }
    ProjectZuluLog.info("Gamerule %s is set to %s", gameruleName, gameRule.getGameRuleBooleanValue(gameruleName));
    return added;
}
 
开发者ID:soultek101,项目名称:projectzulu1.7.10-pre-1.3a,代码行数:10,代码来源:DeathGamerules.java

示例6: serverStarting

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
@Override
public void serverStarting(FMLServerStartingEvent event, File configDirectory) {
    /* Add Custom GameRules */
    GameRules gameRule = event.getServer().worldServerForDimension(0).getGameRules();
    /* Add Does Campfire Burn GameRule: Only if not Present */
    String ruleName = "doesCampfireBurn";
    if (!gameRule.hasRule(ruleName)) {
        gameRule.addGameRule(ruleName, "false");
    }
}
 
开发者ID:soultek101,项目名称:projectzulu1.7.10-pre-1.3a,代码行数:11,代码来源:ProjectZulu_Blocks.java

示例7: processCommand

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
    String var6;

    if (par2ArrayOfStr.length == 2)
    {
        var6 = par2ArrayOfStr[0];
        String var7 = par2ArrayOfStr[1];
        GameRules var8 = this.getGameRules();

        if (var8.hasRule(var6))
        {
            var8.setOrCreateGameRule(var6, var7);
            notifyAdmins(par1ICommandSender, "commands.gamerule.success", new Object[0]);
        }
        else
        {
            notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {var6});
        }
    }
    else if (par2ArrayOfStr.length == 1)
    {
        var6 = par2ArrayOfStr[0];
        GameRules var4 = this.getGameRules();

        if (var4.hasRule(var6))
        {
            String var5 = var4.getGameRuleStringValue(var6);
            par1ICommandSender.addChatMessage((new ChatComponentText(var6)).appendText(" = ").appendText(var5));
        }
        else
        {
            notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {var6});
        }
    }
    else if (par2ArrayOfStr.length == 0)
    {
        GameRules var3 = this.getGameRules();
        par1ICommandSender.addChatMessage(new ChatComponentText(joinNiceString(var3.getRules())));
    }
    else
    {
        throw new WrongUsageException("commands.gamerule.usage", new Object[0]);
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:46,代码来源:CommandGameRule.java

示例8: processCommand

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_)
{
    String s1;

    if (p_71515_2_.length == 2)
    {
        s1 = p_71515_2_[0];
        String s2 = p_71515_2_[1];
        GameRules gamerules2 = this.getGameRules();

        if (gamerules2.hasRule(s1))
        {
            gamerules2.setOrCreateGameRule(s1, s2);
            func_152373_a(p_71515_1_, this, "commands.gamerule.success", new Object[0]);
        }
        else
        {
            func_152373_a(p_71515_1_, this, "commands.gamerule.norule", new Object[] {s1});
        }
    }
    else if (p_71515_2_.length == 1)
    {
        s1 = p_71515_2_[0];
        GameRules gamerules1 = this.getGameRules();

        if (gamerules1.hasRule(s1))
        {
            String s = gamerules1.getGameRuleStringValue(s1);
            p_71515_1_.addChatMessage((new ChatComponentText(s1)).appendText(" = ").appendText(s));
        }
        else
        {
            func_152373_a(p_71515_1_, this, "commands.gamerule.norule", new Object[] {s1});
        }
    }
    else if (p_71515_2_.length == 0)
    {
        GameRules gamerules = this.getGameRules();
        p_71515_1_.addChatMessage(new ChatComponentText(joinNiceString(gamerules.getRules())));
    }
    else
    {
        throw new WrongUsageException("commands.gamerule.usage", new Object[0]);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:46,代码来源:CommandGameRule.java

示例9: processCommand

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
    String s;

    if (par2ArrayOfStr.length == 2)
    {
        s = par2ArrayOfStr[0];
        String s1 = par2ArrayOfStr[1];
        GameRules gamerules = this.getGameRules();

        if (gamerules.hasRule(s))
        {
            gamerules.setOrCreateGameRule(s, s1);
            notifyAdmins(par1ICommandSender, "commands.gamerule.success", new Object[0]);
        }
        else
        {
            notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {s});
        }
    }
    else if (par2ArrayOfStr.length == 1)
    {
        s = par2ArrayOfStr[0];
        GameRules gamerules1 = this.getGameRules();

        if (gamerules1.hasRule(s))
        {
            String s2 = gamerules1.getGameRuleStringValue(s);
            par1ICommandSender.sendChatToPlayer(ChatMessageComponent.createFromText(s).addText(" = ").addText(s2));
        }
        else
        {
            notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {s});
        }
    }
    else if (par2ArrayOfStr.length == 0)
    {
        GameRules gamerules2 = this.getGameRules();
        par1ICommandSender.sendChatToPlayer(ChatMessageComponent.createFromText(joinNiceString(gamerules2.getRules())));
    }
    else
    {
        throw new WrongUsageException("commands.gamerule.usage", new Object[0]);
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:46,代码来源:CommandGameRule.java

示例10: addRule

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
private void addRule(GameRules rules, String key, String val) {
	if (!rules.hasRule(key)) {
		rules.addGameRule(key, val);
	}
}
 
开发者ID:AlexDGr8r,项目名称:MeteorsMod,代码行数:6,代码来源:HandlerWorld.java

示例11: addRule

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
private static void addRule(GameRules rules, String name, String defaultValue) {
	if (!rules.hasRule(name)) rules.addGameRule(name, defaultValue, GameRules.ValueType.BOOLEAN_VALUE);
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:4,代码来源:GameRuleManager.java

示例12: initialize

import net.minecraft.world.GameRules; //导入方法依赖的package包/类
/**
 * Initializes the GameRule for a world.
 *
 * @param world The world to initialize for.
 */
public void initialize (World world) {

    final GameRules rules = world.getGameRules();

    if (!rules.hasRule(this.getId())) {

        rules.addGameRule(this.getId(), String.valueOf(this.getDefaultState()), ValueType.BOOLEAN_VALUE);
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:15,代码来源:GameRule.java


注:本文中的net.minecraft.world.GameRules.hasRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。