Skip to content

Commit

Permalink
Add new recipe provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Feb 23, 2024
1 parent 654c09f commit b33ac97
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-02-22T11:57:16.361669 Recipes
// 1.20.1 2024-02-23T14:58:29.706348 Recipes
4dcec5127078324130ee2a0784057108c8aadc01 data/minecraft/advancements/recipes/misc/gunpowder.json
4a6e67942b0734508f9373351ab324c6cdd81244 data/minecraft/advancements/recipes/misc/lead_ingot_from_blasting_deepslate_lead_ore.json
33c838f63222211d4d44845f4f963dfe2cec8fc9 data/minecraft/advancements/recipes/misc/lead_ingot_from_blasting_lead_ore.json
Expand Down Expand Up @@ -690,14 +690,14 @@ f5891a9e5be986da88df8bc38efd22c96b8d94fa data/railcraft/recipes/brown_strengthen
04d789c4febc7a810bf7d3187ed3dd7cd1d22fee data/railcraft/recipes/buffer_stop_track_kit.json
025a4743266970f17ef2334bb81122e8d5d27703 data/railcraft/recipes/bushing_gear_brass.json
4155a726cf6fdf48c896f0f13a46392199a455e2 data/railcraft/recipes/bushing_gear_bronze.json
0b1dc4b353502890c85854284eb583363cbac6a6 data/railcraft/recipes/cart_disassembly.json
12950433ff4099542ce9910669679ea24bab628c data/railcraft/recipes/cart_dispenser.json
3b7860ac675f913c591bbd7cf72b6f3dd6cdbd1e data/railcraft/recipes/charge_coil.json
fbbf9cd636919bc0256914078feeec32d9877d42 data/railcraft/recipes/charge_meter.json
a553dbfae5f17c774bfad15126426a86f3ed1bfd data/railcraft/recipes/charge_motor.json
0c7fe03cdfbfe3dab1dc5130b70b56277615d16b data/railcraft/recipes/charge_spool_medium_from_large.json
2350956a71ea929f2bd5698dfd7461eaf2ba2113 data/railcraft/recipes/charge_spool_small_from_medium.json
352abb708c30fff261b4e5b029f0b68fcc0c9460 data/railcraft/recipes/charge_terminal.json
d0a914347403c0010f14c584ec3679d413ebdb32 data/railcraft/recipes/chest_minecart_disassembly.json
8ed0e135b26ea5e24cc273553e2400f1419b6f17 data/railcraft/recipes/chiseled_abyssal_stone.json
33c81e7f5da96e4c8660dffdd5eaff643f218f2a data/railcraft/recipes/chiseled_quarried_stone.json
5f140838fe6791326bb9dd094860759023192256 data/railcraft/recipes/coal_coke.json
Expand Down Expand Up @@ -1231,6 +1231,7 @@ f37cdfbcc3f96d6284a385d44a2c348369a91330 data/railcraft/recipes/wooden_tie.json
f7011a8a90b40317aba1b7f8c6db273039ab42fd data/railcraft/recipes/wooden_tie_bottle.json
409f20cfcc310a5141f95caffcbe13ab506c17e5 data/railcraft/recipes/world_spike.json
8bd8dd80a0f1c207f9a4e5f08d06822d0c0886fc data/railcraft/recipes/world_spike_minecart.json
3e715fbc430b6b9a817b82bdc9290f5835b0d898 data/railcraft/recipes/worldspike_minecart_disassembly.json
0f5ab3cd0d388d936201b5dc47d1122107be1fd4 data/railcraft/recipes/yellow_iron_tank_gauge.json
26c3310fcde77abb4ee6565eb9b64129c605129b data/railcraft/recipes/yellow_iron_tank_valve.json
e02c7f80b6037e309bd9d2140818acaf6460db62 data/railcraft/recipes/yellow_iron_tank_wall.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-02-23T11:26:04.621166 Languages: en_us
7791b433b0091862002ab3ebce68d8cf20f680dd assets/railcraft/lang/en_us.json
// 1.20.1 2024-02-23T14:58:29.713925 Languages: en_us
a2f1d7a5a137b1a602a3df80c490404ee081a555 assets/railcraft/lang/en_us.json
1 change: 1 addition & 0 deletions src/generated/resources/assets/railcraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@
"jei.railcraft.desc.token_signal": "This signal can be used to define an area to monitor for carts entering and leaving. It pairs into a net of signals, with no particular limit to the number of signals defining the area. Recommended for junctions and diagonals. It will send the resulting aspect to a paired Receiver.",
"jei.railcraft.desc.tunnel_bore": "Machine designed for digging tunnels and laying track.",
"jei.railcraft.desc.world_spike": "Loads a 3x3 area of chunks at world load and keeps them loaded.",
"jei.railcraft.desc.world_spike_minecart": "Load the current chunk and the north, east, south and west chunks, and keeps them loaded.",
"jei.railcraft.tips.crusher": "(%s%% chance)",
"key.railcraft.category": "Railcraft Reborn",
"key.railcraft.change_aura": "Change Aura",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "railcraft:chest_minecart_disassembly",
"category": "misc"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "railcraft:worldspike_minecart_disassembly",
"category": "misc"
}
1 change: 1 addition & 0 deletions src/main/java/mods/railcraft/Translations.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public static class Jei {
makeKey("jei", "desc.disposable_battery_empty");
public static final String WORLD_SPIKE = makeKey("jei", "desc.world_spike");
public static final String PERSONAL_WORLD_SPIKE = makeKey("jei", "desc.personal_world_spike");
public static final String WORLD_SPIKE_MINECART = makeKey("jei", "desc.world_spike_minecart");

public static final String PAINT = makeKey("jei.gui", "paint");
public static final String COPY_TAG = makeKey("jei.gui", "copy_tag");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,8 @@ private void jeiTranslations() {
this.add(Translations.Jei.PERSONAL_WORLD_SPIKE, """
Loads a 3x3 area of chunks at world load and keeps them loaded. \
It can only be broken by the owner.""");
this.add(Translations.Jei.WORLD_SPIKE_MINECART, """
Load the current chunk and the north, east, south and west chunks, and keeps them loaded.""");
this.add(Translations.Jei.PAINT, "Paint");
this.add(Translations.Jei.COPY_TAG, "Copy Tag");
this.add(Translations.Jei.REPAIR, "Repair");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,8 +1251,10 @@ private void buildCartsVariant(Consumer<FinishedRecipe> consumer) {

RailcraftSpecialRecipeBuilder.special(RailcraftRecipeSerializers.LOCOMOTIVE_PAINTING.get())
.save(consumer, "locomotive_color_variant");
RailcraftSpecialRecipeBuilder.special(RailcraftRecipeSerializers.CART_DISASSEMBLY.get())
.save(consumer, "cart_disassembly");
RailcraftSpecialRecipeBuilder.special(RailcraftRecipeSerializers.CHEST_MINECART_DISASSEMBLY.get())
.save(consumer, "chest_minecart_disassembly");
RailcraftSpecialRecipeBuilder.special(RailcraftRecipeSerializers.WORLDSPIKE_MINECART_DISASSEMBLY.get())
.save(consumer, "worldspike_minecart_disassembly");

ShapedRecipeBuilder.shaped(RecipeCategory.MISC, RailcraftItems.TRACK_LAYER.get())
.pattern("aba")
Expand Down
19 changes: 7 additions & 12 deletions src/main/java/mods/railcraft/particle/RailcraftParticleTypes.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mods.railcraft.particle;

import java.util.function.Function;
import com.mojang.serialization.Codec;
import mods.railcraft.api.core.RailcraftConstants;
import net.minecraft.core.particles.ParticleOptions;
Expand All @@ -24,37 +23,33 @@ public class RailcraftParticleTypes {

public static final RegistryObject<ParticleType<FireSparkParticleOptions>> FIRE_SPARK =
deferredRegister.register("fire_spark",
() -> create(FireSparkParticleOptions.DESERIALIZER,
__ -> FireSparkParticleOptions.CODEC));
() -> create(FireSparkParticleOptions.DESERIALIZER, FireSparkParticleOptions.CODEC));

public static final RegistryObject<SimpleParticleType> PUMPKIN =
deferredRegister.register("pumpkin", () -> new SimpleParticleType(false));

public static final RegistryObject<ParticleType<TuningAuraParticleOptions>> TUNING_AURA =
deferredRegister.register("tuning_aura",
() -> create(TuningAuraParticleOptions.DESERIALIZER,
__ -> TuningAuraParticleOptions.CODEC));
() -> create(TuningAuraParticleOptions.DESERIALIZER, TuningAuraParticleOptions.CODEC));

public static final RegistryObject<ParticleType<ForceSpawnParticleOptions>> FORCE_SPAWN =
deferredRegister.register("force_spawn",
() -> create(ForceSpawnParticleOptions.DESERIALIZER,
__ -> ForceSpawnParticleOptions.CODEC));
() -> create(ForceSpawnParticleOptions.DESERIALIZER, ForceSpawnParticleOptions.CODEC));

public static final RegistryObject<ParticleType<ChunkLoaderParticleOptions>> CHUNK_LOADER =
deferredRegister.register("chunk_loader",
() -> create(ChunkLoaderParticleOptions.DESERIALIZER,
__ -> ChunkLoaderParticleOptions.CODEC));
() -> create(ChunkLoaderParticleOptions.DESERIALIZER, ChunkLoaderParticleOptions.CODEC));

