Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to MC 1.21.2 #2560

Draft
wants to merge 11 commits into
base: api-12
Choose a base branch
from
5 changes: 2 additions & 3 deletions src/main/java/org/spongepowered/api/data/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@
import org.spongepowered.api.world.explosion.Explosion;
import org.spongepowered.api.world.generation.ChunkGenerator;
import org.spongepowered.api.world.generation.carver.Carver;
import org.spongepowered.api.world.generation.carver.CarvingStep;
import org.spongepowered.api.world.generation.config.WorldGenerationConfig;
import org.spongepowered.api.world.generation.feature.DecorationStep;
import org.spongepowered.api.world.generation.feature.PlacedFeature;
Expand Down Expand Up @@ -656,7 +655,7 @@ public final class Keys {
* The carvers of a {@link Biome} used during world generation.
* Readonly
*/
public static final Key<MapValue<CarvingStep, List<Carver>>> CARVERS = Keys.mapKey(ResourceKey.sponge("carvers"), TypeToken.get(CarvingStep.class), new TypeToken<List<Carver>>() {});
public static final Key<ListValue<Carver>> CARVERS = Keys.listKey(ResourceKey.sponge("carvers"), Carver.class);

/**
* The current casting time of a {@link Spellcaster}.
Expand Down Expand Up @@ -1021,7 +1020,7 @@ public final class Keys {
* determined randomly at the time of the explosion or computed from the
* context in which the {@link Explosive} explodes.</p>
*/
public static final Key<Value<Integer>> EXPLOSION_RADIUS = Keys.key(ResourceKey.sponge("explosion_radius"), Integer.class);
public static final Key<Value<Float>> EXPLOSION_RADIUS = Keys.key(ResourceKey.sponge("explosion_radius"), Float.class);

/**
* The eye height of an {@link Entity}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.recipe.crafting.Ingredient;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.registry.DefaultedRegistryValue;
import org.spongepowered.api.util.annotation.CatalogedBy;

import java.util.Optional;
import java.util.function.Predicate;

/**
* Represents a type of "armor", usually applicable to any
Expand All @@ -40,11 +40,10 @@
public interface ArmorMaterial extends DefaultedRegistryValue {

/**
* Gets the {@link ItemType} that can be used to
* "repair" the armor type.
* Gets the {@link ItemType} that can be used to "repair" the armor type.
*
* @return The item type considered to be used for repairing
*/
Optional<Ingredient> repairIngredient();
Predicate<ItemStack> repairIngredient();

}
2 changes: 0 additions & 2 deletions src/main/java/org/spongepowered/api/data/type/BoatType.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
*/
package org.spongepowered.api.data.type;

