Skip to content

Commit

Permalink
Merge branch 'version/main' into Moobien
Browse files Browse the repository at this point in the history
  • Loading branch information
Moobien authored Jan 29, 2025
2 parents b86edbd + e9d793a commit e7fb0a2
Show file tree
Hide file tree
Showing 87 changed files with 593 additions and 439 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"com.minecolonies.research.effects.sifterflintunlock.description": "Stonemason Learns How to Make Flint Meshes for the Sifter",
"com.minecolonies.research.effects.sifterironunlock.description": "Blacksmith Learns How to Make Iron Meshes for the Sifter",
"com.minecolonies.research.effects.sifterstringunlock.description": "Fletcher Learns How to Make String Meshes for the Sifter",
"com.minecolonies.research.effects.sleeplessmultiplier.description": "Guards Need %3$s%% Less Sleep",
"com.minecolonies.research.effects.sleeplessmultiplier.description": "Guards Need Less Sleep",
"com.minecolonies.research.effects.softshoesunlock.description": "Farmers will no longer trample crops",
"com.minecolonies.research.effects.standard.description": "Place Rallying Banner at location",
"com.minecolonies.research.effects.teachingmultiplier.description": "XP Gain When Studying +%3$s%%",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.fml.ModList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

import static com.minecolonies.api.util.constant.Constants.HARVESTCRAFTMODID;

/**
* This class is to store the methods that call the methods to check for miscellaneous compatibility problems.
*/
Expand Down Expand Up @@ -147,16 +144,6 @@ public static int getToolLevel(@NotNull final ItemStack stack)
return tinkersCompat.getToolLevel(stack);
}

/**
* Check if Pams harvestcraft is installed.
*
* @return true if so.
*/
public static boolean isPamsInstalled()
{
return ModList.get().isLoaded(HARVESTCRAFTMODID);
}

