Hammer ores on engineering table to yield rubble
This commit is contained in:
parent
a8e275c73b
commit
c206e13794
11 changed files with 119 additions and 153 deletions
|
@ -60,7 +60,7 @@ public final class MachineRecipes
|
|||
return new HashMap<RecipeType, Map<Resource[], Resource[]>>(this.recipes);
|
||||
}
|
||||
|
||||
public Resource[] getOutput(RecipeType machine, Resource[] input)
|
||||
public Resource[] getOutput(RecipeType machine, Resource... input)
|
||||
{
|
||||
Iterator<Entry<Resource[], Resource[]>> it = this.getRecipes(machine).entrySet().iterator();
|
||||
|
||||
|
@ -77,7 +77,7 @@ public final class MachineRecipes
|
|||
return new Resource[] {};
|
||||
}
|
||||
|
||||
public Resource[] getRecipe(RecipeType machine, ItemStack... inputs)
|
||||
public Resource[] getOutput(RecipeType machine, ItemStack... inputs)
|
||||
{
|
||||
Resource[] resourceInputs = new Resource[inputs.length];
|
||||
|
||||
|
@ -89,7 +89,7 @@ public final class MachineRecipes
|
|||
return this.getOutput(machine, resourceInputs);
|
||||
}
|
||||
|
||||
public Resource[] getRecipe(RecipeType machine, String... oreDictNames)
|
||||
public Resource[] getOutput(RecipeType machine, String... oreDictNames)
|
||||
{
|
||||
Resource[] resourceInputs = new Resource[oreDictNames.length];
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ public class RecipeUtils
|
|||
{
|
||||
return this.chance;
|
||||
}
|
||||
|
||||
public abstract ItemStack getItemStack();
|
||||
}
|
||||
|
||||
public static class ItemStackResource extends Resource
|
||||
|
@ -60,6 +62,12 @@ public class RecipeUtils
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class OreDictResource extends Resource
|
||||
|
@ -82,17 +90,23 @@ public class RecipeUtils
|
|||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof OreDictResource)
|
||||
{
|
||||
{System.out.println(name +" VS " +((OreDictResource) obj).name);
|
||||
return this.name.equals(((OreDictResource) obj).name);
|
||||
}
|
||||
|
||||
if (obj instanceof ItemStackResource)
|
||||
{
|
||||
return this.name.equals(OreDictionary.getOreName(OreDictionary.getOreID(((ItemStackResource) obj).itemStack)));
|
||||
return this.name.equals(OreDictionary.getOreName(OreDictionary.getOreID(((ItemStackResource) obj).itemStack)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return OreDictionary.getOres(name).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FluidStackResource extends Resource
|
||||
|
@ -116,5 +130,11 @@ public class RecipeUtils
|
|||
{
|
||||
return (obj instanceof FluidStack) ? ((FluidStack) obj).equals(obj) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import resonantinduction.archaic.crate.BlockCrate;
|
|||
import resonantinduction.archaic.crate.ItemBlockCrate;
|
||||
import resonantinduction.archaic.crate.TileCrate;
|
||||
import resonantinduction.archaic.engineering.BlockEngineeringTable;
|
||||
import resonantinduction.archaic.engineering.ItemHammer;
|
||||
import resonantinduction.archaic.engineering.TileEngineeringTable;
|
||||
import resonantinduction.archaic.firebox.BlockFirebox;
|
||||
import resonantinduction.archaic.firebox.BlockHotPlate;
|
||||
|
@ -68,9 +69,12 @@ public class Archaic
|
|||
public static Block blockFirebox;
|
||||
public static Block blockHotPlate;
|
||||
public static Block blockMachinePart;
|
||||
|
||||
|
||||
public static Item itemImprint;
|
||||
|
||||
// Machine and Processing
|
||||
public static Item itemHammer;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt)
|
||||
{
|
||||
|
@ -84,8 +88,9 @@ public class Archaic
|
|||
blockHotPlate = contentRegistry.createBlock(BlockHotPlate.class, ItemBlockMetadata.class, TileHotPlate.class);
|
||||
|
||||
blockMachinePart = contentRegistry.createBlock(BlockMachinePart.class, ItemBlockMetadata.class);
|
||||
|
||||
|
||||
itemImprint = contentRegistry.createItem(ItemBlockImprint.class);
|
||||
itemHammer = contentRegistry.createItem(ItemHammer.class);
|
||||
proxy.preInit();
|
||||
Settings.save();
|
||||
}
|
||||
|
|
|
@ -111,6 +111,11 @@ public class BlockEngineeringTable extends BlockRIRotatable
|
|||
@Override
|
||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemHammer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof TileEngineeringTable)
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package resonantinduction.archaic.engineering;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import resonantinduction.api.recipe.MachineRecipes;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
import resonantinduction.api.recipe.RecipeUtils.Resource;
|
||||
import resonantinduction.core.prefab.item.ItemRI;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
|
||||
public class ItemHammer extends ItemRI
|
||||
{
|
||||
public ItemHammer()
|
||||
{
|
||||
super("hammer");
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(400);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof TileEngineeringTable)
|
||||
{
|
||||
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
|
||||
ItemStack inputStack = tile.getStackInSlot(TileEngineeringTable.CENTER_SLOT);
|
||||
|
||||
if (inputStack != null)
|
||||
{
|
||||
String oreName = OreDictionary.getOreName(OreDictionary.getOreID(inputStack));
|
||||
|
||||
if (oreName != null && !oreName.equals("Unknown"))
|
||||
{
|
||||
if (!world.isRemote && world.rand.nextFloat() < 0.04)
|
||||
{
|
||||
Resource[] outputs = MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER, oreName);
|
||||
|
||||
// TODO: Fix multiple outputs.
|
||||
for (Resource resource : outputs)
|
||||
{
|
||||
ItemStack outputStack = resource.getItemStack().copy();
|
||||
|
||||
if (outputStack != null)
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, new Vector3(player), outputStack, 0);
|
||||
tile.setInventorySlotContents(TileEngineeringTable.CENTER_SLOT, --inputStack.stackSize <= 0 ? null : inputStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.addExhaustion(1);
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
|||
public static final int CRAFTING_MATRIX_END = 9;
|
||||
public static final int CRAFTING_OUTPUT_END = CRAFTING_MATRIX_END + 1;
|
||||
public static final int PLAYER_OUTPUT_END = CRAFTING_OUTPUT_END + 40;
|
||||
public static final int CENTER_SLOT = 4;
|
||||
|
||||
// Relative slot IDs
|
||||
public static final int CRAFTING_OUTPUT_SLOT = 0;
|
||||
|
@ -326,7 +327,7 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
|||
*/
|
||||
if (!didCraft)
|
||||
{
|
||||
ItemStack filterStack = craftingMatrix[4];// this.inventory[IMPRINT_SLOT];
|
||||
ItemStack filterStack = craftingMatrix[CENTER_SLOT];
|
||||
|
||||
if (filterStack != null && filterStack.getItem() instanceof ItemBlockImprint)
|
||||
{
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
package resonantinduction.archaic.trough;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.mechanical.fluid.prefab.TileFluidNetwork;
|
||||
|
||||
/**
|
||||
* Enum to hold info about each pipe material. Values are by default and some can change with pipe
|
||||
* upgrades.
|
||||
*
|
||||
* @Note unsupportedFluids should only be used by filters. All pipes should allow all fluid types.
|
||||
* However, pipes that can't support the fluid should have an effect. Eg no gas support should cause
|
||||
* the pipe to leak. No molten support should cause the pipe to take damage.
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public enum EnumPipeMaterial
|
||||
{
|
||||
/** Simple water only pipe. Should render open toped when it can */
|
||||
WOOD("wood", false, true, false, -1, 200),
|
||||
/** Another version of the wooden pipe */
|
||||
STONE("stone", false, true, false, -1, 1000);
|
||||
|
||||
public String matName = "material";
|
||||
List<String> unsupportedFluids = new ArrayList<String>();
|
||||
public boolean canSupportGas = false;
|
||||
public boolean canSupportFluids = false;
|
||||
public boolean canSupportMoltenFluids = false;
|
||||
public int maxPressure = 1000;
|
||||
public int maxVolume = 2000;
|
||||
/**
|
||||
* Materials are stored as meta were there sub types are stored by NBT. Item versions of the
|
||||
* pipes are still meta so there is a set spacing to allow for a large but defined range of sub
|
||||
* pipes
|
||||
*/
|
||||
public static int spacing = 1000;
|
||||
|
||||
private EnumPipeMaterial()
|
||||
{
|
||||
this.canSupportGas = true;
|
||||
this.canSupportFluids = true;
|
||||
canSupportMoltenFluids = true;
|
||||
}
|
||||
|
||||
private EnumPipeMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings)
|
||||
{
|
||||
this.matName = name;
|
||||
this.canSupportGas = gas;
|
||||
this.canSupportFluids = fluid;
|
||||
this.canSupportMoltenFluids = molten;
|
||||
}
|
||||
|
||||
private EnumPipeMaterial(String name, boolean gas, boolean fluid, boolean molten, int pressure, int volume, String... strings)
|
||||
{
|
||||
this(name, gas, fluid, molten, strings);
|
||||
this.maxPressure = pressure;
|
||||
this.maxVolume = volume;
|
||||
}
|
||||
|
||||
public static EnumPipeMaterial get(World world, int x, int y, int z)
|
||||
{
|
||||
return get(world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
public static EnumPipeMaterial get(int i)
|
||||
{
|
||||
if (i < EnumPipeMaterial.values().length)
|
||||
{
|
||||
return EnumPipeMaterial.values()[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnumPipeMaterial get(ItemStack stack)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
return getFromItemMeta(stack.getItemDamage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnumPipeMaterial getFromItemMeta(int meta)
|
||||
{
|
||||
meta = meta / spacing;
|
||||
if (meta < EnumPipeMaterial.values().length)
|
||||
{
|
||||
return EnumPipeMaterial.values()[meta];
|
||||
}
|
||||
return EnumPipeMaterial.WOOD;
|
||||
}
|
||||
|
||||
public int getMeta(int typeID)
|
||||
{
|
||||
return (this.ordinal() * spacing) + typeID;
|
||||
}
|
||||
|
||||
public int getMeta()
|
||||
{
|
||||
return this.getMeta(0);
|
||||
}
|
||||
|
||||
public static int getType(int meta)
|
||||
{
|
||||
return meta / spacing;
|
||||
}
|
||||
|
||||
public static int getDropItemMeta(World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
meta *= spacing;
|
||||
if (ent instanceof TileFluidNetwork)
|
||||
{
|
||||
meta += ((TileFluidNetwork) ent).getSubID();
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
public boolean canSupport(FluidStack fluid)
|
||||
{
|
||||
if (fluid != null && fluid.getFluid() != null)
|
||||
{
|
||||
if (fluid.getFluid().isGaseous(fluid) && this.canSupportGas)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!fluid.getFluid().isGaseous(fluid) && this.canSupportFluids)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -52,6 +53,13 @@ public class ResourceGenerator
|
|||
|
||||
public static void generateOreResources()
|
||||
{
|
||||
OreDictionary.registerOre("ingotGold", Item.ingotGold);
|
||||
OreDictionary.registerOre("ingotIron", Item.ingotIron);
|
||||
|
||||
OreDictionary.registerOre("oreGold", Block.oreGold);
|
||||
OreDictionary.registerOre("oreIron", Block.oreIron);
|
||||
OreDictionary.registerOre("oreLapis", Block.oreLapis);
|
||||
|
||||
for (String materialName : materialNames)
|
||||
{
|
||||
String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
|
||||
|
@ -66,7 +74,7 @@ public class ResourceGenerator
|
|||
}
|
||||
|
||||
// Add to machine recipes
|
||||
ItemStack dust = OreDictionary.getOres("dust" + name).get(0).copy();
|
||||
ItemStack dust = OreDictionary.getOres("rubble" + name).get(0).copy();
|
||||
dust.stackSize = 2;
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "ore" + name, dust);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import resonantinduction.electrical.armbot.TaskBaseArmbot;
|
|||
import resonantinduction.electrical.armbot.TaskBaseProcess;
|
||||
import resonantinduction.electrical.encoder.coding.ITask;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
|
||||
import com.builtbroken.common.Pair;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class TaskBreak extends TaskBaseArmbot
|
|||
|
||||
if (!this.keep || items.size() > 1)
|
||||
{
|
||||
WorldUtility.dropBlockAsItem(location.left(), serachPosition);
|
||||
InventoryUtility.dropBlockAsItem(location.left(), serachPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -122,14 +122,14 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
|
|||
|
||||
public boolean canGrind(ItemStack itemStack)
|
||||
{
|
||||
return MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack) == null ? false : MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack).length > 0;
|
||||
return MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER, itemStack) == null ? false : MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER, itemStack).length > 0;
|
||||
}
|
||||
|
||||
private boolean doGrind(EntityItem entity)
|
||||
{
|
||||
ItemStack itemStack = entity.getEntityItem();
|
||||
|
||||
Resource[] results = MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack);
|
||||
Resource[] results = MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER, itemStack);
|
||||
|
||||
for (Resource resource : results)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ tile.resonantinduction\:DebugBlock.3.name=Power Void
|
|||
### Archaic Module
|
||||
## Items
|
||||
item.resonantinduction\:imprint.name=Imprint
|
||||
item.resonantinduction\:hammer.name=Hammer
|
||||
|
||||
## Machines
|
||||
tile.resonantinduction\:imprinter.name=Imprinter
|
||||
|
|
Loading…
Reference in a new issue