mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-09-18 21:45:12 +00:00
Merge branch 'master' into enums-to-registers
This commit is contained in:
commit
b6bfcff501
8 changed files with 355 additions and 45 deletions
|
@ -253,4 +253,40 @@ public interface Chunk extends PersistentDataHolder {
|
|||
* @return if the biome is contained within
|
||||
*/
|
||||
boolean contains(@NotNull Biome biome);
|
||||
|
||||
/**
|
||||
* Gets the load level of this chunk, which determines what game logic is
|
||||
* processed.
|
||||
*
|
||||
* @return the load level
|
||||
*/
|
||||
@NotNull
|
||||
LoadLevel getLoadLevel();
|
||||
|
||||
/**
|
||||
* An enum to specify the load level of a chunk.
|
||||
*/
|
||||
public enum LoadLevel {
|
||||
|
||||
/**
|
||||
* No game logic is processed, world generation may still occur.
|
||||
*/
|
||||
INACCESSIBLE,
|
||||
/**
|
||||
* Most game logic is not processed, including entities and redstone.
|
||||
*/
|
||||
BORDER,
|
||||
/**
|
||||
* All game logic except entities is processed.
|
||||
*/
|
||||
TICKING,
|
||||
/**
|
||||
* All game logic is processed.
|
||||
*/
|
||||
ENTITY_TICKING,
|
||||
/**
|
||||
* This chunk is not loaded.
|
||||
*/
|
||||
UNLOADED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,4 +348,49 @@ public interface RegionAccessor {
|
|||
*/
|
||||
@NotNull
|
||||
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<T> function) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) coordinate at the given
|
||||
* coordinates.
|
||||
*
|
||||
* @param x X-coordinate of the blocks
|
||||
* @param z Z-coordinate of the blocks
|
||||
* @return Y-coordinate of the highest non-empty block
|
||||
*/
|
||||
public int getHighestBlockYAt(int x, int z);
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) coordinate at the given
|
||||
* {@link Location}.
|
||||
*
|
||||
* @param location Location of the blocks
|
||||
* @return Y-coordinate of the highest non-empty block
|
||||
*/
|
||||
public int getHighestBlockYAt(@NotNull Location location);
|
||||
|
||||
/**
|
||||
* Gets the highest coordinate corresponding to the {@link HeightMap} at the
|
||||
* given coordinates.
|
||||
*
|
||||
* @param x X-coordinate of the blocks
|
||||
* @param z Z-coordinate of the blocks
|
||||
* @param heightMap the heightMap that is used to determine the highest
|
||||
* point
|
||||
*
|
||||
* @return Y-coordinate of the highest block corresponding to the
|
||||
* {@link HeightMap}
|
||||
*/
|
||||
public int getHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap);
|
||||
|
||||
/**
|
||||
* Gets the highest coordinate corresponding to the {@link HeightMap} at the
|
||||
* given {@link Location}.
|
||||
*
|
||||
* @param location Location of the blocks
|
||||
* @param heightMap the heightMap that is used to determine the highest
|
||||
* point
|
||||
* @return Y-coordinate of the highest block corresponding to the
|
||||
* {@link HeightMap}
|
||||
*/
|
||||
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap);
|
||||
}
|
||||
|
|
|
@ -65,25 +65,6 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
|||
@NotNull
|
||||
public Block getBlockAt(@NotNull Location location);
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) coordinate at the given
|
||||
* coordinates.
|
||||
*
|
||||
* @param x X-coordinate of the blocks
|
||||
* @param z Z-coordinate of the blocks
|
||||
* @return Y-coordinate of the highest non-empty block
|
||||
*/
|
||||
public int getHighestBlockYAt(int x, int z);
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) coordinate at the given
|
||||
* {@link Location}.
|
||||
*
|
||||
* @param location Location of the blocks
|
||||
* @return Y-coordinate of the highest non-empty block
|
||||
*/
|
||||
public int getHighestBlockYAt(@NotNull Location location);
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) block at the given coordinates.
|
||||
*
|
||||
|
@ -103,32 +84,6 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
|||
@NotNull
|
||||
public Block getHighestBlockAt(@NotNull Location location);
|
||||
|
||||
/**
|
||||
* Gets the highest coordinate corresponding to the {@link HeightMap} at the
|
||||
* given coordinates.
|
||||
*
|
||||
* @param x X-coordinate of the blocks
|
||||
* @param z Z-coordinate of the blocks
|
||||
* @param heightMap the heightMap that is used to determine the highest
|
||||
* point
|
||||
*
|
||||
* @return Y-coordinate of the highest block corresponding to the
|
||||
* {@link HeightMap}
|
||||
*/
|
||||
public int getHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap);
|
||||
|
||||
/**
|
||||
* Gets the highest coordinate corresponding to the {@link HeightMap} at the
|
||||
* given {@link Location}.
|
||||
*
|
||||
* @param location Location of the blocks
|
||||
* @param heightMap the heightMap that is used to determine the highest
|
||||
* point
|
||||
* @return Y-coordinate of the highest block corresponding to the
|
||||
* {@link HeightMap}
|
||||
*/
|
||||
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap);
|
||||
|
||||
/**
|
||||
* Gets the highest block corresponding to the {@link HeightMap} at the
|
||||
* given coordinates.
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.bukkit.Color;
|
|||
import org.bukkit.util.Transformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
* Represents a display entity which is designed to only have a visual function.
|
||||
|
@ -26,6 +27,13 @@ public interface Display extends Entity {
|
|||
*/
|
||||
public void setTransformation(@NotNull Transformation transformation);
|
||||
|
||||
/**
|
||||
* Sets the raw transformation matrix applied to this display
|
||||
*
|
||||
* @param transformationMatrix the transformation matrix
|
||||
*/
|
||||
public void setTransformationMatrix(@NotNull Matrix4f transformationMatrix);
|
||||
|
||||
/**
|
||||
* Gets the interpolation duration of this display.
|
||||
*
|
||||
|
|
123
src/main/java/org/bukkit/event/block/TNTPrimeEvent.java
Normal file
123
src/main/java/org/bukkit/event/block/TNTPrimeEvent.java
Normal file
|
@ -0,0 +1,123 @@
|
|||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when a block of TNT in the world become primed.
|
||||
* <p>
|
||||
* If a TNT Prime event is cancelled, the block of TNT will not become primed.
|
||||
*/
|
||||
public class TNTPrimeEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final PrimeCause igniteCause;
|
||||
private final Entity primingEntity;
|
||||
private final Block primingBlock;
|
||||
|
||||
public TNTPrimeEvent(@NotNull final Block block, @NotNull final PrimeCause igniteCause, @Nullable final Entity primingEntity, @Nullable final Block primingBlock) {
|
||||
super(block);
|
||||
this.igniteCause = igniteCause;
|
||||
this.primingEntity = primingEntity;
|
||||
this.primingBlock = primingBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cause of the TNT becoming primed.
|
||||
*
|
||||
* @return the cause
|
||||
*/
|
||||
@NotNull
|
||||
public PrimeCause getCause() {
|
||||
return igniteCause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity that caused the TNT to be primed.
|
||||
*
|
||||
* @return the entity that caused the TNT to be primed, or null if it was
|
||||
* not caused by an entity.
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getPrimingEntity() {
|
||||
return primingEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block that caused the TNT to be primed.
|
||||
*
|
||||
* @return the block that caused the TNT to be primed, or null if it was not
|
||||
* caused by a block.
|
||||
*/
|
||||
@Nullable
|
||||
public Block getPrimingBlock() {
|
||||
return primingBlock;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* An enum to represent the cause of a TNT block becoming primed.
|
||||
*/
|
||||
public enum PrimeCause {
|
||||
|
||||
/**
|
||||
* When TNT is primed by fire spreading.
|
||||
*/
|
||||
FIRE,
|
||||
/**
|
||||
* When TNT is primed by a redstone signal.
|
||||
*/
|
||||
REDSTONE,
|
||||
/**
|
||||
* When TNT is primed by a player interacting with it directly.
|
||||
*/
|
||||
PLAYER,
|
||||
/**
|
||||
* When TNT is primed by a nearby explosion.
|
||||
*/
|
||||
EXPLOSION,
|
||||
/**
|
||||
* When TNT is primed after getting hit with a burning projectile.
|
||||
*/
|
||||
PROJECTILE,
|
||||
/**
|
||||
* When TNT with the unstable block state set to true is broken.
|
||||
* <p>
|
||||
* Note: Canceling a prime event with this cause will stop the primed
|
||||
* TNT from spawning but will not stop the block from being broken.
|
||||
*/
|
||||
BLOCK_BREAK,
|
||||
/**
|
||||
* When TNT is primed by a dispenser holding flint and steel.
|
||||
* <p>
|
||||
* Note: This event is not called for a dispenser dispensing TNT
|
||||
* directly.
|
||||
*/
|
||||
DISPENSER;
|
||||
}
|
||||
}
|
|
@ -454,4 +454,25 @@ public abstract class InventoryView {
|
|||
*/
|
||||
@NotNull
|
||||
public abstract String getTitle();
|
||||
|
||||
/**
|
||||
* Get the original title of this inventory window, before any changes were
|
||||
* made using {@link #setTitle(String)}.
|
||||
*
|
||||
* @return the original title
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getOriginalTitle();
|
||||
|
||||
/**
|
||||
* Sets the title of this inventory window to the specified title if the
|
||||
* inventory window supports it.
|
||||
* <p>
|
||||
* Note if the inventory does not support titles that can be changed (ie, it
|
||||
* is not creatable or viewed by a player), then this method will throw an
|
||||
* exception.
|
||||
*
|
||||
* @param title The new title.
|
||||
*/
|
||||
public abstract void setTitle(@NotNull String title);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,20 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
private String group = "";
|
||||
private CraftingBookCategory category = CraftingBookCategory.MISC;
|
||||
|
||||
/**
|
||||
* Create a shaped recipe to craft the specified ItemStack. The
|
||||
* constructor merely determines the result and type; to set the actual
|
||||
* recipe, you'll need to call the appropriate methods.
|
||||
*
|
||||
* @param result The item you want the recipe to create.
|
||||
* @see ShapedRecipe#shape(String...)
|
||||
* @see ShapedRecipe#setIngredient(char, Material)
|
||||
* @see ShapedRecipe#setIngredient(char, Material, int)
|
||||
* @see ShapedRecipe#setIngredient(char, MaterialData)
|
||||
* @see ShapedRecipe#setIngredient(char, RecipeChoice)
|
||||
* @deprecated Recipes must have keys. Use {@link #ShapedRecipe(NamespacedKey, ItemStack)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ShapedRecipe(@NotNull ItemStack result) {
|
||||
Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result.");
|
||||
|
@ -40,6 +54,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
* @see ShapedRecipe#setIngredient(char, Material)
|
||||
* @see ShapedRecipe#setIngredient(char, Material, int)
|
||||
* @see ShapedRecipe#setIngredient(char, MaterialData)
|
||||
* @see ShapedRecipe#setIngredient(char, RecipeChoice)
|
||||
*/
|
||||
public ShapedRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) {
|
||||
Preconditions.checkArgument(key != null, "key");
|
||||
|
@ -92,10 +107,14 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
|
||||
/**
|
||||
* Sets the material that a character in the recipe shape refers to.
|
||||
* <p>
|
||||
* Note that before an ingredient can be set, the recipe's shape must be defined
|
||||
* with {@link #shape(String...)}.
|
||||
*
|
||||
* @param key The character that represents the ingredient in the shape.
|
||||
* @param ingredient The ingredient.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
* @throws IllegalArgumentException if the {@code key} does not appear in the shape.
|
||||
*/
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull MaterialData ingredient) {
|
||||
|
@ -104,10 +123,14 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
|
||||
/**
|
||||
* Sets the material that a character in the recipe shape refers to.
|
||||
* <p>
|
||||
* Note that before an ingredient can be set, the recipe's shape must be defined
|
||||
* with {@link #shape(String...)}.
|
||||
*
|
||||
* @param key The character that represents the ingredient in the shape.
|
||||
* @param ingredient The ingredient.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
* @throws IllegalArgumentException if the {@code key} does not appear in the shape.
|
||||
*/
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull Material ingredient) {
|
||||
|
@ -116,11 +139,15 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
|
||||
/**
|
||||
* Sets the material that a character in the recipe shape refers to.
|
||||
* <p>
|
||||
* Note that before an ingredient can be set, the recipe's shape must be defined
|
||||
* with {@link #shape(String...)}.
|
||||
*
|
||||
* @param key The character that represents the ingredient in the shape.
|
||||
* @param ingredient The ingredient.
|
||||
* @param raw The raw material data as an integer.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
* @throws IllegalArgumentException if the {@code key} does not appear in the shape.
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -137,6 +164,17 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link RecipeChoice} that a character in the recipe shape refers to.
|
||||
* <p>
|
||||
* Note that before an ingredient can be set, the recipe's shape must be defined
|
||||
* with {@link #shape(String...)}.
|
||||
*
|
||||
* @param key The character that represents the ingredient in the shape.
|
||||
* @param ingredient The ingredient.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
* @throws IllegalArgumentException if the {@code key} does not appear in the shape.
|
||||
*/
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull RecipeChoice ingredient) {
|
||||
Preconditions.checkArgument(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
||||
|
@ -163,6 +201,11 @@ public class ShapedRecipe implements Recipe, Keyed {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the choice map.
|
||||
*
|
||||
* @return The mapping of character to ingredients.
|
||||
*/
|
||||
@NotNull
|
||||
public Map<Character, RecipeChoice> getChoiceMap() {
|
||||
Map<Character, RecipeChoice> result = new HashMap<>();
|
||||
|
|
|
@ -10,6 +10,10 @@ import org.bukkit.World;
|
|||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.RoundingMode;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
/**
|
||||
* Represents a mutable vector. Because the components of Vectors are mutable,
|
||||
|
@ -814,6 +818,48 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
|||
return new BlockVector(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this vector as a JOML {@link Vector3f}.
|
||||
*
|
||||
* @return the JOML vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3f toVector3f() {
|
||||
return new Vector3f((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this vector as a JOML {@link Vector3d}.
|
||||
*
|
||||
* @return the JOML vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3d toVector3d() {
|
||||
return new Vector3d(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this vector as a JOML {@link Vector3i}.
|
||||
*
|
||||
* @param roundingMode the {@link RoundingMode} to use for this vector's components
|
||||
* @return the JOML vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3i toVector3i(int roundingMode) {
|
||||
return new Vector3i(x, y, z, roundingMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this vector as a JOML {@link Vector3i} with its components floored.
|
||||
*
|
||||
* @return the JOML vector
|
||||
* @see #toVector3i(int)
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3i toVector3i() {
|
||||
return toVector3i(RoundingMode.FLOOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if each component of this Vector is finite.
|
||||
*
|
||||
|
@ -869,6 +915,39 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
|||
return new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vector with components that match the provided JOML {@link Vector3f}.
|
||||
*
|
||||
* @param vector the vector to match
|
||||
* @return the new vector
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector fromJOML(@NotNull Vector3f vector) {
|
||||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vector with components that match the provided JOML {@link Vector3d}.
|
||||
*
|
||||
* @param vector the vector to match
|
||||
* @return the new vector
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector fromJOML(@NotNull Vector3d vector) {
|
||||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vector with components that match the provided JOML {@link Vector3i}.
|
||||
*
|
||||
* @param vector the vector to match
|
||||
* @return the new vector
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector fromJOML(@NotNull Vector3i vector) {
|
||||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String, Object> serialize() {
|
||||
|
|
Loading…
Add table
Reference in a new issue