Fix for #1782, cheap basic tools and fixed some warnings here and there

This commit is contained in:
drcrazy 2019-08-14 17:15:34 +03:00
parent dc8511f1f0
commit 9035e4376a
9 changed files with 29 additions and 37 deletions

View file

@ -134,7 +134,10 @@ public class CableBlockEntity extends BlockEntity
continue; continue;
} else if (blockEntity instanceof EnergyBlockEntity) { } else if (blockEntity instanceof EnergyBlockEntity) {
EnergyBlockEntity acceptor = (EnergyBlockEntity) blockEntity; 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; continue;
} }
acceptors.add(acceptor); acceptors.add(acceptor);

View file

@ -34,7 +34,6 @@ import reborncore.client.containerBuilder.IContainerProvider;
import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.containerBuilder.builder.ContainerBuilder; import reborncore.client.containerBuilder.builder.ContainerBuilder;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.IInventoryAccess;
import reborncore.common.util.RebornInventory; import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import techreborn.config.TechRebornConfig; import techreborn.config.TechRebornConfig;
@ -76,16 +75,6 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
&& centerBlock.getMaterial() == Material.WATER); && centerBlock.getMaterial() == Material.WATER);
return down && center && blade && up; return down && center && blade && up;
} }
private static IInventoryAccess<IndustrialGrinderBlockEntity> 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 // TilePowerAcceptor
@Override @Override

View file