import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.registry.DefaultedRegistryValue;
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(BoatTypes.class)
public interface BoatType extends DefaultedRegistryValue {

BlockType representedBlock();
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface Explosive extends Entity {
*
* @return The explosion radius
*/
default Optional<Value.Mutable<Integer>> explosionRadius() {
default Optional<Value.Mutable<Float>> explosionRadius() {
return this.getValue(Keys.EXPLOSION_RADIUS).map(Value::asMutable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Ageable;

/**
* Represents a Dolphin
*/
public interface Dolphin extends Aquatic {
public interface Dolphin extends Aquatic, Ageable {

/**
* {@link Keys#SKIN_MOISTURE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
*/
package org.spongepowered.api.entity.living.aquatic;

import org.spongepowered.api.entity.Ageable;

/**
* Represents a Squid.
*/
public interface Squid extends Aquatic {
public interface Squid extends Aquatic, Ageable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface Zombie extends Monster {
*
* @return Whether this zombie is an adult or not
*/
@Override
default Value.Mutable<Boolean> adult() {
return this.requireValue(Keys.IS_ADULT).asMutable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
*/
package org.spongepowered.api.entity.living.player;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.util.Ticks;

import java.util.Optional;
Expand All @@ -39,41 +41,49 @@ public interface CooldownTracker {
* Checks if the specified {@link ItemType} is currently on cooldown
* for the player.
*
* @param type The item type to check is on cooldown
* @param stack The item type to check is on cooldown
* @return Whether or not the specified item type is cooldown
*/
boolean hasCooldown(ItemType type);
boolean hasCooldown(ItemStack stack);

boolean hasCooldown(ResourceKey group);

/**
* Gets the cooldown of the specified {@link ItemType} in ticks for the
* player, or empty if the the item type is currently not on cooldown.
*
* @param type The item type to get the cooldown for
* @param stack The item type to get the cooldown for
* @return The cooldown remaining for this item type in ticks, if not
* on cooldown
*/
Optional<Ticks> cooldown(ItemType type);
Optional<Ticks> cooldown(ItemStack stack);

Optional<Ticks> cooldown(ResourceKey group);

/**
* Sets the cooldown for the specified {@link ItemType} for the
* specified amount of ticks.
*
* @param type The item type to set the cooldown for
* @param stack The item type to set the cooldown for
* @param ticks The amount of ticks to set the item type on cooldown for
* @return False if setting the cooldown failed, possibly due to the event
* being cancelled
*/
boolean setCooldown(ItemType type, Ticks ticks);
boolean setCooldown(ItemStack stack, Ticks ticks);

boolean setCooldown(ResourceKey group, Ticks ticks);

/**
* Resets the cooldown of the specified {@link ItemType} for the
* player.
*
* @param type The item type to reset the cooldown for
* @param stack The item type to reset the cooldown for
* @return False if setting the cooldown failed, possibly due to the event
* being cancelled
*/
boolean resetCooldown(ItemType type);
boolean resetCooldown(ItemStack stack);

boolean resetCooldown(ResourceKey group);

/**
* Gets the fraction of the specified {@link ItemType}'s cooldown that
Expand All @@ -82,9 +92,11 @@ public interface CooldownTracker {
*
* <p>If present, this value will be between 0.0 and 1.0.</p>
*
* @param type The item type to get the cooldown fraction remaining
* @param stack The item type to get the cooldown fraction remaining
* @return The fraction of cooldown remaining for the specified item type
*/
OptionalDouble fractionRemaining(ItemType type);
OptionalDouble fractionRemaining(ItemStack stack);

OptionalDouble fractionRemaining(ResourceKey group);

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.spongepowered.api.event.entity.living.player;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.entity.living.player.CooldownTracker;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.Cancellable;
Expand All @@ -47,11 +48,11 @@ public interface CooldownEvent extends Event {
ServerPlayer player();

/**
* Gets the associated item type whose cooldown is being set or removed.
* Gets the associated item group whose cooldown is being set or removed.
*
* @return The associated item type
*/
ItemType itemType();
ResourceKey group();

/**
* Handles an {@link ItemType} being given a cooldown for a {@link ServerPlayer player}.
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/org/spongepowered/api/item/recipe/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.spongepowered.api.item.inventory.crafting.CraftingInventory;
import org.spongepowered.api.item.recipe.cooking.CookingRecipe;
import org.spongepowered.api.item.recipe.crafting.CraftingRecipe;
import org.spongepowered.api.item.recipe.crafting.Ingredient;
import org.spongepowered.api.item.recipe.crafting.RecipeInput;
import org.spongepowered.api.item.recipe.crafting.RecipeResult;
import org.spongepowered.api.item.recipe.crafting.ShapedCraftingRecipe;
Expand Down Expand Up @@ -124,13 +123,6 @@ default Optional<RecipeResult> result(T inventory, ServerWorld world) {
return Optional.empty();
}

/**
* Gets the ingredients for this recipe.
*
* @return An unmodifiable list of the ingredients.
*/
List<Ingredient> ingredients();

/**
* Returns true if the recipe is dynamic.
* <p>Dynamic recipes are not displayed in the recipe book.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
*/
public interface ShapedCraftingRecipe extends CraftingRecipe {

/**
* Gets the ingredients for this recipe.
*
* @return An unmodifiable list of the ingredients.
*/
List<Ingredient> ingredients();

/**
* Creates a new {@link ShapedCraftingRecipe.Builder} to build a {@link ShapedCraftingRecipe}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
*/
public interface ShapelessCraftingRecipe extends CraftingRecipe {

/**
* Gets the ingredients for this recipe.
*
* @return An unmodifiable list of the ingredients.
*/
List<Ingredient> ingredients();

/**
* Creates a new {@link Builder} to build a {@link ShapelessCraftingRecipe}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ static StoneCutterRecipe.Builder builder() {
return Sponge.game().builderProvider().provide(StoneCutterRecipe.Builder.class);
}

/**
* Returns the {@link Ingredient} for this {@link StoneCutterRecipe}.
*
* @return The {@link Ingredient} for this {@link StoneCutterRecipe}.
*/
Ingredient ingredient();

@Override
RecipeType<? extends StoneCutterRecipe> type();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.spongepowered.api.item.recipe.crafting.RecipeInput;
import org.spongepowered.api.util.ResourceKeyedBuilder;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

Expand All @@ -50,6 +51,27 @@ static SmithingRecipe.Builder builder() {
return Sponge.game().builderProvider().provide(SmithingRecipe.Builder.class);
}

/**
* Returns the smithing template {@link Ingredient} for this {@link SmithingRecipe}.
*
* @return The smithing template {@link Ingredient} for this {@link SmithingRecipe}.
*/
Optional<Ingredient> templateIngredient();

/**
* Returns the base {@link Ingredient} for this {@link SmithingRecipe}.
*
* @return The base {@link Ingredient} for this {@link SmithingRecipe}.
*/
Optional<Ingredient> baseIngredient();

/**
* Returns the additional {@link Ingredient} for this {@link SmithingRecipe}.
*
* @return The additional {@link Ingredient} for this {@link SmithingRecipe}.
*/
Optional<Ingredient> additionalIngredient();

@Override
RecipeType<? extends SmithingRecipe> type();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@
import org.spongepowered.api.world.biome.climate.TemperatureModifier;
import org.spongepowered.api.world.chunk.ChunkState;
import org.spongepowered.api.world.difficulty.Difficulty;
import org.spongepowered.api.world.explosion.ExplosionBlockInteraction;
import org.spongepowered.api.world.gamerule.GameRule;
import org.spongepowered.api.world.generation.carver.Carver;
import org.spongepowered.api.world.generation.carver.CarverType;
import org.spongepowered.api.world.generation.carver.CarvingStep;
import org.spongepowered.api.world.generation.config.flat.FlatGeneratorConfig;
import org.spongepowered.api.world.generation.config.noise.DensityFunction;
import org.spongepowered.api.world.generation.config.noise.Noise;
Expand Down Expand Up @@ -306,8 +306,6 @@ public final class RegistryTypes {

public static final DefaultedRegistryType<CatType> CAT_TYPE = RegistryTypes.minecraftKeyInGame("cat_variant");

public static final DefaultedRegistryType<CarvingStep> CARVING_STEP = RegistryTypes.spongeKeyInGame("carving_step");

public static final DefaultedRegistryType<ChatVisibility> CHAT_VISIBILITY = RegistryTypes.spongeKeyInGame("chat_visibility");

public static final DefaultedRegistryType<ChestAttachmentType> CHEST_ATTACHMENT_TYPE = RegistryTypes.spongeKeyInGame("chest_attachment_type");
Expand Down Expand Up @@ -360,6 +358,8 @@ public final class RegistryTypes {

public static final DefaultedRegistryType<EquipmentType> EQUIPMENT_TYPE = RegistryTypes.spongeKeyInGame("equipment_type");

public static final RegistryType<ExplosionBlockInteraction> EXPLOSION_BLOCK_INTERACTION = RegistryTypes.spongeKeyInGame("explosion_block_interaction");

public static final DefaultedRegistryType<FireworkShape> FIREWORK_SHAPE = RegistryTypes.spongeKeyInGame("firework_shape");

public static final DefaultedRegistryType<FlatGeneratorConfig> FLAT_GENERATOR_CONFIG = RegistryTypes.spongeKeyInGame("flat_generator_config");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public final class StatisticCategories {

public static final DefaultedRegistryReference<StatisticCategory.Typed<ItemType>> DROPPED = StatisticCategories.typedKey(ResourceKey.minecraft("dropped"));

@SuppressWarnings("rawtypes")
public static final DefaultedRegistryReference<StatisticCategory.Typed<EntityType>> KILLED = StatisticCategories.typedKey(ResourceKey.minecraft("killed"));

@SuppressWarnings("rawtypes")
public static final DefaultedRegistryReference<StatisticCategory.Typed<EntityType>> KILLED_BY = StatisticCategories.typedKey(ResourceKey.minecraft("killed_by"));

public static final DefaultedRegistryReference<StatisticCategory.Typed<BlockType>> MINED = StatisticCategories.typedKey(ResourceKey.minecraft("mined"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ interface Builder extends DataPackEntryBuilder<WorldType, WorldTypeTemplate, Bui
* @param pack The data
* @return This builder, for chaining
*/
@Override
Builder fromDataPack(DataView pack) throws IOException;

Builder from(WorldType type);

@Override
Builder pack(DataPack<WorldTypeTemplate> pack);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/spongepowered/api/world/biome/Biome.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.spongepowered.api.world.biome.spawner.NaturalSpawnCost;
import org.spongepowered.api.world.biome.spawner.NaturalSpawner;
import org.spongepowered.api.world.generation.carver.Carver;
import org.spongepowered.api.world.generation.carver.CarvingStep;
import org.spongepowered.api.world.generation.feature.DecorationStep;
import org.spongepowered.api.world.generation.feature.PlacedFeature;

Expand Down Expand Up @@ -116,7 +115,7 @@ default TemperatureModifier temperatureModifier() {
*
* @return The carvers
*/
default Map<CarvingStep, List<Carver>> carvers() {
default List<Carver> carvers() {
return this.require(Keys.CARVERS);
}

Expand Down
Loading