org.spongepowered.api.world.gamerule.GameRules Maven / Gradle / Ivy
Show all versions of spongeapi Show documentation
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.world.gamerule;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.block.entity.CommandBlock;
import org.spongepowered.api.entity.living.Agent;
import org.spongepowered.api.entity.living.Bat;
import org.spongepowered.api.entity.living.animal.Rabbit;
import org.spongepowered.api.entity.living.animal.Sheep;
import org.spongepowered.api.entity.living.golem.SnowGolem;
import org.spongepowered.api.entity.living.monster.Creeper;
import org.spongepowered.api.entity.living.monster.Enderman;
import org.spongepowered.api.entity.living.monster.Ghast;
import org.spongepowered.api.entity.living.monster.Patroller;
import org.spongepowered.api.entity.living.monster.Phantom;
import org.spongepowered.api.entity.living.monster.Silverfish;
import org.spongepowered.api.entity.living.monster.boss.Wither;
import org.spongepowered.api.entity.living.monster.boss.dragon.EnderDragon;
import org.spongepowered.api.entity.living.monster.skeleton.Skeleton;
import org.spongepowered.api.entity.living.monster.zombie.Zombie;
import org.spongepowered.api.entity.living.monster.zombie.ZombifiedPiglin;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
import org.spongepowered.api.entity.living.trader.Villager;
import org.spongepowered.api.entity.living.trader.WanderingTrader;
import org.spongepowered.api.entity.vehicle.Boat;
import org.spongepowered.api.entity.vehicle.minecart.MinecartLike;
import org.spongepowered.api.raid.Raid;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
import org.spongepowered.api.registry.RegistryTypes;
/**
* An enumeration of all the possible game rules in vanilla minecraft.
*/
@SuppressWarnings("unused")
@RegistryScopes(scopes = RegistryScope.GAME)
public final class GameRules {
// @formatter:off
// SORTFIELDS:ON
/**
* If advancements should be announced to the server.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> ANNOUNCE_ADVANCEMENTS = GameRules.key(ResourceKey.sponge("announce_advancements"));
/**
* Whether {@link CommandBlock}s should notify admins when
* they perform commands.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> COMMAND_BLOCK_OUTPUT = GameRules.key(ResourceKey.sponge("command_block_output"));
/**
* Whether the server should skip checking player speed when
* the player is wearing elytra.
*
* This is a boolean game rule, with a default value of
* {@code false}.
*/
public static final DefaultedRegistryReference> DISABLE_ELYTRA_MOVEMENT_CHECK = GameRules.key(ResourceKey.sponge("disable_elytra_movement_check"));
/**
* Whether {@link Raid}s are disabled.
*
* If the value of this game rule is {@code true}, all {@link Raid}s will stop.
*
*
This is a boolean game rule, with a default value of
* {@code false}.
*/
public static final DefaultedRegistryReference> DISABLE_RAIDS = GameRules.key(ResourceKey.sponge("disable_raids"));
/**
* Whether the day-night cycle and moon phases progress.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> DO_DAYLIGHT_CYCLE = GameRules.key(ResourceKey.sponge("do_daylight_cycle"));
/**
* Whether entities that are not mobs should have drops.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> DO_ENTITY_DROPS = GameRules.key(ResourceKey.sponge("do_entity_drops"));
/**
* Whether fire should spread and naturally extinguish.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> DO_FIRE_TICK = GameRules.key(ResourceKey.sponge("do_fire_tick"));
/**
* Whether {@link Phantom}s can spawn in the night-time.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> DO_INSOMNIA = GameRules.key(ResourceKey.sponge("do_insomnia"));
/**
* Whether {@link Player}s should respawn immediately without showing the death screen.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> DO_IMMEDIATE_RESPAWN = GameRules.key(ResourceKey.sponge("do_immediate_respawn"));
/**
* Whether {@link Player}s can only craft recipes they have unlocked.
*
* This is a boolean game rule, with a default value of
* {@code false}.
*/
public static final DefaultedRegistryReference> DO_LIMITED_CRAFTING = GameRules.key(ResourceKey.sponge("do_limited_crafting"));
/**
* Whether {@link Agent}s should drop items.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> DO_MOB_LOOT = GameRules.key(ResourceKey.sponge("do_mob_loot"));
/**
* Whether {@link Agent}s should naturally spawn.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> DO_MOB_SPAWNING = GameRules.key(ResourceKey.sponge("do_mob_spawning"));
/**
* Whether {@link Patroller patrollers} will go out on patrol (typically in a {@link Raid}.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> DO_PATROL_SPAWNING = GameRules.key(ResourceKey.sponge("do_patrol_spawning"));
/**
* Whether blocks should have drops.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> DO_TILE_DROPS = GameRules.key(ResourceKey.sponge("do_tile_drops"));
/**
* Whether {@link WanderingTrader traders} will naturally spawn.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> DO_TRADER_SPAWNING = GameRules.key(ResourceKey.sponge("do_trader_spawning"));
/**
* Whether the weather will change.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> DO_WEATHER_CYCLE = GameRules.key(ResourceKey.sponge("do_weather_cycle"));
/**
* Whether entities should take drowning damage.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> DROWNING_DAMAGE = GameRules.key(ResourceKey.sponge("drowning_damage"));
/**
* Whether entities should take fall damage.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> FALL_DAMAGE = GameRules.key(ResourceKey.sponge("fall_damage"));
/**
* Whether entities should take fire damage.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> FIRE_DAMAGE = GameRules.key(ResourceKey.sponge("fire_damage"));
/**
* Makes angered neutral mobs stop being angry when the targeted player dies nearby.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> FORGIVE_DEAD_PLAYERS = GameRules.key(ResourceKey.sponge("forgive_dead_players"));
/**
* Whether entities should take freeze damage.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> FREEZE_DAMAGE = GameRules.key(ResourceKey.sponge("freeze_damage"));
/**
* Whether {@link Player}s should keep items in their inventory
* after death.
*
* This is a boolean game rule, with a default value of
* {@code false}.
*/
public static final DefaultedRegistryReference> KEEP_INVENTORY = GameRules.key(ResourceKey.sponge("keep_inventory"));
/**
* Whether to log admin commands to server log.
*
* This is a boolean game rule, with a default value of
* {@code true}.
*/
public static final DefaultedRegistryReference> LOG_ADMIN_COMMANDS = GameRules.key(ResourceKey.sponge("log_admin_commands"));
/**
* The total number of {@link BlockTypes#CHAIN_COMMAND_BLOCK chain command
* blocks} that can run during a single tick.
*
* This is a numerical game rule, with a default value
* of {@code 65536}.
*/
public static final DefaultedRegistryReference> MAX_COMMAND_CHAIN_LENGTH = GameRules.key(ResourceKey.sponge("max_command_chain_length"));
/**
* The maximum number of other pushable entities a mob or player can push,
* before taking 3 suffocation damage per half-second.
*
* Damage affects {@link GameModes#SURVIVAL survival mode} or
* {@link GameModes#ADVENTURE adventure mode} {@link Player}s, and all
* mobs but bats. Pushable entities include non-spectator-mode
* {@link Player}, any mob except {@link Bat}s, as well as
* {@link Boat}s and {@link MinecartLike}.
*
* Setting to {@code 0} disables the rule.
*
* This is a numerical game rule, with a default value of {@code 24}.
*/
public static final DefaultedRegistryReference> MAX_ENTITY_CRAMMING = GameRules.key(ResourceKey.sponge("max_entity_cramming"));
/**
* Whether {@link Agent}s should be able to change blocks, and whether
* {@link Agent}s can pick up items.
*
* In vanilla Minecraft, the following entities can change blocks when
* this game rule is {@code true}:
*
* - {@link Creeper}
* - {@link Zombie}
* - {@link Enderman}
* - {@link Ghast}
* - {@link Wither}
* - {@link EnderDragon}
* - {@link Rabbit}
* - {@link Sheep}
* - {@link Villager}
* - {@link SnowGolem}
* - {@link Silverfish}
*
*
* In vanilla Minecraft, the following entities can pick up items when
* this game rule is {@code true}:
*
* - {@link Villager}
* - {@link Zombie}
* - {@link Skeleton}
* - {@link ZombifiedPiglin}
*
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> MOB_GRIEFING = GameRules.key(ResourceKey.sponge("mob_griefing"));
/**
* Whether {@link Player}s can regenerate health naturally if their
* hunger is full enough (doesn't affect external healing, such as
* golden apples, the Regeneration effect, etc.).
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> NATURAL_REGENERATION = GameRules.key(ResourceKey.sponge("natural_regeneration"));
/**
* What percentage of players must sleep to skip the night.
*
* This is a numerical game rule, with a default value of {@code 100}.
*/
public static final DefaultedRegistryReference> PLAYERS_SLEEPING_PERCENTAGE = GameRules.key(ResourceKey.sponge("players_sleeping_percentage"));
/**
* How often a random block tick occurs (such as plant growth,
* leaf decay, etc.) per chunk section per game tick.
*
* 0 will disable random ticks, higher numbers will increase random
* ticks
*
* This is a numerical game rule, with a default value of {@code 3}.
*/
public static final DefaultedRegistryReference> RANDOM_TICK_SPEED = GameRules.key(ResourceKey.sponge("random_tick_speed"));
/**
* Whether the debug screen shows all or reduced information.
*
* This is a boolean game rule, with a default value of
* {@code false}.
*/
public static final DefaultedRegistryReference> REDUCED_DEBUG_INFO = GameRules.key(ResourceKey.sponge("reduced_debug_info"));
/**
* Whether the feedback from commands executed by a {@link Player}
* should show up in chat.
*
* This game rule affects the default behavior of whether
* {@link CommandBlock}s store their output text.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> SEND_COMMAND_FEEDBACK = GameRules.key(ResourceKey.sponge("send_command_feedback"));
/**
* Whether a message appears in chat when a {@link Player} dies.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> SHOW_DEATH_MESSAGES = GameRules.key(ResourceKey.sponge("show_death_messages"));
/**
* The number of blocks outward from the world spawn coordinates
* that a player will spawn in when first joining a server or when
* dying without a spawn point.
*
* This is a numerical game rule, with a default value of {@code 10}.
*/
public static final DefaultedRegistryReference> SPAWN_RADIUS = GameRules.key(ResourceKey.sponge("spawn_radius"));
/**
* Whether players in {@link GameModes#SPECTATOR spectator mode} can
* generate chunks.
*
* This is a boolean game rule, with a default value of {@code true}.
*/
public static final DefaultedRegistryReference> SPECTATORS_GENERATE_CHUNKS = GameRules.key(ResourceKey.sponge("spectators_generate_chunks"));
/**
* Makes angered neutral mobs attack any nearby player, not just the player that angered them.
*
* This is a boolean game rule, with a default value of
* {@code false}.
*/
public static final DefaultedRegistryReference> UNIVERSAL_ANGER = GameRules.key(ResourceKey.sponge("universal_anger"));
// SORTFIELDS:OFF
// @formatter:on
private GameRules() {
}
public static Registry> registry() {
return Sponge.game().registry(RegistryTypes.GAME_RULE);
}
private static DefaultedRegistryReference> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.GAME_RULE, location).asDefaultedReference(Sponge::game);
}
}