/**
* Check if dynamic tree's is present
*
Expand Down Expand Up @@ -299,4 +286,4 @@ public static List<ItemStack> getCombsFromHive(BlockPos pos, Level world, int am
{
return beeHiveCompat.getCombsFromHive(pos, world, amount);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.minecolonies.core.entity.pathfinding.navigation;
package com.minecolonies.api.entity.pathfinding;

/**
* Interface for navigators which keep an internal heuristic mod
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.minecolonies.api.entity.pathfinding;

import com.minecolonies.core.entity.pathfinding.navigation.MinecoloniesAdvancedPathNavigate;
import com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob;
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Mob;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Describes the Navigator used by minecolonies entities
*/
public interface IMinecoloniesNavigator
{
/**
* Sets a new pathjob to execute
*
* @param job to run
* @param dest
* @param speedFactor
* @param safeDestination
* @param <T>
* @return null or new pathresult
*/
@Nullable
<T extends AbstractPathJob> PathResult<T> setPathJob(
@NotNull AbstractPathJob job,
BlockPos dest,
double speedFactor, boolean safeDestination);

/**
* Indirectly triggers a recalulation, by marking the navigator as done
*/
void recalc();

/**
* Returns the pathresult holding the current pathing task and result
*
* @return
*/
PathResult getPathResult();

/**
* Gets the safe destination the entity wants to travel to
*
* @return
*/
BlockPos getSafeDestination();

/**
* Gets the entity of the navigator
*
* @return
*/
Mob getOurEntity();

/**
* Pauses the navigator for X ticks from starting any new pathing tasks
*
* @param pauseTicks
*/
void setPauseTicks(int pauseTicks);

/**
* Returns the stuck handler used by the navigator
*
* @return
*/
IStuckHandler<MinecoloniesAdvancedPathNavigate> getStuckHandler();
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package com.minecolonies.api.entity.pathfinding;

import com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate;
import net.minecraft.world.entity.ai.navigation.PathNavigation;

/**
* Stuck handler for pathing, gets called to check/deal with stuck status
*/
public interface IStuckHandler
public interface IStuckHandler<NAV extends PathNavigation & IMinecoloniesNavigator>
{
/**
* Checks if the navigator is stuck
*
* @param navigator navigator to check
*/
void checkStuck(final AbstractAdvancedPathNavigate navigator);
void checkStuck(final NAV navigator);

void resetGlobalStuckTimers();

/**
* Returns the stuck level (0-9) indicating how long the entity is stuck and which stuck actions got used
*
* @return
*/
public int getStuckLevel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ public class AbstractCitizenModEvent extends AbstractColonyModEvent
/**
* The citizen related to the event.
*/
private final @NotNull ICitizenData citizen;
@NotNull
private final ICitizenData citizen;

/**
* Constructs a citizen-based event.
*
* @param citizen the citizen related to the event.
*/
protected AbstractCitizenModEvent(final @NotNull ICitizenData citizen)
protected AbstractCitizenModEvent(@NotNull final ICitizenData citizen)
{
super(citizen.getColony());
this.citizen = citizen;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
package com.minecolonies.api.eventbus.events.colony.citizens;

import com.minecolonies.api.colony.ICitizenData;
import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.eventbus.events.colony.AbstractColonyModEvent;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.NotNull;

/**
* Event for when a citizen was removed from the colony.
*/
public final class CitizenRemovedModEvent extends AbstractCitizenModEvent
public final class CitizenRemovedModEvent extends AbstractColonyModEvent
{
/**
* The id of the citizen.
*/
private final int citizenId;

/**
* The damage source that caused a citizen to die.
*/
private final @NotNull Entity.RemovalReason reason;
@NotNull
private final Entity.RemovalReason reason;

/**
* Citizen removed event.
*
* @param citizen the citizen related to the event.
* @param reason the reason the citizen was removed.
* @param colony the colony related to the event.
* @param citizenId the id of the citizen.
* @param reason the reason the citizen was removed.
*/
public CitizenRemovedModEvent(final @NotNull ICitizenData citizen, final @NotNull Entity.RemovalReason reason)
public CitizenRemovedModEvent(final @NotNull IColony colony, final int citizenId, final @NotNull Entity.RemovalReason reason)
{
super(citizen);
super(colony);
this.citizenId = citizenId;
this.reason = reason;
}

/**
* The id of the citizen.
*
* @return the id.
*/
public int getCitizenId()
{
return citizenId;
}

/**
* The damage source that caused the citizen to die.
*
Expand Down
118 changes: 61 additions & 57 deletions src/main/java/com/minecolonies/api/loot/ModLootConditions.java
Original file line number Diff line number Diff line change
@@ -1,57 +1,61 @@
package com.minecolonies.api.loot;

import com.minecolonies.api.util.constant.Constants;
import net.minecraft.advancements.critereon.EnchantmentPredicate;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
import net.minecraft.world.level.storage.loot.predicates.MatchTool;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import static com.minecolonies.api.util.constant.Constants.MOD_ID;

/** Container class for registering custom loot conditions */
public final class ModLootConditions
{
public final static DeferredRegister<LootItemConditionType> DEFERRED_REGISTER = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Constants.MOD_ID);

public static final ResourceLocation ENTITY_IN_BIOME_TAG_ID = new ResourceLocation(MOD_ID, "entity_in_biome_tag");
public static final ResourceLocation RESEARCH_UNLOCKED_ID = new ResourceLocation(MOD_ID, "research_unlocked");

public static final RegistryObject<LootItemConditionType> entityInBiomeTag;
public static final RegistryObject<LootItemConditionType> researchUnlocked;

// also some convenience definitions for existing conditions; some stolen from BlockLootSubProvider
public static final LootItemCondition.Builder HAS_SILK_TOUCH = MatchTool.toolMatches(ItemPredicate.Builder.item().hasEnchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.Ints.atLeast(1))));
public static final LootItemCondition.Builder HAS_SHEARS = MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.SHEARS));
public static final LootItemCondition.Builder HAS_SHEARS_OR_SILK_TOUCH = HAS_SHEARS.or(HAS_SILK_TOUCH);
public static final LootItemCondition.Builder HAS_NO_SHEARS_OR_SILK_TOUCH = HAS_SHEARS_OR_SILK_TOUCH.invert();
public static final LootItemCondition.Builder HAS_HOE = MatchTool.toolMatches(ItemPredicate.Builder.item().of(ItemTags.HOES));

public static void init()
{
// just for classloading
}

static
{
entityInBiomeTag = DEFERRED_REGISTER.register(ModLootConditions.ENTITY_IN_BIOME_TAG_ID.getPath(),
() -> new LootItemConditionType(new EntityInBiomeTag.Serializer()));

researchUnlocked = DEFERRED_REGISTER.register(ModLootConditions.RESEARCH_UNLOCKED_ID.getPath(),
() -> new LootItemConditionType(new ResearchUnlocked.Serializer()));
}


private ModLootConditions()
{
throw new IllegalStateException("Tried to initialize: ModLootConditions but this is a Utility class.");
}
}
package com.minecolonies.api.loot;

import com.minecolonies.api.util.constant.Constants;
import net.minecraft.advancements.critereon.EnchantmentPredicate;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
import net.minecraft.world.level.storage.loot.predicates.MatchTool;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import static com.minecolonies.api.util.constant.Constants.MOD_ID;

/** Container class for registering custom loot conditions */
public final class ModLootConditions
{
public final static DeferredRegister<LootItemConditionType> DEFERRED_REGISTER = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Constants.MOD_ID);

public static final ResourceLocation ENTITY_IN_BIOME_TAG_ID = new ResourceLocation(MOD_ID, "entity_in_biome_tag");
public static final ResourceLocation RESEARCH_UNLOCKED_ID = new ResourceLocation(MOD_ID, "research_unlocked");

