From 0338393b2ab9cd732fcf0c96eb3822e1cfb2c89c Mon Sep 17 00:00:00 2001 From: CannoliCatfish Date: Wed, 22 Jun 2022 13:12:35 -0400 Subject: [PATCH] Fixed element indexer and removed foraging recipes --- .../rankine/ProjectRankine.java | 1 + .../items/indexer/ElementIndexerScreen.java | 11 ++-- .../rankine/recipe/ForagingRecipe.java | 35 ++++++---- src/main/resources/META-INF/mods.toml | 2 +- .../recipes/foraging/badlands_foraging.json | 36 ---------- .../recipes/foraging/desert_foraging.json | 36 ---------- .../recipes/foraging/forest_foraging.json | 39 ----------- .../recipes/foraging/hill_foraging.json | 35 ---------- .../recipes/foraging/jungle_foraging.json | 39 ----------- .../recipes/foraging/mountain_foraging.json | 35 ---------- .../recipes/foraging/mycelium_foraging.json | 15 ----- .../recipes/foraging/plains_foraging.json | 65 ------------------- .../recipes/foraging/podzol_foraging.json | 19 ------ .../recipes/foraging/river_foraging.json | 47 -------------- .../recipes/foraging/savanna_foraging.json | 61 ----------------- .../recipes/foraging/swamp_foraging.json | 35 ---------- .../recipes/foraging/taiga_foraging.json | 43 ------------ 17 files changed, 30 insertions(+), 524 deletions(-) delete mode 100644 src/main/resources/data/rankine/recipes/foraging/badlands_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/desert_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/forest_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/hill_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/jungle_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/mountain_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/mycelium_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/plains_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/podzol_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/river_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/savanna_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/swamp_foraging.json delete mode 100644 src/main/resources/data/rankine/recipes/foraging/taiga_foraging.json diff --git a/src/main/java/com/cannolicatfish/rankine/ProjectRankine.java b/src/main/java/com/cannolicatfish/rankine/ProjectRankine.java index 1e3a2777f7..4def252f06 100644 --- a/src/main/java/com/cannolicatfish/rankine/ProjectRankine.java +++ b/src/main/java/com/cannolicatfish/rankine/ProjectRankine.java @@ -265,6 +265,7 @@ public static void clientSetupEvent(FMLClientSetupEvent event) } @SubscribeEvent + @OnlyIn(Dist.CLIENT) public static void registerEntityRenderers(EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(RankineEntityTypes.ALLOY_SPEAR.get(), SpearEntityRenderer.instance); diff --git a/src/main/java/com/cannolicatfish/rankine/items/indexer/ElementIndexerScreen.java b/src/main/java/com/cannolicatfish/rankine/items/indexer/ElementIndexerScreen.java index 7221836f3b..c9c8a2e758 100644 --- a/src/main/java/com/cannolicatfish/rankine/items/indexer/ElementIndexerScreen.java +++ b/src/main/java/com/cannolicatfish/rankine/items/indexer/ElementIndexerScreen.java @@ -3,11 +3,13 @@ import com.cannolicatfish.rankine.ProjectRankine; import com.cannolicatfish.rankine.recipe.ElementRecipe; import com.cannolicatfish.rankine.util.PeriodicTableUtils; +import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.resources.ResourceLocation; import net.minecraft.Util; @@ -103,16 +105,17 @@ protected void renderLabels(PoseStack matrixStack, int x, int y) { } public void drawScaledString(PoseStack stack, Font fontRendererIn, String text, int x, int y, float size, int color) { - GL11.glScalef(size,size,size); + stack.scale(size,size,size); float mSize = (float)Math.pow(size,-1); drawString(stack, fontRendererIn,text,Math.round(x / size),Math.round(y / size),color); - GL11.glScalef(mSize,mSize,mSize); + stack.scale(mSize,mSize,mSize); } @Override protected void renderBg(PoseStack matrixStack, float partialTicks, int x, int y) { - GlStateManager._clearColor(1.0F, 1.0F, 1.0F, 1.0F); - this.minecraft.getTextureManager().bindForSetup(this.GUI); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, this.GUI); int i = this.leftPos; int j = this.topPos; this.blit(matrixStack, i, j, 0, 0, this.imageWidth, this.imageHeight); diff --git a/src/main/java/com/cannolicatfish/rankine/recipe/ForagingRecipe.java b/src/main/java/com/cannolicatfish/rankine/recipe/ForagingRecipe.java index d12621896e..d2395f9d23 100644 --- a/src/main/java/com/cannolicatfish/rankine/recipe/ForagingRecipe.java +++ b/src/main/java/com/cannolicatfish/rankine/recipe/ForagingRecipe.java @@ -37,14 +37,16 @@ public class ForagingRecipe implements Recipe { private final NonNullList recipeOutputs; private final NonNullList weights; private final NonNullList enchantments; + private final boolean allBiomes; - public ForagingRecipe(ResourceLocation id, List biomes, Ingredient ingredientIn, NonNullList recipeOutputsIn, NonNullList weights, NonNullList enchantments) { + public ForagingRecipe(ResourceLocation id, List biomes, Ingredient ingredientIn, NonNullList recipeOutputsIn, NonNullList weights, NonNullList enchantments, boolean allBiomes) { this.id = id; this.biomes = biomes; this.ingredient = ingredientIn; this.recipeOutputs = recipeOutputsIn; this.weights = weights; this.enchantments = enchantments; + this.allBiomes = allBiomes; } @Override @@ -107,7 +109,7 @@ public static List getValidRecipes(Level levelIn, ResourceLocati if (levelIn != null) { List recipes = new ArrayList<>(); for (ForagingRecipe recipe : levelIn.getRecipeManager().getAllRecipesFor(RankineRecipeTypes.FORAGING)) { - if (recipe.getBiomes().contains(biomeName.toString()) && recipe.getIngredient().test(new ItemStack(state.getBlock().asItem()))) { + if ((recipe.allBiomes || recipe.getBiomes().contains(biomeName.toString())) && recipe.getIngredient().test(new ItemStack(state.getBlock().asItem()))) { recipes.add(recipe); } } @@ -162,12 +164,9 @@ public static class Serializer extends ForgeRegistryEntry> i public ForagingRecipe fromJson(ResourceLocation recipeId, JsonObject json) { JsonElement biomesArray = json.has("biomes") ? json.get("biomes") : null; List biomes = new ArrayList<>(); - - if (biomesArray == null) { - for (Biome b : ForgeRegistries.BIOMES.getValues()) { - biomes.add(b.getRegistryName().toString()); - } - } else if (biomesArray.isJsonObject()) { + boolean allBiomes = true; + if (biomesArray != null && biomesArray.isJsonObject()) { + allBiomes = false; JsonObject object = biomesArray.getAsJsonObject(); if (object.has("biome")){ biomes.add(object.get("biome").getAsString()); @@ -207,7 +206,7 @@ public ForagingRecipe fromJson(ResourceLocation recipeId, JsonObject json) { i++; } - return new ForagingRecipe(recipeId,biomes,ingredient,stacks,weights,enchantements); + return new ForagingRecipe(recipeId,biomes,ingredient,stacks,weights,enchantements,allBiomes); } @Nullable @@ -215,9 +214,14 @@ public ForagingRecipe fromJson(ResourceLocation recipeId, JsonObject json) { public ForagingRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) { int biomesSize = buffer.readInt(); List biomes = new ArrayList<>(); - for (int i = 0; i < biomesSize; i++) { - biomes.set(i,buffer.readUtf()); + boolean allBiomes = true; + if (biomesSize > 0) { + allBiomes = false; + for (int i = 0; i < biomesSize; i++) { + biomes.set(i,buffer.readUtf()); + } } + Ingredient input = Ingredient.fromNetwork(buffer); int t = buffer.readVarInt(); @@ -231,15 +235,18 @@ public ForagingRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buf enchantements.set(i,buffer.readBoolean()); } - return new ForagingRecipe(recipeId, biomes, input, stacks, weights, enchantements); + return new ForagingRecipe(recipeId, biomes, input, stacks, weights, enchantements, allBiomes); } @Override public void toNetwork(FriendlyByteBuf buffer, ForagingRecipe recipe) { buffer.writeInt(recipe.getBiomes().size()); - for (int i = 0; i < recipe.getBiomes().size(); i++) { - buffer.writeUtf(recipe.getBiomes().get(i)); + if (recipe.getBiomes().size() > 0) { + for (int i = 0; i < recipe.getBiomes().size(); i++) { + buffer.writeUtf(recipe.getBiomes().get(i)); + } } + recipe.getIngredient().toNetwork(buffer); buffer.writeVarInt(recipe.getOutputs().size()); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ec36ab8c2a..fe09e66da8 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -16,7 +16,7 @@ issueTrackerURL="http://my.issue.tracker/" #optional # The modid of the mod modId="rankine" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version="1.3.1" #mandatory +version="1.3.3" #mandatory # A display name for the mod displayName="Project Rankine" #mandatory # A URL to query for updates for this mod. See the JSON update specification diff --git a/src/main/resources/data/rankine/recipes/foraging/badlands_foraging.json b/src/main/resources/data/rankine/recipes/foraging/badlands_foraging.json deleted file mode 100644 index 76b8ada83e..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/badlands_foraging.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:badlands" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 40 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "minecraft:stick", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - }, - { - "item": "minecraft:bone", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/desert_foraging.json b/src/main/resources/data/rankine/recipes/foraging/desert_foraging.json deleted file mode 100644 index afd513030d..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/desert_foraging.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:desert" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 40 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "minecraft:stick", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - }, - { - "item": "minecraft:bone", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/forest_foraging.json b/src/main/resources/data/rankine/recipes/foraging/forest_foraging.json deleted file mode 100644 index ea19cf36e1..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/forest_foraging.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:forest" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "minecraft:carrot", - "weight": 1 - }, - { - "item": "rankine:elderberries", - "weight": 1 - }, - { - "item": "rankine:pokeberries", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/hill_foraging.json b/src/main/resources/data/rankine/recipes/foraging/hill_foraging.json deleted file mode 100644 index 6f4a71861a..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/hill_foraging.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biomeTag": "minecraft:is_hill" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "rankine:strawberries", - "weight": 1 - }, - { - "item": "rankine:snowberries", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/jungle_foraging.json b/src/main/resources/data/rankine/recipes/foraging/jungle_foraging.json deleted file mode 100644 index 0b7456e508..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/jungle_foraging.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:jungle" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "minecraft:melon_seeds", - "weight": 1 - }, - { - "item": "minecraft:cocoa_beans", - "weight": 1 - }, - { - "item": "rankine:pineapple", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/mountain_foraging.json b/src/main/resources/data/rankine/recipes/foraging/mountain_foraging.json deleted file mode 100644 index 31b713612e..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/mountain_foraging.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biomeTag": "minecraft:is_mountain" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "rankine:strawberries", - "weight": 1 - }, - { - "item": "rankine:snowberries", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/mycelium_foraging.json b/src/main/resources/data/rankine/recipes/foraging/mycelium_foraging.json deleted file mode 100644 index a1c9b20449..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/mycelium_foraging.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "type": "rankine:foraging", - "input": { - "tag": "forge:mycelium" - }, - "outputs": [ - { - "weight": 19 - }, - { - "tag": "minecraft:mushrooms", - "weight": 1 - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/plains_foraging.json b/src/main/resources/data/rankine/recipes/foraging/plains_foraging.json deleted file mode 100644 index f951bf3f63..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/plains_foraging.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:plains" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "minecraft:wheat_seeds", - "weight": 0.5 - }, - { - "item": "rankine:oat_seeds", - "weight": 0.5 - }, - { - "item": "rankine:barley_seeds", - "weight": 0.5 - }, - { - "item": "rankine:sorghum_seeds", - "weight": 0.5 - }, - { - "item": "rankine:corn_seeds", - "weight": 0.5 - }, - { - "item": "rankine:blueberries", - "weight": 1 - }, - { - "item": "rankine:strawberries", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - }, - { - "item": "minecraft:feather", - "weight": 1, - "enchantmentRequired": true - }, - { - "item": "minecraft:leather", - "weight": 0.2, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/podzol_foraging.json b/src/main/resources/data/rankine/recipes/foraging/podzol_foraging.json deleted file mode 100644 index 162090a916..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/podzol_foraging.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "rankine:foraging", - "input": { - "tag": "forge:podzol" - }, - "outputs": [ - { - "weight": 20 - }, - { - "tag": "minecraft:leaves", - "weight": 1 - }, - { - "item": "minecraft:stick", - "weight": 4 - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/river_foraging.json b/src/main/resources/data/rankine/recipes/foraging/river_foraging.json deleted file mode 100644 index ecdf62aec9..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/river_foraging.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:river" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "rankine:rice_seeds", - "weight": 1 - }, - { - "item": "minecraft:sugar_cane", - "weight": 1 - }, - { - "item": "minecraft:potato", - "weight": 1 - }, - { - "item": "minecraft:carrot", - "weight": 1 - }, - { - "item": "minecraft:beetroot", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/savanna_foraging.json b/src/main/resources/data/rankine/recipes/foraging/savanna_foraging.json deleted file mode 100644 index f674f199db..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/savanna_foraging.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:savanna" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 4 - }, - { - "item": "minecraft:wheat_seeds", - "weight": 0.5 - }, - { - "item": "rankine:millet_seeds", - "weight": 0.5 - }, - { - "item": "rankine:rye_seeds", - "weight": 0.5 - }, - { - "item": "rankine:sorghum_seeds", - "weight": 0.5 - }, - { - "item": "rankine:aloe", - "weight": 0.5 - }, - { - "item": "rankine:banana_yucca", - "weight": 0.5 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - }, - { - "item": "minecraft:feather", - "weight": 1, - "enchantmentRequired": true - }, - { - "item": "minecraft:leather", - "weight": 0.2, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/swamp_foraging.json b/src/main/resources/data/rankine/recipes/foraging/swamp_foraging.json deleted file mode 100644 index 84f05b1359..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/swamp_foraging.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:swamp" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "tag": "minecraft:mushrooms", - "weight": 1 - }, - { - "item": "rankine:cranberries", - "weight": 1 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/rankine/recipes/foraging/taiga_foraging.json b/src/main/resources/data/rankine/recipes/foraging/taiga_foraging.json deleted file mode 100644 index 5a411d960e..0000000000 --- a/src/main/resources/data/rankine/recipes/foraging/taiga_foraging.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "type": "rankine:foraging", - "biomes": { - "biome": "minecraft:taiga" - }, - "input": { - "tag": "forge:grass_blocks" - }, - "outputs": [ - { - "weight": 20 - }, - { - "item": "rankine:grass_seeds", - "weight": 1 - }, - { - "item": "rankine:plant_fiber", - "weight": 2 - }, - { - "item": "minecraft:beetroot", - "weight": 1 - }, - { - "item": "minecraft:sweet_berries", - "weight": 0.5 - }, - { - "item": "rankine:raspberries", - "weight": 0.5 - }, - { - "item": "rankine:blackberries", - "weight": 0.5 - }, - { - "item": "rankine:saltpeter", - "weight": 1, - "enchantmentRequired": true - } - ] -} \ No newline at end of file