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

项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent
public void loadWorld(WorldEvent.Load event) {
    /*if (!event.getWorld().isRemote && event.getWorld().getPerWorldStorage().getOrLoadData(TF2WorldStorage.class, TF2weapons.MOD_ID)==null){
        event.getWorld().getPerWorldStorage().setData(TF2weapons.MOD_ID, new TF2WorldStorage());
        dummyEnt = new EntityCreeper(null);
    }*/
    TF2weapons.dummyEnt = new EntityCreeper(event.getWorld());
    if(!event.getWorld().getGameRules().hasRule("doTF2AI"))
        event.getWorld().getGameRules().addGameRule("doTF2AI", "true", ValueType.BOOLEAN_VALUE);
    if (!event.getWorld().isRemote && event.getWorld().getScoreboard().getTeam("RED") == null) {
        ScorePlayerTeam teamRed = event.getWorld().getScoreboard().createTeam("RED");
        ScorePlayerTeam teamBlu = event.getWorld().getScoreboard().createTeam("BLU");

        teamRed.setSeeFriendlyInvisiblesEnabled(true);
        teamRed.setAllowFriendlyFire(false);
        teamBlu.setSeeFriendlyInvisiblesEnabled(true);
        teamBlu.setAllowFriendlyFire(false);
        teamRed.setPrefix(TextFormatting.RED.toString());
        teamBlu.setPrefix(TextFormatting.BLUE.toString());
        teamRed.setColor(TextFormatting.RED);
        teamBlu.setColor(TextFormatting.BLUE);
        event.getWorld().getScoreboard().broadcastTeamInfoUpdate(teamRed);
        event.getWorld().getScoreboard().broadcastTeamInfoUpdate(teamBlu);

    }
    if (!event.getWorld().isRemote && event.getWorld().getScoreboard().getTeam("TF2Bosses") == null) {
        ScorePlayerTeam teamBosses = event.getWorld().getScoreboard().createTeam("TF2Bosses");
        teamBosses.setSeeFriendlyInvisiblesEnabled(true);
        teamBosses.setAllowFriendlyFire(false);
        teamBosses.setPrefix(TextFormatting.DARK_PURPLE.toString());
        teamBosses.setColor(TextFormatting.DARK_PURPLE);
        event.getWorld().getScoreboard().broadcastTeamInfoUpdate(teamBosses);
    }
    if (!event.getWorld().isRemote && event.getWorld().getScoreboard().getTeam("RED").getColor() == TextFormatting.RESET) {
        event.getWorld().getScoreboard().getTeam("RED").setColor(TextFormatting.RED);
        event.getWorld().getScoreboard().getTeam("BLU").setColor(TextFormatting.BLUE);
    }
}
项目:Alagaesias-Ancient-Language    文件:GameRule.java   
/**
 * Processes the value, correcting the value if incorrect, adding it if it
 * doesn't exist, other corrections according to {@link #rules}
 */
private void processValue() {
    if (this.value == null)
        this.value = "";
    if (this.type == null)
        this.type = ValueType.ANY_VALUE;
    if (rules != null && !this.doesRuleExist())
        rules.addGameRule(this.name, this.value, this.type);
    this.value = rules == null ? "" : rules
            .getGameRuleStringValue(this.name);
}
项目:Alagaesias-Ancient-Language    文件:GameRule.java   
/**
 * Processes the type, performing corrections according to {@link #rules}
 */
private void processType() {
    if (rules == null)
        this.type = ValueType.ANY_VALUE;
    else
        for (ValueType t : ValueType.values()) {
            if (rules.areSameType(this.name, t))
                this.type = t;
        }
}
项目:Alagaesias-Ancient-Language    文件:GameRule.java   
/**
 * Sets the type for the game rule
 */
public void setType(ValueType type) {
    if (rules == null)
        return;
    this.type = type;
    rules.addGameRule(this.name, this.value, this.type);
}
项目:Alagaesias-Ancient-Language    文件:GameRule.java   
public GameRule(String name, String defValue) {
    this(name, defValue, ValueType.ANY_VALUE);
}
项目:Alagaesias-Ancient-Language    文件:GameRule.java   
/**
 * Returns the {@link ValueType} of the game rule
 */
public ValueType getType() {
    return this.type;
}
项目:Alagaesias-Ancient-Language    文件:GameRule.java   
/**
 * Defines a game rule (if it doesn't already exist)
 * 
 * @param name
 *            The name of the game rule
 * @param defValue
 *            The default value of the game rule (if value does not exist)
 * @param defType
 *            The default type of the game rule (if value's type does not
 *            exist)
 */
public GameRule(String name, String defValue, ValueType defType) {
    this.name = name;
    this.value = defValue;
    this.type = defType;
    this.processValue();
    this.processType();
    gameRulesList.add(this);
}
项目:Bookshelf    文件:GameRule.java   
/**
 * 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);
    }
}