diff --git a/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java b/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java index c7150451a13..e030f33e639 100644 --- a/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java +++ b/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java @@ -40,7 +40,6 @@ import bartworks.util.BWUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTechAPI; import gregtech.api.enums.GTValues; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -63,12 +62,10 @@ public ItemCircuitProgrammer() { this.setNoRepair(); this.setHasSubtypes(false); this.setCreativeTab(MainMod.BWT); - GregTechAPI.registerCircuitProgrammer( - s -> s.getItem() instanceof ItemCircuitProgrammer && ElectricItem.manager.canUse(s, COST_PER_USE), - (s, p) -> { - ElectricItem.manager.use(s, COST_PER_USE, p); - return s; - }); + } + + public void useItem(ItemStack stack, EntityPlayer player) { + ElectricItem.manager.use(stack, COST_PER_USE, player); } @Override diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java index 0d36a897aec..cde9519e351 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java @@ -72,7 +72,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -120,7 +120,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 6; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java index 472af5e84e2..44af8fb18dd 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java @@ -73,7 +73,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -121,7 +121,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 7; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java index f1e46b2c6f9..6e89cf067ff 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java @@ -74,7 +74,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -122,7 +122,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 8; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java index a54348f19ac..bff630a06ea 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java @@ -73,7 +73,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -121,7 +121,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 9; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java index fd652356f95..e382dc99a9b 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java @@ -74,7 +74,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -122,7 +122,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 10; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java index c6c54e448a8..5c1a49e58f0 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java @@ -105,10 +105,8 @@ protected IStructureDefinition computeValue(Class typ .atLeast( gregtech.api.enums.HatchElement.InputHatch.or(gregtech.api.enums.HatchElement.InputBus), gregtech.api.enums.HatchElement.OutputHatch) - .adder(MTELargeFusionComputer::addFluidIO) .casingIndex(x.textureIndex()) .dot(1) - .hatchItemFilterAnd(x2 -> filterByMTETier(x2.hatchTier(), Integer.MAX_VALUE)) .buildAndChain(x.getGlassBlock(), x.getGlassMeta()))) .addElement( 'E', @@ -119,7 +117,7 @@ protected IStructureDefinition computeValue(Class typ .or(gregtech.api.enums.HatchElement.Energy)) .adder(MTELargeFusionComputer::addEnergyInjector) .casingIndex(x.textureIndex()) - .hatchItemFilterAnd(x2 -> filterByMTETier(x2.hatchTier(), Integer.MAX_VALUE)) + .hatchItemFilterAnd(x2 -> filterByMTETier(x2.energyHatchTier(), Integer.MAX_VALUE)) .dot(2) .buildAndChain(x.getCasingBlock(), x.getCasingMeta()))) .addElement('F', lazy(x -> ofFrame(x.getFrameBox()))) @@ -197,7 +195,7 @@ public long maxEUStore() { public abstract int getGlassMeta(); - public abstract int hatchTier(); + public abstract int energyHatchTier(); public abstract Materials getFrameBox(); @@ -485,40 +483,17 @@ private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int a IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof MTEHatchEnergy tHatch) { - if (tHatch.getTierForStructure() < hatchTier()) return false; + if (tHatch.getTierForStructure() < energyHatchTier()) return false; tHatch.updateTexture(aBaseCasingIndex); return mEnergyHatches.add(tHatch); } else if (aMetaTileEntity instanceof MTEHatchEnergyMulti tHatch) { - if (tHatch.getTierForStructure() < hatchTier()) return false; + if (tHatch.getTierForStructure() < energyHatchTier()) return false; tHatch.updateTexture(aBaseCasingIndex); return eEnergyMulti.add(tHatch); } return false; } - private boolean addFluidIO(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof MTEHatch hatch) { - hatch.updateTexture(aBaseCasingIndex); - hatch.updateCraftingIcon(this.getMachineCraftingIcon()); - } - if (aMetaTileEntity instanceof MTEHatchInput tInput) { - if (tInput.getTierForStructure() < hatchTier()) return false; - tInput.mRecipeMap = getRecipeMap(); - return mInputHatches.add(tInput); - } - if (aMetaTileEntity instanceof MTEHatchOutput tOutput) { - if (tOutput.getTierForStructure() < hatchTier()) return false; - return mOutputHatches.add(tOutput); - } - if (aMetaTileEntity instanceof IDualInputHatch tInput) { - tInput.updateCraftingIcon(this.getMachineCraftingIcon()); - return mDualInputHatches.add(tInput); - } - return false; - } - private boolean addDroneHatch(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { if (aBaseMetaTileEntity == null) return false; IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); diff --git a/src/main/java/gregtech/GTMod.java b/src/main/java/gregtech/GTMod.java index c071cd291da..a9379f18df2 100644 --- a/src/main/java/gregtech/GTMod.java +++ b/src/main/java/gregtech/GTMod.java @@ -3,7 +3,6 @@ import static gregtech.GT_Version.VERSION_MAJOR; import static gregtech.GT_Version.VERSION_MINOR; import static gregtech.GT_Version.VERSION_PATCH; -import static gregtech.api.GregTechAPI.registerCircuitProgrammer; import static gregtech.api.enums.Mods.Forestry; import static gregtech.api.util.GTRecipe.setItemStacks; @@ -13,7 +12,6 @@ import java.util.Arrays; import java.util.Locale; import java.util.Map; -import java.util.function.Predicate; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -26,7 +24,6 @@ import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.oredict.OreDictionary; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -354,17 +351,6 @@ public void onLoad(FMLInitializationEvent aEvent) { gregtechproxy.onLoad(); - registerCircuitProgrammer(new Predicate<>() { - - private final int screwdriverOreId = OreDictionary.getOreID("craftingToolScrewdriver"); - - @Override - public boolean test(ItemStack stack) { - for (int i : OreDictionary.getOreIDs(stack)) if (i == screwdriverOreId) return true; - return false; - } - }, true); - new MTERecipeLoader().run(); new GTItemIterator().run(); diff --git a/src/main/java/gregtech/api/GregTechAPI.java b/src/main/java/gregtech/api/GregTechAPI.java index c9f1d90a1ba..95388686c66 100644 --- a/src/main/java/gregtech/api/GregTechAPI.java +++ b/src/main/java/gregtech/api/GregTechAPI.java @@ -8,16 +8,13 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.BiFunction; import java.util.function.IntFunction; -import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -25,7 +22,6 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -163,9 +159,6 @@ public class GregTechAPI { private static final Multimap sRealConfigurationList = Multimaps .newListMultimap(new TreeMap<>(), ArrayList::new); private static final Map> sConfigurationLists = new ConcurrentHashMap<>(); - private static final Map, BiFunction> sRealCircuitProgrammerList = new LinkedHashMap<>(); - public static final Map, BiFunction> sCircuitProgrammerList = Collections - .unmodifiableMap(sRealCircuitProgrammerList); /** * The List of Dimensions, which are Whitelisted for the Teleporter. This list should not contain other Planets. @@ -449,22 +442,6 @@ public static Comparator getConfigurationCircuitsComparator() { .thenComparing(ItemStack::getItemDamage); } - public static void registerCircuitProgrammer(ItemStack stack, boolean ignoreNBT, boolean useContainer) { - registerCircuitProgrammer(rhs -> GTUtility.areStacksEqual(stack, rhs, ignoreNBT), useContainer); - } - - public static void registerCircuitProgrammer(Predicate predicate, boolean useContainer) { - sRealCircuitProgrammerList.put( - predicate, - useContainer ? (s, p) -> s.getItem() - .getContainerItem(s) : (s, p) -> s); - } - - public static void registerCircuitProgrammer(Predicate predicate, - BiFunction doDamage) { - sRealCircuitProgrammerList.put(predicate, doDamage); - } - public static void registerCover(ItemStack aStack, ITexture aCover, CoverBehavior aBehavior) { registerCover(aStack, aCover, (CoverBehaviorBase) aBehavior); } diff --git a/src/main/java/gregtech/common/items/ItemIntegratedCircuit.java b/src/main/java/gregtech/common/items/ItemIntegratedCircuit.java index b6dfa079a20..876bda59630 100644 --- a/src/main/java/gregtech/common/items/ItemIntegratedCircuit.java +++ b/src/main/java/gregtech/common/items/ItemIntegratedCircuit.java @@ -5,9 +5,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.function.Predicate; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -16,6 +13,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; @@ -23,11 +21,11 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.FakePlayer; - -import org.apache.commons.lang3.tuple.Pair; +import net.minecraftforge.oredict.OreDictionary; import com.gtnewhorizons.modularui.api.UIInfos; +import bartworks.common.items.ItemCircuitProgrammer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTechAPI; @@ -43,8 +41,10 @@ import gregtech.api.util.GTLanguageManager; import gregtech.api.util.GTLog; import gregtech.api.util.GTModHandler; -import gregtech.api.util.GTUtility; import gregtech.common.gui.modularui.uifactory.SelectItemUIFactory; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.item.ItemToolbox; public class ItemIntegratedCircuit extends GTGenericItem implements INetworkUpdatableItem { @@ -246,12 +246,7 @@ public boolean receive(ItemStack stack, EntityPlayerMP player, NBTTagCompound ta if (meta < 0 || meta > 24) return true; if (!player.capabilities.isCreativeMode) { - Pair> toolIndex = findConfiguratorInInv(player); - if (toolIndex == null) return true; - - ItemStack[] mainInventory = player.inventory.mainInventory; - mainInventory[toolIndex.getKey()] = toolIndex.getValue() - .apply(mainInventory[toolIndex.getKey()], player); + findConfiguratorInInv(player, true); // damage the tool } stack.setItemDamage(meta); @@ -267,8 +262,8 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla if (player.capabilities.isCreativeMode) { configuratorStack = null; } else { - Pair configurator = findConfiguratorInInv(player); - if (configurator == null) { + configuratorStack = findConfiguratorInInv(player, false); + if (configuratorStack == null) { int count; try { count = Integer @@ -285,7 +280,6 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla "GT5U.item.programmed_circuit.no_screwdriver." + XSTR.XSTR_INSTANCE.nextInt(count))); return stack; } - configuratorStack = player.inventory.mainInventory[configurator.getKey()]; } openSelectorGui(configuratorStack, stack.getItemDamage(), player); return stack; @@ -309,19 +303,86 @@ private static void onConfigured(ItemStack stack) { GTValues.NW.sendToServer(new GTPacketUpdateItem(tag)); } - private static Pair> findConfiguratorInInv( - EntityPlayer player) { + private static final int screwdriverOreId = OreDictionary.getOreID("craftingToolScrewdriver"); + + /** + * Test a player's inventory for a circuit configuring item. + * + * @param player The player whose inventory will be tested. + * @param doDamage Whether a found item should be damaged. + * + * @return A display stack representing the item that was found. Do not modify this item! + */ + public static ItemStack findConfiguratorInInv(EntityPlayer player, boolean doDamage) { ItemStack[] mainInventory = player.inventory.mainInventory; - for (int j = 0, mainInventoryLength = mainInventory.length; j < mainInventoryLength; j++) { - ItemStack toolStack = mainInventory[j]; + for (int i = 0; i < mainInventory.length; i++) { + ItemStack potentialStack = mainInventory[i]; + if (potentialStack == null || potentialStack.getItem() == null || potentialStack.stackSize <= 0) continue; + + // Circuit Configurator + if (potentialStack.getItem() instanceof ItemCircuitProgrammer programmer) { + if (doDamage) programmer.useItem(potentialStack, player); + return potentialStack; + } - if (!GTUtility.isStackValid(toolStack)) continue; + // Toolbox with Screwdriver inside + if (potentialStack.getItem() instanceof ItemToolbox toolbox) { + IHasGui toolboxInventory = toolbox.getInventory(player, potentialStack); + if (!IC2.platform.isSimulating()) { + populateToolboxInventory(toolboxInventory, potentialStack); + } + for (int j = 0; j < toolboxInventory.getSizeInventory(); j++) { + ItemStack toolboxStack = toolboxInventory.getStackInSlot(j); + if (toolboxStack == null || toolboxStack.getItem() == null || toolboxStack.stackSize <= 0) continue; - for (Map.Entry, BiFunction> p : GregTechAPI.sCircuitProgrammerList - .entrySet()) - if (p.getKey() - .test(toolStack)) return Pair.of(j, p.getValue()); + for (int id : OreDictionary.getOreIDs(toolboxStack)) { + if (id == screwdriverOreId) { + if (doDamage) { + toolboxStack = toolboxStack.getItem() + .getContainerItem(toolboxStack); + if (toolboxStack != null && toolboxStack.stackSize <= 0) { + toolboxInventory.setInventorySlotContents(j, null); + } else { + toolboxInventory.setInventorySlotContents(j, toolboxStack); + } + } + return potentialStack; // return the toolbox for display + } + } + } + } + + // Screwdriver + for (int id : OreDictionary.getOreIDs(potentialStack)) { + if (id == screwdriverOreId) { + if (doDamage) { + potentialStack = potentialStack.getItem() + .getContainerItem(potentialStack); + if (potentialStack != null && potentialStack.stackSize <= 0) { + mainInventory[i] = null; + } else { + mainInventory[i] = potentialStack; + } + } + return potentialStack; + } + } } return null; } + + // Because for some reason, the toolbox inventory refuses to read the itemstack nbt + // on the client (according to IC2 this is in fact intentional). + private static void populateToolboxInventory(IHasGui toolboxInventory, ItemStack toolbox) { + NBTTagCompound nbt = toolbox.getTagCompound(); + if (nbt == null) return; + NBTTagList stacks = nbt.getTagList("Items", 10); + for (int i = 0; i < stacks.tagCount(); i++) { + NBTTagCompound slotNbt = stacks.getCompoundTagAt(i); + int slot = slotNbt.getByte("Slot"); + if (slot >= 0 && slot < toolboxInventory.getSizeInventory()) { + toolboxInventory.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(slotNbt)); + } + } + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java index aefef077fde..841739ffca7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java +++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java @@ -385,10 +385,10 @@ public MTEHatchCraftingInputME(int aID, String aName, String aNameRegional, bool aID, aName, aNameRegional, - supportFluids ? 11 : 6, + supportFluids ? 10 : 6, MAX_INV_COUNT, new String[] { "Advanced item input for Multiblocks", - "Hatch Tier: " + TIER_COLORS[supportFluids ? 11 : 6] + VN[supportFluids ? 11 : 6], + "Hatch Tier: " + TIER_COLORS[supportFluids ? 10 : 6] + VN[supportFluids ? 10 : 6], "Processes patterns directly from ME", supportFluids ? "It supports patterns including fluids" : "It does not support patterns including fluids", diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java index 73216f46743..43db24f49b3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java +++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines; +import static gregtech.api.enums.GTValues.TIER_COLORS; +import static gregtech.api.enums.GTValues.VN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_CRAFTING_INPUT_SLAVE; import java.util.ArrayList; @@ -42,9 +44,9 @@ public MTEHatchCraftingInputSlave(int aID, String aName, String aNameRegional) { aID, aName, aNameRegional, - 6, + 11, 0, - new String[] { "Proxy for Crafting Input Buffer/Bus", + new String[] { "Proxy for Crafting Input Buffer/Bus", "Hatch Tier: " + TIER_COLORS[11] + VN[11], "Link with Crafting Input Buffer/Bus using Data Stick to share inventory", "Left click on the Crafting Input Buffer/Bus, then right click on this block to link them", }); disableSort = true; diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java index 5fc0156c851..5e7fd23d95e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java +++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java @@ -117,7 +117,7 @@ public class MTEHatchInputME extends MTEHatchInput implements IPowerChannelState protected static final FluidStack[] EMPTY_FLUID_STACK = new FluidStack[0]; public MTEHatchInputME(int aID, boolean autoPullAvailable, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, autoPullAvailable ? 10 : 8, 1, getDescriptionArray(autoPullAvailable)); + super(aID, aName, aNameRegional, autoPullAvailable ? 9 : 8, 1, getDescriptionArray(autoPullAvailable)); this.autoPullAvailable = autoPullAvailable; } @@ -929,7 +929,7 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou private static String[] getDescriptionArray(boolean autoPullAvailable) { List strings = new ArrayList<>(8); strings.add("Advanced fluid input for Multiblocks"); - strings.add("Hatch Tier: " + TIER_COLORS[autoPullAvailable ? 10 : 8] + VN[autoPullAvailable ? 10 : 8]); + strings.add("Hatch Tier: " + TIER_COLORS[autoPullAvailable ? 9 : 8] + VN[autoPullAvailable ? 9 : 8]); strings.add("Retrieves directly from ME"); strings.add("Keeps 16 fluid types in stock"); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java index 4b69a930099..515987bdddf 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java @@ -155,7 +155,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @Override public boolean onRunningTick(ItemStack aStack) { - float progressAmount = ((float) this.mProgresstime) / this.mMaxProgresstime; + float progressAmount = ((float) this.mProgresstime + 1) / this.mMaxProgresstime; int requiredVis = (int) Math.ceil(progressAmount * recipeAspectCost - aspectsAbsorbed); syncTimer--; diff --git a/src/main/java/gtPlusPlus/core/item/circuit/GTPPIntegratedCircuitItem.java b/src/main/java/gtPlusPlus/core/item/circuit/GTPPIntegratedCircuitItem.java index ec5548a9a30..68e90dce6f4 100644 --- a/src/main/java/gtPlusPlus/core/item/circuit/GTPPIntegratedCircuitItem.java +++ b/src/main/java/gtPlusPlus/core/item/circuit/GTPPIntegratedCircuitItem.java @@ -1,12 +1,10 @@ package gtPlusPlus.core.item.circuit; import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.common.items.ItemIntegratedCircuit.findConfiguratorInInv; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.function.Predicate; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -24,18 +22,14 @@ import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.FakePlayer; -import org.apache.commons.lang3.tuple.Pair; - import com.gtnewhorizons.modularui.api.UIInfos; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.GregTechAPI; import gregtech.api.enums.GTValues; import gregtech.api.interfaces.INetworkUpdatableItem; import gregtech.api.net.GTPacketUpdateItem; import gregtech.api.objects.XSTR; import gregtech.api.util.GTLanguageManager; -import gregtech.api.util.GTUtility; import gregtech.common.gui.modularui.uifactory.SelectItemUIFactory; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -68,7 +62,7 @@ public boolean isDamageable() { } @Override - public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { try { aList.add("Configuration == " + aStack.getItemDamage()); aList.add( @@ -90,7 +84,7 @@ public EnumRarity getRarity(ItemStack p_77613_1_) { } @Override - public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { aList.add(ItemUtils.simpleMetaStack(aItem, 0, 1)); } @@ -127,12 +121,7 @@ public boolean receive(ItemStack stack, EntityPlayerMP player, NBTTagCompound ta if (meta < 0 || meta > 24) return true; if (!player.capabilities.isCreativeMode) { - Pair> toolIndex = findConfiguratorInInv(player); - if (toolIndex == null) return true; - - ItemStack[] mainInventory = player.inventory.mainInventory; - mainInventory[toolIndex.getKey()] = toolIndex.getValue() - .apply(mainInventory[toolIndex.getKey()], player); + findConfiguratorInInv(player, true); // damage the tool } stack.setItemDamage(meta); @@ -148,8 +137,8 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla if (player.capabilities.isCreativeMode) { configuratorStack = null; } else { - Pair configurator = findConfiguratorInInv(player); - if (configurator == null) { + configuratorStack = findConfiguratorInInv(player, false); + if (configuratorStack == null) { int count; try { count = Integer @@ -166,7 +155,6 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla "GT5U.item.programmed_circuit.no_screwdriver." + XSTR.XSTR_INSTANCE.nextInt(count))); return stack; } - configuratorStack = player.inventory.mainInventory[configurator.getKey()]; } openSelectorGui(configuratorStack, stack.getItemDamage(), player); return stack; @@ -189,20 +177,4 @@ private static void onConfigured(ItemStack stack) { tag.setByte("meta", (byte) stack.getItemDamage()); GTValues.NW.sendToServer(new GTPacketUpdateItem(tag)); } - - private static Pair> findConfiguratorInInv( - EntityPlayer player) { - ItemStack[] mainInventory = player.inventory.mainInventory; - for (int j = 0, mainInventoryLength = mainInventory.length; j < mainInventoryLength; j++) { - ItemStack toolStack = mainInventory[j]; - - if (!GTUtility.isStackValid(toolStack)) continue; - - for (Map.Entry, BiFunction> p : GregTechAPI.sCircuitProgrammerList - .entrySet()) - if (p.getKey() - .test(toolStack)) return Pair.of(j, p.getValue()); - } - return null; - } } diff --git a/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java b/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java index c96212c8e61..6ef577aa4e9 100644 --- a/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java +++ b/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java @@ -10,22 +10,20 @@ public class ItemPhotolithographicMask extends Item implements ICanFocus { - private final String name; private final String descSpectrum; public ItemPhotolithographicMask(String name, int maxDamage, String descSpectrum) { super(); - this.name = name; this.descSpectrum = descSpectrum; this.setUnlocalizedName("photomask." + name); this.setMaxStackSize(1); this.setMaxDamage(maxDamage); + this.setNoRepair(); this.setTextureName(Tags.MODID + ":photomask/" + name); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { if (!this.descSpectrum.isEmpty()) list.add("Suitable for the " + this.descSpectrum + " segment of the electromagnetic spectrum and lower");