public static final RegistryObject<LootItemConditionType> entityInBiomeTag;
public static final RegistryObject<LootItemConditionType> researchUnlocked;

// also some convenience definitions for existing conditions; some stolen from BlockLootSubProvider
public static final LootItemCondition.Builder HAS_SILK_TOUCH = MatchTool.toolMatches(ItemPredicate.Builder.item().hasEnchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.Ints.atLeast(1))));
public static final LootItemCondition.Builder HAS_SHEARS = MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.SHEARS));
public static final LootItemCondition.Builder HAS_SHEARS_OR_SILK_TOUCH = HAS_SHEARS.or(HAS_SILK_TOUCH);
public static final LootItemCondition.Builder HAS_NO_SHEARS_OR_SILK_TOUCH = HAS_SHEARS_OR_SILK_TOUCH.invert();
public static final LootItemCondition.Builder HAS_NETHERITE_HOE = MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.NETHERITE_HOE));
public static final LootItemCondition.Builder HAS_DIAMOND_HOE = MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.DIAMOND_HOE));
public static final LootItemCondition.Builder HAS_IRON_HOE = MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.IRON_HOE));
public static final LootItemCondition.Builder HAS_GOLDEN_HOE = MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.GOLDEN_HOE));
public static final LootItemCondition.Builder HAS_HOE = MatchTool.toolMatches(ItemPredicate.Builder.item().of(ItemTags.HOES));

public static void init()
{
// just for classloading
}

static
{
entityInBiomeTag = DEFERRED_REGISTER.register(ModLootConditions.ENTITY_IN_BIOME_TAG_ID.getPath(),
() -> new LootItemConditionType(new EntityInBiomeTag.Serializer()));

researchUnlocked = DEFERRED_REGISTER.register(ModLootConditions.RESEARCH_UNLOCKED_ID.getPath(),
() -> new LootItemConditionType(new ResearchUnlocked.Serializer()));
}


private ModLootConditions()
{
throw new IllegalStateException("Tried to initialize: ModLootConditions but this is a Utility class.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class DamageSourceKeys
public static ResourceKey<DamageType> CAMP_NORSEMENARCHER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "campnorsemenarcher"));
public static ResourceKey<DamageType> CAMP_SHIELDMAIDEN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "campshieldmaiden"));
public static ResourceKey<DamageType> CAMP_BARBARIAN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "campbarbarian"));
public static ResourceKey<DamageType> CAMP_CHIEFBARBARIAN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "ccamphiefbarbarian"));
public static ResourceKey<DamageType> CAMP_CHIEFBARBARIAN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "campchiefbarbarian"));
public static ResourceKey<DamageType> CAMP_ARCHERBARBARIAN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "camparcherbarbarian"));
public static ResourceKey<DamageType> CAMP_PIRATE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "camppirate"));
public static ResourceKey<DamageType> CAMP_CHIEFPIRATE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(Constants.MOD_ID, "campchiefpirate"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/minecolonies/api/util/FoodUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FoodUtils
/**
* Predicate describing food which can be eaten (is not raw).
*/
public static Predicate<ItemStack> EDIBLE;
public static final Predicate<ItemStack> EDIBLE = itemStack -> ItemStackUtils.ISFOOD.test(itemStack) && !ItemStackUtils.ISCOOKABLE.test(itemStack);

/**
* @param stack
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/minecolonies/api/util/ItemStackUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.minecolonies.api.items.ModTags;
import com.minecolonies.core.items.ItemBowlFood;
import com.minecolonies.core.util.AdvancementUtils;
import com.minecolonies.core.util.FurnaceRecipes;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -115,12 +116,12 @@ public final class ItemStackUtils
/**
* Predicate describing things which work in the furnace.
*/
public static Predicate<ItemStack> IS_SMELTABLE;
public static Predicate<ItemStack> IS_SMELTABLE = itemStack -> !ItemStackUtils.isEmpty(FurnaceRecipes.getInstance().getSmeltingResult(itemStack));

/**
* Predicate describing cookables.
*/
public static Predicate<ItemStack> ISCOOKABLE;
public static Predicate<ItemStack> ISCOOKABLE = itemStack -> ItemStackUtils.ISFOOD.test(FurnaceRecipes.getInstance().getSmeltingResult(itemStack));

/**
* Predicate to check for compost items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
public final class Constants
{
public static final String MOD_ID = "minecolonies";
public static final String HARVESTCRAFTMODID = "harvestcraft";
public static final int ROTATE_0_TIMES = 0;
public static final int ROTATE_ONCE = 1;
public static final int ROTATE_TWICE = 2;
Expand Down
Loading

0 comments on commit e7fb0a2

Please sign in to comment.