diff --git a/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java b/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java index accee126f..1e30762f8 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumHand; +import net.minecraft.util.Util; import net.minecraftforge.registries.IRegistryDelegate; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; @@ -171,9 +172,9 @@ public final class ColorHandler { } else return -1; }, ModItems.manaGun); - items.register((s, t) -> t == 1 ? Color.HSBtoRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 100D) * 0.5 + 1.2F)) : -1, ModItems.enderDagger); + items.register((s, t) -> t == 1 ? Color.HSBtoRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(Util.milliTime() / 100D) * 0.5 + 1.2F)) : -1, ModItems.enderDagger); - items.register((s, t) -> t == 1 && ItemTerraPick.isEnabled(s) ? Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F) : -1, ModItems.terraPick); + items.register((s, t) -> t == 1 && ItemTerraPick.isEnabled(s) ? Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F) : -1, ModItems.terraPick); handler = (s, t) -> t == 0 ? ((ItemLens) s.getItem()).getLensColor(s) : -1; items.register(handler, ModItems.lensNormal, ModItems.lensSpeed, ModItems.lensPower, ModItems.lensTime, ModItems.lensEfficiency, ModItems.lensBounce, diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index 4369e0462..54fd999f5 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.profiler.Profiler; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Util; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.event.RenderGameOverlayEvent; @@ -302,7 +303,7 @@ public final class HUDHandler { else return; } - Color color = new Color(Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F)); + Color color = new Color(Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F)); GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) (255 - color.getRed())); mc.textureManager.bindTexture(manaBar); diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 5c8c7ee45..b93aa0075 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -69,6 +69,7 @@ import vazkii.botania.common.crafting.ModPetalRecipes; import vazkii.botania.common.crafting.ModPureDaisyRecipes; import vazkii.botania.common.crafting.ModRuneRecipes; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; +import vazkii.botania.common.crafting.recipe.ArmorUpgradeRecipe; import vazkii.botania.common.crafting.recipe.BlackHoleTalismanExtractRecipe; import vazkii.botania.common.crafting.recipe.CompositeLensRecipe; import vazkii.botania.common.crafting.recipe.CosmeticAttachRecipe; @@ -79,6 +80,7 @@ import vazkii.botania.common.crafting.recipe.LensDyeingRecipe; import vazkii.botania.common.crafting.recipe.ManaGunClipRecipe; import vazkii.botania.common.crafting.recipe.ManaGunLensRecipe; import vazkii.botania.common.crafting.recipe.ManaGunRemoveLensRecipe; +import vazkii.botania.common.crafting.recipe.ManaUpgradeRecipe; import vazkii.botania.common.crafting.recipe.PhantomInkRecipe; import vazkii.botania.common.crafting.recipe.SpellClothRecipe; import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; @@ -181,6 +183,7 @@ public class Botania { CriteriaTriggers.register(UseItemSuccessTrigger.INSTANCE); RecipeSerializers.register(AncientWillRecipe.SERIALIZER); + RecipeSerializers.register(ArmorUpgradeRecipe.SERIALIZER); RecipeSerializers.register(BlackHoleTalismanExtractRecipe.SERIALIZER); RecipeSerializers.register(CompositeLensRecipe.SERIALIZER); RecipeSerializers.register(CosmeticAttachRecipe.SERIALIZER); @@ -191,6 +194,7 @@ public class Botania { RecipeSerializers.register(ManaGunClipRecipe.SERIALIZER); RecipeSerializers.register(ManaGunLensRecipe.SERIALIZER); RecipeSerializers.register(ManaGunRemoveLensRecipe.SERIALIZER); + RecipeSerializers.register(ManaUpgradeRecipe.SERIALIZER); RecipeSerializers.register(PhantomInkRecipe.SERIALIZER); RecipeSerializers.register(SpellClothRecipe.SERIALIZER); RecipeSerializers.register(TerraPickTippingRecipe.SERIALIZER); diff --git a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java index 278588f0e..a7495cc0e 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java @@ -13,10 +13,15 @@ package vazkii.botania.common.crafting; import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.crafting.VanillaRecipeTypes; import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.event.server.FMLServerStartingEvent; +import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.registries.IForgeRegistry; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.Botania; @@ -46,6 +51,7 @@ import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibOreDict; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -322,63 +328,14 @@ public final class ModCraftingRecipes { public static ResourceLocation recipeEndPortal; @SubscribeEvent - public static void registerRecipes(RegistryEvent.Register evt) { - IForgeRegistry r = evt.getRegistry(); - - for (ResourceLocation s : BotaniaAPI.getAllSubTiles()) { - r.register(new SpecialFloatingFlowerRecipe(s).setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "floating_" + s.toString().replaceAll(":", "_")))); - } - - // Terrasteel Armor Recipes - r.register(new ArmorUpgradeRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[4], - 'A', new ItemStack(ModItems.manasteelHelmRevealing)).setRegistryName(ModItems.terrasteelHelmRevealing.getRegistryName())); - - r.register(new ArmorUpgradeRecipe(new ItemStack(ModItems.terrasteelHelm), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[4], - 'A', new ItemStack(ModItems.manasteelHelm)).setRegistryName(ModItems.terrasteelHelm.getRegistryName())); - - r.register(new ArmorUpgradeRecipe(new ItemStack(ModItems.terrasteelChest), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[5], - 'A', new ItemStack(ModItems.manasteelChest)).setRegistryName(ModItems.terrasteelChest.getRegistryName())); - - r.register(new ArmorUpgradeRecipe(new ItemStack(ModItems.terrasteelLegs), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[6], - 'A', new ItemStack(ModItems.manasteelLegs)).setRegistryName(ModItems.terrasteelLegs.getRegistryName())); - - r.register(new ArmorUpgradeRecipe(new ItemStack(ModItems.terrasteelBoots), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[7], - 'A', new ItemStack(ModItems.manasteelBoots)).setRegistryName(ModItems.terrasteelBoots.getRegistryName())); - - r.register(new ManaUpgradeRecipe(new ItemStack(ModItems.manaRing), - "TI ", "I I", " I ", - 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), - 'I', LibOreDict.MANA_STEEL).setRegistryName(ModItems.manaRing.getRegistryName())); - - r.register(new ShapelessManaUpgradeRecipe(new ItemStack(ModItems.manaRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.manaRing, 1, Short.MAX_VALUE)).setRegistryName(ModItems.manaRingGreater.getRegistryName())); - - // Terra Shatterer Recipe - r.register(new ManaUpgradeRecipe(new ItemStack(ModItems.terraPick), - "ITI", "ILI", " L ", - 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), - 'I', LibOreDict.TERRA_STEEL, - 'L', LibOreDict.LIVINGWOOD_TWIG).setRegistryName(ModItems.terraPick.getRegistryName())); - + public static void registerRecipes(FMLServerStartingEvent evt) { + evt.getServer().getResourceManager().addReloadListener(manager -> { + // todo 1.13 have each subtile responsible for itself + for (ResourceLocation s : BotaniaAPI.getAllSubTiles()) { + ResourceLocation id = new ResourceLocation(LibMisc.MOD_ID, "floating_" + s.toString().replaceAll(":", "_")); + evt.getServer().getRecipeManager().addRecipe(new SpecialFloatingFlowerRecipe(id, s)); + } + }); } public static void init() { @@ -646,16 +603,16 @@ public final class ModCraftingRecipes { recipeLavenderQuartz = ModItems.lavenderQuartz.getRegistryName(); recipeRedQuartz = ModItems.redQuartz.getRegistryName(); recipeSunnyQuartz = ModItems.sunnyQuartz.getRegistryName(); - recipesShinyFlowers = allOfGroup(ModBlocks.shinyFlower.getRegistryName()); - recipesMiniIsland = allOfGroup(ModBlocks.floatingFlower.getRegistryName()); + recipesShinyFlowers = allOfGroup("shiny_flower"); + recipesMiniIsland = allOfGroup("mini_island"); recipeAzulejo = ModBlocks.azulejo0.getRegistryName(); recipesAzulejoCycling = allOfGroup("azulejo_cycling"); recipeStarfield = ModBlocks.starfield.getRegistryName(); - recipesMushrooms = allOfGroup(ModBlocks.mushroom.getRegistryName()); + recipesMushrooms = allOfGroup("mushroom"); recipePhantomInk = ModItems.phantomInk.getRegistryName(); recipeBlazeBlock = gogPath("blazeblock"); recipeCacophonium = ModItems.cacophonium.getRegistryName(); - recipesPavement = allOfGroup(ModFluffBlocks.pavement.getRegistryName()); + recipesPavement = allOfGroup("pavement"); recipeCellBlock = ModBlocks.cellBlock.getRegistryName(); } @@ -677,11 +634,15 @@ public final class ModCraftingRecipes { } private static List allOfGroup(ResourceLocation group) { + MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); + if(server == null) + return Collections.emptyList(); String jsonGroup = group.toString(); - return ForgeRegistries.RECIPES.getEntries().stream() - .filter(e -> jsonGroup.equals(e.getValue().getGroup())) - .map(Map.Entry::getKey) + return server.getRecipeManager().getRecipes(VanillaRecipeTypes.CRAFTING) + .stream() + .filter(r -> jsonGroup.equals(r.getGroup())) + .map(IRecipe::getId) .collect(Collectors.toList()); } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java index 7bd7526cd..bf92b83d9 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java @@ -25,7 +25,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class ShapelessManaUpgradeRecipe implements IRecipe { - private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "shapeless_mana_upgrade"); + private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "mana_upgrade_shapeless"); private final ShapelessRecipe compose; public ShapelessManaUpgradeRecipe(ShapelessRecipe compose) { diff --git a/src/main/resources/data/botania/recipes/mana_ring.json b/src/main/resources/data/botania/recipes/mana_ring.json new file mode 100644 index 000000000..0b28abe06 --- /dev/null +++ b/src/main/resources/data/botania/recipes/mana_ring.json @@ -0,0 +1,20 @@ +{ + "type": "botania:mana_upgrade", + "result": { + "item": "botania:mana_ring" + }, + "pattern": [ + "TI ", + "I I", + " I " + ], + "key": { + "T": { + "item": "botania:mana_tablet" + }, + "I": { + "todo": "todo tags", + "item": "botania:manasteel_ingot" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/mana_ring_greater.json b/src/main/resources/data/botania/recipes/mana_ring_greater.json new file mode 100644 index 000000000..6b2731f35 --- /dev/null +++ b/src/main/resources/data/botania/recipes/mana_ring_greater.json @@ -0,0 +1,15 @@ +{ + "type": "botania:mana_upgrade_shapeless", + "result": { + "item": "botania:mana_ring_greater" + }, + "ingredients": [ + { + "todo": "TODO tags", + "item": "botania:terrasteel_ingot" + }, + { + "item": "botania:mana_ring" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/terra_pick.json b/src/main/resources/data/botania/recipes/terra_pick.json new file mode 100644 index 000000000..3fc99b5de --- /dev/null +++ b/src/main/resources/data/botania/recipes/terra_pick.json @@ -0,0 +1,23 @@ +{ + "type": "botania:mana_upgrade", + "result": { + "item": "botania:terra_pick" + }, + "pattern": [ + "ITI", + "ILI", + " L " + ], + "key": { + "T": { + "item": "botania:mana_tablet" + }, + "I": { + "__comment": "TODO tag", + "item": "botania:terrasteel_ingot" + }, + "L": { + "item": "botania:livingwood_twig" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/terrasteel_boots.json b/src/main/resources/data/botania/recipes/terrasteel_boots.json new file mode 100644 index 000000000..386744b38 --- /dev/null +++ b/src/main/resources/data/botania/recipes/terrasteel_boots.json @@ -0,0 +1,26 @@ +{ + "type": "botania:armor_upgrade", + "result": { + "item": "botania:terrasteel_boots" + }, + "pattern": [ + "TRT", + "SAS", + " S " + ], + "key": { + "todo": "todo tags", + "T": { + "item": "botania:livingwood_twig" + }, + "S": { + "item": "botania:terrasteel_ingot" + }, + "R": { + "tag": "botania:runes/winter" + }, + "A": { + "item": "botania:manasteel_boots" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/terrasteel_chestplate.json b/src/main/resources/data/botania/recipes/terrasteel_chestplate.json new file mode 100644 index 000000000..aa32d1773 --- /dev/null +++ b/src/main/resources/data/botania/recipes/terrasteel_chestplate.json @@ -0,0 +1,26 @@ +{ + "type": "botania:armor_upgrade", + "result": { + "item": "botania:terrasteel_chestplate" + }, + "pattern": [ + "TRT", + "SAS", + " S " + ], + "key": { + "todo": "todo tags", + "T": { + "item": "botania:livingwood_twig" + }, + "S": { + "item": "botania:terrasteel_ingot" + }, + "R": { + "tag": "botania:runes/summer" + }, + "A": { + "item": "botania:manasteel_chestplate" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/terrasteel_helmet.json b/src/main/resources/data/botania/recipes/terrasteel_helmet.json new file mode 100644 index 000000000..2620c0d6e --- /dev/null +++ b/src/main/resources/data/botania/recipes/terrasteel_helmet.json @@ -0,0 +1,26 @@ +{ + "type": "botania:armor_upgrade", + "result": { + "item": "botania:terrasteel_helmet" + }, + "pattern": [ + "TRT", + "SAS", + " S " + ], + "key": { + "__comment": "todo tags", + "T": { + "item": "botania:livingwood_twig" + }, + "S": { + "item": "botania:terrasteel_ingot" + }, + "R": { + "tag": "botania:runes/spring" + }, + "A": { + "item": "botania:manasteel_helmet" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/terrasteel_helmet_revealing.json b/src/main/resources/data/botania/recipes/terrasteel_helmet_revealing.json new file mode 100644 index 000000000..fb78ec6e0 --- /dev/null +++ b/src/main/resources/data/botania/recipes/terrasteel_helmet_revealing.json @@ -0,0 +1,26 @@ +{ + "type": "botania:armor_upgrade", + "result": { + "item": "botania:terrasteel_helmet_revealing" + }, + "pattern": [ + "TRT", + "SAS", + " S " + ], + "key": { + "__comment": "todo tags", + "T": { + "item": "botania:livingwood_twig" + }, + "S": { + "item": "botania:terrasteel_ingot" + }, + "R": { + "tag": "botania:runes/spring" + }, + "A": { + "item": "botania:manasteel_helmet_revealing" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/terrasteel_leggings.json b/src/main/resources/data/botania/recipes/terrasteel_leggings.json new file mode 100644 index 000000000..0078f833a --- /dev/null +++ b/src/main/resources/data/botania/recipes/terrasteel_leggings.json @@ -0,0 +1,26 @@ +{ + "type": "botania:armor_upgrade", + "result": { + "item": "botania:terrasteel_leggings" + }, + "pattern": [ + "TRT", + "SAS", + " S " + ], + "key": { + "todo": "todo tags", + "T": { + "item": "botania:livingwood_twig" + }, + "S": { + "item": "botania:terrasteel_ingot" + }, + "R": { + "tag": "botania:runes/autumn" + }, + "A": { + "item": "botania:manasteel_leggings" + } + } +} \ No newline at end of file