CraftTweaker support
This commit is contained in:
75
README.md
75
README.md
@@ -1,6 +1,8 @@
|
|||||||
|
<!-- modrinth_exclude.start -->
|
||||||
Trading Station
|
Trading Station
|
||||||
=============
|
=============
|
||||||
|
<!-- modrinth_exclude.end -->
|
||||||
|
Item trading machine.
|
||||||
Made for modpacks. It doesn't add any recipe.
|
Made for modpacks. It doesn't add any recipe.
|
||||||
|
|
||||||
Features
|
Features
|
||||||
@@ -11,7 +13,7 @@ Features
|
|||||||
- Custom *Trading recipe*
|
- Custom *Trading recipe*
|
||||||
- Indestructible variant for each station.
|
- Indestructible variant for each station.
|
||||||
- Configurable consumption & progress.
|
- Configurable consumption & progress.
|
||||||
- Mechanical station available with companion mod.
|
- Mechanical (Create Addon) station available with companion mod.
|
||||||
-
|
-
|
||||||
Trading recipe
|
Trading recipe
|
||||||
---------------
|
---------------
|
||||||
@@ -23,13 +25,76 @@ Trading recipe
|
|||||||
- `exclusiveTo` (optional). Required station. Defaults any. Possible values: `basic`, `powered`, `mechanical`
|
- `exclusiveTo` (optional). Required station. Defaults any. Possible values: `basic`, `powered`, `mechanical`
|
||||||
|
|
||||||
### Example (basic input & output)
|
### Example (basic input & output)
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"type": "trading_station:trading",
|
||||||
|
"ingredients": [
|
||||||
|
{"item": "minecraft:emerald", "count": 5}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "minecraft:diamond",
|
||||||
|
"count": 5
|
||||||
|
},
|
||||||
|
"processingTime": 500
|
||||||
|
}
|
||||||
|
```
|
||||||
### Example (output item with NBT)
|
### Example (output item with NBT)
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"type": "trading_station:trading",
|
||||||
|
"ingredients": [
|
||||||
|
{"item": "minecraft:diamond", "count": 5}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "minecraft:enchanted_book",
|
||||||
|
"nbt": "{StoredEnchantments: [{id:\"looting\",lvl:3s}]}"
|
||||||
|
},
|
||||||
|
"processingTime": 100
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
### Example (biome requirement)
|
### Example (biome requirement)
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"type": "trading_station:trading",
|
||||||
|
"result": {
|
||||||
|
"item": "minecraft:diamond_sword",
|
||||||
|
"count": 1,
|
||||||
|
"nbt": "{Damage:0,Enchantments:[{id:\"mending\",lvl:1s}]}"
|
||||||
|
},
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "minecraft:diamond",
|
||||||
|
"count": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"processingTime": 100,
|
||||||
|
"biome": {
|
||||||
|
"name": "minecraft:plains"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
### Example (exclusiveTo)
|
### Example (exclusiveTo)
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"type": "trading_station:trading",
|
||||||
|
"result": {
|
||||||
|
"item": "minecraft:diamond_sword",
|
||||||
|
"count": 1,
|
||||||
|
"nbt": "{Damage:0,Enchantments:[{id:\"sharpness\",lvl:1s}]}"
|
||||||
|
},
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "minecraft:diamond",
|
||||||
|
"count": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"processingTime": 100,
|
||||||
|
"exclusiveTo": [
|
||||||
|
"powered"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
KubeJS 6.1 Integration
|
KubeJS 6.1 Integration
|
||||||
----------------------
|
----------------------
|
||||||
|
|||||||
33
build.gradle
33
build.gradle
@@ -298,18 +298,18 @@ if(System.getenv('MODRINTH_TOKEN') != null) {
|
|||||||
|
|
||||||
modrinth {
|
modrinth {
|
||||||
token = System.getenv("MODRINTH_TOKEN")
|
token = System.getenv("MODRINTH_TOKEN")
|
||||||
projectId = "mechanical_trading_station"
|
projectId = "trading-station"
|
||||||
versionNumber = "${mod_version}"
|
versionNumber = "${version}"
|
||||||
versionName = "${display_name} - v${mod_version} for Minecraft ${minecraft_version}"
|
versionName = "${display_name} - v${mod_version} for Minecraft ${minecraft_version}"
|
||||||
versionType = "release" // This is the default -- can also be `beta` or `alpha`
|
versionType = "release" // This is the default -- can also be `beta` or `alpha`
|
||||||
uploadFile = tasks.jarJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
|
uploadFile = tasks.jarJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
|
||||||
gameVersions = ["${minecraft_version}"] // Must be an array, even with only one version
|
gameVersions = ["${minecraft_version}"] // Must be an array, even with only one version
|
||||||
loaders = ["forge"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
|
loaders = ["forge"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
|
||||||
dependencies { // A special DSL for creating dependencies
|
dependencies { // A special DSL for creating dependencies
|
||||||
optional.project "create"
|
optional.project "kubejs"
|
||||||
optional.project "jei"
|
optional.project "jei"
|
||||||
optional.project "crafttweaker"
|
|
||||||
}
|
}
|
||||||
|
changelog = rootProject.file("changes/${minecraft_version}-${mod_version}.md").text
|
||||||
syncBodyFrom = rootProject.file("README.md").text
|
syncBodyFrom = rootProject.file("README.md").text
|
||||||
}
|
}
|
||||||
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
|
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
|
||||||
@@ -323,7 +323,7 @@ if(System.getenv('MODRINTH_TOKEN') != null) {
|
|||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
}
|
}
|
||||||
publishing {
|
/*publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifact jar
|
artifact jar
|
||||||
@@ -334,4 +334,27 @@ publishing {
|
|||||||
url "file://${project.projectDir}/mcmodsrepo"
|
url "file://${project.projectDir}/mcmodsrepo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
publishing {
|
||||||
|
// other settings of publication
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
artifact jar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Gitea"
|
||||||
|
url = uri("https://git.fosil.eu/api/packages/oier/maven")
|
||||||
|
|
||||||
|
credentials(HttpHeaderCredentials) {
|
||||||
|
name = "Authorization"
|
||||||
|
value = "token ${System.getenv("FOSIL_TOKEN")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
authentication {
|
||||||
|
header(HttpHeaderAuthentication)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
2
changes/1.19.2-0.1.1.md
Normal file
2
changes/1.19.2-0.1.1.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- Fixed recipe filtering.
|
||||||
|
- Added examples to documentation.
|
||||||
1
changes/1.19.2-0.1.2.md
Normal file
1
changes/1.19.2-0.1.2.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- CraftTweaker support.
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
|
||||||
mod_version=0.1.0
|
mod_version=0.1.2
|
||||||
modid=trading_station
|
modid=trading_station
|
||||||
author=oierbravo
|
author=oierbravo
|
||||||
display_name=Trading Station
|
display_name=Trading Station
|
||||||
@@ -42,7 +42,7 @@ kubejs_version=1902.6.1-build.348
|
|||||||
|
|
||||||
jade_id = 3960379
|
jade_id = 3960379
|
||||||
|
|
||||||
ct_enabled = false
|
ct_enabled = true
|
||||||
ct_minecraft_version = 1.19.2
|
ct_minecraft_version = 1.19.2
|
||||||
ct_version = 10.1.40
|
ct_version = 10.1.40
|
||||||
ct_annotation_processor_version = 3.0.0.10
|
ct_annotation_processor_version = 3.0.0.10
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class TradingRecipeHandler implements IRecipeHandler<TradingRecipe>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String dumpToCommandString(IRecipeManager<? super TradingRecipe> manager, TradingRecipe recipe) {
|
public String dumpToCommandString(IRecipeManager<? super TradingRecipe> manager, TradingRecipe recipe) {
|
||||||
return manager.getCommandString() + recipe.toString() + recipe.getOutput() + "[" + recipe.getIngredient() + "]";
|
return manager.getCommandString() + recipe.toString() + recipe.getResultItem() + "[" + recipe.getIngredients() + "]";
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public <U extends Recipe<?>> boolean doesConflict(IRecipeManager<? super TradingRecipe> manager, TradingRecipe firstRecipe, U secondRecipe) {
|
public <U extends Recipe<?>> boolean doesConflict(IRecipeManager<? super TradingRecipe> manager, TradingRecipe firstRecipe, U secondRecipe) {
|
||||||
@@ -6,13 +6,23 @@ import com.blamejared.crafttweaker.api.action.recipe.ActionAddRecipe;
|
|||||||
import com.blamejared.crafttweaker.api.annotation.ZenRegister;
|
import com.blamejared.crafttweaker.api.annotation.ZenRegister;
|
||||||
import com.blamejared.crafttweaker.api.fluid.IFluidStack;
|
import com.blamejared.crafttweaker.api.fluid.IFluidStack;
|
||||||
import com.blamejared.crafttweaker.api.ingredient.IIngredient;
|
import com.blamejared.crafttweaker.api.ingredient.IIngredient;
|
||||||
|
import com.blamejared.crafttweaker.api.item.IItemStack;
|
||||||
import com.blamejared.crafttweaker.api.recipe.manager.base.IRecipeManager;
|
import com.blamejared.crafttweaker.api.recipe.manager.base.IRecipeManager;
|
||||||
import com.oierbravo.trading_station.TradingStation;
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
|
import com.oierbravo.trading_station.content.trading_recipe.BiomeCondition;
|
||||||
|
import com.oierbravo.trading_station.content.trading_recipe.ExclusiveToCondition;
|
||||||
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
|
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
|
||||||
|
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipeBuilder;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import org.openzen.zencode.java.ZenCodeType;
|
import org.openzen.zencode.java.ZenCodeType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@ZenRegister
|
@ZenRegister
|
||||||
@ZenCodeType.Name("mods.trading_station.TradingManager")
|
@ZenCodeType.Name("mods.trading_station.TradingManager")
|
||||||
//@Document("mods/trading_station/melting")
|
//@Document("mods/trading_station/melting")
|
||||||
@@ -33,10 +43,24 @@ public class TradingRecipeManager implements IRecipeManager<TradingRecipe> {
|
|||||||
* @docParam heatLevel 2
|
* @docParam heatLevel 2
|
||||||
*/
|
*/
|
||||||
@ZenCodeType.Method
|
@ZenCodeType.Method
|
||||||
public void addRecipe(String name, IFluidStack output, IIngredient input, int processingTime, int heatLevel ){
|
public void addRecipe(String name, IItemStack output, IIngredient[] itemInputs, int processingTime, String biome, String[] exclusiveTo ){
|
||||||
name = fixRecipeName(name);
|
name = fixRecipeName(name);
|
||||||
ResourceLocation resourceLocation = new ResourceLocation(TradingStation.MODID, name);
|
ResourceLocation resourceLocation = new ResourceLocation(TradingStation.MODID, name);
|
||||||
CraftTweakerAPI.apply(new ActionAddRecipe<>( this, new TradingRecipe(resourceLocation, output.getInternal(), input.asVanillaIngredient(), processingTime, heatLevel)));
|
TradingRecipeBuilder builder = new TradingRecipeBuilder(resourceLocation);
|
||||||
|
List<Ingredient> ingredients = new ArrayList();
|
||||||
|
Arrays.stream(itemInputs).forEach((iIngredient) -> {
|
||||||
|
ingredients.add(iIngredient.asVanillaIngredient());
|
||||||
|
});
|
||||||
|
builder.withItemIngredients((Ingredient[])ingredients.toArray(new Ingredient[0]));
|
||||||
|
builder.withSingleItemOutput(output.asItemLike());
|
||||||
|
builder.processingTime(processingTime);
|
||||||
|
builder.withBiomeCondition(BiomeCondition.fromString(biome));
|
||||||
|
builder.exclusiveTo(ExclusiveToCondition.fromList(List.of(exclusiveTo)));
|
||||||
|
|
||||||
|
TradingRecipe recipe = builder.build();
|
||||||
|
|
||||||
|
CraftTweakerAPI.apply(new ActionAddRecipe<>(this, recipe));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4,6 +4,7 @@ import net.minecraft.core.NonNullList;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -31,6 +32,9 @@ public class TradingRecipeBuilder {
|
|||||||
params.result = output;
|
params.result = output;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public TradingRecipeBuilder withSingleItemOutput(ItemLike output) {
|
||||||
|
return withSingleItemOutput(new ItemStack(output));
|
||||||
|
}
|
||||||
|
|
||||||
public TradingRecipeBuilder processingTime(int time) {
|
public TradingRecipeBuilder processingTime(int time) {
|
||||||
params.processingTime = time;
|
params.processingTime = time;
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ public interface ITradingStationBlockEntity {
|
|||||||
|
|
||||||
ItemStack getTargetItemStack();
|
ItemStack getTargetItemStack();
|
||||||
|
|
||||||
BlockPos getBlockPos();
|
|
||||||
|
|
||||||
void setPreferedItem(ItemStack itemStack);
|
void setPreferedItem(ItemStack itemStack);
|
||||||
|
|
||||||
void setItemStack(int slot, ItemStack itemStack, ItemStackSyncS2CPacket.SlotType slotType);
|
void setItemStack(int slot, ItemStack itemStack, ItemStackSyncS2CPacket.SlotType slotType);
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ public class ModRecipes {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public static List<TradingRecipe> getAllRecipesForMachine(Level pLevel, Biome biome, String machineType) {
|
public static List<TradingRecipe> getAllRecipesForMachine(Level pLevel, Biome biome, String machineType) {
|
||||||
if(pLevel.isClientSide())
|
|
||||||
return NonNullList.create();
|
|
||||||
return pLevel.getRecipeManager().getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
|
return pLevel.getRecipeManager().getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
|
||||||
.filter((tradingRecipe -> tradingRecipe.matchesBiome(biome, pLevel)))
|
.filter((tradingRecipe -> tradingRecipe.matchesBiome(biome, pLevel)))
|
||||||
.filter((tradingRecipe -> tradingRecipe.matchesExclusiveTo(machineType)))
|
.filter((tradingRecipe -> tradingRecipe.matchesExclusiveTo(machineType)))
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "trading_station:trading",
|
|
||||||
"ingredients": [
|
|
||||||
{"item": "minecraft:emerald", "count": 5}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"item": "minecraft:diamond",
|
|
||||||
"count": 5
|
|
||||||
},
|
|
||||||
"processingTime": 500
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "trading_station:trading",
|
|
||||||
"ingredients": [
|
|
||||||
{"item": "minecraft:diamond", "count": 5}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"item": "minecraft:enchanted_book",
|
|
||||||
"nbt": "{StoredEnchantments: [{id:\"looting\",lvl:3s}]}"
|
|
||||||
},
|
|
||||||
"processingTime": 100
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "minecraft:crafting_shaped",
|
|
||||||
"pattern": [
|
|
||||||
"S S",
|
|
||||||
"S S",
|
|
||||||
"NSN"
|
|
||||||
],
|
|
||||||
"key": {
|
|
||||||
"N": {
|
|
||||||
"item": "minecraft:iron_nugget"
|
|
||||||
},
|
|
||||||
"S": {
|
|
||||||
"tag": "forge:stone"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "trading_station:trading_station"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user