Skip to content

Commit

Permalink
Tool registry (#10190)
Browse files Browse the repository at this point in the history
Change tooltypes from hardcoded to a registry. This allows addon makers to define their own tool types to use in custom recipes + jobs. As part of this, some of the tool level generation + checks for tool type have been unified + updated.
  • Loading branch information
Wmaxlees authored Sep 15, 2024
1 parent dd7a489 commit ab33551
Show file tree
Hide file tree
Showing 108 changed files with 1,119 additions and 974 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:carved_pumpkin",
"tool": "shears"
"tool": "minecolonies:shears"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:stripped_bamboo_block",
"tool": "axe"
"tool": "minecolonies:axe"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:copper_block",
"tool": "axe"
"tool": "minecolonies:axe"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:cut_copper",
"tool": "axe"
"tool": "minecolonies:axe"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:weathered_copper",
"tool": "axe"
"tool": "minecolonies:axe"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:weathered_cut_copper",
"tool": "axe"
"tool": "minecolonies:axe"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:exposed_copper",
"tool": "axe"
"tool": "minecolonies:axe"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"intermediate": "minecraft:air",
"result": "minecraft:exposed_cut_copper",
"tool": "axe"
"tool": "minecolonies:axe"
}
3 changes: 3 additions & 0 deletions src/main/java/com/minecolonies/api/IMinecoloniesAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.minecolonies.api.entity.mobs.registry.IMobAIRegistry;
import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry;
import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry;
import com.minecolonies.api.equipment.registry.EquipmentTypeEntry;
import com.minecolonies.api.quests.registries.QuestRegistries;
import com.minecolonies.api.research.IGlobalResearchTree;
import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType;
Expand Down Expand Up @@ -98,4 +99,6 @@ static IMinecoloniesAPI getInstance()
IForgeRegistry<HappinessRegistry.HappinessFunctionEntry> getHappinessFunctionRegistry();

void onRegistryNewRegistry(NewRegistryEvent event);

IForgeRegistry<EquipmentTypeEntry> getEquipmentTypeRegistry();
}
7 changes: 7 additions & 0 deletions src/main/java/com/minecolonies/api/MinecoloniesAPIProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.minecolonies.api.entity.mobs.registry.IMobAIRegistry;
import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry;
import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry;
import com.minecolonies.api.equipment.registry.EquipmentTypeEntry;
import com.minecolonies.api.quests.registries.QuestRegistries;
import com.minecolonies.api.research.IGlobalResearchTree;
import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType;
Expand Down Expand Up @@ -228,4 +229,10 @@ public void onRegistryNewRegistry(final NewRegistryEvent event)
{
apiInstance.onRegistryNewRegistry(event);
}

@Override
public IForgeRegistry<EquipmentTypeEntry> getEquipmentTypeRegistry()
{
return apiInstance.getEquipmentTypeRegistry();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import java.util.function.Predicate;

import static com.minecolonies.api.util.constant.Suppression.GENERIC_WILDCARD;
import static com.minecolonies.api.util.constant.ToolLevelConstants.BASIC_TOOL_LEVEL;
import static com.minecolonies.api.util.constant.ToolLevelConstants.TOOL_LEVEL_MAXIMUM;
import static com.minecolonies.api.util.constant.EquipmentLevelConstants.BASIC_TOOL_LEVEL;
import static com.minecolonies.api.util.constant.EquipmentLevelConstants.TOOL_LEVEL_MAXIMUM;

public interface IBuilding extends IBuildingContainer, IModuleContainer<IBuildingModule>, IRequestResolverProvider, IRequester, ISchematicProvider
{
Expand Down Expand Up @@ -440,11 +440,11 @@ <R> ImmutableList<IRequest<? extends R>> getOpenRequestsOfTypeFiltered(
boolean isItemStackInRequest(@Nullable ItemStack stack);

/**
* Get the max tool level useable by the worker.
* Get the max equipment level useable by the worker.
*
* @return the integer.
*/
default int getMaxToolLevel()
default int getMaxEquipmentLevel()
{
if (getBuildingLevel() >= getMaxBuildingLevel())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface IBuildingWorker extends IBuilding
*
* @return the integer.
*/
int getMaxToolLevel();
int getMaxEquipmentLevel();

/**
* Method which defines if a worker should be allowed to work during the rain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.minecolonies.api.colony.fields.modules.IFieldModule;
import com.minecolonies.api.entity.citizen.AbstractEntityCitizen;
import com.minecolonies.api.util.constant.ToolType;
import com.minecolonies.api.equipment.registry.EquipmentTypeEntry;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -137,7 +137,7 @@ public interface IPlantationModule extends IFieldModule
*
* @return the tool to work on this module.
*/
ToolType getRequiredTool();
EquipmentTypeEntry getRequiredTool();

/**
* Hashcode implementation for this field.
Expand Down
Loading

0 comments on commit ab33551

Please sign in to comment.