From 9035e4376ad30848157be8051644f58e3f056ca6 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Wed, 14 Aug 2019 17:15:34 +0300 Subject: [PATCH] Fix for #1782, cheap basic tools and fixed some warnings here and there --- .../blockentity/cable/CableBlockEntity.java | 5 ++- .../IndustrialGrinderBlockEntity.java | 11 ------ .../tier1/AutoCraftingTableBlockEntity.java | 35 +++++++++---------- .../client/gui/GuiAutoCrafting.java | 4 +-- .../client/gui/GuiDestructoPack.java | 4 +-- .../assets/techreborn/lang/en_us.json | 1 + .../crafting_table/tool/basic_chainsaw.json | 2 +- .../crafting_table/tool/basic_drill.json | 2 +- .../crafting_table/tool/basic_jackhammer.json | 2 +- 9 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java b/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java index 18202f011..a9c4ad120 100644 --- a/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java +++ b/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java @@ -134,7 +134,10 @@ public class CableBlockEntity extends BlockEntity continue; } else if (blockEntity instanceof EnergyBlockEntity) { EnergyBlockEntity acceptor = (EnergyBlockEntity) blockEntity; - if (energy <= acceptor.getEnergy() || !acceptor.canAcceptEnergy(face.getOpposite())) { + if (blockEntity instanceof CableBlockEntity && energy <= acceptor.getEnergy()) { + continue; + } + if (!acceptor.canAcceptEnergy(face.getOpposite())) { continue; } acceptors.add(acceptor); diff --git a/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java b/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java index 90cf6a951..b5bb357ff 100644 --- a/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java @@ -34,7 +34,6 @@ import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; import reborncore.common.recipes.RecipeCrafter; -import reborncore.common.util.IInventoryAccess; import reborncore.common.util.RebornInventory; import reborncore.common.util.Tank; import techreborn.config.TechRebornConfig; @@ -76,16 +75,6 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl && centerBlock.getMaterial() == Material.WATER); return down && center && blade && up; } - - private static IInventoryAccess getInventoryAccess(){ - return (slotID, stack, face, direction, blockEntity) -> { - if(slotID == 1){ - //TODO check if the item has fluid in it - //return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).isPresent(); - } - return true; - }; - } // TilePowerAcceptor @Override diff --git a/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java index 45392c2bc..297a565dd 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java @@ -29,6 +29,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; +import net.minecraft.recipe.CraftingRecipe; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeType; @@ -48,12 +49,12 @@ import reborncore.common.util.ItemUtils; import techreborn.config.TechRebornConfig; import techreborn.init.ModSounds; import techreborn.init.TRContent; -import techreborn.utils.RecipeUtils; import techreborn.init.TRBlockEntities; import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.Optional; /** * Created by modmuss50 on 20/06/2017. @@ -67,8 +68,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity public int euTick = 10; CraftingInventory inventoryCrafting = null; - Recipe lastCustomRecipe = null; - Recipe lastRecipe = null; + CraftingRecipe lastCustomRecipe = null; + CraftingRecipe lastRecipe = null; public boolean locked = true; @@ -77,7 +78,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity } @Nullable - public Recipe getIRecipe() { + public CraftingRecipe getIRecipe() { CraftingInventory crafting = getCraftingInventory(); if (!crafting.isInvEmpty()) { if (lastRecipe != null) { @@ -85,11 +86,10 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity return lastRecipe; } } - for (Recipe testRecipe : RecipeUtils.getRecipes(world, RecipeType.CRAFTING)) { - if (testRecipe.matches(crafting, world)) { - lastRecipe = testRecipe; - return testRecipe; - } + Optional testRecipe = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, crafting, world); + if (testRecipe.isPresent()) { + lastRecipe = testRecipe.get(); + return lastRecipe; } } return null; @@ -110,7 +110,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity return inventoryCrafting; } - public boolean canMake(Recipe recipe) { + public boolean canMake(CraftingRecipe recipe) { if (recipe != null && recipe.fits(3, 3)) { boolean missingOutput = false; int[] stacksInSlots = new int[9]; @@ -177,7 +177,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity return false; } - public boolean make(Recipe recipe) { + public boolean make(CraftingRecipe recipe) { if (recipe == null || !canMake(recipe)) { return false; } @@ -203,10 +203,9 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity } } ItemStack output = inventory.getInvStack(9); - // TODO fire forge recipe event - ItemStack ouputStack = recipe.craft(getCraftingInventory()); + ItemStack outputStack = recipe.craft(getCraftingInventory()); if (output.isEmpty()) { - inventory.setInvStack(9, ouputStack.copy()); + inventory.setInvStack(9, outputStack.copy()); } else { // TODO use ouputStack in someway? output.increment(recipe.getOutput().getCount()); @@ -239,7 +238,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity return false; } - public boolean isItemValidForRecipeSlot(Recipe recipe, ItemStack stack, int slotID) { + public boolean isItemValidForRecipeSlot(Recipe recipe, ItemStack stack, int slotID) { if (recipe == null) { return true; } @@ -250,7 +249,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity return true; } - public int findBestSlotForStack(Recipe recipe, ItemStack stack) { + public int findBestSlotForStack(Recipe recipe, ItemStack stack) { if (recipe == null) { return -1; } @@ -314,7 +313,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity if (world.isClient) { return; } - Recipe recipe = getIRecipe(); + CraftingRecipe recipe = getIRecipe(); if (recipe != null) { if (progress >= maxProgress) { if (make(recipe)) { @@ -427,7 +426,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity // ItemHandlerProvider @Override - public RebornInventory getInventory() { + public RebornInventory getInventory() { return inventory; } diff --git a/src/main/java/techreborn/client/gui/GuiAutoCrafting.java b/src/main/java/techreborn/client/gui/GuiAutoCrafting.java index 8d39c1184..353662be5 100644 --- a/src/main/java/techreborn/client/gui/GuiAutoCrafting.java +++ b/src/main/java/techreborn/client/gui/GuiAutoCrafting.java @@ -27,7 +27,7 @@ package techreborn.client.gui; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.CraftingRecipe; import net.minecraft.util.Identifier; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.gui.builder.GuiBase; @@ -57,7 +57,7 @@ public class GuiAutoCrafting extends GuiBase { @Override protected void drawForeground(int mouseX, int mouseY) { super.drawForeground(mouseX, mouseY); - Recipe recipe = blockEntityAutoCraftingTable.getIRecipe(); + CraftingRecipe recipe = blockEntityAutoCraftingTable.getIRecipe(); if (recipe != null) { renderItemStack(recipe.getOutput(), 95, 42); } diff --git a/src/main/java/techreborn/client/gui/GuiDestructoPack.java b/src/main/java/techreborn/client/gui/GuiDestructoPack.java index a1b8c3209..a26a0462e 100644 --- a/src/main/java/techreborn/client/gui/GuiDestructoPack.java +++ b/src/main/java/techreborn/client/gui/GuiDestructoPack.java @@ -32,7 +32,7 @@ import net.minecraft.container.Container; import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; -public class GuiDestructoPack extends AbstractContainerScreen { +public class GuiDestructoPack extends AbstractContainerScreen { private static final Identifier texture = new Identifier("techreborn", "textures/gui/destructopack.png"); @@ -53,7 +53,7 @@ public class GuiDestructoPack extends AbstractContainerScreen { @Override protected void drawForeground(int arg0, int arg1) { - String name = I18n.translate("item.techreborn.part.destructoPack.name"); + String name = I18n.translate("item.techreborn.destructopack"); font.draw(name, containerWidth / 2 - font.getStringWidth(name) / 2, 5, 4210752); this.font.draw(I18n.translate("container.inventory"), 8, this.containerHeight - 96 + 2, 4210752); diff --git a/src/main/resources/assets/techreborn/lang/en_us.json b/src/main/resources/assets/techreborn/lang/en_us.json index a0cd7abbf..cbe986d3c 100644 --- a/src/main/resources/assets/techreborn/lang/en_us.json +++ b/src/main/resources/assets/techreborn/lang/en_us.json @@ -511,6 +511,7 @@ "item.techreborn.basic_jackhammer": "Steel Jackhammer", "item.techreborn.treetap": "Treetap", "item.techreborn.wrench": "Wrench", + "item.techreborn.destructopack": "Destructopack", "_comment17": "Items-Misc", "item.techreborn.cell": "Empty Cell", diff --git a/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_chainsaw.json b/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_chainsaw.json index 99e410139..6820bfd62 100644 --- a/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_chainsaw.json +++ b/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_chainsaw.json @@ -7,7 +7,7 @@ ], "key": { "S": { - "tag": "c:steel_ingot" + "item": "techreborn:refined_iron_ingot" }, "C": { "item": "techreborn:electronic_circuit" diff --git a/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_drill.json b/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_drill.json index 07ca42b70..715214942 100644 --- a/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_drill.json +++ b/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_drill.json @@ -7,7 +7,7 @@ ], "key": { "S": { - "tag": "c:steel_ingot" + "item": "techreborn:refined_iron_ingot" }, "C": { "item": "techreborn:electronic_circuit" diff --git a/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_jackhammer.json b/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_jackhammer.json index 59110e5a1..89339b135 100644 --- a/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_jackhammer.json +++ b/src/main/resources/data/techreborn/recipes/crafting_table/tool/basic_jackhammer.json @@ -7,7 +7,7 @@ ], "key": { "S": { - "tag": "c:steel_ingot" + "item": "techreborn:refined_iron_ingot" }, "C": { "item": "techreborn:electronic_circuit"