Java 类net.minecraft.world.GameRules 实例源码

项目:DecompiledMinecraft    文件:CommandGameRule.java   
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, this.getGameRules().getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getGameRules();

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return null;
    }
}
项目:DecompiledMinecraft    文件:CommandGameRule.java   
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, this.getGameRules().getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getGameRules();

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return null;
    }
}
项目:BaseClient    文件:CommandGameRule.java   
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, this.getGameRules().getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getGameRules();

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return null;
    }
}
项目:BaseClient    文件:CommandGameRule.java   
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, this.getGameRules().getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getGameRules();

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return null;
    }
}
项目:Backmemed    文件:CommandGameRule.java   
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, this.getOverWorldGameRules(server).getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getOverWorldGameRules(server);

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return Collections.<String>emptyList();
    }
}
项目:Dimension-Rules    文件:RuleHandler.java   
public static GameRules getGameRuleInstance(DerivedWorldInfo worldInfo)
{
    World worldObj = null;

    for (World world : DimensionManager.getWorlds())
    {
        if (world.getWorldInfo() == worldInfo)
        {
            worldObj = world;
            break;
        }
    }

    if (worldObj != null)
    {
        return getGameRuleInstance(worldObj);
    }

    return null;
}
项目:TFICore    文件:EventRainOverride.java   
@SubscribeEvent(priority = EventPriority.NORMAL)
public void rainOverrideGR (TickEvent.ServerTickEvent event) {
    WorldInfo worldinfo = GameInfo.worldInfo;
    GameRules gameRules = GameInfo.gameRules;

    try {
        if (!gameRules.getBoolean("doWeather")) {
            gameRules.setOrCreateGameRule("doWeather", "true");
            gameRules.setOrCreateGameRule("doWeatherCycle", "false");
            LogHelper.info("Switched weather GameRule over to Vanilla GameRule.");
        }
    }
    catch (Exception e) {
        LogHelper.error("Exception in RainOverride: " + e);
    }
}
项目:TaleCraft    文件:TCWorldManager.java   
public void tickWorld(WorldTickEvent event) {
    if(!(event.world instanceof WorldServer))
        return;

    // System.out.println("TICKING WORLD -> @" + event.world);
    // TaleCraft.proxy.tick(event);

    GameRules rules = event.world.getGameRules();
    //TODO: Fix this
    if(rules.getBoolean("tc_disableWeather")) {
        // Clear the weather for 5 seconds.
        event.world.getWorldInfo().setCleanWeatherTime(20*5);
    }
    NBTTagCompound current = rules.writeToNBT();
    if(!current.equals(gamerules)){
        gamerules = current;
        TaleCraft.network.sendToAll(new GameruleSyncPacket(current));
    }
}
项目:GlobalGameRules    文件:WorldEvents.java   
@SubscribeEvent
public static void onWorldLoad(WorldEvent.Load event) {
    World world = event.getWorld();
    WorldInfo info = world.getWorldInfo();
    GameRules gRules = world.getGameRules();

    Reference.logger.info("Applying config gamerules to dimension {} ({})", world.provider.getDimension(), info.getWorldName());
    GlobalGR.getConfig().rules.forEach((s, value) -> gRules.setOrCreateGameRule(s, value.getStringValue()));

    if (!event.getWorld().isRemote && !info.isDifficultyLocked()) {
        int diff = GlobalGR.getConfig().misc.get(GGRConfig.MISC_WORLDDIFFICULTY).getIntegerValue();
        if (diff != -1) {
            info.setDifficulty(EnumDifficulty.getDifficultyEnum(diff));
            Reference.logger.info("Setting difficulty of dimension {} ({}) to {}", world.provider.getDimension(), info.getWorldName(),
                    EnumDifficulty.getDifficultyEnum(diff).toString());
        }

        if (GlobalGR.getConfig().misc.get(GGRConfig.MISC_WORLDDIFFICULTYLOCK).getBooleanValue()) {
            info.setDifficultyLocked(true);
            Reference.logger.info("Locking difficulty of dimension {} ({})", world.provider.getDimension(), info.getWorldName());
        }
    }
}
项目:GlobalGameRules    文件:WorldEvents.java   
@SubscribeEvent
public static void onWorldUnLoad(WorldEvent.Unload event) {
    World world = event.getWorld();
    WorldInfo info = world.getWorldInfo();
    GameRules gRules = event.getWorld().getGameRules();

    if (GlobalGR.getConfig().misc.get(GGRConfig.MISC_SAVEGAMRULES).getBooleanValue()) {
        Reference.logger.info("Saving gamerules of dimension {} ({}) to config", world.provider.getDimension(), info.getWorldName());
        Arrays.stream(gRules.getRules()).forEach(s -> GlobalGR.getConfig().rules.put(s, new GGRConfig.Value(gRules.getString(s), getType(gRules, s))));


        if (!event.getWorld().isRemote && GlobalGR.getConfig().misc.get(GGRConfig.MISC_WORLDDIFFICULTY).getIntegerValue() != -1 && !event.getWorld().getWorldInfo().isDifficultyLocked()) {
            GGRConfig.Value val = GlobalGR.getConfig().misc.get(GGRConfig.MISC_WORLDDIFFICULTY);
            GGRConfig.Value newVal = new GGRConfig.Value(String.valueOf(info.getDifficulty().getDifficultyId()), val.getType(), val.getShowInGui());
            GlobalGR.getConfig().misc.put(GGRConfig.MISC_WORLDDIFFICULTY, newVal);
        }
    }

    if (!GlobalGR.getConfig().misc.get(GGRConfig.MISC_SAVEGAMRULES).getBooleanValue()) {
        Arrays.stream(gRules.getRules()).filter(s -> !GlobalGR.getConfig().rules.containsKey(s)).forEach(s -> GlobalGR.getConfig().rules.put(s, new GGRConfig.Value(gRules.getString(s), getType(gRules, s))));
    }

    GlobalGR.getConfig().saveConfig();
}
项目:Easy-Editors    文件:SyntaxGamerule.java   
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);
    }
}
项目:HardModeTweaks    文件:ProxyModHardModeTweaksGameRules.java   
@Override
public CategoryConfigManagerBuilder getConfig() {
    CategoryConfigManagerBuilder cfg =
            new CategoryConfigManagerBuilder("GameRules").addValue("enableGameRules", "true",
                    Type.BOOLEAN, "Enable changing the game rules.", property -> {
                        if (property.getBoolean()) {
                            if (rulesManager == null) {
                                rulesManager = new GameRulesManager();
                                MinecraftForge.EVENT_BUS.register(rulesManager);
                            }
                        } else {
                            if (rulesManager != null) {
                                MinecraftForge.EVENT_BUS.unregister(rulesManager);
                                rulesManager = null;
                            }
                        }
                    });
    GameRules rules = new GameRules();
    for (String ruleName : rules.getRules()) {
        cfg = cfg.addValue(ruleName, rules.getString(ruleName), Type.STRING, "", property -> {
            GameRulesManager.gameRules.put(property.getName(), property.getString());
        }, false, true);
    }
    return cfg;
}
项目:projectzulu1.7.10    文件:DeathGamerules.java   
@SubscribeEvent
public void worldLoad(WorldEvent.Load event) {
    GameRules gameRule = event.world.getGameRules();

   // if (createGameruleIfAbsent(gameRule, "pzKeepInventory", keepInventoryDefault)) {
   //   System.out.println("******** pzKeepInventory rule is not present, creating it.....");
   //   
   //     gameRule.setOrCreateGameRule("keepInventory", Boolean.toString(keepInventoryDefault));
  //  }

    //createGameruleIfAbsent(gameRule, "dropInventory", dropInventoryDefault);
    //createGameruleIfAbsent(gameRule, "dropHotbar", dropHotbarDefault);
    //createGameruleIfAbsent(gameRule, "dropArmor", dropArmorDefault);
    //createGameruleIfAbsent(gameRule, "dropXP", dropXPDefault);
    gameRule.setOrCreateGameRule("keepInventory", Boolean.toString(keepInventoryDefault));
    gameRule.setOrCreateGameRule("dropInventory", String.valueOf(dropInventoryDefault));
    gameRule.setOrCreateGameRule("dropHotbar", String.valueOf(dropHotbarDefault));
    gameRule.setOrCreateGameRule("dropArmor", String.valueOf(dropArmorDefault));
    gameRule.setOrCreateGameRule("dropXP", String.valueOf(dropXPDefault));
}
项目:DecompiledMinecraft    文件:CommandGameRule.java   
/**
 * 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]);
    }
}
项目:DecompiledMinecraft    文件:CommandGameRule.java   
public static void func_175773_a(GameRules p_175773_0_, String p_175773_1_)
{
    if ("reducedDebugInfo".equals(p_175773_1_))
    {
        byte b0 = (byte)(p_175773_0_.getBoolean(p_175773_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
        {
            entityplayermp.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:DecompiledMinecraft    文件:CommandGameRule.java   
/**
 * 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]);
    }
}
项目:DecompiledMinecraft    文件:CommandGameRule.java   
public static void func_175773_a(GameRules p_175773_0_, String p_175773_1_)
{
    if ("reducedDebugInfo".equals(p_175773_1_))
    {
        byte b0 = (byte)(p_175773_0_.getBoolean(p_175773_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
        {
            entityplayermp.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:BaseClient    文件:CommandGameRule.java   
/**
 * 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]);
    }
}
项目:BaseClient    文件:CommandGameRule.java   
public static void func_175773_a(GameRules p_175773_0_, String p_175773_1_)
{
    if ("reducedDebugInfo".equals(p_175773_1_))
    {
        byte b0 = (byte)(p_175773_0_.getBoolean(p_175773_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
        {
            entityplayermp.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:BaseClient    文件:CommandGameRule.java   
/**
 * 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]);
    }
}
项目:BaseClient    文件:CommandGameRule.java   
public static void func_175773_a(GameRules p_175773_0_, String p_175773_1_)
{
    if ("reducedDebugInfo".equals(p_175773_1_))
    {
        byte b0 = (byte)(p_175773_0_.getBoolean(p_175773_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
        {
            entityplayermp.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:UniversalRemote    文件:WorldServerProxy.java   
@Override
public GameRules getGameRules() {
    if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
        return m_proxyWorld.getGameRules();
    } else if (m_realWorld != null) {
        return m_realWorld.getGameRules();
    } else {
        return super.getGameRules();
    }
}
项目:Backmemed    文件:CommandGameRule.java   
/**
 * 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});
    }
}
项目:Backmemed    文件:CommandGameRule.java   
public static void notifyGameRuleChange(GameRules rules, String p_184898_1_, MinecraftServer server)
{
    if ("reducedDebugInfo".equals(p_184898_1_))
    {
        byte b0 = (byte)(rules.getBoolean(p_184898_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : server.getPlayerList().getPlayerList())
        {
            entityplayermp.connection.sendPacket(new SPacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:CustomWorldGen    文件:CommandGameRule.java   
/**
 * 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});
    }
}
项目:CustomWorldGen    文件:CommandGameRule.java   
public static void notifyGameRuleChange(GameRules rules, String p_184898_1_, MinecraftServer server)
{
    if ("reducedDebugInfo".equals(p_184898_1_))
    {
        byte b0 = (byte)(rules.getBoolean(p_184898_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : server.getPlayerList().getPlayerList())
        {
            entityplayermp.connection.sendPacket(new SPacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:CustomWorldGen    文件:CommandGameRule.java   
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    if (args.length == 1)
    {
        /**
         * Returns a List of strings (chosen from the given strings) which the last word in the given string array
         * is a beginning-match for. (Tab completion).
         */
        return getListOfStringsMatchingLastWord(args, this.getOverWorldGameRules(server).getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getOverWorldGameRules(server);

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                /**
                 * Returns a List of strings (chosen from the given strings) which the last word in the given string
                 * array is a beginning-match for. (Tab completion).
                 */
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return Collections.<String>emptyList();
    }
}
项目:Dimension-Rules    文件:CommandGameRuleD.java   
public static void func_175773_a(GameRules p_175773_0_, String p_175773_1_)
{
    if ("reducedDebugInfo".equals(p_175773_1_))
    {
        byte b0 = (byte) (p_175773_0_.getBoolean(p_175773_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers())
        {
            entityplayermp.connection.sendPacket(new SPacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:Dimension-Rules    文件:RuleHandler.java   
public static GameRules getGameRuleInstance(World worldObj)
{
    RuleData ruleData = RuleData.getFromWorld(worldObj);
    if (ruleData != null)
    {
        return ruleData.getGameRules();
    }

    return null;
}
项目:justenoughdimensions    文件:CommandJEDGameRule.java   
static void notifyGameRuleChange(GameRules rules, String key, World world)
{
    if (key.equals("reducedDebugInfo"))
    {
        byte opCode = (byte)(rules.getBoolean(key) ? 22 : 23);

        for (EntityPlayerMP player : world.getPlayers(EntityPlayerMP.class, Predicates.alwaysTrue()))
        {
            player.connection.sendPacket(new SPacketEntityStatus(player, opCode));
        }
    }
}
项目:TaleCraft    文件:TaleCraftGameRules.java   
public static void registerGameRules(GameRules rules){
    rules.addGameRule("tc_playDefaultMusic", "true", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disableInvokeSystem", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_visualEventDebugging", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disableTeleporter", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disableWeather", "false", GameRules.ValueType.BOOLEAN_VALUE);

    rules.addGameRule("tc_disable.damage.*", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disable.damage.fall", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disable.damage.drown", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disable.damage.lava", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disable.damage.magic", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disable.damage.fire", "false", GameRules.ValueType.BOOLEAN_VALUE);
    rules.addGameRule("tc_disable.damage.suffocate", "false", GameRules.ValueType.BOOLEAN_VALUE);
}
项目:TaleCraft    文件:ClientProxy.java   
@Override
public void postInit(FMLPostInitializationEvent event) {
    super.postInit(event);

    // Create the InfoBar Instance
    infoBarInstance = new InfoBar();

    // Create the invoke tracker instance
    invokeTracker = new InvokeTracker();

    ItemMetaWorldRenderer.ITEM_RENDERS.put(TaleCraftItems.paste, new PasteItemRender());
    ItemMetaWorldRenderer.ITEM_RENDERS.put(TaleCraftItems.custompainting, new CustomPaintingRender());

    gamerules = new GameRules();
}
项目:GlobalGameRules    文件:WorldEvents.java   
public static GGRConfig.ValueType getType(GameRules rules, String s) {
    if (rules.areSameType(s, GameRules.ValueType.BOOLEAN_VALUE))
        return GGRConfig.ValueType.BOOLEAN;
    else if (rules.areSameType(s, GameRules.ValueType.NUMERICAL_VALUE))
        return GGRConfig.ValueType.INTEGER;
    else
        return GGRConfig.ValueType.STRING;
}
项目:DynamicLib    文件:GameRuleManager.java   
@SubscribeEvent
public void onWorldLoad(final WorldEvent.Load event) {
    modRules.forEach(new BiConsumer<String, String>() {
        @Override
        public void accept(String name, String defaultValue) {
            final GameRules rules = event.world.getGameRules();
            if (!rules.hasRule(name))
                rules.addGameRule(name, defaultValue);
        }
    });
}
项目:Resilience-Client-Source    文件:WorldInfo.java   
public WorldInfo(WorldSettings par1WorldSettings, String par2Str)
{
    this.terrainType = WorldType.DEFAULT;
    this.generatorOptions = "";
    this.theGameRules = new GameRules();
    this.randomSeed = par1WorldSettings.getSeed();
    this.theGameType = par1WorldSettings.getGameType();
    this.mapFeaturesEnabled = par1WorldSettings.isMapFeaturesEnabled();
    this.levelName = par2Str;
    this.hardcore = par1WorldSettings.getHardcoreEnabled();
    this.terrainType = par1WorldSettings.getTerrainType();
    this.generatorOptions = par1WorldSettings.func_82749_j();
    this.allowCommands = par1WorldSettings.areCommandsAllowed();
    this.initialized = false;
}
项目:Resilience-Client-Source    文件:WorldInfo.java   
public WorldInfo(WorldInfo par1WorldInfo)
{
    this.terrainType = WorldType.DEFAULT;
    this.generatorOptions = "";
    this.theGameRules = new GameRules();
    this.randomSeed = par1WorldInfo.randomSeed;
    this.terrainType = par1WorldInfo.terrainType;
    this.generatorOptions = par1WorldInfo.generatorOptions;
    this.theGameType = par1WorldInfo.theGameType;
    this.mapFeaturesEnabled = par1WorldInfo.mapFeaturesEnabled;
    this.spawnX = par1WorldInfo.spawnX;
    this.spawnY = par1WorldInfo.spawnY;
    this.spawnZ = par1WorldInfo.spawnZ;
    this.totalTime = par1WorldInfo.totalTime;
    this.worldTime = par1WorldInfo.worldTime;
    this.lastTimePlayed = par1WorldInfo.lastTimePlayed;
    this.sizeOnDisk = par1WorldInfo.sizeOnDisk;
    this.playerTag = par1WorldInfo.playerTag;
    this.dimension = par1WorldInfo.dimension;
    this.levelName = par1WorldInfo.levelName;
    this.saveVersion = par1WorldInfo.saveVersion;
    this.rainTime = par1WorldInfo.rainTime;
    this.raining = par1WorldInfo.raining;
    this.thunderTime = par1WorldInfo.thunderTime;
    this.thundering = par1WorldInfo.thundering;
    this.hardcore = par1WorldInfo.hardcore;
    this.allowCommands = par1WorldInfo.allowCommands;
    this.initialized = par1WorldInfo.initialized;
    this.theGameRules = par1WorldInfo.theGameRules;
}
项目:Gadomancy    文件:EventHandlerWorld.java   
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(WorldEvent.Load e) {
    if (!e.world.isRemote && e.world.provider.dimensionId == 0) {
        Gadomancy.loadModData();

        GolemEnumHelper.validateSavedMapping();
        GolemEnumHelper.reorderEnum();

        TCMazeHandler.init();
    }

    GameRules rules = e.world.getGameRules();
    rules.theGameRules.put("mobGriefing", new ValueOverride(this, String.valueOf(rules.getGameRuleBooleanValue("mobGriefing"))));
}
项目:ExpandedRailsMod    文件:CommandGameRule.java   
/**
 * 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});
    }
}
项目:ExpandedRailsMod    文件:CommandGameRule.java   
public static void notifyGameRuleChange(GameRules rules, String p_184898_1_, MinecraftServer server)
{
    if ("reducedDebugInfo".equals(p_184898_1_))
    {
        byte b0 = (byte)(rules.getBoolean(p_184898_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : server.getPlayerList().getPlayerList())
        {
            entityplayermp.connection.sendPacket(new SPacketEntityStatus(entityplayermp, b0));
        }
    }
}
项目:ExpandedRailsMod    文件:CommandGameRule.java   
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    if (args.length == 1)
    {
        /**
         * Returns a List of strings (chosen from the given strings) which the last word in the given string array
         * is a beginning-match for. (Tab completion).
         */
        return getListOfStringsMatchingLastWord(args, this.getOverWorldGameRules(server).getRules());
    }
    else
    {
        if (args.length == 2)
        {
            GameRules gamerules = this.getOverWorldGameRules(server);

            if (gamerules.areSameType(args[0], GameRules.ValueType.BOOLEAN_VALUE))
            {
                /**
                 * Returns a List of strings (chosen from the given strings) which the last word in the given string
                 * array is a beginning-match for. (Tab completion).
                 */
                return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
            }
        }

        return Collections.<String>emptyList();
    }
}