public static void register(IEventBus modEventBus) {
deferredRegister.register(modEventBus);
}

private static <T extends ParticleOptions> ParticleType<T> create(
@SuppressWarnings("deprecation") ParticleOptions.Deserializer<T> deserializer,
Function<ParticleType<T>, Codec<T>> factory) {
return new ParticleType<T>(false, deserializer) {
Codec<T> codec) {
return new ParticleType<>(false, deserializer) {
public Codec<T> codec() {
return factory.apply(this);
return codec;
}
};
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/mods/railcraft/world/item/RailcraftItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.util.VariantRegistrar;
import mods.railcraft.world.entity.vehicle.TankMinecart;
import mods.railcraft.world.entity.vehicle.WorldSpikeMinecart;
import mods.railcraft.world.entity.vehicle.locomotive.CreativeLocomotive;
import mods.railcraft.world.entity.vehicle.locomotive.ElectricLocomotive;
import mods.railcraft.world.entity.vehicle.locomotive.SteamLocomotive;
Expand Down Expand Up @@ -469,9 +468,9 @@ public static Collection<RegistryObject<Item>> entries() {
deferredRegister.register("tank_minecart",
() -> new CartItem(TankMinecart::new, new Item.Properties().stacksTo(1)));

public static final RegistryObject<CartItem> WORLD_SPIKE_MINECART =
public static final RegistryObject<WorldSpikeMinecartItem> WORLD_SPIKE_MINECART =
deferredRegister.register("world_spike_minecart",
() -> new CartItem(WorldSpikeMinecart::new, new Item.Properties()
() -> new WorldSpikeMinecartItem(new Item.Properties()
.stacksTo(1)
.rarity(Rarity.UNCOMMON)));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mods.railcraft.world.item;

import mods.railcraft.Translations;
import mods.railcraft.integrations.jei.JeiSearchable;
import mods.railcraft.world.entity.vehicle.WorldSpikeMinecart;
import net.minecraft.network.chat.Component;

public class WorldSpikeMinecartItem extends CartItem implements JeiSearchable {

public WorldSpikeMinecartItem(Properties properties) {
super(WorldSpikeMinecart::new, properties);
}

@Override
public Component jeiDescription() {
return Component.translatable(Translations.Jei.WORLD_SPIKE_MINECART);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CraftingBookCategory;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;

public class CartDisassemblyRecipe extends CustomRecipe {
public abstract class CartDisassemblyRecipe extends CustomRecipe {

public CartDisassemblyRecipe(ResourceLocation id, CraftingBookCategory category) {
private final Item ingredient;
private final Item result;

public CartDisassemblyRecipe(ResourceLocation id, Item ingredient, Item result,
CraftingBookCategory category) {
super(id, category);
this.ingredient = ingredient;
this.result = result;
}

@Override
Expand All @@ -25,7 +31,7 @@ public boolean matches(CraftingContainer container, Level level) {
.mapToObj(container::getItem)
.filter(x -> !x.isEmpty())
.count();
return items == 1 && container.hasAnyMatching(x -> x.is(Items.CHEST_MINECART));
return items == 1 && container.hasAnyMatching(x -> x.is(this.ingredient));
}

@Override
Expand All @@ -40,13 +46,13 @@ public boolean canCraftInDimensions(int width, int height) {

@Override
public ItemStack getResultItem(RegistryAccess registryAccess) {
return new ItemStack(Items.CHEST);
return new ItemStack(this.result);
}

@Override
public NonNullList<Ingredient> getIngredients() {
NonNullList<Ingredient> ingredients = NonNullList.create();
ingredients.add(Ingredient.of(Items.CHEST_MINECART));
ingredients.add(Ingredient.of(this.ingredient));
return ingredients;
}

Expand All @@ -55,15 +61,10 @@ public NonNullList<ItemStack> getRemainingItems(CraftingContainer container) {
var grid = NonNullList.withSize(container.getContainerSize(), ItemStack.EMPTY);
for (int i = 0; i < container.getContainerSize(); i++) {
var itemStack = container.getItem(i);
if (itemStack.is(Items.CHEST_MINECART)) {
if (itemStack.is(this.ingredient)) {
grid.set(i, new ItemStack(Items.MINECART));
}
}
return grid;
}

@Override
public RecipeSerializer<?> getSerializer() {
return RailcraftRecipeSerializers.CART_DISASSEMBLY.get();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mods.railcraft.world.item.crafting;

import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.world.item.RailcraftItems;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer;
import net.minecraftforge.eventbus.api.IEventBus;
Expand Down Expand Up @@ -37,9 +39,27 @@ public class RailcraftRecipeSerializers {
deferredRegister.register("rotor_repair",
() -> new SimpleCraftingRecipeSerializer<>(RotorRepairRecipe::new));

public static final RegistryObject<RecipeSerializer<CartDisassemblyRecipe>> CART_DISASSEMBLY =
deferredRegister.register("cart_disassembly",
() -> new SimpleCraftingRecipeSerializer<>(CartDisassemblyRecipe::new));
public static final RegistryObject<RecipeSerializer<CartDisassemblyRecipe>> CHEST_MINECART_DISASSEMBLY =
deferredRegister.register("chest_minecart_disassembly",
() -> new SimpleCraftingRecipeSerializer<>((resourceLocation, craftingBookCategory) ->
new CartDisassemblyRecipe(resourceLocation, Items.CHEST_MINECART, Items.CHEST,
craftingBookCategory) {
@Override
public RecipeSerializer<?> getSerializer() {
return CHEST_MINECART_DISASSEMBLY.get();
}
}));

public static final RegistryObject<RecipeSerializer<CartDisassemblyRecipe>> WORLDSPIKE_MINECART_DISASSEMBLY =
deferredRegister.register("worldspike_minecart_disassembly",
() -> new SimpleCraftingRecipeSerializer<>((resourceLocation, craftingBookCategory) ->
new CartDisassemblyRecipe(resourceLocation, RailcraftItems.WORLD_SPIKE_MINECART.get(),
RailcraftItems.WORLD_SPIKE.get(), craftingBookCategory) {
@Override
public RecipeSerializer<?> getSerializer() {
return WORLDSPIKE_MINECART_DISASSEMBLY.get();
}
}));

public static final RegistryObject<SimpleCraftingRecipeSerializer<PatchouliBookCrafting>> PATCHOULI_BOOK_CRAFTING =
deferredRegister.register("patchouli_book_crafting",
Expand Down

0 comments on commit b33ac97

Please sign in to comment.