@ -29,6 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeType;
@ -48,12 +49,12 @@ import reborncore.common.util.ItemUtils;
import techreborn.config.TechRebornConfig; import techreborn.config.TechRebornConfig;
import techreborn.init.ModSounds; import techreborn.init.ModSounds;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.utils.RecipeUtils;
import techreborn.init.TRBlockEntities; import techreborn.init.TRBlockEntities;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* Created by modmuss50 on 20/06/2017. * Created by modmuss50 on 20/06/2017.
@ -67,8 +68,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
public int euTick = 10; public int euTick = 10;
CraftingInventory inventoryCrafting = null; CraftingInventory inventoryCrafting = null;
Recipe lastCustomRecipe = null; CraftingRecipe lastCustomRecipe = null;
Recipe lastRecipe = null; CraftingRecipe lastRecipe = null;
public boolean locked = true; public boolean locked = true;
@ -77,7 +78,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
} }
@Nullable @Nullable
public Recipe getIRecipe() { public CraftingRecipe getIRecipe() {
CraftingInventory crafting = getCraftingInventory(); CraftingInventory crafting = getCraftingInventory();
if (!crafting.isInvEmpty()) { if (!crafting.isInvEmpty()) {
if (lastRecipe != null) { if (lastRecipe != null) {
@ -85,11 +86,10 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return lastRecipe; return lastRecipe;
} }
} }
for (Recipe testRecipe : RecipeUtils.getRecipes(world, RecipeType.CRAFTING)) { Optional<CraftingRecipe> testRecipe = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, crafting, world);
if (testRecipe.matches(crafting, world)) { if (testRecipe.isPresent()) {
lastRecipe = testRecipe; lastRecipe = testRecipe.get();
return testRecipe; return lastRecipe;
}
} }
} }
return null; return null;
@ -110,7 +110,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return inventoryCrafting; return inventoryCrafting;
} }
public boolean canMake(Recipe<CraftingInventory> recipe) { public boolean canMake(CraftingRecipe recipe) {
if (recipe != null && recipe.fits(3, 3)) { if (recipe != null && recipe.fits(3, 3)) {
boolean missingOutput = false; boolean missingOutput = false;
int[] stacksInSlots = new int[9]; int[] stacksInSlots = new int[9];
@ -177,7 +177,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return false; return false;
} }
public boolean make(Recipe<CraftingInventory> recipe) { public boolean make(CraftingRecipe recipe) {
if (recipe == null || !canMake(recipe)) { if (recipe == null || !canMake(recipe)) {
return false; return false;
} }
@ -203,10 +203,9 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
} }
} }
ItemStack output = inventory.getInvStack(9); ItemStack output = inventory.getInvStack(9);
// TODO fire forge recipe event ItemStack outputStack = recipe.craft(getCraftingInventory());
ItemStack ouputStack = recipe.craft(getCraftingInventory());
if (output.isEmpty()) { if (output.isEmpty()) {
inventory.setInvStack(9, ouputStack.copy()); inventory.setInvStack(9, outputStack.copy());
} else { } else {
// TODO use ouputStack in someway? // TODO use ouputStack in someway?
output.increment(recipe.getOutput().getCount()); output.increment(recipe.getOutput().getCount());
@ -239,7 +238,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return false; return false;
} }
public boolean isItemValidForRecipeSlot(Recipe recipe, ItemStack stack, int slotID) { public boolean isItemValidForRecipeSlot(Recipe<CraftingInventory> recipe, ItemStack stack, int slotID) {
if (recipe == null) { if (recipe == null) {
return true; return true;
} }
@ -250,7 +249,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return true; return true;
} }
public int findBestSlotForStack(Recipe recipe, ItemStack stack) { public int findBestSlotForStack(Recipe<CraftingInventory> recipe, ItemStack stack) {
if (recipe == null) { if (recipe == null) {
return -1; return -1;
} }
@ -314,7 +313,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if (world.isClient) { if (world.isClient) {
return; return;
} }
Recipe recipe = getIRecipe(); CraftingRecipe recipe = getIRecipe();
if (recipe != null) { if (recipe != null) {
if (progress >= maxProgress) { if (progress >= maxProgress) {
if (make(recipe)) { if (make(recipe)) {
@ -427,7 +426,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
// ItemHandlerProvider // ItemHandlerProvider
@Override @Override
public RebornInventory getInventory() { public RebornInventory<AutoCraftingTableBlockEntity> getInventory() {
return inventory; return inventory;
} }

View file

@ -27,7 +27,7 @@ package techreborn.client.gui;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
@ -57,7 +57,7 @@ public class GuiAutoCrafting extends GuiBase<BuiltContainer> {
@Override @Override
protected void drawForeground(int mouseX, int mouseY) { protected void drawForeground(int mouseX, int mouseY) {
super.drawForeground(mouseX, mouseY); super.drawForeground(mouseX, mouseY);
Recipe recipe = blockEntityAutoCraftingTable.getIRecipe(); CraftingRecipe recipe = blockEntityAutoCraftingTable.getIRecipe();
if (recipe != null) { if (recipe != null) {
renderItemStack(recipe.getOutput(), 95, 42); renderItemStack(recipe.getOutput(), 95, 42);
} }

View file

@ -32,7 +32,7 @@ import net.minecraft.container.Container;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class GuiDestructoPack extends AbstractContainerScreen { public class GuiDestructoPack extends AbstractContainerScreen<Container> {
private static final Identifier texture = new Identifier("techreborn", private static final Identifier texture = new Identifier("techreborn",
"textures/gui/destructopack.png"); "textures/gui/destructopack.png");
@ -53,7 +53,7 @@ public class GuiDestructoPack extends AbstractContainerScreen {
@Override @Override
protected void drawForeground(int arg0, int arg1) { 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); font.draw(name, containerWidth / 2 - font.getStringWidth(name) / 2, 5, 4210752);
this.font.draw(I18n.translate("container.inventory"), 8, this.containerHeight - 96 + 2, this.font.draw(I18n.translate("container.inventory"), 8, this.containerHeight - 96 + 2,
4210752); 4210752);

View file

@ -511,6 +511,7 @@
"item.techreborn.basic_jackhammer": "Steel Jackhammer", "item.techreborn.basic_jackhammer": "Steel Jackhammer",
"item.techreborn.treetap": "Treetap", "item.techreborn.treetap": "Treetap",
"item.techreborn.wrench": "Wrench", "item.techreborn.wrench": "Wrench",
"item.techreborn.destructopack": "Destructopack",
"_comment17": "Items-Misc", "_comment17": "Items-Misc",
"item.techreborn.cell": "Empty Cell", "item.techreborn.cell": "Empty Cell",

View file

@ -7,7 +7,7 @@
], ],
"key": { "key": {
"S": { "S": {
"tag": "c:steel_ingot" "item": "techreborn:refined_iron_ingot"
}, },
"C": { "C": {
"item": "techreborn:electronic_circuit" "item": "techreborn:electronic_circuit"

View file

@ -7,7 +7,7 @@
], ],
"key": { "key": {
"S": { "S": {
"tag": "c:steel_ingot" "item": "techreborn:refined_iron_ingot"
}, },
"C": { "C": {
"item": "techreborn:electronic_circuit" "item": "techreborn:electronic_circuit"

View file

@ -7,7 +7,7 @@
], ],
"key": { "key": {
"S": { "S": {
"tag": "c:steel_ingot" "item": "techreborn:refined_iron_ingot"
}, },
"C": { "C": {
"item": "techreborn:electronic_circuit" "item": "techreborn:electronic_circuit"