mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
riveting, block tooling crafting handler
This commit is contained in:
parent
ce5435f07d
commit
ed829fc7ec
@ -1,6 +1,13 @@
|
|||||||
package api.hbm.block;
|
package api.hbm.block;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IToolable {
|
public interface IToolable {
|
||||||
@ -13,6 +20,28 @@ public interface IToolable {
|
|||||||
DEFUSER,
|
DEFUSER,
|
||||||
WRENCH,
|
WRENCH,
|
||||||
TORCH,
|
TORCH,
|
||||||
BOLT
|
BOLT;
|
||||||
|
|
||||||
|
public List<ItemStack> stacksForDisplay = new ArrayList();
|
||||||
|
private static HashMap<ComparableStack, ToolType> map = new HashMap();
|
||||||
|
|
||||||
|
public void register(ItemStack stack) {
|
||||||
|
stacksForDisplay.add(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToolType getType(ItemStack stack) {
|
||||||
|
|
||||||
|
if(!map.isEmpty()) {
|
||||||
|
return map.get(new ComparableStack(stack));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ToolType type : ToolType.values()) {
|
||||||
|
for(ItemStack tool : type.stacksForDisplay) {
|
||||||
|
map.put(new ComparableStack(tool), type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map.get(new ComparableStack(stack));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.hbm.main.MainRegistry;
|
|||||||
import com.hbm.tileentity.DoorDecl;
|
import com.hbm.tileentity.DoorDecl;
|
||||||
import com.hbm.tileentity.machine.storage.TileEntityFileCabinet;
|
import com.hbm.tileentity.machine.storage.TileEntityFileCabinet;
|
||||||
|
|
||||||
|
import api.hbm.block.IToolable.ToolType;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
@ -1981,7 +1982,7 @@ public class ModBlocks {
|
|||||||
watz_element = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_element_top").setBlockName("watz_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_element_side");
|
watz_element = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_element_top").setBlockName("watz_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_element_side");
|
||||||
watz_control = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_control_top").setBlockName("watz_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_control_side");
|
watz_control = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_control_top").setBlockName("watz_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_control_side");
|
||||||
watz_cooler = new BlockGeneric(Material.iron).setBlockName("watz_cooler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_cooler");
|
watz_cooler = new BlockGeneric(Material.iron).setBlockName("watz_cooler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_cooler");
|
||||||
watz_end = new BlockBoltable(Material.iron).setBlockName("watz_end").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_casing");
|
watz_end = new BlockToolConversion(Material.iron).addVariant("_bolted").setBlockName("watz_end").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_casing");
|
||||||
watz_hatch = new WatzHatch(Material.iron).setBlockName("watz_hatch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_hatch");
|
watz_hatch = new WatzHatch(Material.iron).setBlockName("watz_hatch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_hatch");
|
||||||
watz_conductor = new BlockCableConnect(Material.iron).setBlockName("watz_conductor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_conductor_top");
|
watz_conductor = new BlockCableConnect(Material.iron).setBlockName("watz_conductor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_conductor_top");
|
||||||
watz_core = new WatzCore(Material.iron).setBlockName("watz_core").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_computer");
|
watz_core = new WatzCore(Material.iron).setBlockName("watz_core").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_computer");
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
package com.hbm.blocks.generic;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.hbm.blocks.BlockBase;
|
|
||||||
import com.hbm.blocks.IBlockMulti;
|
|
||||||
import com.hbm.blocks.ILookOverlay;
|
|
||||||
import com.hbm.inventory.RecipesCommon.AStack;
|
|
||||||
import com.hbm.items.ModItems;
|
|
||||||
import com.hbm.util.I18nUtil;
|
|
||||||
|
|
||||||
import api.hbm.block.IToolable;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
|
||||||
|
|
||||||
public class BlockBoltable extends BlockBase implements IToolable, ILookOverlay, IBlockMulti {
|
|
||||||
|
|
||||||
public BlockBoltable(Material mat) {
|
|
||||||
super(mat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
|
||||||
if(tool != ToolType.BOLT) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AStack> getMaterials(int meta) {
|
|
||||||
List<AStack> list = new ArrayList();
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
|
||||||
|
|
||||||
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
|
||||||
if(held == null || held.getItem() != ModItems.boltgun) return;
|
|
||||||
|
|
||||||
List<String> text = new ArrayList();
|
|
||||||
text.add(EnumChatFormatting.GOLD + "Requires:");
|
|
||||||
List<AStack> materials = getMaterials(world.getBlockMetadata(x, y, z));
|
|
||||||
|
|
||||||
for(AStack stack : materials) {
|
|
||||||
try {
|
|
||||||
ItemStack display = stack.extractForCyclingDisplay(20);
|
|
||||||
text.add("- " + display.getDisplayName() + " x" + display.stackSize);
|
|
||||||
} catch(Exception ex) {
|
|
||||||
text.add(EnumChatFormatting.RED + "- ERROR");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!materials.isEmpty()) {
|
|
||||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSubCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
176
src/main/java/com/hbm/blocks/generic/BlockToolConversion.java
Normal file
176
src/main/java/com/hbm/blocks/generic/BlockToolConversion.java
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
package com.hbm.blocks.generic;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.hbm.blocks.BlockBase;
|
||||||
|
import com.hbm.blocks.IBlockMulti;
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
|
import com.hbm.blocks.ModBlocks;
|
||||||
|
import com.hbm.inventory.RecipesCommon.AStack;
|
||||||
|
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||||
|
import com.hbm.inventory.RecipesCommon.MetaBlock;
|
||||||
|
import com.hbm.items.ModItems;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
|
import com.hbm.util.InventoryUtil;
|
||||||
|
import com.hbm.util.Tuple.Pair;
|
||||||
|
|
||||||
|
import api.hbm.block.IToolable;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
|
|
||||||
|
public class BlockToolConversion extends BlockBase implements IToolable, ILookOverlay, IBlockMulti {
|
||||||
|
|
||||||
|
public IIcon[] icons;
|
||||||
|
public String[] names;
|
||||||
|
|
||||||
|
public BlockToolConversion(Material mat) {
|
||||||
|
super(mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockToolConversion addVariant(String... name) {
|
||||||
|
this.names = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||||
|
for(int i = 0; i < getSubCount(); ++i) {
|
||||||
|
list.add(new ItemStack(item, 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
|
super.registerBlockIcons(iconRegister);
|
||||||
|
|
||||||
|
if(names != null) {
|
||||||
|
icons = new IIcon[names.length];
|
||||||
|
for(int i = 0; i < names.length; i++) {
|
||||||
|
icons[i] = iconRegister.registerIcon(getTextureName() + names[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getIcon(int side, int metadata) {
|
||||||
|
|
||||||
|
metadata -= 1;
|
||||||
|
|
||||||
|
if(metadata == -1 || icons == null || metadata >= icons.length) {
|
||||||
|
return super.getIcon(side, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
return icons[metadata];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||||
|
|
||||||
|
if(world.isRemote) return false;
|
||||||
|
|
||||||
|
Pair<AStack[], MetaBlock> result = conversions.get(new Pair(tool, new MetaBlock(this, world.getBlockMetadata(x, y, z))));
|
||||||
|
|
||||||
|
if(result == null) return false;
|
||||||
|
|
||||||
|
List<AStack> list = new ArrayList();
|
||||||
|
for(AStack stack : result.key) list.add(stack);
|
||||||
|
|
||||||
|
if(list == null || list.isEmpty() || InventoryUtil.doesPlayerHaveAStacks(player, list, true)) {
|
||||||
|
world.setBlock(x, y, z, result.value.block, result.value.meta, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
|
||||||
|
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||||
|
if(held == null) return;
|
||||||
|
ToolType tool = this.quickLookup(held);
|
||||||
|
if(tool == null) return;
|
||||||
|
|
||||||
|
Pair<AStack[], MetaBlock> result = conversions.get(new Pair(tool, new MetaBlock(this, world.getBlockMetadata(x, y, z))));
|
||||||
|
|
||||||
|
if(result == null) return;
|
||||||
|
|
||||||
|
List<String> text = new ArrayList();
|
||||||
|
text.add(EnumChatFormatting.GOLD + "Requires:");
|
||||||
|
List<AStack> materials = new ArrayList();
|
||||||
|
for(AStack stack : result.key) materials.add(stack);
|
||||||
|
|
||||||
|
List<ItemStack> tools = tool.stacksForDisplay;
|
||||||
|
ItemStack displayTool = tools.get((int) (Math.abs(System.currentTimeMillis() / 1000) % tools.size()));
|
||||||
|
text.add(EnumChatFormatting.BLUE + "- " + displayTool.getDisplayName());
|
||||||
|
|
||||||
|
for(AStack stack : materials) {
|
||||||
|
try {
|
||||||
|
ItemStack display = stack.extractForCyclingDisplay(20);
|
||||||
|
text.add("- " + display.getDisplayName() + " x" + display.stackSize);
|
||||||
|
} catch(Exception ex) {
|
||||||
|
text.add(EnumChatFormatting.RED + "- ERROR");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!materials.isEmpty()) {
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSubCount() {
|
||||||
|
return names != null ? names.length + 1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToolType quickLookup(ItemStack stack) {
|
||||||
|
return ToolType.getType(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap<Pair<ToolType, MetaBlock>, Pair<AStack[], MetaBlock>> conversions = new HashMap();
|
||||||
|
|
||||||
|
public static void registerRecipes() {
|
||||||
|
conversions.put(new Pair(ToolType.BOLT, new MetaBlock(ModBlocks.watz_end, 0)), new Pair(new AStack[] {new ComparableStack(ModItems.bolt_dura_steel, 4)}, new MetaBlock(ModBlocks.watz_end, 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap<Object[], Object> bufferedRecipes = new HashMap();
|
||||||
|
public static HashMap<Object[], Object> bufferedTools = new HashMap();
|
||||||
|
|
||||||
|
public static HashMap<Object[], Object> getRecipes(boolean recipes) {
|
||||||
|
|
||||||
|
if(!bufferedRecipes.isEmpty()) return recipes ? bufferedRecipes : bufferedTools;
|
||||||
|
|
||||||
|
for(Entry<Pair<ToolType, MetaBlock>, Pair<AStack[], MetaBlock>> entry : conversions.entrySet()) {
|
||||||
|
|
||||||
|
List<AStack> list = new ArrayList();
|
||||||
|
|
||||||
|
for(AStack stack : entry.getValue().getKey()) {
|
||||||
|
list.add(stack);
|
||||||
|
}
|
||||||
|
list.add(new ComparableStack(entry.getKey().getValue().block, 1, entry.getKey().getValue().meta));
|
||||||
|
|
||||||
|
Object[] inputInstance = list.toArray(new AStack[0]); // the instance has to match for the machine lookup to succeed
|
||||||
|
bufferedRecipes.put(inputInstance, new ItemStack(entry.getValue().getValue().block, 1, entry.getValue().getValue().meta));
|
||||||
|
bufferedTools.put(inputInstance, entry.getKey().getKey().stacksForDisplay.toArray(new ItemStack[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return recipes ? bufferedRecipes : bufferedTools;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -32,12 +32,19 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
|
|||||||
public final String display;
|
public final String display;
|
||||||
public final ItemStack[] machine;
|
public final ItemStack[] machine;
|
||||||
public final HashMap<Object, Object> recipes;
|
public final HashMap<Object, Object> recipes;
|
||||||
|
public HashMap<Object, Object> machineOverrides;
|
||||||
/// SETUP ///
|
/// SETUP ///
|
||||||
|
|
||||||
public NEIUniversalHandler(String display, ItemStack machine[], HashMap recipes) {
|
public NEIUniversalHandler(String display, ItemStack machine[], HashMap recipes) {
|
||||||
this.display = display;
|
this.display = display;
|
||||||
this.machine = machine;
|
this.machine = machine;
|
||||||
this.recipes = recipes;
|
this.recipes = recipes;
|
||||||
|
this.machineOverrides = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NEIUniversalHandler(String display, HashMap recipes, HashMap machines) {
|
||||||
|
this(display, (ItemStack[]) null, recipes);
|
||||||
|
this.machineOverrides = machines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NEIUniversalHandler(String display, ItemStack machine, HashMap recipes) { this(display, new ItemStack[]{machine}, recipes); }
|
public NEIUniversalHandler(String display, ItemStack machine, HashMap recipes) { this(display, new ItemStack[]{machine}, recipes); }
|
||||||
@ -50,7 +57,7 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
|
|||||||
PositionedStack[] output;
|
PositionedStack[] output;
|
||||||
PositionedStack machinePositioned;
|
PositionedStack machinePositioned;
|
||||||
|
|
||||||
public RecipeSet(ItemStack[][] in, ItemStack[][] out) {
|
public RecipeSet(ItemStack[][] in, ItemStack[][] out, Object originalInputInstance /* for custom machine lookup */) {
|
||||||
|
|
||||||
input = new PositionedStack[in.length];
|
input = new PositionedStack[in.length];
|
||||||
for(int i = 0; i < in.length; i++) {
|
for(int i = 0; i < in.length; i++) {
|
||||||
@ -65,7 +72,17 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
|
|||||||
this.output[i] = new PositionedStack(sub, 102 + i * 18 - ((twos && i > 1) ? 36 : 0), 24 + (twos ? (i < 2 ? -9 : 9) : 0));
|
this.output[i] = new PositionedStack(sub, 102 + i * 18 - ((twos && i > 1) ? 36 : 0), 24 + (twos ? (i < 2 ? -9 : 9) : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.machinePositioned = new PositionedStack(machine, 75, 31);
|
ItemStack[] m = machine;
|
||||||
|
|
||||||
|
if(NEIUniversalHandler.this.machineOverrides != null) {
|
||||||
|
Object key = NEIUniversalHandler.this.machineOverrides.get(originalInputInstance);
|
||||||
|
|
||||||
|
if(key != null) {
|
||||||
|
this.machinePositioned = new PositionedStack(key, 75, 31);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(machinePositioned == null) this.machinePositioned = new PositionedStack(m, 75, 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -123,7 +140,7 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
|
|||||||
for(Entry<Object, Object> recipe : recipes.entrySet()) {
|
for(Entry<Object, Object> recipe : recipes.entrySet()) {
|
||||||
ItemStack[][] ins = InventoryUtil.extractObject(recipe.getKey());
|
ItemStack[][] ins = InventoryUtil.extractObject(recipe.getKey());
|
||||||
ItemStack[][] outs = InventoryUtil.extractObject(recipe.getValue());
|
ItemStack[][] outs = InventoryUtil.extractObject(recipe.getValue());
|
||||||
this.arecipes.add(new RecipeSet(ins, outs));
|
this.arecipes.add(new RecipeSet(ins, outs, recipe.getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -142,7 +159,7 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
|
|||||||
for(ItemStack[] array : outs) {
|
for(ItemStack[] array : outs) {
|
||||||
for(ItemStack stack : array) {
|
for(ItemStack stack : array) {
|
||||||
if(NEIServerUtils.areStacksSameTypeCrafting(stack, result)) {
|
if(NEIServerUtils.areStacksSameTypeCrafting(stack, result)) {
|
||||||
this.arecipes.add(new RecipeSet(ins, outs));
|
this.arecipes.add(new RecipeSet(ins, outs, recipe.getKey()));
|
||||||
break match;
|
break match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +187,7 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
|
|||||||
for(ItemStack[] array : ins) {
|
for(ItemStack[] array : ins) {
|
||||||
for(ItemStack stack : array) {
|
for(ItemStack stack : array) {
|
||||||
if(NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
|
if(NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
|
||||||
this.arecipes.add(new RecipeSet(ins, outs));
|
this.arecipes.add(new RecipeSet(ins, outs, recipe.getKey()));
|
||||||
break match;
|
break match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/main/java/com/hbm/handler/nei/ToolingHandler.java
Normal file
15
src/main/java/com/hbm/handler/nei/ToolingHandler.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.hbm.handler.nei;
|
||||||
|
|
||||||
|
import com.hbm.blocks.generic.BlockToolConversion;
|
||||||
|
|
||||||
|
public class ToolingHandler extends NEIUniversalHandler {
|
||||||
|
|
||||||
|
public ToolingHandler() {
|
||||||
|
super("Tooling", BlockToolConversion.getRecipes(true), BlockToolConversion.getRecipes(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return "ntmTooling";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -455,17 +455,41 @@ public class RecipesCommon {
|
|||||||
this.block = block;
|
this.block = block;
|
||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + Block.blockRegistry.getNameForObject(block).hashCode();
|
||||||
|
result = prime * result + meta;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if(this == obj)
|
||||||
|
return true;
|
||||||
|
if(obj == null)
|
||||||
|
return false;
|
||||||
|
if(getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
MetaBlock other = (MetaBlock) obj;
|
||||||
|
if(block == null) {
|
||||||
|
if(other.block != null)
|
||||||
|
return false;
|
||||||
|
} else if(!block.equals(other.block))
|
||||||
|
return false;
|
||||||
|
if(meta != other.meta)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public MetaBlock(Block block) {
|
public MetaBlock(Block block) {
|
||||||
this(block, 0);
|
this(block, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getID() {
|
@Deprecated public int getID() {
|
||||||
final int prime = 31;
|
return hashCode();
|
||||||
int result = 1;
|
|
||||||
result = prime * result + Block.getIdFromBlock(block);
|
|
||||||
result = prime * result + meta;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,8 @@ public class ItemBlowtorch extends Item implements IFillableItem {
|
|||||||
this.setMaxStackSize(1);
|
this.setMaxStackSize(1);
|
||||||
this.setFull3D();
|
this.setFull3D();
|
||||||
this.setCreativeTab(MainRegistry.controlTab);
|
this.setCreativeTab(MainRegistry.controlTab);
|
||||||
|
|
||||||
|
ToolType.TORCH.register(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -26,6 +26,8 @@ public class ItemBoltgun extends Item implements IAnimatedItem {
|
|||||||
|
|
||||||
public ItemBoltgun() {
|
public ItemBoltgun() {
|
||||||
this.setMaxStackSize(1);
|
this.setMaxStackSize(1);
|
||||||
|
|
||||||
|
ToolType.BOLT.register(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -18,6 +18,8 @@ public class ItemTooling extends ItemCraftingDegradation {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
this.setFull3D();
|
this.setFull3D();
|
||||||
this.setCreativeTab(MainRegistry.controlTab);
|
this.setCreativeTab(MainRegistry.controlTab);
|
||||||
|
|
||||||
|
type.register(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.hbm.blocks.BlockEnums.EnumStoneType;
|
import com.hbm.blocks.BlockEnums.EnumStoneType;
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.blocks.generic.BlockMotherOfAllOres;
|
import com.hbm.blocks.generic.BlockMotherOfAllOres;
|
||||||
|
import com.hbm.blocks.generic.BlockToolConversion;
|
||||||
import com.hbm.commands.CommandReloadRecipes;
|
import com.hbm.commands.CommandReloadRecipes;
|
||||||
import com.hbm.config.*;
|
import com.hbm.config.*;
|
||||||
import com.hbm.creativetabs.*;
|
import com.hbm.creativetabs.*;
|
||||||
@ -829,6 +830,7 @@ public class MainRegistry {
|
|||||||
HazmatRegistry.registerHazmats();
|
HazmatRegistry.registerHazmats();
|
||||||
FluidContainerRegistry.register();
|
FluidContainerRegistry.register();
|
||||||
TileEntityMachineReactorLarge.registerAll();
|
TileEntityMachineReactorLarge.registerAll();
|
||||||
|
BlockToolConversion.registerRecipes();
|
||||||
|
|
||||||
proxy.registerMissileItems();
|
proxy.registerMissileItems();
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ public class NEIConfig implements IConfigureNEI {
|
|||||||
registerHandler(new CrucibleSmeltingHandler());
|
registerHandler(new CrucibleSmeltingHandler());
|
||||||
registerHandler(new CrucibleAlloyingHandler());
|
registerHandler(new CrucibleAlloyingHandler());
|
||||||
registerHandler(new CrucibleCastingHandler());
|
registerHandler(new CrucibleCastingHandler());
|
||||||
|
registerHandler(new ToolingHandler());
|
||||||
|
|
||||||
//universal boyes
|
//universal boyes
|
||||||
registerHandler(new ZirnoxRecipeHandler());
|
registerHandler(new ZirnoxRecipeHandler());
|
||||||
|
|||||||
@ -44,15 +44,15 @@ public class RenderWatzMultiblock extends TileEntitySpecialRenderer {
|
|||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_cooler, 0, 1F, i, -2F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_cooler, 0, 1F, i, -2F);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_cooler, 0, -1F, i, -2F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_cooler, 0, -1F, i, -2F);
|
||||||
for(int j = -1; j < 2; j++) {
|
for(int j = -1; j < 2; j++) {
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, 3F, i, j);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, 3F, i, j);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, j, i, 3F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, j, i, 3F);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, -3F, i, j);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, -3F, i, j);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, j, i, -3F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, j, i, -3F);
|
||||||
}
|
}
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, 2F, i, 2F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, 2F, i, 2F);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, 2F, i, -2F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, 2F, i, -2F);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, -2F, i, 2F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, -2F, i, 2F);
|
||||||
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 0, -2F, i, -2F);
|
SmallBlockPronter.drawSmolBlockAt(ModBlocks.watz_end, 1, -2F, i, -2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallBlockPronter.draw();
|
SmallBlockPronter.draw();
|
||||||
|
|||||||
@ -49,15 +49,15 @@ public class TileEntityWatzStruct extends TileEntity {
|
|||||||
if(!cbr(ModBlocks.watz_cooler, -1, i, -2)) return;
|
if(!cbr(ModBlocks.watz_cooler, -1, i, -2)) return;
|
||||||
|
|
||||||
for(int j = -1; j < 2; j++) {
|
for(int j = -1; j < 2; j++) {
|
||||||
if(!cbr(ModBlocks.watz_end, 3, i, j)) return;
|
if(!cbr(ModBlocks.watz_end, 1, 3, i, j)) return;
|
||||||
if(!cbr(ModBlocks.watz_end, j, i, 3)) return;
|
if(!cbr(ModBlocks.watz_end, 1, j, i, 3)) return;
|
||||||
if(!cbr(ModBlocks.watz_end, -3, i, j)) return;
|
if(!cbr(ModBlocks.watz_end, 1, -3, i, j)) return;
|
||||||
if(!cbr(ModBlocks.watz_end, j, i, -3)) return;
|
if(!cbr(ModBlocks.watz_end, 1, j, i, -3)) return;
|
||||||
}
|
}
|
||||||
if(!cbr(ModBlocks.watz_end, 2, i, 2)) return;
|
if(!cbr(ModBlocks.watz_end, 1, 2, i, 2)) return;
|
||||||
if(!cbr(ModBlocks.watz_end, 2, i, -2)) return;
|
if(!cbr(ModBlocks.watz_end, 1, 2, i, -2)) return;
|
||||||
if(!cbr(ModBlocks.watz_end, -2, i, 2)) return;
|
if(!cbr(ModBlocks.watz_end, 1, -2, i, 2)) return;
|
||||||
if(!cbr(ModBlocks.watz_end, -2, i, -2)) return;
|
if(!cbr(ModBlocks.watz_end, 1, -2, i, -2)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Watz watz = (Watz)ModBlocks.watz;
|
Watz watz = (Watz)ModBlocks.watz;
|
||||||
@ -72,10 +72,18 @@ public class TileEntityWatzStruct extends TileEntity {
|
|||||||
return worldObj.getBlock(xCoord + x, yCoord + y, zCoord + z);
|
return worldObj.getBlock(xCoord + x, yCoord + y, zCoord + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** [G]et [M]eta at [R]elative position */
|
||||||
|
private int gmr(int x, int y, int z) {
|
||||||
|
return worldObj.getBlockMetadata(xCoord + x, yCoord + y, zCoord + z);
|
||||||
|
}
|
||||||
|
|
||||||
/** [C]heck [B]lock at [R]elative position */
|
/** [C]heck [B]lock at [R]elative position */
|
||||||
private boolean cbr(Block b, int x, int y, int z) {
|
private boolean cbr(Block b, int x, int y, int z) {
|
||||||
return b == gbr(x, y, z);
|
return b == gbr(x, y, z);
|
||||||
}
|
}
|
||||||
|
private boolean cbr(Block b, int meta, int x, int y, int z) {
|
||||||
|
return b == gbr(x, y, z) && meta == gmr(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
AxisAlignedBB bb = null;
|
AxisAlignedBB bb = null;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 410 B |
Loading…
x
Reference in New Issue
Block a user