- * If your mod does not require a dependency on Forestry, it is recommended to use your own CapabilityTokens instead
- * of the ones below, as recommended by {@link net.minecraftforge.common.capabilities.ForgeCapabilities}.
*/
public class ForestryCapabilities {
- // Apiculture
- public static Capability ARMOR_APIARIST = CapabilityManager.get(new CapabilityToken<>() {
- });
-
- // Arboriculture
- public static Capability ARMOR_NATURALIST = CapabilityManager.get(new CapabilityToken<>() {
- });
+ /**
+ * Items with this capability can protect the wearer from harmful bee effects.
+ */
+ public static ItemCapability BEE_PROTECTION = ItemCapability.createVoid(forestry("bee_protection"), IBeeProtection.class);
- // Genetics
- public static Capability INDIVIDUAL_HANDLER_ITEM = CapabilityManager.get(new CapabilityToken<>() {
- });
+ /**
+ * Grants the wearer the ability to see wild bee hives and pollinated leaves more easily.
+ */
+ public static ItemCapability SPECTACLE_VISION = ItemCapability.createVoid(forestry("spectacle_vision"), ISpectacleVision.class);
- // Genetic Filter
- public static Capability FILTER_LOGIC = CapabilityManager.get(new CapabilityToken<>() {
- });
+ /**
+ * Items with this capability support Forestry's genetic data.
+ */
+ public static ItemCapability INDIVIDUAL_HANDLER_ITEM = ItemCapability.createVoid(forestry("individual"), IIndividualHandlerItem.class);
}
diff --git a/src/main/java/forestry/api/ForestryConstants.java b/src/main/java/forestry/api/ForestryConstants.java
index 13eabf6049..092063f3cc 100644
--- a/src/main/java/forestry/api/ForestryConstants.java
+++ b/src/main/java/forestry/api/ForestryConstants.java
@@ -15,6 +15,6 @@ public class ForestryConstants {
* @return A new resource location under the Forestry namespace. In most cases, mods should use their own namespace instead.
*/
public static ResourceLocation forestry(String path) {
- return new ResourceLocation(MOD_ID, path);
+ return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
}
}
diff --git a/src/main/java/forestry/api/ForestryDataMaps.java b/src/main/java/forestry/api/ForestryDataMaps.java
new file mode 100644
index 0000000000..267a82c570
--- /dev/null
+++ b/src/main/java/forestry/api/ForestryDataMaps.java
@@ -0,0 +1,60 @@
+package forestry.api;
+
+import com.mojang.serialization.Codec;
+import forestry.api.fuels.*;
+import net.minecraft.core.Registry;
+import net.minecraft.core.registries.Registries;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.level.material.Fluid;
+
+import net.neoforged.neoforge.registries.datamaps.DataMapType;
+
+public class ForestryDataMaps {
+ /**
+ * Add new fuels for the fermenter here (i.e. fertilizer)
+ */
+ public static final DataMapType FERMENTER_FUELS = create("fermenter_fuels", Registries.ITEM, FermenterFuel.CODEC)
+ .build();
+
+ /**
+ * Add new resources for the moistener here (i.e. wheat)
+ */
+ public static final DataMapType MOISTENER_FUELS = create("moistener_fuels", Registries.ITEM, MoistenerFuel.CODEC)
+ .build();
+
+ /**
+ * Add new substrates for the rainmaker here
+ */
+ public static final DataMapType RAINMAKER_FUELS = create("rainmaker_fuels", Registries.ITEM, RainmakerFuel.CODEC)
+ .synced(RainmakerFuel.CODEC, true)
+ .build();
+
+ /**
+ * Add new fuels for the Biogas Engine here
+ */
+ public static final DataMapType BIOGAS_FUELS = create("biogas_fuels", Registries.FLUID, BiogasEngineFuel.CODEC)
+ .build();
+
+ /**
+ * Add new fuels for the Peat Engine here
+ */
+ public static final DataMapType PEAT_FUELS = create("peat_fuels", Registries.ITEM, PeatEngineFuel.CODEC)
+ .build();
+
+ /**
+ * Add new fertilizers to use in Multiblock Farms and Planters
+ */
+ public static final DataMapType FARM_FERTILIZERS = create("farm_fertilizers", Registries.ITEM, Codec.INT)
+ .build();
+
+ /**
+ * Add new items to be used as feed for the Alveary Swarmer
+ */
+ public static final DataMapType SWARMER_FEED = create("swarmer_feed", Registries.ITEM, Codec.INT)
+ .build();
+
+ private static DataMapType.Builder create(String id, ResourceKey> registry, Codec codec) {
+ return DataMapType.builder(ForestryConstants.forestry(id), registry, codec);
+ }
+}
diff --git a/src/main/java/forestry/api/ForestryRegistries.java b/src/main/java/forestry/api/ForestryRegistries.java
new file mode 100644
index 0000000000..cfbbf33e73
--- /dev/null
+++ b/src/main/java/forestry/api/ForestryRegistries.java
@@ -0,0 +1,28 @@
+package forestry.api;
+
+import forestry.api.circuits.ICircuit;
+import forestry.api.genetics.ISpeciesType;
+import forestry.api.mail.IPostalCarrier;
+import net.minecraft.core.Registry;
+import net.minecraft.resources.ResourceKey;
+import net.neoforged.neoforge.registries.RegistryBuilder;
+
+public class ForestryRegistries {
+ public static final Registry CIRCUIT = new RegistryBuilder<>(Keys.CIRCUIT_TYPE)
+ .sync(true)
+ .create();
+
+ public static final Registry POSTAL_CARRIER = new RegistryBuilder<>(Keys.POSTAL_CARRIER)
+ .sync(true)
+ .create();
+
+ public static final Registry> SPECIES_TYPE = new RegistryBuilder<>(Keys.SPECIES_TYPE)
+ .sync(true)
+ .create();
+
+ public static class Keys {
+ public static final ResourceKey> CIRCUIT_TYPE = ResourceKey.createRegistryKey(ForestryConstants.forestry("circuit"));
+ public static final ResourceKey> POSTAL_CARRIER = ResourceKey.createRegistryKey(ForestryConstants.forestry("postal_carrier"));
+ public static final ResourceKey>> SPECIES_TYPE = ResourceKey.createRegistryKey(ForestryConstants.forestry("species_type"));
+ }
+}
diff --git a/src/main/java/forestry/api/ForestryTags.java b/src/main/java/forestry/api/ForestryTags.java
index 54bba08783..47f97c8f4a 100644
--- a/src/main/java/forestry/api/ForestryTags.java
+++ b/src/main/java/forestry/api/ForestryTags.java
@@ -1,16 +1,13 @@
package forestry.api;
-import forestry.arboriculture.ForestryWoodType;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
-import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.material.Fluid;
import org.jetbrains.annotations.ApiStatus;
public class ForestryTags {
@@ -32,36 +29,6 @@ public static class Blocks {
public static final TagKey STORAGE_BLOCKS_RAW_TIN = forgeTag("storage_blocks/raw_tin");
- // todo remove in favor of directly using IWoodAccess
- public static final TagKey LARCH_LOGS = ForestryWoodType.LARCH.blockTag;
- public static final TagKey TEAK_LOGS = ForestryWoodType.TEAK.blockTag;
- public static final TagKey ACACIA_DESERT_LOGS = ForestryWoodType.ACACIA_DESERT.blockTag;
- public static final TagKey LIME_LOGS = ForestryWoodType.LIME.blockTag;
- public static final TagKey CHESTNUT_LOGS = ForestryWoodType.CHESTNUT.blockTag;
- public static final TagKey WENGE_LOGS = ForestryWoodType.WENGE.blockTag;
- public static final TagKey BAOBAB_LOGS = ForestryWoodType.BAOBAB.blockTag;
- public static final TagKey SEQUOIA_LOGS = ForestryWoodType.SEQUOIA.blockTag;
- public static final TagKey KAPOK_LOGS = ForestryWoodType.KAPOK.blockTag;
- public static final TagKey EBONY_LOGS = ForestryWoodType.EBONY.blockTag;
- public static final TagKey MAHOGANY_LOGS = ForestryWoodType.MAHOGANY.blockTag;
- public static final TagKey BALSA_LOGS = ForestryWoodType.BALSA.blockTag;
- public static final TagKey WILLOW_LOGS = ForestryWoodType.WILLOW.blockTag;
- public static final TagKey WALNUT_LOGS = ForestryWoodType.WALNUT.blockTag;
- public static final TagKey GREENHEART_LOGS = ForestryWoodType.GREENHEART.blockTag;
- public static final TagKey MAHOE_LOGS = ForestryWoodType.MAHOE.blockTag;
- public static final TagKey POPLAR_LOGS = ForestryWoodType.POPLAR.blockTag;
- public static final TagKey PALM_LOGS = ForestryWoodType.PALM.blockTag;
- public static final TagKey PAPAYA_LOGS = ForestryWoodType.PAPAYA.blockTag;
- public static final TagKey PINE_LOGS = ForestryWoodType.PINE.blockTag;
- public static final TagKey PLUM_LOGS = ForestryWoodType.PLUM.blockTag;
- public static final TagKey MAPLE_LOGS = ForestryWoodType.MAPLE.blockTag;
- public static final TagKey CITRUS_LOGS = ForestryWoodType.CITRUS.blockTag;
- public static final TagKey GIGANTEUM_LOGS = ForestryWoodType.GIGANTEUM.blockTag;
- public static final TagKey IPE_LOGS = ForestryWoodType.IPE.blockTag;
- public static final TagKey PADAUK_LOGS = ForestryWoodType.PADAUK.blockTag;
- public static final TagKey COCOBOLO_LOGS = ForestryWoodType.COCOBOLO.blockTag;
- public static final TagKey ZEBRAWOOD_LOGS = ForestryWoodType.ZEBRAWOOD.blockTag;
-
// Categories of flowers
public static final TagKey VANILLA_FLOWERS = blockTag("flowers/vanilla");
public static final TagKey NETHER_FLOWERS = blockTag("flowers/nether");
@@ -93,7 +60,7 @@ public static class Blocks {
public static final TagKey SWARM_BEE_GROUND = blockTag("hive_grounds/swarm");
private static TagKey forgeTag(String name) {
- return BlockTags.create(new ResourceLocation("forge", name));
+ return BlockTags.create(ResourceLocation.fromNamespaceAndPath("c", name));
}
}
@@ -129,38 +96,10 @@ public static class Items {
public static final TagKey STORAGE_BLOCKS_RAW_TIN = forgeTag("storage_blocks/raw_tin");
- public static final TagKey LARCH_LOGS = ForestryWoodType.LARCH.itemTag;
- public static final TagKey TEAK_LOGS = ForestryWoodType.TEAK.itemTag;
- public static final TagKey ACACIA_DESERT_LOGS = ForestryWoodType.ACACIA_DESERT.itemTag;
- public static final TagKey LIME_LOGS = ForestryWoodType.LIME.itemTag;
- public static final TagKey CHESTNUT_LOGS = ForestryWoodType.CHESTNUT.itemTag;
- public static final TagKey WENGE_LOGS = ForestryWoodType.WENGE.itemTag;
- public static final TagKey BAOBAB_LOGS = ForestryWoodType.BAOBAB.itemTag;
- public static final TagKey SEQUOIA_LOGS = ForestryWoodType.SEQUOIA.itemTag;
- public static final TagKey KAPOK_LOGS = ForestryWoodType.KAPOK.itemTag;
- public static final TagKey EBONY_LOGS = ForestryWoodType.EBONY.itemTag;
- public static final TagKey MAHOGANY_LOGS = ForestryWoodType.MAHOGANY.itemTag;
- public static final TagKey BALSA_LOGS = ForestryWoodType.BALSA.itemTag;
- public static final TagKey WILLOW_LOGS = ForestryWoodType.WILLOW.itemTag;
- public static final TagKey WALNUT_LOGS = ForestryWoodType.WALNUT.itemTag;
- public static final TagKey GREENHEART_LOGS = ForestryWoodType.GREENHEART.itemTag;
- public static final TagKey MAHOE_LOGS = ForestryWoodType.MAHOE.itemTag;
- public static final TagKey POPLAR_LOGS = ForestryWoodType.POPLAR.itemTag;
- public static final TagKey PALM_LOGS = ForestryWoodType.PALM.itemTag;
- public static final TagKey PAPAYA_LOGS = ForestryWoodType.PAPAYA.itemTag;
- public static final TagKey PINE_LOGS = ForestryWoodType.PINE.itemTag;
- public static final TagKey PLUM_LOGS = ForestryWoodType.PLUM.itemTag;
- public static final TagKey MAPLE_LOGS = ForestryWoodType.MAPLE.itemTag;
- public static final TagKey CITRUS_LOGS = ForestryWoodType.CITRUS.itemTag;
- public static final TagKey GIGANTEUM_LOGS = ForestryWoodType.GIGANTEUM.itemTag;
- public static final TagKey IPE_LOGS = ForestryWoodType.IPE.itemTag;
- public static final TagKey PADAUK_LOGS = ForestryWoodType.PADAUK.itemTag;
- public static final TagKey COCOBOLO_LOGS = ForestryWoodType.COCOBOLO.itemTag;
- public static final TagKey ZEBRAWOOD_LOGS = ForestryWoodType.ZEBRAWOOD.itemTag;
-
public static final TagKey STAMPS = itemTag("stamps");
public static final TagKey SCOOPS = itemTag("scoops");
+ public static final TagKey SOLDERING_IRONS = itemTag("soldering_irons");
public static final TagKey FORESTRY_FRUITS = itemTag("forestry_fruits");
public static final TagKey FRUITS = forgeTag("fruits");
@@ -190,14 +129,10 @@ public static class Items {
public static final TagKey HUNTER_ALLOW = itemTag("backpack/allow/hunter");
public static final TagKey HUNTER_REJECT = itemTag("backpack/reject/hunter");
- // needed because forge doesn't have it and mods can't agree on a crafting table tag...
- // todo: remove in 1.21 when Neo merges the tags unification PR
- public static final TagKey CRAFTING_TABLES = itemTag("crafting_tables");
-
public static final TagKey BEES = itemTag("bees");
private static TagKey forgeTag(String name) {
- return ItemTags.create(new ResourceLocation("forge", name));
+ return ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", name));
}
}
@@ -224,14 +159,6 @@ private static TagKey tag(String path) {
}
}
- public static class Fluids {
- public static final TagKey HONEY = forgeTag("honey");
-
- private static TagKey forgeTag(String name) {
- return FluidTags.create(new ResourceLocation("forge", name));
- }
- }
-
// These have to be outside of Blocks and Items classes so that ForestryWoodType doesn't cause a circular dependency
@ApiStatus.Internal
public static TagKey blockTag(String name) {
diff --git a/src/main/java/forestry/api/apiculture/BeeManager.java b/src/main/java/forestry/api/apiculture/BeeManager.java
deleted file mode 100644
index a6581dc717..0000000000
--- a/src/main/java/forestry/api/apiculture/BeeManager.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package forestry.api.apiculture;
-
-import javax.annotation.Nullable;
-
-/**
- * Some miscellaneous lists and settings for bees.
- */
-public class BeeManager {
- /**
- * Used to check whether a player is wearing Apiarist Armor.
- */
- @Nullable
- public static IArmorApiaristHelper armorApiaristHelper;
-}
diff --git a/src/main/java/forestry/api/apiculture/IApiaristTracker.java b/src/main/java/forestry/api/apiculture/IApiaristTracker.java
index 50088a221d..7381eb7517 100644
--- a/src/main/java/forestry/api/apiculture/IApiaristTracker.java
+++ b/src/main/java/forestry/api/apiculture/IApiaristTracker.java
@@ -1,6 +1,6 @@
package forestry.api.apiculture;
-import forestry.api.apiculture.genetics.IBee;
+import forestry.api.apiculture.bee.IBee;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.ISpeciesType;
diff --git a/src/main/java/forestry/api/apiculture/IArmorApiarist.java b/src/main/java/forestry/api/apiculture/IArmorApiarist.java
deleted file mode 100644
index 9351e461c2..0000000000
--- a/src/main/java/forestry/api/apiculture/IArmorApiarist.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package forestry.api.apiculture;
-
-import forestry.api.ForestryCapabilities;
-import forestry.api.apiculture.genetics.IBeeEffect;
-import net.minecraft.world.entity.LivingEntity;
-import net.minecraft.world.item.ItemStack;
-
-import javax.annotation.Nullable;
-
-/**
- * When implemented as a capability by armor items, protects the wearer from negative bee effects.
- *
- * @see ForestryCapabilities#ARMOR_APIARIST
- */
-public interface IArmorApiarist {
- /**
- * Called when the apiarist's armor acts as protection against an attack.
- *
- * @param entity Entity being attacked
- * @param armor Armor item
- * @param cause Optional cause of attack, such as a bee effect identifier
- * @param doProtect Whether or not to actually do the side effects of protection
- * @return Whether or not the armor should protect the player from that attack
- */
- boolean protectEntity(LivingEntity entity, ItemStack armor, @Nullable IBeeEffect cause, boolean doProtect);
-}
diff --git a/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java b/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java
deleted file mode 100644
index acd199e9a8..0000000000
--- a/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package forestry.api.apiculture;
-
-import forestry.api.apiculture.genetics.IBeeEffect;
-import net.minecraft.world.entity.LivingEntity;
-import net.minecraft.world.item.ItemStack;
-
-import javax.annotation.Nullable;
-
-/**
- * Helper class for checking whether an entity is wearing Apiarist Armor
- *
- * @author Vexatos
- */
-public interface IArmorApiaristHelper {
- /**
- * Called when the apiarist's armor acts as protection against an attack.
- *
- * @param stack ItemStack to check
- * @param entity Entity being attacked
- * @param cause Optional cause of attack, such as a bee effect identifier
- * @param doProtect Whether or not to actually do the side effects of protection
- * @return Whether or not the item is valid Apiarist Armor and should protect the player from that attack
- * @since Forestry 4.2
- */
- boolean isArmorApiarist(ItemStack stack, LivingEntity entity, IBeeEffect cause, boolean doProtect);
-
- /**
- * Called when the apiarist's armor acts as protection against an attack.
- *
- * @param entity Entity being attacked
- * @param cause Optional cause of attack, such as a bee effect identifier
- * @param doProtect Whether or not to actually do the side effects of protection
- * @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting.
- * 4 means full protection, but it can go higher if they are holding items like the smoker.
- * @since Forestry 4.2
- */
- int wearsItems(LivingEntity entity, @Nullable IBeeEffect cause, boolean doProtect);
-}
diff --git a/src/main/java/forestry/api/apiculture/IBeeHousing.java b/src/main/java/forestry/api/apiculture/IBeeHousing.java
index 436e2d479f..3004cd007c 100644
--- a/src/main/java/forestry/api/apiculture/IBeeHousing.java
+++ b/src/main/java/forestry/api/apiculture/IBeeHousing.java
@@ -1,19 +1,18 @@
package forestry.api.apiculture;
import com.mojang.authlib.GameProfile;
-import forestry.api.apiculture.genetics.IBeeSpeciesType;
import forestry.api.climate.IBiomeProvider;
import forestry.api.climate.IClimateProvider;
import forestry.api.core.IErrorLogicSource;
import forestry.api.core.ILocationProvider;
+import net.minecraft.world.item.component.ResolvableProfile;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nullable;
public interface IBeeHousing extends IErrorLogicSource, IClimateProvider, IBiomeProvider, ILocationProvider {
-
/**
- * Used by {@link IBeeSpeciesType#createBeeHousingModifier(IBeeHousing)}
+ * Used by {@link forestry.api.apiculture.hives.IHiveManager#createBeeHousingModifier(IBeeHousing)}
* to combine bee modifiers from several sources that can change over time.
*
* @return IBeeModifiers from the housing, frames, etc.
@@ -21,7 +20,7 @@ public interface IBeeHousing extends IErrorLogicSource, IClimateProvider, IBiome
Iterable getBeeModifiers();
/**
- * Used by {@link IBeeSpeciesType#createBeeHousingListener(IBeeHousing)}
+ * Used by {@link forestry.api.apiculture.hives.IHiveManager#createBeeHousingListener(IBeeHousing)}
* to combine bee listeners from several sources that can change over time.
*
* @return IBeeListeners from the housing, multiblock parts, etc.
@@ -39,7 +38,7 @@ public interface IBeeHousing extends IErrorLogicSource, IClimateProvider, IBiome
boolean isRaining();
@Nullable
- GameProfile getOwner();
+ ResolvableProfile getOwner();
/**
* @return exact coordinates where bee particle FX should spawn from
diff --git a/src/main/java/forestry/api/apiculture/IBeeModelProvider.java b/src/main/java/forestry/api/apiculture/IBeeModelProvider.java
deleted file mode 100644
index 3184ff8764..0000000000
--- a/src/main/java/forestry/api/apiculture/IBeeModelProvider.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package forestry.api.apiculture;
-
-import forestry.api.apiculture.genetics.BeeLifeStage;
-import net.minecraft.client.resources.model.ModelResourceLocation;
-
-public interface IBeeModelProvider {
-
- ModelResourceLocation getModel(BeeLifeStage type);
-}
diff --git a/src/main/java/forestry/api/apiculture/IBeeModifier.java b/src/main/java/forestry/api/apiculture/IBeeModifier.java
index 33e1ef71a5..32e0de7ec9 100644
--- a/src/main/java/forestry/api/apiculture/IBeeModifier.java
+++ b/src/main/java/forestry/api/apiculture/IBeeModifier.java
@@ -1,6 +1,6 @@
package forestry.api.apiculture;
-import forestry.api.apiculture.genetics.IBeeSpecies;
+import forestry.api.apiculture.bee.IBeeSpecies;
import forestry.api.core.TemperatureType;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
diff --git a/src/main/java/forestry/api/apiculture/IBeeProtection.java b/src/main/java/forestry/api/apiculture/IBeeProtection.java
new file mode 100644
index 0000000000..9493475511
--- /dev/null
+++ b/src/main/java/forestry/api/apiculture/IBeeProtection.java
@@ -0,0 +1,48 @@
+package forestry.api.apiculture;
+
+import forestry.api.ForestryCapabilities;
+import forestry.api.apiculture.bee.IBeeEffect;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.world.item.ItemStack;
+
+import javax.annotation.Nullable;
+
+/**
+ * When implemented as a capability by armor items, protects the wearer from negative bee effects.
+ *
+ * @see ForestryCapabilities#BEE_PROTECTION
+ */
+public interface IBeeProtection {
+ /**
+ * Called when the apiarist's armor acts as protection against an attack.
+ *
+ * @param entity Entity being attacked
+ * @param armor Armor item
+ * @param cause Optional cause of attack, such as a bee effect identifier
+ * @param execute Whether or not to actually do the side effects of protection, use {@code false} if simulating
+ * @return Whether or not the armor should protect the player from that attack
+ */
+ boolean doBeeProtection(LivingEntity entity, ItemStack armor, @Nullable IBeeEffect cause, boolean execute);
+
+ /**
+ * Called when the apiarist's armor acts as protection against an attack.
+ *
+ * @param entity Entity being attacked
+ * @param cause Optional cause of attack, such as a bee effect identifier
+ * @param doProtect Whether or not to actually do the side effects of protection
+ * @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting.
+ * 4 means full protection.
+ */
+ static int getBeeProtectionLevel(LivingEntity entity, @Nullable IBeeEffect cause, boolean doProtect) {
+ int count = 0;
+
+ for (ItemStack armorItem : entity.getArmorSlots()) {
+ IBeeProtection capability = armorItem.getCapability(ForestryCapabilities.BEE_PROTECTION);
+ if (capability != null && capability.doBeeProtection(entity, armorItem, cause, doProtect)) {
+ count++;
+ }
+ }
+
+ return count;
+ }
+}
diff --git a/src/main/java/forestry/api/apiculture/IBeeSpriteColourProvider.java b/src/main/java/forestry/api/apiculture/IBeeSpriteColourProvider.java
deleted file mode 100644
index ee01985b33..0000000000
--- a/src/main/java/forestry/api/apiculture/IBeeSpriteColourProvider.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package forestry.api.apiculture;
-
-/**
- * Custom colour provider for bees with complicated colors.
- */
-public interface IBeeSpriteColourProvider {
- int getSpriteColour(int renderPass);
-}
diff --git a/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java b/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java
index 92e15745ca..3185a966aa 100644
--- a/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java
+++ b/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java
@@ -3,10 +3,10 @@
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import net.minecraft.core.BlockPos;
-import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
+import net.neoforged.api.distmarker.Dist;
+import net.neoforged.api.distmarker.OnlyIn;
import java.util.List;
@@ -54,7 +54,7 @@ default void setWorkThrottle(int workThrottle) {
/* CLIENT */
/**
- * Sync to client by using {@link #write(net.minecraft.nbt.CompoundTag)} in your {@link net.minecraft.world.level.block.entity.BlockEntity#getUpdateTag()}
+ * Sync to client by using {@link INbtWritable#write(net.minecraft.nbt.CompoundTag, net.minecraft.core.HolderLookup.Provider)} in your {@link net.minecraft.world.level.block.entity.BlockEntity#getUpdateTag()}
*/
void syncToClient();
@@ -87,9 +87,9 @@ default void setWorkThrottle(int workThrottle) {
*/
List getFlowerPositions();
- default void readData(FriendlyByteBuf data) {
+ default void readData(RegistryFriendlyByteBuf buffer) {
}
- default void writeData(FriendlyByteBuf data) {
+ default void writeData(RegistryFriendlyByteBuf buffer) {
}
}
diff --git a/src/main/java/forestry/api/apiculture/IBeekeepingMode.java b/src/main/java/forestry/api/apiculture/IBeekeepingMode.java
deleted file mode 100644
index 93f3e7fc30..0000000000
--- a/src/main/java/forestry/api/apiculture/IBeekeepingMode.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package forestry.api.apiculture;
-
-import forestry.api.apiculture.genetics.IBee;
-import net.minecraft.core.BlockPos;
-import net.minecraft.world.level.Level;
-
-import java.util.List;
-
-public interface IBeekeepingMode {
-
- /**
- * @return Localized name of this beekeeping mode.
- */
- String getName();
-
- /**
- * @return Localized list of strings outlining the behaviour of this beekeeping mode.
- */
- List getDescription();
-
- /**
- * @return Float used to modify the wear on comb frames.
- */
- float getWearModifier();
-
- /**
- * @return fertility taking into account the birthing queen and surroundings.
- */
- int getFinalFertility(IBee queen, Level world, BlockPos pos);
-
- /**
- * @return true if the queen is genetically "fatigued" and should not be reproduced anymore.
- */
- boolean isFatigued(IBee queen, IBeeHousing housing);
-
- /**
- * @return true if the genetic structure of the queen is breaking down during spawning of the offspring (with chance). will trigger a negative effect.
- */
- boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing);
-
- /**
- * @return {@code true} if an offspring of this queen is considered pristine
- */
- boolean isOffspringPristine(IBee queen);
-
- /**
- * @return true if this mode allows the passed queen or princess to be multiplied
- */
- boolean mayMultiplyPrincess(IBee queen);
-
- /**
- * @return the bee modifier for this mode
- */
- IBeeModifier getBeeModifier();
-}
diff --git a/src/main/java/forestry/api/apiculture/IJubilanceFactory.java b/src/main/java/forestry/api/apiculture/IJubilanceFactory.java
deleted file mode 100644
index 749abea1bb..0000000000
--- a/src/main/java/forestry/api/apiculture/IJubilanceFactory.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package forestry.api.apiculture;
-
-import net.minecraft.world.level.block.state.BlockState;
-
-public interface IJubilanceFactory {
- /**
- * The default Jubilance Provider is satisfied when the humidity and temperature are ideal for the bee.
- */
- IBeeJubilance getDefault();
-
- /**
- * The jubilance provider for bees who prefer not to live near other creatures (other bees are fine).
- */
- IBeeJubilance getHermit();
-
- /**
- * The Requires Resource Jubilance Provider is satisfied when a specific block is under the hive.
- */
- IBeeJubilance getRequiresResource(BlockState... acceptedBlockStates);
-}
diff --git a/src/main/java/forestry/api/apiculture/genetics/BeeLifeStage.java b/src/main/java/forestry/api/apiculture/bee/BeeLifeStage.java
similarity index 94%
rename from src/main/java/forestry/api/apiculture/genetics/BeeLifeStage.java
rename to src/main/java/forestry/api/apiculture/bee/BeeLifeStage.java
index 36e33385ee..13176c1b7a 100644
--- a/src/main/java/forestry/api/apiculture/genetics/BeeLifeStage.java
+++ b/src/main/java/forestry/api/apiculture/bee/BeeLifeStage.java
@@ -1,4 +1,4 @@
-package forestry.api.apiculture.genetics;
+package forestry.api.apiculture.bee;
import forestry.api.genetics.ILifeStage;
import forestry.apiculture.features.ApicultureItems;
diff --git a/src/main/java/forestry/api/apiculture/IActivityType.java b/src/main/java/forestry/api/apiculture/bee/IActivityType.java
similarity index 96%
rename from src/main/java/forestry/api/apiculture/IActivityType.java
rename to src/main/java/forestry/api/apiculture/bee/IActivityType.java
index 8d755307d0..23da8874ff 100644
--- a/src/main/java/forestry/api/apiculture/IActivityType.java
+++ b/src/main/java/forestry/api/apiculture/bee/IActivityType.java
@@ -1,5 +1,6 @@
-package forestry.api.apiculture;
+package forestry.api.apiculture.bee;
+import forestry.api.apiculture.ForestryActivityTypes;
import forestry.api.core.IError;
import forestry.api.genetics.alleles.IRegistryAlleleValue;
import net.minecraft.core.BlockPos;
diff --git a/src/main/java/forestry/api/apiculture/genetics/IBee.java b/src/main/java/forestry/api/apiculture/bee/IBee.java
similarity index 88%
rename from src/main/java/forestry/api/apiculture/genetics/IBee.java
rename to src/main/java/forestry/api/apiculture/bee/IBee.java
index 6d3571da24..e0bf580f32 100644
--- a/src/main/java/forestry/api/apiculture/genetics/IBee.java
+++ b/src/main/java/forestry/api/apiculture/bee/IBee.java
@@ -1,4 +1,4 @@
-package forestry.api.apiculture.genetics;
+package forestry.api.apiculture.bee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.IError;
@@ -7,13 +7,10 @@
import forestry.api.genetics.IIndividualLiving;
import forestry.api.genetics.pollen.IPollen;
import net.minecraft.core.BlockPos;
-import net.minecraft.core.Holder;
-import net.minecraft.core.Registry;
import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
+import net.neoforged.api.distmarker.Dist;
+import net.neoforged.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
import java.util.Iterator;
@@ -52,8 +49,6 @@ public interface IBee extends IIndividualLiving {
*/
Set getCanWork(IBeeHousing housing);
- List> getSuitableBiomes(Registry registry);
-
/**
* @return A list of item stacks used for displaying this bee's products in the Analyzer GUI.
*/
diff --git a/src/main/java/forestry/api/apiculture/genetics/IBeeEffect.java b/src/main/java/forestry/api/apiculture/bee/IBeeEffect.java
similarity index 96%
rename from src/main/java/forestry/api/apiculture/genetics/IBeeEffect.java
rename to src/main/java/forestry/api/apiculture/bee/IBeeEffect.java
index df5c0301f9..193871bf5e 100644
--- a/src/main/java/forestry/api/apiculture/genetics/IBeeEffect.java
+++ b/src/main/java/forestry/api/apiculture/bee/IBeeEffect.java
@@ -1,7 +1,8 @@
-package forestry.api.apiculture.genetics;
+package forestry.api.apiculture.bee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
+import forestry.api.core.IEffect;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.alleles.IRegistryAlleleValue;
diff --git a/src/main/java/forestry/api/apiculture/IBeeJubilance.java b/src/main/java/forestry/api/apiculture/bee/IBeeJubilance.java
similarity index 74%
rename from src/main/java/forestry/api/apiculture/IBeeJubilance.java
rename to src/main/java/forestry/api/apiculture/bee/IBeeJubilance.java
index 928bb36fc2..902ed1337c 100644
--- a/src/main/java/forestry/api/apiculture/IBeeJubilance.java
+++ b/src/main/java/forestry/api/apiculture/bee/IBeeJubilance.java
@@ -1,6 +1,7 @@
-package forestry.api.apiculture;
+package forestry.api.apiculture.bee;
-import forestry.api.apiculture.genetics.IBeeSpecies;
+import forestry.api.apiculture.IBeeHousing;
+import forestry.api.apiculture.bee.IBeeSpecies;
import forestry.api.genetics.IGenome;
/**
diff --git a/src/main/java/forestry/api/apiculture/genetics/IBeeSpecies.java b/src/main/java/forestry/api/apiculture/bee/IBeeSpecies.java
similarity index 94%
rename from src/main/java/forestry/api/apiculture/genetics/IBeeSpecies.java
rename to src/main/java/forestry/api/apiculture/bee/IBeeSpecies.java
index 5db80ec841..2cd8e11ee9 100644
--- a/src/main/java/forestry/api/apiculture/genetics/IBeeSpecies.java
+++ b/src/main/java/forestry/api/apiculture/bee/IBeeSpecies.java
@@ -1,4 +1,4 @@
-package forestry.api.apiculture.genetics;
+package forestry.api.apiculture.bee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.HumidityType;
@@ -33,7 +33,7 @@ public interface IBeeSpecies extends ISpecies, IProductProducer, ISpecialt
* @param genome The genome of a bee of this species.
* @param housing The hive where the bee is working. Provides access to the bee's working environment.
* @return Whether this bee should produce its specialty products.
- * @see forestry.api.apiculture.IBeeJubilance
+ * @see IBeeJubilance
*/
boolean isJubilant(IGenome genome, IBeeHousing housing);
diff --git a/src/main/java/forestry/api/apiculture/genetics/IBeeSpeciesType.java b/src/main/java/forestry/api/apiculture/bee/IBeeSpeciesType.java
similarity index 83%
rename from src/main/java/forestry/api/apiculture/genetics/IBeeSpeciesType.java
rename to src/main/java/forestry/api/apiculture/bee/IBeeSpeciesType.java
index e49746ac1d..a8d71386b1 100644
--- a/src/main/java/forestry/api/apiculture/genetics/IBeeSpeciesType.java
+++ b/src/main/java/forestry/api/apiculture/bee/IBeeSpeciesType.java
@@ -1,20 +1,19 @@
-package forestry.api.apiculture.genetics;
+package forestry.api.apiculture.bee;
-import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.ISpeciesType;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.component.ResolvableProfile;
import net.minecraft.world.level.LevelAccessor;
import javax.annotation.Nullable;
-// todo reimplement beekeeping mode
public interface IBeeSpeciesType extends ISpeciesType {
/**
* @return {@link IApiaristTracker} associated with the passed world.
*/
@Override
- IApiaristTracker getBreedingTracker(LevelAccessor level, @Nullable GameProfile profile);
+ IApiaristTracker getBreedingTracker(LevelAccessor level, @Nullable @Nullable ResolvableProfile profile);
/**
* @return true if passed item is a drone. Equal to getLifeStage(ItemStack stack) == EnumBeeType.DRONE
diff --git a/src/main/java/forestry/api/apiculture/IFlowerType.java b/src/main/java/forestry/api/apiculture/bee/IFlowerType.java
similarity index 97%
rename from src/main/java/forestry/api/apiculture/IFlowerType.java
rename to src/main/java/forestry/api/apiculture/bee/IFlowerType.java
index 1de8226a38..7db6697019 100644
--- a/src/main/java/forestry/api/apiculture/IFlowerType.java
+++ b/src/main/java/forestry/api/apiculture/bee/IFlowerType.java
@@ -1,4 +1,4 @@
-package forestry.api.apiculture;
+package forestry.api.apiculture.bee;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.alleles.IRegistryAlleleValue;
diff --git a/src/main/java/forestry/api/apiculture/LightPreference.java b/src/main/java/forestry/api/apiculture/bee/LightPreference.java
similarity index 89%
rename from src/main/java/forestry/api/apiculture/LightPreference.java
rename to src/main/java/forestry/api/apiculture/bee/LightPreference.java
index 178747c9f7..3046621f3c 100644
--- a/src/main/java/forestry/api/apiculture/LightPreference.java
+++ b/src/main/java/forestry/api/apiculture/bee/LightPreference.java
@@ -1,4 +1,4 @@
-package forestry.api.apiculture;
+package forestry.api.apiculture.bee;
/**
* Used in {@link IActivityType} to determine whether a bee prefers high light levels or low light levels.
diff --git a/src/main/java/forestry/core/gui/buttons/package-info.java b/src/main/java/forestry/api/apiculture/bee/package-info.java
similarity index 53%
rename from src/main/java/forestry/core/gui/buttons/package-info.java
rename to src/main/java/forestry/api/apiculture/bee/package-info.java
index 4395437d7b..e391bd090e 100644
--- a/src/main/java/forestry/core/gui/buttons/package-info.java
+++ b/src/main/java/forestry/api/apiculture/bee/package-info.java
@@ -1,4 +1,4 @@
@javax.annotation.ParametersAreNonnullByDefault
-@forestry.core.utils.FieldsAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
@net.minecraft.MethodsReturnNonnullByDefault
-package forestry.core.gui.buttons;
+package forestry.api.apiculture.bee;
diff --git a/src/main/java/forestry/api/apiculture/genetics/package-info.java b/src/main/java/forestry/api/apiculture/genetics/package-info.java
deleted file mode 100644
index 908857db21..0000000000
--- a/src/main/java/forestry/api/apiculture/genetics/package-info.java
+++ /dev/null
@@ -1,7 +0,0 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
-package forestry.api.apiculture.genetics;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveDefinition.java b/src/main/java/forestry/api/apiculture/hives/IHiveDefinition.java
index 59994ea0d8..7409ce7779 100644
--- a/src/main/java/forestry/api/apiculture/hives/IHiveDefinition.java
+++ b/src/main/java/forestry/api/apiculture/hives/IHiveDefinition.java
@@ -17,7 +17,7 @@ public interface IHiveDefinition {
/**
* The hive generator for this hive.
*/
- IHiveGen getHiveGen();
+ IHivePlacement getHiveGen();
/**
* The hive block to be placed in the world.
diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveDrop.java b/src/main/java/forestry/api/apiculture/hives/IHiveDrop.java
index 23fcfee127..fe4f589d3a 100644
--- a/src/main/java/forestry/api/apiculture/hives/IHiveDrop.java
+++ b/src/main/java/forestry/api/apiculture/hives/IHiveDrop.java
@@ -1,6 +1,6 @@
package forestry.api.apiculture.hives;
-import forestry.api.apiculture.genetics.IBee;
+import forestry.api.apiculture.bee.IBee;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
@@ -8,7 +8,7 @@
import java.util.List;
/**
- * Represents an
+ * Represents a drop from a wild bee hive.
*/
public interface IHiveDrop {
IBee createIndividual(BlockGetter level, BlockPos pos);
diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveFrame.java b/src/main/java/forestry/api/apiculture/hives/IHiveFrame.java
index a61e6ed5fa..506d068ba0 100644
--- a/src/main/java/forestry/api/apiculture/hives/IHiveFrame.java
+++ b/src/main/java/forestry/api/apiculture/hives/IHiveFrame.java
@@ -2,11 +2,10 @@
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
-import forestry.api.apiculture.genetics.IBee;
+import forestry.api.apiculture.bee.IBee;
import net.minecraft.world.item.ItemStack;
public interface IHiveFrame {
-
/**
* Wears out a frame.
*
@@ -21,7 +20,6 @@ public interface IHiveFrame {
/**
* @param frame ItemStack containing the actual frame.
* @return the {@link IBeeModifier} for this frame.
- * @since Forestry 5.5.1
*/
IBeeModifier getBeeModifier(ItemStack frame);
}
diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveManager.java b/src/main/java/forestry/api/apiculture/hives/IHiveManager.java
index ece4209ba7..bc2c07f6a7 100644
--- a/src/main/java/forestry/api/apiculture/hives/IHiveManager.java
+++ b/src/main/java/forestry/api/apiculture/hives/IHiveManager.java
@@ -1,6 +1,7 @@
package forestry.api.apiculture.hives;
import com.google.common.collect.ImmutableList;
+import forestry.api.IForestryApi;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -11,6 +12,9 @@
import java.util.List;
+/**
+ * Contains data and factory methods related to bee hives. Obtain from {@link IForestryApi#getHiveManager()}.
+ */
public interface IHiveManager {
/**
* @return List of all registered hives.
diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveGen.java b/src/main/java/forestry/api/apiculture/hives/IHivePlacement.java
similarity index 96%
rename from src/main/java/forestry/api/apiculture/hives/IHiveGen.java
rename to src/main/java/forestry/api/apiculture/hives/IHivePlacement.java
index 2c9c7c068e..e29a8471ae 100644
--- a/src/main/java/forestry/api/apiculture/hives/IHiveGen.java
+++ b/src/main/java/forestry/api/apiculture/hives/IHivePlacement.java
@@ -10,9 +10,8 @@
/**
* Determines placement conditions for a naturally generated wild beehive.
- * todo 1.21.1 rename to IHivePlacement
*/
-public interface IHiveGen {
+public interface IHivePlacement {
/**
* @deprecated Use {@link #getPosForHive(WorldGenLevel, RandomSource, int, int)} with a world gen random instead.
*/
diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveTile.java b/src/main/java/forestry/api/apiculture/hives/IHiveTile.java
deleted file mode 100644
index 7e855f5292..0000000000
--- a/src/main/java/forestry/api/apiculture/hives/IHiveTile.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package forestry.api.apiculture.hives;
-
-import net.minecraft.core.BlockPos;
-import net.minecraft.world.entity.player.Player;
-import net.minecraft.world.level.Level;
-
-public interface IHiveTile {
- /**
- * Call to calm agitated bees. Used by the smoker to stop wild bees from attacking as much.
- * Bees will not stay calm for very long.
- */
- void calmBees();
-
- boolean isAngry();
-
- /**
- * Called when the hive is attacked.
- */
- void onAttack(Level world, BlockPos pos, Player player);
-
- /**
- * Called when the hive is broken.
- */
- void onBroken(Level world, BlockPos pos, Player player, boolean canHarvest);
-}
diff --git a/src/main/java/forestry/api/apiculture/hives/package-info.java b/src/main/java/forestry/api/apiculture/hives/package-info.java
index 4dc73792c9..6c120e6cb0 100644
--- a/src/main/java/forestry/api/apiculture/hives/package-info.java
+++ b/src/main/java/forestry/api/apiculture/hives/package-info.java
@@ -1,7 +1,7 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+/**
+ * Contains classes relating to wild bee hives and their generation.
+ */
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.apiculture.hives;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/apiculture/package-info.java b/src/main/java/forestry/api/apiculture/package-info.java
index 5b2f403cbd..a5a0b37340 100644
--- a/src/main/java/forestry/api/apiculture/package-info.java
+++ b/src/main/java/forestry/api/apiculture/package-info.java
@@ -1,7 +1,7 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+/**
+ * Contains all bee-related API, including bee species, beekeeping, wild bee hives, and more.
+ */
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.apiculture;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/arboriculture/ICharcoalManager.java b/src/main/java/forestry/api/arboriculture/ICharcoalManager.java
deleted file mode 100644
index e324c52e79..0000000000
--- a/src/main/java/forestry/api/arboriculture/ICharcoalManager.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package forestry.api.arboriculture;
-
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.state.BlockState;
-
-import javax.annotation.Nullable;
-import java.util.List;
-
-/**
- * Provides functions that are related to the forestry charcoal pile.
- */
-@Deprecated
-public interface ICharcoalManager {
- /**
- * Registers the given block as a valid block for the charcoal pile wall and adds the given charcoal amount to it.
- *
- * This method unlike {@link #registerWall(BlockState, int)} ignores the metadata of the actual block and
- * only compares the world block with the given block.
- *
- * @deprecated Use {@link forestry.api.plugin.IArboricultureRegistration#registerCharcoalPitWall}
- */
- @Deprecated(forRemoval = true)
- void registerWall(Block block, int amount);
-
- /**
- * Registers the given block as a valid block for the charcoal pile wall and adds the given charcoal amount to it.
- *
- * This method unlike {@link #registerWall(Block, int)} compares the world state with the given state and not
- * only the block.
- *
- * @deprecated Use {@link forestry.api.plugin.IArboricultureRegistration#registerCharcoalPitWall}
- */
- @Deprecated(forRemoval = true)
- void registerWall(BlockState blockState, int amount);
-
- /**
- * Registers your implementation of the {@link ICharcoalPileWall} interface.
- *
- * @deprecated Use {@link forestry.api.plugin.IArboricultureRegistration#registerCharcoalPitWall}
- */
- @Deprecated(forRemoval = true)
- void registerWall(ICharcoalPileWall wall);
-
- @Nullable
- ICharcoalPileWall getWall(BlockState state);
-
- /**
- * Remove a wall associated with the given block. Not guaranteed to work depending on how {@link ICharcoalPileWall} is implemented.
- * {@link #removeWall(BlockState)} is preferred.
- *
- * @return true if the wall was removed.
- * @deprecated Use {@link forestry.api.plugin.IArboricultureRegistration#registerCharcoalPitWall} and set to 0
- */
- @Deprecated(forRemoval = true)
- boolean removeWall(Block block);
-
- /**
- * Remove a wall that {@link ICharcoalPileWall#matches(BlockState)} the given blockstate.
- *
- * @param state the blockstate to remove.
- * @return true if the wall was removed.
- * @deprecated Use {@link forestry.api.plugin.IArboricultureRegistration#registerCharcoalPitWall} and set to 0
- */
- @Deprecated(forRemoval = true)
- boolean removeWall(BlockState state);
-
- /**
- * @return A collection with all registered charcoal pile walls.
- */
- List getWalls();
-}
diff --git a/src/main/java/forestry/api/arboriculture/ICharcoalPileWall.java b/src/main/java/forestry/api/arboriculture/ICharcoalPileWall.java
index b14197bf1e..4cfd8a088e 100644
--- a/src/main/java/forestry/api/arboriculture/ICharcoalPileWall.java
+++ b/src/main/java/forestry/api/arboriculture/ICharcoalPileWall.java
@@ -1,16 +1,14 @@
package forestry.api.arboriculture;
-import net.minecraft.core.NonNullList;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
-@Deprecated
-public interface ICharcoalPileWall {
+import java.util.List;
+public interface ICharcoalPileWall {
int getCharcoalAmount();
boolean matches(BlockState state);
- NonNullList getDisplayItems();
-
+ List getDisplayItems();
}
diff --git a/src/main/java/forestry/api/arboriculture/ITreeGenData.java b/src/main/java/forestry/api/arboriculture/ITreeGenData.java
deleted file mode 100644
index 367e61f96b..0000000000
--- a/src/main/java/forestry/api/arboriculture/ITreeGenData.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package forestry.api.arboriculture;
-
-import forestry.api.genetics.IGenome;
-import net.minecraft.core.BlockPos;
-import net.minecraft.core.Direction;
-import net.minecraft.util.RandomSource;
-import net.minecraft.world.level.LevelAccessor;
-
-import javax.annotation.Nullable;
-
-public interface ITreeGenData {
- int getGirth(IGenome genome);
-
- float getHeightModifier(IGenome genome);
-
- /**
- * @return Position that this tree can grow, or {@code null} if it cannot grow. May be different from pos if there are multiple saplings.
- */
- @Nullable
- BlockPos getGrowthPos(IGenome genome, LevelAccessor level, BlockPos pos, int expectedGirth, int expectedHeight);
-
- /**
- * Places a leaf block for this species with genetic data included.
- *
- * @param genome The genome to use for the leaves.
- * @param level The level.
- * @param pos The position to set the leaves at.
- * @param random Random number generation.
- * @param convertBlockEntity If {@code true}, ALWAYS use a block entity even if a "default" block can be used.
- * @return {@code true} if the leaf block was placed.
- */
- boolean setLeaves(IGenome genome, LevelAccessor level, BlockPos pos, RandomSource random, boolean convertBlockEntity);
-
- boolean setLogBlock(IGenome genome, LevelAccessor level, BlockPos pos, Direction facing);
-
- boolean allowsFruitBlocks(IGenome genome);
-
- boolean trySpawnFruitBlock(LevelAccessor level, RandomSource rand, BlockPos pos);
-
- IGenome getDefaultGenome();
-}
diff --git a/src/main/java/forestry/api/arboriculture/ITreeGenerator.java b/src/main/java/forestry/api/arboriculture/ITreeGenerator.java
index cfb30a0207..5a3cec4328 100644
--- a/src/main/java/forestry/api/arboriculture/ITreeGenerator.java
+++ b/src/main/java/forestry/api/arboriculture/ITreeGenerator.java
@@ -1,5 +1,6 @@
package forestry.api.arboriculture;
+import forestry.api.arboriculture.genetics.ITreeSpecies;
import forestry.api.genetics.IGenome;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -12,7 +13,7 @@
* Implements the tree generation for a tree species.
*/
public interface ITreeGenerator {
- Feature getTreeFeature(ITreeGenData tree);
+ Feature getTreeFeature(ITreeSpecies tree);
boolean setLogBlock(IGenome genome, LevelAccessor level, BlockPos pos, Direction facing);
diff --git a/src/main/java/forestry/api/arboriculture/ITreeManager.java b/src/main/java/forestry/api/arboriculture/ITreeManager.java
index 72c5de4df3..c492fc0515 100644
--- a/src/main/java/forestry/api/arboriculture/ITreeManager.java
+++ b/src/main/java/forestry/api/arboriculture/ITreeManager.java
@@ -1,8 +1,11 @@
package forestry.api.arboriculture;
import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
import javax.annotation.Nullable;
+import java.util.Collection;
+import java.util.List;
/**
* @since 2.6.0
@@ -17,9 +20,15 @@ public interface ITreeManager {
Block getRefractoryWaxed(Block block);
/**
- * This getter will be replaced by separate methods in 1.21, as ICharcoalManager will be removed
+ * @return Read-only view of all registered charcoal pit wall types.
*/
- ICharcoalManager getCharcoalManager();
+ List getWalls();
+
+ /**
+ * @return Information about the block in a charcoal pit wall, {@code null} if not a valid charcoal pit wall.
+ */
+ @Nullable
+ ICharcoalPileWall getWall(BlockState state);
IWoodAccess getWoodAccess();
}
diff --git a/src/main/java/forestry/api/arboriculture/IWoodAccess.java b/src/main/java/forestry/api/arboriculture/IWoodAccess.java
index beae910376..21024f0894 100644
--- a/src/main/java/forestry/api/arboriculture/IWoodAccess.java
+++ b/src/main/java/forestry/api/arboriculture/IWoodAccess.java
@@ -26,14 +26,8 @@ public interface IWoodAccess {
BlockState getBlock(IWoodType woodType, WoodBlockKind kind, boolean fireproof);
- /**
- * @since 2.6.0
- */
- TagKey getLogBlockTag(IWoodType kind, boolean fireproof);
+ TagKey getLogBlockTag(IWoodType type, boolean fireproof);
- /**
- * @since 2.6.0
- */
TagKey getLogItemTag(IWoodType kind, boolean fireproof);
List getRegisteredWoodTypes();
diff --git a/src/main/java/forestry/api/arboriculture/TreeManager.java b/src/main/java/forestry/api/arboriculture/TreeManager.java
deleted file mode 100644
index 150c0a8958..0000000000
--- a/src/main/java/forestry/api/arboriculture/TreeManager.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package forestry.api.arboriculture;
-
-import forestry.api.IForestryApi;
-
-/**
- * @deprecated Use {@link IForestryApi#getTreeManager}
- */
-@Deprecated(forRemoval = true)
-public class TreeManager {
- /**
- * Convenient access to wood items.
- *
- * @deprecated Use {@link ITreeManager#getWoodAccess}
- */
- @Deprecated(forRemoval = true)
- public static IWoodAccess woodAccess;
-
- /**
- * Can be used to add new charcoal pile walls.
- *
- * @deprecated Use {@link ITreeManager#getCharcoalManager}
- */
- @Deprecated(forRemoval = true)
- public static ICharcoalManager charcoalManager;
-}
diff --git a/src/main/java/forestry/api/arboriculture/genetics/IFruit.java b/src/main/java/forestry/api/arboriculture/genetics/IFruit.java
index 1a899532f6..f3af498710 100644
--- a/src/main/java/forestry/api/arboriculture/genetics/IFruit.java
+++ b/src/main/java/forestry/api/arboriculture/genetics/IFruit.java
@@ -8,20 +8,18 @@
import forestry.api.genetics.alleles.TreeChromosomes;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.tags.BlockTags;
-import net.minecraft.tags.TagKey;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
-import net.minecraft.world.level.block.Block;
import javax.annotation.Nullable;
import java.util.List;
/**
- * Provides all information that is needed to spawn a fruit leaves / pod block in the world.
+ * Provides all information that is needed to spawn a fruit leaves in the world.
+ * If your fruit is a pod fruit, like Cocoa, Dates, or Papaya, use the more sensitive {@link IPodFruit}.
*/
public interface IFruit extends IRegistryAlleleValue, IProductProducer, ISpecialtyProducer {
/**
@@ -30,7 +28,7 @@ public interface IFruit extends IRegistryAlleleValue, IProductProducer, ISpecial
* @param genome The genome of the tree of the pod / leaves block.
* @param ripeningTime The ripening time of the leaves / pod block. From 0 to {@link #getRipeningPeriod()}.
*/
- int getColour(IGenome genome, BlockGetter world, BlockPos pos, int ripeningTime);
+ int getColour(IGenome genome, BlockGetter level, BlockPos pos, int ripeningTime);
/**
* return the color to use for decorative leaves. Usually the ripe color.
@@ -85,34 +83,10 @@ default List getSpecialties() {
* @return ResourceLocation of the texture to overlay on the leaf block.
*/
@Nullable
- ResourceLocation getSprite(IGenome genome, BlockGetter world, BlockPos pos, int ripeningTime);
+ ResourceLocation getSprite(IGenome genome, BlockGetter level, BlockPos pos, int ripeningTime);
@Nullable
default ResourceLocation getDecorativeSprite() {
return null;
}
-
- /**
- * @return true if this fruit provider requires fruit blocks to spawn, false otherwise.
- */
- boolean requiresFruitBlocks();
-
- /**
- * Tries to spawn a fruit block at the potential position when the tree generates.
- * Spawning a fruit has a random chance of success based on {@link TreeChromosomes#SAPPINESS}.
- *
- * @return true if a fruit block was spawned, false otherwise.
- */
- boolean trySpawnFruitBlock(IGenome genome, LevelAccessor world, RandomSource rand, BlockPos pos);
-
- // Replaced with atlas JSONs pointing to the BLOCK atlas.
- //default void registerSprites(TextureStitchEvent.Pre event) {
- //}
-
- /**
- * Tag for the log that a pod fruit is placed on
- */
- default TagKey getLogTag() {
- return BlockTags.JUNGLE_LOGS;
- }
}
diff --git a/src/main/java/forestry/api/arboriculture/genetics/IPodFruit.java b/src/main/java/forestry/api/arboriculture/genetics/IPodFruit.java
new file mode 100644
index 0000000000..71c3897277
--- /dev/null
+++ b/src/main/java/forestry/api/arboriculture/genetics/IPodFruit.java
@@ -0,0 +1,26 @@
+package forestry.api.arboriculture.genetics;
+
+import forestry.api.genetics.IGenome;
+import net.minecraft.core.BlockPos;
+import net.minecraft.world.level.LevelAccessor;
+import net.minecraft.world.level.block.state.BlockState;
+
+/**
+ * Use this interface if your fruit is a pod, like Cocoa, Dates, or Papaya.
+ */
+public interface IPodFruit extends IFruit {
+ /**
+ * @return Whether this pod fruit can hang off of the given block, ex. Cocoa can only hang off of Jungle logs
+ */
+ boolean canSurviveOn(BlockState state);
+
+ /**
+ * Attempts to place the pod fruit into the world.
+ *
+ * @param level The world to place the pod fruit in.
+ * @param pos The position to place the pod fruit at.
+ * @param genome The genome of the tree whose fruit is being placed.
+ * @return {@code true} if the placement was successful, {@code false} if the position was not valid for the pod.
+ */
+ boolean tryPlace(LevelAccessor level, BlockPos pos, IGenome genome);
+}
diff --git a/src/main/java/forestry/api/arboriculture/genetics/ITree.java b/src/main/java/forestry/api/arboriculture/genetics/ITree.java
index 3a919f93c1..d951a14e5f 100644
--- a/src/main/java/forestry/api/arboriculture/genetics/ITree.java
+++ b/src/main/java/forestry/api/arboriculture/genetics/ITree.java
@@ -1,7 +1,6 @@
package forestry.api.arboriculture.genetics;
import com.mojang.authlib.GameProfile;
-import forestry.api.arboriculture.ITreeSpecies;
import forestry.api.core.IProductProducer;
import forestry.api.core.ISpecialtyProducer;
import forestry.api.genetics.IEffectData;
diff --git a/src/main/java/forestry/api/arboriculture/genetics/ITreeEffect.java b/src/main/java/forestry/api/arboriculture/genetics/ITreeEffect.java
index 844c87a209..56f52a0c1c 100644
--- a/src/main/java/forestry/api/arboriculture/genetics/ITreeEffect.java
+++ b/src/main/java/forestry/api/arboriculture/genetics/ITreeEffect.java
@@ -1,6 +1,6 @@
package forestry.api.arboriculture.genetics;
-import forestry.api.apiculture.genetics.IEffect;
+import forestry.api.core.IEffect;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.alleles.IRegistryAlleleValue;
diff --git a/src/main/java/forestry/api/arboriculture/ITreeSpecies.java b/src/main/java/forestry/api/arboriculture/genetics/ITreeSpecies.java
similarity index 56%
rename from src/main/java/forestry/api/arboriculture/ITreeSpecies.java
rename to src/main/java/forestry/api/arboriculture/genetics/ITreeSpecies.java
index f4b376abb9..2095e08abb 100644
--- a/src/main/java/forestry/api/arboriculture/ITreeSpecies.java
+++ b/src/main/java/forestry/api/arboriculture/genetics/ITreeSpecies.java
@@ -1,22 +1,27 @@
-package forestry.api.arboriculture;
+package forestry.api.arboriculture.genetics;
+import forestry.api.arboriculture.ITreeGenerator;
import forestry.api.arboriculture.genetics.ITree;
import forestry.api.arboriculture.genetics.ITreeSpeciesType;
import forestry.api.core.HumidityType;
import forestry.api.core.IProductProducer;
import forestry.api.core.ISpecialtyProducer;
import forestry.api.core.TemperatureType;
+import forestry.api.genetics.IGenome;
import forestry.api.genetics.ILifeStage;
import forestry.api.genetics.ISpecies;
import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction;
+import net.minecraft.util.RandomSource;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
+import javax.annotation.Nullable;
import java.util.List;
-public interface ITreeSpecies extends ISpecies, ITreeGenData, IProductProducer, ISpecialtyProducer {
+public interface ITreeSpecies extends ISpecies, IProductProducer, ISpecialtyProducer {
@Override
ITreeSpeciesType getType();
@@ -62,4 +67,30 @@ public interface ITreeSpecies extends ISpecies, ITreeGenData, IProductPro
* @return {@code true} if this is a leaves block with fruit on it, false otherwise.
*/
boolean isFruitLeaf(LevelAccessor level, BlockPos pos);
+
+ int getGirth(IGenome genome);
+
+ float getHeightModifier(IGenome genome);
+
+ /**
+ * @return Position that this tree can grow, or {@code null} if it cannot grow. May be different from pos if there are multiple saplings.
+ */
+ @Nullable
+ BlockPos getGrowthPos(IGenome genome, LevelAccessor level, BlockPos pos, int expectedGirth, int expectedHeight);
+
+ /**
+ * Places a leaf block for this species with genetic data included.
+ *
+ * @param genome The genome to use for the leaves.
+ * @param level The level.
+ * @param pos The position to set the leaves at.
+ * @param random Random number generation.
+ * @param convertBlockEntity If {@code true}, ALWAYS use a block entity even if a "default" block can be used.
+ * @return {@code true} if the leaf block was placed.
+ */
+ boolean setLeaves(IGenome genome, LevelAccessor level, BlockPos pos, RandomSource random, boolean convertBlockEntity);
+
+ boolean setLogBlock(IGenome genome, LevelAccessor level, BlockPos pos, Direction facing);
+
+ void trySpawnFruitPod(LevelAccessor level, RandomSource rand, BlockPos pos);
}
diff --git a/src/main/java/forestry/api/arboriculture/genetics/ITreeSpeciesType.java b/src/main/java/forestry/api/arboriculture/genetics/ITreeSpeciesType.java
index 347f5f27f9..be185ab4d6 100644
--- a/src/main/java/forestry/api/arboriculture/genetics/ITreeSpeciesType.java
+++ b/src/main/java/forestry/api/arboriculture/genetics/ITreeSpeciesType.java
@@ -3,11 +3,11 @@
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.IArboristTracker;
import forestry.api.arboriculture.ILeafTickHandler;
-import forestry.api.arboriculture.ITreeSpecies;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.ISpeciesType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.Item;
+import net.minecraft.world.item.component.ResolvableProfile;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -15,10 +15,11 @@
import javax.annotation.Nullable;
import java.util.Collection;
+import java.util.Map;
public interface ITreeSpeciesType extends ISpeciesType {
@Override
- IArboristTracker getBreedingTracker(LevelAccessor level, @Nullable GameProfile profile);
+ IArboristTracker getBreedingTracker(LevelAccessor level, @Nullable @Nullable ResolvableProfile profile);
/**
* Register a leaf random tick handler. Used for butterfly spawner.
@@ -37,8 +38,6 @@ public interface ITreeSpeciesType extends ISpeciesType {
boolean plantSapling(Level level, ITree tree, GameProfile owner, BlockPos pos);
- boolean setFruitBlock(LevelAccessor level, IGenome genome, IFruit fruit, float yield, BlockPos pos);
-
/**
* Tries to get genetic information of a species from a mundane/vanilla block, like from Oak Leaves to Apple Oak Leaves.
* Does not affect the block in the world, just returns an individual.
@@ -58,4 +57,6 @@ public interface ITreeSpeciesType extends ISpeciesType {
*/
@Nullable
ITree getVanillaIndividual(Item item);
+
+ Map getAllVanillaIndividuals();
}
diff --git a/src/main/java/forestry/api/arboriculture/genetics/package-info.java b/src/main/java/forestry/api/arboriculture/genetics/package-info.java
index b0d8a2b58b..c3f56c0ce4 100644
--- a/src/main/java/forestry/api/arboriculture/genetics/package-info.java
+++ b/src/main/java/forestry/api/arboriculture/genetics/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.arboriculture.genetics;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/arboriculture/package-info.java b/src/main/java/forestry/api/arboriculture/package-info.java
index aafff0133a..299bacb21d 100644
--- a/src/main/java/forestry/api/arboriculture/package-info.java
+++ b/src/main/java/forestry/api/arboriculture/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.arboriculture;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/circuits/CircuitLayout.java b/src/main/java/forestry/api/circuits/CircuitLayout.java
new file mode 100644
index 0000000000..4683551700
--- /dev/null
+++ b/src/main/java/forestry/api/circuits/CircuitLayout.java
@@ -0,0 +1,32 @@
+package forestry.api.circuits;
+
+import com.mojang.serialization.Codec;
+import com.mojang.serialization.codecs.RecordCodecBuilder;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
+import net.minecraft.resources.ResourceLocation;
+
+/**
+ * @param id Unique ID for this circuit layout
+ * @param socketType Specifies where a circuit layout is used
+ */
+public record CircuitLayout(String id, ResourceLocation socketType) {
+ public static final Codec CODEC = RecordCodecBuilder.create(inst -> inst.group(
+ Codec.STRING.fieldOf("id").forGetter(CircuitLayout::id),
+ ResourceLocation.CODEC.fieldOf("socket_type").forGetter(CircuitLayout::socketType)
+ ).apply(inst, CircuitLayout::new));
+
+ /**
+ * @return localized name for this circuit layout
+ */
+ public MutableComponent getName() {
+ return Component.translatable("circuit.layout." + this.id);
+ }
+
+ /**
+ * @return localized string for how this circuit layout is used
+ */
+ public MutableComponent getUsage() {
+ return Component.translatable("circuit.layout." + this.id + ".usage");
+ }
+}
diff --git a/src/main/java/forestry/api/circuits/ICircuit.java b/src/main/java/forestry/api/circuits/ICircuit.java
index a81240766c..20e6c37df2 100644
--- a/src/main/java/forestry/api/circuits/ICircuit.java
+++ b/src/main/java/forestry/api/circuits/ICircuit.java
@@ -1,10 +1,14 @@
package forestry.api.circuits;
+import com.mojang.serialization.Codec;
+import forestry.api.ForestryRegistries;
import net.minecraft.network.chat.Component;
import java.util.List;
public interface ICircuit {
+ Codec CODEC = ForestryRegistries.CIRCUIT.byNameCodec();
+
String getId();
String getTranslationKey();
diff --git a/src/main/java/forestry/api/circuits/ICircuitBoard.java b/src/main/java/forestry/api/circuits/ICircuitBoard.java
index 920a2dfae8..c39f54f25d 100644
--- a/src/main/java/forestry/api/circuits/ICircuitBoard.java
+++ b/src/main/java/forestry/api/circuits/ICircuitBoard.java
@@ -1,15 +1,14 @@
package forestry.api.circuits;
-import forestry.api.core.INbtWritable;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
+import net.neoforged.api.distmarker.Dist;
+import net.neoforged.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
import java.util.List;
-public interface ICircuitBoard extends INbtWritable {
+public interface ICircuitBoard {
@OnlyIn(Dist.CLIENT)
int getPrimaryColor();
@@ -27,7 +26,7 @@ public interface ICircuitBoard extends INbtWritable {
void onTick(Object tile);
- ICircuit[] getCircuits();
+ List getCircuits();
/**
* Specifies where a circuit can be used.
diff --git a/src/main/java/forestry/api/circuits/ICircuitLayout.java b/src/main/java/forestry/api/circuits/ICircuitLayout.java
deleted file mode 100644
index 0eac697205..0000000000
--- a/src/main/java/forestry/api/circuits/ICircuitLayout.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package forestry.api.circuits;
-
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.MutableComponent;
-import net.minecraft.resources.ResourceLocation;
-
-public interface ICircuitLayout {
- /**
- * unique ID for this circuit layout
- */
- String getId();
-
- /**
- * localized name for this circuit layout
- */
- Component getName();
-
- /**
- * localized string for how this circuit layout is used
- */
- MutableComponent getUsage();
-
- /**
- * Specifies where a circuit layout is used.
- */
- ResourceLocation getSocketType();
-}
diff --git a/src/main/java/forestry/api/circuits/ICircuitLibrary.java b/src/main/java/forestry/api/circuits/ICircuitLibrary.java
deleted file mode 100644
index 1f38d6ccea..0000000000
--- a/src/main/java/forestry/api/circuits/ICircuitLibrary.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package forestry.api.circuits;
-
-public interface ICircuitLibrary {
-
-}
diff --git a/src/main/java/forestry/api/circuits/ICircuitManager.java b/src/main/java/forestry/api/circuits/ICircuitManager.java
index a101c00c60..886134134a 100644
--- a/src/main/java/forestry/api/circuits/ICircuitManager.java
+++ b/src/main/java/forestry/api/circuits/ICircuitManager.java
@@ -14,7 +14,7 @@ public interface ICircuitManager {
/**
* @return A collection of all registered circuit layouts.
*/
- List getLayouts();
+ List getLayouts();
/**
* Retrieves the item's circuit for the given circuit layout, or null if this item is not applicable for the layout.
@@ -24,22 +24,13 @@ public interface ICircuitManager {
* @return The circuit associated with the circuit layout and item, or {@code null} if this item doesn't work for the circuit layout.
*/
@Nullable
- ICircuit getCircuit(ICircuitLayout layout, ItemStack stack);
-
- @Nullable
- ICircuit getCircuit(String circuitId);
+ ICircuit getCircuit(CircuitLayout layout, ItemStack stack);
/**
* @return The circuit layout with the given ID, or {@code null} if none was registered with that ID.
*/
@Nullable
- ICircuitLayout getLayout(String layoutId);
-
- /**
- * @return The circuit board stored in this item's NBT, {@code null} if this item has no NBT or is not a chipset.
- */
- @Nullable
- ICircuitBoard getCircuitBoard(ItemStack stack);
+ CircuitLayout getLayout(String layoutId);
/**
* Note: Currently hardcoded to Forestry circuit board.
diff --git a/src/main/java/forestry/api/circuits/package-info.java b/src/main/java/forestry/api/circuits/package-info.java
index 321b3e0c78..3ebef8e512 100644
--- a/src/main/java/forestry/api/circuits/package-info.java
+++ b/src/main/java/forestry/api/circuits/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.circuits;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/client/IClientModuleHandler.java b/src/main/java/forestry/api/client/IClientModuleHandler.java
index 554e417b0b..05ca81e413 100644
--- a/src/main/java/forestry/api/client/IClientModuleHandler.java
+++ b/src/main/java/forestry/api/client/IClientModuleHandler.java
@@ -1,6 +1,6 @@
package forestry.api.client;
-import net.minecraftforge.eventbus.api.IEventBus;
+import net.neoforged.bus.api.IEventBus;
/**
* Used to separate client-only code and events from a {@link forestry.api.modules.IForestryModule}.
diff --git a/src/main/java/forestry/api/client/apiculture/IBeeClientManager.java b/src/main/java/forestry/api/client/apiculture/IBeeClientManager.java
index 6d52cc1042..f1a34aa5eb 100644
--- a/src/main/java/forestry/api/client/apiculture/IBeeClientManager.java
+++ b/src/main/java/forestry/api/client/apiculture/IBeeClientManager.java
@@ -1,6 +1,6 @@
package forestry.api.client.apiculture;
-import forestry.api.apiculture.genetics.IBeeSpecies;
+import forestry.api.apiculture.bee.IBeeSpecies;
import forestry.api.genetics.ILifeStage;
import net.minecraft.resources.ResourceLocation;
diff --git a/src/main/java/forestry/api/client/apiculture/package-info.java b/src/main/java/forestry/api/client/apiculture/package-info.java
index 8ed743928c..26cb74f8e4 100644
--- a/src/main/java/forestry/api/client/apiculture/package-info.java
+++ b/src/main/java/forestry/api/client/apiculture/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.client.apiculture;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/client/arboriculture/ITreeClientManager.java b/src/main/java/forestry/api/client/arboriculture/ITreeClientManager.java
index aec2b7ef60..79c4eea8c6 100644
--- a/src/main/java/forestry/api/client/arboriculture/ITreeClientManager.java
+++ b/src/main/java/forestry/api/client/arboriculture/ITreeClientManager.java
@@ -1,7 +1,7 @@
package forestry.api.client.arboriculture;
import com.mojang.datafixers.util.Pair;
-import forestry.api.arboriculture.ITreeSpecies;
+import forestry.api.arboriculture.genetics.ITreeSpecies;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
diff --git a/src/main/java/forestry/api/client/arboriculture/package-info.java b/src/main/java/forestry/api/client/arboriculture/package-info.java
index 2da3d1e1b4..83111062ff 100644
--- a/src/main/java/forestry/api/client/arboriculture/package-info.java
+++ b/src/main/java/forestry/api/client/arboriculture/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.client.arboriculture;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/client/lepidopterology/package-info.java b/src/main/java/forestry/api/client/lepidopterology/package-info.java
index 24c8f63391..54f680ba2f 100644
--- a/src/main/java/forestry/api/client/lepidopterology/package-info.java
+++ b/src/main/java/forestry/api/client/lepidopterology/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.client.lepidopterology;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/client/package-info.java b/src/main/java/forestry/api/client/package-info.java
index e2918d0da8..c34970a062 100644
--- a/src/main/java/forestry/api/client/package-info.java
+++ b/src/main/java/forestry/api/client/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.client;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/client/plugin/package-info.java b/src/main/java/forestry/api/client/plugin/package-info.java
index ee3c432072..b45eb0c5e1 100644
--- a/src/main/java/forestry/api/client/plugin/package-info.java
+++ b/src/main/java/forestry/api/client/plugin/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.client.plugin;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/climate/IBiomeProvider.java b/src/main/java/forestry/api/climate/IBiomeProvider.java
index 339c546849..806f4cb1d4 100644
--- a/src/main/java/forestry/api/climate/IBiomeProvider.java
+++ b/src/main/java/forestry/api/climate/IBiomeProvider.java
@@ -1,6 +1,7 @@
package forestry.api.climate;
import net.minecraft.core.Holder;
+import net.minecraft.core.HolderLookup;
import net.minecraft.world.level.biome.Biome;
/**
@@ -10,5 +11,5 @@ public interface IBiomeProvider {
/**
* @return The biome the object that implements this interface is located in.
*/
- Holder getBiome();
+ Holder getBiome(HolderLookup.Provider registries);
}
diff --git a/src/main/java/forestry/api/climate/package-info.java b/src/main/java/forestry/api/climate/package-info.java
index 3f86197bf8..d1dfb4bf73 100644
--- a/src/main/java/forestry/api/climate/package-info.java
+++ b/src/main/java/forestry/api/climate/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.climate;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/core/utils/FieldsAreNonnullByDefault.java b/src/main/java/forestry/api/core/FieldsAreNonnullByDefault.java
similarity index 92%
rename from src/main/java/forestry/core/utils/FieldsAreNonnullByDefault.java
rename to src/main/java/forestry/api/core/FieldsAreNonnullByDefault.java
index bd12f6ef25..6f98302b75 100644
--- a/src/main/java/forestry/core/utils/FieldsAreNonnullByDefault.java
+++ b/src/main/java/forestry/api/core/FieldsAreNonnullByDefault.java
@@ -1,4 +1,4 @@
-package forestry.core.utils;
+package forestry.api.core;
import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
diff --git a/src/main/java/forestry/api/core/ForestryEvent.java b/src/main/java/forestry/api/core/ForestryEvent.java
deleted file mode 100644
index 772fd2f7f6..0000000000
--- a/src/main/java/forestry/api/core/ForestryEvent.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package forestry.api.core;
-
-import com.mojang.authlib.GameProfile;
-import forestry.api.apiculture.IBeeHousing;
-import forestry.api.apiculture.genetics.IBee;
-import forestry.api.genetics.IBreedingTracker;
-import forestry.api.genetics.IMutation;
-import forestry.api.genetics.ISpecies;
-import forestry.api.genetics.ISpeciesType;
-import net.minecraft.world.entity.player.Player;
-import net.minecraftforge.eventbus.api.Cancelable;
-import net.minecraftforge.eventbus.api.Event;
-import org.jetbrains.annotations.ApiStatus;
-
-// todo move to forestry.api.event
-public abstract class ForestryEvent extends Event {
- /**
- * Supertype for events concerning breeding and mutation.
- */
- @ApiStatus.Internal
- private static abstract class BreedingEvent extends ForestryEvent {
- public final ISpeciesType, ?> root;
- public final IBreedingTracker tracker;
- public final GameProfile username;
-
- private BreedingEvent(ISpeciesType, ?> root, GameProfile username, IBreedingTracker tracker) {
- this.root = root;
- this.username = username;
- this.tracker = tracker;
- }
- }
-
- /**
- * Fired before a queen is created as a result of breeding a princess and a drone.
- *
- * @since 2.4.4
- */
- @Cancelable
- public static class BeeMatingEvent extends ForestryEvent {
- private final IBeeHousing housing;
- private IBee princess;
- private final IBee drone;
-
- public BeeMatingEvent(IBeeHousing housing, IBee princess, IBee drone) {
- this.housing = housing;
- this.princess = princess;
- this.drone = drone;
- }
-
- public IBeeHousing getHousing() {
- return this.housing;
- }
-
- public IBee getPrincess() {
- return this.princess;
- }
-
- /**
- * Used to override the princess individual, which will become the queen individual.
- *
- * @param princess The new princess individual to replace the queen with.
- */
- public void setPrincess(IBee princess) {
- this.princess = princess;
- }
-
- public IBee getDrone() {
- return this.drone;
- }
- }
-
- public static class SpeciesDiscovered extends BreedingEvent {
- public final ISpecies> species;
-
- public SpeciesDiscovered(ISpeciesType, ?> root, GameProfile username, ISpecies> species, IBreedingTracker tracker) {
- super(root, username, tracker);
- this.species = species;
- }
- }
-
- public static class MutationDiscovered extends BreedingEvent {
- public final IMutation> allele;
-
- public MutationDiscovered(ISpeciesType, ?> root, GameProfile username, IMutation> allele, IBreedingTracker tracker) {
- super(root, username, tracker);
- this.allele = allele;
- }
- }
-
- public static class SyncedBreedingTracker extends ForestryEvent {
- public final IBreedingTracker tracker;
- public final Player player;
-
- public SyncedBreedingTracker(IBreedingTracker tracker, Player player) {
- this.tracker = tracker;
- this.player = player;
- }
- }
-}
diff --git a/src/main/java/forestry/api/apiculture/genetics/IEffect.java b/src/main/java/forestry/api/core/IEffect.java
similarity index 92%
rename from src/main/java/forestry/api/apiculture/genetics/IEffect.java
rename to src/main/java/forestry/api/core/IEffect.java
index 91b58e8599..0c64b9df4e 100644
--- a/src/main/java/forestry/api/apiculture/genetics/IEffect.java
+++ b/src/main/java/forestry/api/core/IEffect.java
@@ -1,4 +1,4 @@
-package forestry.api.apiculture.genetics;
+package forestry.api.core;
import forestry.api.genetics.IEffectData;
diff --git a/src/main/java/forestry/api/core/IFeatureSubtype.java b/src/main/java/forestry/api/core/IFeatureSubtype.java
index 8f9b969bc7..4d83fdc719 100644
--- a/src/main/java/forestry/api/core/IFeatureSubtype.java
+++ b/src/main/java/forestry/api/core/IFeatureSubtype.java
@@ -1,6 +1,8 @@
package forestry.api.core;
-import net.minecraft.util.StringRepresentable;
-
-public interface IFeatureSubtype extends StringRepresentable {
+public interface IFeatureSubtype {
+ /**
+ * @return The identifier associated with this subtype, without any group prefix or suffix (ex. vintage for comb_vintage)
+ */
+ String identifier();
}
diff --git a/src/main/java/forestry/api/core/ILocationProvider.java b/src/main/java/forestry/api/core/ILocationProvider.java
index 65af8c5d6b..aca7cdda31 100644
--- a/src/main/java/forestry/api/core/ILocationProvider.java
+++ b/src/main/java/forestry/api/core/ILocationProvider.java
@@ -7,13 +7,10 @@
/**
* Interface for things, that have a location.
- * Must not be named "getWorld" and "getPos" to avoid
- * SpecialSource issue https://github.com/md-5/SpecialSource/issues/12
- * TODO rename to getBlockPos, getLevel in 1.21
*/
public interface ILocationProvider {
- BlockPos getCoordinates();
+ BlockPos getBlockPos();
@Nullable
- Level getWorldObj();
+ Level getLevel();
}
diff --git a/src/main/java/forestry/api/core/INbtReadable.java b/src/main/java/forestry/api/core/INbtReadable.java
index 6a382c08d0..f9d0b35097 100644
--- a/src/main/java/forestry/api/core/INbtReadable.java
+++ b/src/main/java/forestry/api/core/INbtReadable.java
@@ -1,7 +1,8 @@
package forestry.api.core;
+import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
public interface INbtReadable {
- void read(CompoundTag nbt);
+ void read(CompoundTag nbt, HolderLookup.Provider registries);
}
diff --git a/src/main/java/forestry/api/core/INbtWritable.java b/src/main/java/forestry/api/core/INbtWritable.java
index 4c4c5290d4..80654e5323 100644
--- a/src/main/java/forestry/api/core/INbtWritable.java
+++ b/src/main/java/forestry/api/core/INbtWritable.java
@@ -1,7 +1,8 @@
package forestry.api.core;
+import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
public interface INbtWritable {
- CompoundTag write(CompoundTag nbt);
+ CompoundTag write(CompoundTag nbt, HolderLookup.Provider registries);
}
diff --git a/src/main/java/forestry/api/core/IProduct.java b/src/main/java/forestry/api/core/IProduct.java
index 5c5fe0ffc1..3506395df4 100644
--- a/src/main/java/forestry/api/core/IProduct.java
+++ b/src/main/java/forestry/api/core/IProduct.java
@@ -1,6 +1,7 @@
package forestry.api.core;
import it.unimi.dsi.fastutil.Hash;
+import net.minecraft.core.Holder;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -29,8 +30,6 @@ public boolean equals(@Nullable IProduct a, @Nullable IProduct b) {
}
};
- // todo should this be replaced with is(ItemStack) and getIconStack() methods instead?
-
/**
* Gets the item this product contains. In the case of a dynamic product, return an item that might
* be used to display it in a screen or for equality purposes in {@link #ITEM_ONLY_STRATEGY}.
@@ -39,6 +38,13 @@ public boolean equals(@Nullable IProduct a, @Nullable IProduct b) {
*/
Item item();
+ /**
+ * @return The holder if the item this product contains, just like {@link #item}.
+ */
+ default Holder itemHolder() {
+ return item().builtInRegistryHolder();
+ }
+
/**
* @return The set chance of this product being produced.
*/
diff --git a/src/main/java/forestry/api/core/ISpecialtyProducer.java b/src/main/java/forestry/api/core/ISpecialtyProducer.java
index 2ded217004..fe648da06e 100644
--- a/src/main/java/forestry/api/core/ISpecialtyProducer.java
+++ b/src/main/java/forestry/api/core/ISpecialtyProducer.java
@@ -1,10 +1,12 @@
package forestry.api.core;
+import forestry.api.apiculture.bee.IBeeJubilance;
+
import java.util.List;
/**
* Denotes a species that can produce "specialty" products when in a jubilant state,
- * as described by {@link forestry.api.apiculture.IBeeJubilance} or something similar.
+ * as described by {@link IBeeJubilance} or something similar.
*/
public interface ISpecialtyProducer {
/**
diff --git a/src/main/java/forestry/api/core/IArmorNaturalist.java b/src/main/java/forestry/api/core/ISpectacleVision.java
similarity index 88%
rename from src/main/java/forestry/api/core/IArmorNaturalist.java
rename to src/main/java/forestry/api/core/ISpectacleVision.java
index bccabc353b..01842d6c0b 100644
--- a/src/main/java/forestry/api/core/IArmorNaturalist.java
+++ b/src/main/java/forestry/api/core/ISpectacleVision.java
@@ -7,9 +7,9 @@
/**
* Naturalist armor allows players to see pollinated tree leaves.
*
- * @see ForestryCapabilities#ARMOR_NATURALIST
+ * @see ForestryCapabilities#SPECTACLE_VISION
*/
-public interface IArmorNaturalist {
+public interface ISpectacleVision {
/**
* Called to see if this naturalist's armor allows for seeing pollinated tree leaves/flowers.
diff --git a/src/main/java/forestry/api/core/IToolPipette.java b/src/main/java/forestry/api/core/IToolPipette.java
index ef4201ff05..578ab6a1b1 100644
--- a/src/main/java/forestry/api/core/IToolPipette.java
+++ b/src/main/java/forestry/api/core/IToolPipette.java
@@ -2,9 +2,6 @@
import net.minecraft.world.item.ItemStack;
-/**
- * Taken from BuildCraft 5.0.x
- */
public interface IToolPipette {
/**
* @return true if the pipette can pipette.
diff --git a/src/main/java/forestry/api/core/ItemGroups.java b/src/main/java/forestry/api/core/ItemGroups.java
deleted file mode 100644
index a2c82a5cb7..0000000000
--- a/src/main/java/forestry/api/core/ItemGroups.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package forestry.api.core;
-
-import net.minecraft.world.item.CreativeModeTab;
-
-/**
- * References to the specialised tabs added by Forestry to creative inventory.
- */
-public class ItemGroups {
- public static CreativeModeTab tabForestry;
- public static CreativeModeTab tabStorage;
- public static CreativeModeTab tabApiculture;
- public static CreativeModeTab tabArboriculture;
- public static CreativeModeTab tabLepidopterology;
-}
diff --git a/src/main/java/forestry/api/core/Product.java b/src/main/java/forestry/api/core/Product.java
index 47a73050c8..c486952490 100644
--- a/src/main/java/forestry/api/core/Product.java
+++ b/src/main/java/forestry/api/core/Product.java
@@ -2,13 +2,14 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
+import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.registries.BuiltInRegistries;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.RegistryFriendlyByteBuf;
+import net.minecraft.network.codec.StreamCodec;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.Items;
-import javax.annotation.Nullable;
import java.util.Optional;
/**
@@ -16,53 +17,52 @@
*
* @param item The item this product represents.
* @param count The count the produced stack should have.
- * @param tag The NBT tag
+ * @param data The item's data components, if any, otherwise {@link DataComponentPatch#EMPTY}.
* @param chance
*/
-public record Product(Item item, int count, @Nullable CompoundTag tag, float chance) implements IProduct {
+public record Product(Item item, int count, DataComponentPatch data, float chance) implements IProduct {
public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group(
BuiltInRegistries.ITEM.byNameCodec().fieldOf("item").forGetter(Product::item),
Codec.intRange(1, 64).optionalFieldOf("count", 1).forGetter(Product::count),
- CompoundTag.CODEC.optionalFieldOf("tag").forGetter(product -> Optional.ofNullable(product.tag)),
+ DataComponentPatch.CODEC.optionalFieldOf("data").forGetter(product -> Optional.ofNullable(product.data)),
Codec.floatRange(0f, 1f).fieldOf("chance").forGetter(Product::chance)
).apply(instance, (item, count, tag, chance) -> new Product(item, count, tag.orElse(null), chance)));
- // todo StreamCodec in 1.21
+ public static final StreamCodec STREAM_CODEC = StreamCodec.of(Product::toNetwork, Product::fromNetwork);
@Override
public ItemStack createStack() {
- ItemStack stack = new ItemStack(this.item, this.count);
- if (this.tag != null) {
- // defensive copy
- stack.setTag(this.tag.copy());
- }
- return stack;
+ return new ItemStack(this.item.builtInRegistryHolder(), this.count, this.data);
}
public static Product of(Item item) {
- return new Product(item, 1, null, 1f);
+ return new Product(item, 1, DataComponentPatch.EMPTY, 1f);
+ }
+
+ public static Product of(Item item, float chance) {
+ return new Product(item, 1, DataComponentPatch.EMPTY, chance);
}
public static Product of(Item item, int amount, float chance) {
- return new Product(item, amount, null, chance);
+ return new Product(item, amount, DataComponentPatch.EMPTY, chance);
}
- public static void toNetwork(FriendlyByteBuf buffer, Product product) {
- buffer.writeId(BuiltInRegistries.ITEM, product.item);
+ public static void toNetwork(RegistryFriendlyByteBuf buffer, Product product) {
+ buffer.writeById(BuiltInRegistries.ITEM::getId, product.item);
buffer.writeByte(product.count);
- buffer.writeNbt(product.tag);
+ DataComponentPatch.STREAM_CODEC.encode(buffer, product.data);
buffer.writeFloat(product.chance);
}
- public static Product fromNetwork(FriendlyByteBuf buffer) {
- Item item = buffer.readById(BuiltInRegistries.ITEM);
+ public static Product fromNetwork(RegistryFriendlyByteBuf buffer) {
+ Item item = buffer.readById(BuiltInRegistries.ITEM::byId);
int count = buffer.readByte();
- CompoundTag tag = buffer.readNbt();
+ DataComponentPatch data = DataComponentPatch.STREAM_CODEC.decode(buffer);
float chance = buffer.readFloat();
- if (item == null) {
+ if (item == Items.AIR) {
throw new IllegalStateException("Received invalid item ID");
}
- return new Product(item, count, tag, chance);
+ return new Product(item, count, data, chance);
}
}
diff --git a/src/main/java/forestry/api/core/package-info.java b/src/main/java/forestry/api/core/package-info.java
index 62b4f89a14..ad5af87869 100644
--- a/src/main/java/forestry/api/core/package-info.java
+++ b/src/main/java/forestry/api/core/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.core;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/core/tooltips/ITextInstance.java b/src/main/java/forestry/api/core/tooltips/ITextInstance.java
index cb2e6895a9..a6942b17ce 100644
--- a/src/main/java/forestry/api/core/tooltips/ITextInstance.java
+++ b/src/main/java/forestry/api/core/tooltips/ITextInstance.java
@@ -10,6 +10,7 @@
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
+// todo remove this from existence
public interface ITextInstance, S, R> {
default I text(String text) {
return add(Component.literal(text));
diff --git a/src/main/java/forestry/api/core/tooltips/ToolTip.java b/src/main/java/forestry/api/core/tooltips/ToolTip.java
index 627d0515aa..ade84ef1c6 100644
--- a/src/main/java/forestry/api/core/tooltips/ToolTip.java
+++ b/src/main/java/forestry/api/core/tooltips/ToolTip.java
@@ -1,13 +1,3 @@
-/*******************************************************************************
- * Copyright (c) 2011-2014 SirSengir.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser Public License v3
- * which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl-3.0.txt
- *
- * Various Contributors including, but not limited to:
- * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
- ******************************************************************************/
package forestry.api.core.tooltips;
public class ToolTip extends TextCollection {
diff --git a/src/main/java/forestry/api/core/tooltips/package-info.java b/src/main/java/forestry/api/core/tooltips/package-info.java
index c9ded9e447..e256e2520e 100644
--- a/src/main/java/forestry/api/core/tooltips/package-info.java
+++ b/src/main/java/forestry/api/core/tooltips/package-info.java
@@ -1,7 +1,4 @@
-@ParametersAreNonnullByDefault
-@MethodsReturnNonnullByDefault
+@javax.annotation.ParametersAreNonnullByDefault
+@forestry.api.core.FieldsAreNonnullByDefault
+@net.minecraft.MethodsReturnNonnullByDefault
package forestry.api.core.tooltips;
-
-import net.minecraft.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/forestry/api/event/BackpackEvent.java b/src/main/java/forestry/api/event/BackpackEvent.java
new file mode 100644
index 0000000000..192d0fbefb
--- /dev/null
+++ b/src/main/java/forestry/api/event/BackpackEvent.java
@@ -0,0 +1,44 @@
+package forestry.api.event;
+
+import forestry.api.storage.BackpackDefinition;
+import net.minecraft.world.Container;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
+import net.neoforged.bus.api.Event;
+import net.neoforged.bus.api.ICancellableEvent;
+
+public abstract class BackpackEvent extends Event {
+ public final Player player;
+ public final BackpackDefinition definition;
+ public final Container backpackInventory;
+
+ public BackpackEvent(Player player, BackpackDefinition definition, Container backpackInventory) {
+ this.player = player;
+ this.definition = definition;
+ this.backpackInventory = backpackInventory;
+ }
+
+ /**
+ * Will fire whenever a backpack tries to store an item. Processing will stop if the stack size
+ * of stackToStow drops to 0 or less or the event is canceled.
+ */
+ public static class Stow extends BackpackEvent implements ICancellableEvent {
+ public final ItemStack stackToStow;
+
+ public Stow(Player player, BackpackDefinition backpackDefinition, Container backpackInventory, ItemStack stackToStow) {
+ super(player, backpackDefinition, backpackInventory);
+
+ this.stackToStow = stackToStow;
+ }
+ }
+
+ /**
+ * Use @SubscribeEvent on a method taking this event as an argument. Will fire whenever a backpack tries to resupply to a player inventory. Processing will stop
+ * if the event is canceled.
+ */
+ public static class Resupply extends BackpackEvent implements ICancellableEvent {
+ public Resupply(Player player, BackpackDefinition backpackDefinition, Container backpackInventory) {
+ super(player, backpackDefinition, backpackInventory);
+ }
+ }
+}
diff --git a/src/main/java/forestry/api/event/BeeMatingEvent.java b/src/main/java/forestry/api/event/BeeMatingEvent.java
new file mode 100644
index 0000000000..c90c8c90e7
--- /dev/null
+++ b/src/main/java/forestry/api/event/BeeMatingEvent.java
@@ -0,0 +1,43 @@
+package forestry.api.event;
+
+import forestry.api.apiculture.IBeeHousing;
+import forestry.api.apiculture.bee.IBee;
+import net.neoforged.bus.api.Event;
+import net.neoforged.bus.api.ICancellableEvent;
+
+/**
+ * Fired before a queen is created as a result of breeding a princess and a drone.
+ * For example, this can be used to cancel the breeding or change the resultant queen's genome (ex. to make Zombified).
+ */
+public class BeeMatingEvent extends Event implements ICancellableEvent {
+ private final IBeeHousing housing;
+ private IBee princess;
+ private final IBee drone;
+
+ public BeeMatingEvent(IBeeHousing housing, IBee princess, IBee drone) {
+ this.housing = housing;
+ this.princess = princess;
+ this.drone = drone;
+ }
+
+ public IBeeHousing getHousing() {
+ return this.housing;
+ }
+
+ public IBee getPrincess() {
+ return this.princess;
+ }
+
+ /**
+ * Used to override the princess individual, which will become the queen individual.
+ *
+ * @param princess The new princess individual to replace the queen with.
+ */
+ public void setPrincess(IBee princess) {
+ this.princess = princess;
+ }
+
+ public IBee getDrone() {
+ return this.drone;
+ }
+}
diff --git a/src/main/java/forestry/api/event/BreedingTrackerEvent.java b/src/main/java/forestry/api/event/BreedingTrackerEvent.java
new file mode 100644
index 0000000000..455592ffd0
--- /dev/null
+++ b/src/main/java/forestry/api/event/BreedingTrackerEvent.java
@@ -0,0 +1,73 @@
+package forestry.api.event;
+
+import com.mojang.authlib.GameProfile;
+import forestry.api.genetics.IBreedingTracker;
+import forestry.api.genetics.IMutation;
+import forestry.api.genetics.ISpecies;
+import forestry.api.genetics.ISpeciesType;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.component.ResolvableProfile;
+import net.neoforged.bus.api.Event;
+import org.jetbrains.annotations.ApiStatus;
+
+/**
+ * Supertype for events concerning breeding and mutation.
+ */
+@ApiStatus.Internal
+public abstract class BreedingTrackerEvent extends Event {
+ public final ISpeciesType, ?> root;
+ public final IBreedingTracker tracker;
+ public final ResolvableProfile username;
+
+ private BreedingTrackerEvent(ISpeciesType, ?> root, ResolvableProfile username, IBreedingTracker tracker) {
+ this.root = root;
+ this.username = username;
+ this.tracker = tracker;
+ }
+
+ /**
+ * Fired when a player first discovers a mutation, such as:
+ *
+ *
when successfully triggering the mutation through breeding
+ *
when learning the mutation from Research Notes in the Escritoire
+ *
+ */
+ public static class MutationDiscovered extends BreedingTrackerEvent {
+ public final IMutation> allele;
+
+ public MutationDiscovered(ISpeciesType, ?> root, ResolvableProfile username, IMutation> allele, IBreedingTracker tracker) {
+ super(root, username, tracker);
+ this.allele = allele;
+ }
+ }
+
+ /**
+ * Fired when a player first discovers a species, such as:
+ *
+ *
when successfully breeding the species
+ *
when picking up the item form of the species after using a Scoop or Grafter
+ *
when learning a mutation involving the species from Research Notes in the Escritoire