mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1693 from abel1502/abel-crates-crafting
Fix #1690 (upgrading crates & mass storage)
This commit is contained in:
commit
3ac994c707
33
.gitignore
vendored
33
.gitignore
vendored
@ -1,25 +1,28 @@
|
|||||||
# eclipse
|
# eclipse
|
||||||
eclipse
|
/eclipse
|
||||||
bin
|
/bin
|
||||||
*.launch
|
/*.launch
|
||||||
.settings
|
/.settings
|
||||||
.metadata
|
/.metadata
|
||||||
.classpath
|
/.classpath
|
||||||
.project
|
/.project
|
||||||
|
|
||||||
# idea
|
# idea
|
||||||
out
|
/out
|
||||||
*.ipr
|
/*.ipr
|
||||||
*.iws
|
/*.iws
|
||||||
*.iml
|
/*.iml
|
||||||
.idea
|
/.idea
|
||||||
|
|
||||||
# gradle
|
# gradle
|
||||||
build
|
/build
|
||||||
.gradle
|
/.gradle
|
||||||
|
|
||||||
|
# vscode
|
||||||
|
/.vscode
|
||||||
|
|
||||||
# other
|
# other
|
||||||
run
|
/run
|
||||||
|
|
||||||
# CurseForge configuration
|
# CurseForge configuration
|
||||||
/curseforge.properties
|
/curseforge.properties
|
||||||
|
|||||||
@ -167,7 +167,8 @@ public class BlockScaffoldDynamic extends BlockContainer implements IToolable, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TileEntityScaffoldDynamic extends TileEntity {
|
// Full class name needed because otherwise there's some conflict with the static import * from this class
|
||||||
|
public static class TileEntityScaffoldDynamic extends net.minecraft.tileentity.TileEntity {
|
||||||
|
|
||||||
public int composite;
|
public int composite;
|
||||||
public int prevComposite;
|
public int prevComposite;
|
||||||
|
|||||||
@ -0,0 +1,58 @@
|
|||||||
|
package com.hbm.crafting.handlers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.hbm.blocks.generic.BlockStorageCrate;
|
||||||
|
import com.hbm.blocks.machine.BlockMassStorage;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles upgrading storage crates and mass storage blocks, preserving their contents.
|
||||||
|
*
|
||||||
|
* Note: this assumes the input and the output items store their inventory in the same format
|
||||||
|
* in the NBT
|
||||||
|
*/
|
||||||
|
public class ContainerUpgradeCraftingHandler extends ShapedOreRecipe {
|
||||||
|
|
||||||
|
public ContainerUpgradeCraftingHandler(ItemStack result, Object... items){
|
||||||
|
super(result, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
|
||||||
|
|
||||||
|
ItemStack source = getFirstContainer(inventoryCrafting);
|
||||||
|
ItemStack result = super.getCraftingResult(inventoryCrafting);
|
||||||
|
|
||||||
|
result.setTagCompound(source.getTagCompound());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack getFirstContainer(InventoryCrafting inventoryCrafting) {
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
ItemStack itemstack = inventoryCrafting.getStackInRowAndColumn(i % 3, i / 3);
|
||||||
|
if (itemstack == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Block block = Block.getBlockFromItem(itemstack.getItem());
|
||||||
|
if (block == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (block instanceof BlockStorageCrate || block instanceof BlockMassStorage)
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -79,6 +79,7 @@ public class CraftingManager {
|
|||||||
RecipeSorter.register("hbm:cargo", CargoShellCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
RecipeSorter.register("hbm:cargo", CargoShellCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||||
RecipeSorter.register("hbm:scraps", ScrapsCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
RecipeSorter.register("hbm:scraps", ScrapsCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||||
RecipeSorter.register("hbm:mku", MKUCraftingHandler.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped before:minecraft:shapeless");
|
RecipeSorter.register("hbm:mku", MKUCraftingHandler.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped before:minecraft:shapeless");
|
||||||
|
RecipeSorter.register("hbm:containerupgrade", ContainerUpgradeCraftingHandler.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped before:minecraft:shapeless");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddCraftingRec() {
|
public static void AddCraftingRec() {
|
||||||
@ -282,13 +283,17 @@ public class CraftingManager {
|
|||||||
addRecipeAuto(new ItemStack(ModBlocks.crate_template, 1), new Object[] { "IPI", "P P", "IPI", 'I', IRON.ingot(), 'P', Items.paper });
|
addRecipeAuto(new ItemStack(ModBlocks.crate_template, 1), new Object[] { "IPI", "P P", "IPI", 'I', IRON.ingot(), 'P', Items.paper });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.crate_iron, 1), new Object[] { "PPP", "I I", "III", 'P', IRON.plate(), 'I', IRON.ingot() });
|
addRecipeAuto(new ItemStack(ModBlocks.crate_iron, 1), new Object[] { "PPP", "I I", "III", 'P', IRON.plate(), 'I', IRON.ingot() });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.crate_steel, 1), new Object[] { "PPP", "I I", "III", 'P', STEEL.plate(), 'I', STEEL.ingot() });
|
addRecipeAuto(new ItemStack(ModBlocks.crate_steel, 1), new Object[] { "PPP", "I I", "III", 'P', STEEL.plate(), 'I', STEEL.ingot() });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.crate_desh, 1), new Object[] { " D ", "DSD", " D ", 'D', ModItems.plate_desh, 'S', ModBlocks.crate_steel });
|
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.crate_tungsten, 1), new Object[] { "BPB", "PCP", "BPB", 'B', W.block(), 'P', CU.plateCast(), 'C', ModBlocks.crate_steel });
|
GameRegistry.addRecipe(new ContainerUpgradeCraftingHandler(new ItemStack(ModBlocks.crate_desh, 1), new Object[] { " D ", "DSD", " D ", 'D', ModItems.plate_desh, 'S', ModBlocks.crate_steel }));
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.safe, 1), new Object[] { "LAL", "ACA", "LAL", 'L', PB.plate(), 'A', ALLOY.plate(), 'C', ModBlocks.crate_steel });
|
GameRegistry.addRecipe(new ContainerUpgradeCraftingHandler(new ItemStack(ModBlocks.crate_tungsten, 1), new Object[] { "BPB", "PCP", "BPB", 'B', W.block(), 'P', CU.plateCast(), 'C', ModBlocks.crate_steel }));
|
||||||
|
// Note: voids the last few slots when placed, because a safe's inventory is smaller than a crate's one
|
||||||
|
GameRegistry.addRecipe(new ContainerUpgradeCraftingHandler(new ItemStack(ModBlocks.safe, 1), new Object[] { "LAL", "ACA", "LAL", 'L', PB.plate(), 'A', ALLOY.plate(), 'C', ModBlocks.crate_steel }));
|
||||||
|
// Note: doesn't preserve storage because a crate's contents are different items, but a mass storage's is just one
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 0), new Object[] { "ICI", "CLC", "ICI", 'I', TI.ingot(), 'C', ModBlocks.crate_steel, 'L', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) });
|
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 0), new Object[] { "ICI", "CLC", "ICI", 'I', TI.ingot(), 'C', ModBlocks.crate_steel, 'L', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 1), new Object[] { "PCP", "PMP", "PPP", 'P', DESH.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CHIP), 'M', new ItemStack(ModBlocks.mass_storage, 1, 0) });
|
GameRegistry.addRecipe(new ContainerUpgradeCraftingHandler(new ItemStack(ModBlocks.mass_storage, 1, 1), new Object[] { "PCP", "PMP", "PPP", 'P', DESH.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CHIP), 'M', new ItemStack(ModBlocks.mass_storage, 1, 0) }));
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 2), new Object[] { "PCP", "PMP", "PPP", 'P', ANY_RESISTANTALLOY.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'M', new ItemStack(ModBlocks.mass_storage, 1, 1) });
|
GameRegistry.addRecipe(new ContainerUpgradeCraftingHandler(new ItemStack(ModBlocks.mass_storage, 1, 2), new Object[] { "PCP", "PMP", "PPP", 'P', ANY_RESISTANTALLOY.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), 'M', new ItemStack(ModBlocks.mass_storage, 1, 1) }));
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 3), new Object[] { "PPP", "PIP", "PPP", 'P', KEY_PLANKS, 'I', IRON.plate() });
|
GameRegistry.addRecipe(new ContainerUpgradeCraftingHandler(new ItemStack(ModBlocks.mass_storage, 1, 3), new Object[] { "PPP", "PIP", "PPP", 'P', KEY_PLANKS, 'I', IRON.plate() }));
|
||||||
|
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.machine_autocrafter, 1), new Object[] { "SCS", "MWM", "SCS", 'S', STEEL.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE), 'M', ModItems.motor, 'W', Blocks.crafting_table });
|
addRecipeAuto(new ItemStack(ModBlocks.machine_autocrafter, 1), new Object[] { "SCS", "MWM", "SCS", 'S', STEEL.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE), 'M', ModItems.motor, 'W', Blocks.crafting_table });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.machine_funnel, 1), new Object[] { "S S", "SRS", " S ", 'S', STEEL.ingot(), 'R', REDSTONE.dust() });
|
addRecipeAuto(new ItemStack(ModBlocks.machine_funnel, 1), new Object[] { "S S", "SRS", " S ", 'S', STEEL.ingot(), 'R', REDSTONE.dust() });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.machine_waste_drum, 1), new Object[] { "LRL", "BRB", "LRL", 'L', PB.ingot(), 'B', Blocks.iron_bars, 'R', ModItems.rod_quad_empty });
|
addRecipeAuto(new ItemStack(ModBlocks.machine_waste_drum, 1), new Object[] { "LRL", "BRB", "LRL", 'L', PB.ingot(), 'B', Blocks.iron_bars, 'R', ModItems.rod_quad_empty });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user