From f90da739ebb5ed684ae59bbe937a6c1ee82828c5 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sun, 9 Jun 2019 09:46:52 +0100 Subject: [PATCH] And bump Forge again --- gradle.properties | 2 +- .../dan200/computercraft/shared/Registry.java | 27 +++++++++++++++++++ .../computer/recipe/ComputerFamilyRecipe.java | 4 +-- .../proxy/ComputerCraftProxyCommon.java | 21 --------------- .../shared/util/BasicRecipeSerializer.java | 20 ++++++++++++++ .../shared/util/ImpostorRecipe.java | 2 +- .../shared/util/ImpostorShapelessRecipe.java | 2 +- 7 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java diff --git a/gradle.properties b/gradle.properties index 3f0302f1b..e3246dfd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,5 @@ mod_version=1.83.1 # Minecraft properties mc_version=1.14.2 -forge_version=26.0.10 +forge_version=26.0.12 mappings_version=20190609-1.14.2 diff --git a/src/main/java/dan200/computercraft/shared/Registry.java b/src/main/java/dan200/computercraft/shared/Registry.java index 31512adc1..938bd30e0 100644 --- a/src/main/java/dan200/computercraft/shared/Registry.java +++ b/src/main/java/dan200/computercraft/shared/Registry.java @@ -8,6 +8,7 @@ package dan200.computercraft.shared; import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.ComputerCraftAPI; +import dan200.computercraft.shared.common.ColourableRecipe; import dan200.computercraft.shared.common.ContainerHeldItem; import dan200.computercraft.shared.computer.blocks.BlockComputer; import dan200.computercraft.shared.computer.blocks.TileCommandComputer; @@ -16,9 +17,12 @@ import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.inventory.ContainerComputer; import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; import dan200.computercraft.shared.computer.items.ItemComputer; +import dan200.computercraft.shared.computer.recipe.ComputerUpgradeRecipe; import dan200.computercraft.shared.media.items.ItemDisk; import dan200.computercraft.shared.media.items.ItemPrintout; import dan200.computercraft.shared.media.items.ItemTreasureDisk; +import dan200.computercraft.shared.media.recipes.DiskRecipe; +import dan200.computercraft.shared.media.recipes.PrintoutRecipe; import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive; import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive; @@ -36,13 +40,18 @@ import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer; import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.peripherals.PocketModem; import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker; +import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe; import dan200.computercraft.shared.turtle.blocks.BlockTurtle; import dan200.computercraft.shared.turtle.blocks.TileTurtle; import dan200.computercraft.shared.turtle.core.TurtlePlayer; import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; import dan200.computercraft.shared.turtle.items.ItemTurtle; +import dan200.computercraft.shared.turtle.recipes.TurtleRecipe; +import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe; import dan200.computercraft.shared.turtle.upgrades.*; import dan200.computercraft.shared.util.CreativeTabMain; +import dan200.computercraft.shared.util.ImpostorRecipe; +import dan200.computercraft.shared.util.ImpostorShapelessRecipe; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityType; @@ -51,6 +60,7 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.Items; +import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; @@ -335,4 +345,21 @@ public final class Registry ContainerViewComputer.TYPE.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "view_computer" ) ) ); } + + @SubscribeEvent + public static void regsterRecipeSerializers( RegistryEvent.Register> event ) + { + + event.getRegistry().registerAll( + ColourableRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "colour" ) ), + ComputerUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer_upgrade" ) ), + PocketComputerUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer_upgrade" ) ), + DiskRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ), + PrintoutRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ), + TurtleRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ), + TurtleUpgradeRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_upgrade" ) ), + ImpostorShapelessRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shapeless" ) ), + ImpostorRecipe.SERIALIZER.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shaped" ) ) + ); + } } diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java index fee97cd68..4a1e5879c 100644 --- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java +++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java @@ -8,9 +8,9 @@ package dan200.computercraft.shared.computer.recipe; import com.google.gson.JsonObject; import dan200.computercraft.shared.computer.core.ComputerFamily; +import dan200.computercraft.shared.util.BasicRecipeSerializer; import dan200.computercraft.shared.util.RecipeUtil; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; @@ -34,7 +34,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe return family; } - public abstract static class Serializer implements IRecipeSerializer + public abstract static class Serializer extends BasicRecipeSerializer { protected abstract T create( ResourceLocation identifier, String group, int width, int height, NonNullList ingredients, ItemStack result, ComputerFamily family ); diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index 65f1747d1..06ad4fec8 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -15,28 +15,18 @@ import dan200.computercraft.core.tracking.Tracking; import dan200.computercraft.shared.Config; import dan200.computercraft.shared.command.CommandComputerCraft; import dan200.computercraft.shared.command.arguments.ArgumentSerializers; -import dan200.computercraft.shared.common.ColourableRecipe; import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider; import dan200.computercraft.shared.computer.core.IComputer; import dan200.computercraft.shared.computer.core.IContainerComputer; import dan200.computercraft.shared.computer.core.ServerComputer; -import dan200.computercraft.shared.computer.recipe.ComputerUpgradeRecipe; import dan200.computercraft.shared.media.items.RecordMedia; -import dan200.computercraft.shared.media.recipes.DiskRecipe; -import dan200.computercraft.shared.media.recipes.PrintoutRecipe; import dan200.computercraft.shared.network.NetworkHandler; import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeripheral; import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; -import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe; -import dan200.computercraft.shared.turtle.recipes.TurtleRecipe; -import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe; -import dan200.computercraft.shared.util.ImpostorRecipe; -import dan200.computercraft.shared.util.ImpostorShapelessRecipe; import dan200.computercraft.shared.wired.CapabilityWiredElement; import net.minecraft.inventory.container.Container; import net.minecraft.item.Item; import net.minecraft.item.MusicDiscItem; -import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.tileentity.CommandBlockTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.event.entity.player.PlayerContainerEvent; @@ -59,17 +49,6 @@ public final class ComputerCraftProxyCommon registerProviders(); - // Eww, eww, eww - can we move this to an event? - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":colour", ColourableRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":computer_upgrade", ComputerUpgradeRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":pocket_computer_upgrade", PocketComputerUpgradeRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":disk", DiskRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":printout", PrintoutRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":turtle", TurtleRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":turtle_upgrade", TurtleUpgradeRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":impostor_shapeless", ImpostorShapelessRecipe.SERIALIZER ); - IRecipeSerializer.register( ComputerCraft.MOD_ID + ":impostor_shaped", ImpostorRecipe.SERIALIZER ); - ArgumentSerializers.register(); // if( Loader.isModLoaded( ModCharset.MODID ) ) IntegrationCharset.register(); diff --git a/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java b/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java new file mode 100644 index 000000000..6c54dff49 --- /dev/null +++ b/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java @@ -0,0 +1,20 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ + +package dan200.computercraft.shared.util; + +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraftforge.registries.ForgeRegistryEntry; + +/** + * A {@link IRecipeSerializer} which implements all the Forge registry entries. + * + * @param The reciep serializer + */ +public abstract class BasicRecipeSerializer> extends ForgeRegistryEntry> implements IRecipeSerializer +{ +} diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java index 9d73fa54e..8227831b7 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java @@ -58,7 +58,7 @@ public final class ImpostorRecipe extends ShapedRecipe return SERIALIZER; } - public static final IRecipeSerializer SERIALIZER = new IRecipeSerializer() + public static final IRecipeSerializer SERIALIZER = new BasicRecipeSerializer() { @Override public ImpostorRecipe read( @Nonnull ResourceLocation identifier, @Nonnull JsonObject json ) diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java index 779f7e470..16cad7f6d 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java @@ -60,7 +60,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe return SERIALIZER; } - public static final IRecipeSerializer SERIALIZER = new IRecipeSerializer() + public static final IRecipeSerializer SERIALIZER = new BasicRecipeSerializer() { @Override public ImpostorShapelessRecipe read( @Nonnull ResourceLocation id, @Nonnull JsonObject json )