Search in sources :

Example 1 with MinechemBlueprint

use of minechem.item.blueprint.MinechemBlueprint in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method setInventorySlotContents.

@Override
public void setInventorySlotContents(int slot, ItemStack itemstack) {
    super.setInventorySlotContents(slot, itemstack);
    if (itemstack != null) {
        MinechemBlueprint blueprint = MinechemItemsRegistration.blueprint.getBlueprint(itemstack);
        setBlueprint(blueprint);
    }
}
Also used : MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Example 2 with MinechemBlueprint

use of minechem.item.blueprint.MinechemBlueprint in project Minechem by iopleke.

the class BlueprintProjectorGui method getBlockCount.

private HashMap<Integer, Integer> getBlockCount(MinechemBlueprint blueprint) {
    HashMap<Integer, Integer> blockCount = new HashMap<Integer, Integer>();
    for (int x = 0; x < blueprint.xSize; x++) {
        for (int y = 0; y < blueprint.ySize; y++) {
            for (int z = 0; z < blueprint.zSize; z++) {
                int structureID = blueprint.getStructure()[y][x][z];
                int count = 0;
                if (blockCount.get(structureID) != null) {
                    count = blockCount.get(structureID);
                }
                count++;
                blockCount.put(structureID, count);
            }
        }
    }
    return blockCount;
}
Also used : HashMap(java.util.HashMap) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Example 3 with MinechemBlueprint

use of minechem.item.blueprint.MinechemBlueprint in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbtTagCompound) {
    super.readFromNBT(nbtTagCompound);
    this.inventory = new ItemStack[getSizeInventory()];
    this.isComplete = false;
    NBTTagCompound blueprintNBT = (NBTTagCompound) nbtTagCompound.getTag("blueprint");
    if (blueprintNBT != null) {
        ItemStack blueprintStack = ItemStack.loadItemStackFromNBT(blueprintNBT);
        MinechemBlueprint blueprint = MinechemItemsRegistration.blueprint.getBlueprint(blueprintStack);
        setBlueprint(blueprint);
        this.inventory[0] = blueprintStack;
    }
}
Also used : MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 4 with MinechemBlueprint

use of minechem.item.blueprint.MinechemBlueprint in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method takeBlueprint.

public MinechemBlueprint takeBlueprint() {
    MinechemBlueprint blueprint = this.blueprint;
    setBlueprint(null);
    return blueprint;
}
Also used : MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Example 5 with MinechemBlueprint

use of minechem.item.blueprint.MinechemBlueprint in project Minechem by iopleke.

the class BlueprintProjectorGui method drawBlueprintInfo.

private void drawBlueprintInfo(ItemStack blueprintStack) {
    MinechemBlueprint blueprint = MinechemItemsRegistration.blueprint.getBlueprint(blueprintStack);
    if (blueprint == null) {
        return;
    }
    String name = blueprintStack.getDisplayName().replace("Blueprint", "");
    this.fontRendererObj.drawStringWithShadow(name, 64, 12, 0xFFFFFF);
    HashMap<Integer, Integer> blockCount = getBlockCount(blueprint);
    HashMap<Integer, BlueprintBlock> blockLookup = blueprint.getBlockLookup();
    int y = 23;
    Iterator<Entry<Integer, Integer>> it = blockCount.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<Integer, Integer> entry = it.next();
        BlueprintBlock block = blockLookup.get(entry.getKey());
        if (block != null) {
            ItemStack itemstack = new ItemStack(block.block, 1, block.metadata);
            String info = String.format("%dx%s", entry.getValue(), itemstack.getDisplayName());
            this.fontRendererObj.drawString(info, 64, y, 0xDDDDDD);
            y += 10;
        }
    }
}
Also used : BlueprintBlock(minechem.item.blueprint.BlueprintBlock) Entry(java.util.Map.Entry) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint) ItemStack(net.minecraft.item.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Aggregations

MinechemBlueprint (minechem.item.blueprint.MinechemBlueprint)5 HashMap (java.util.HashMap)2 ItemStack (net.minecraft.item.ItemStack)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 BlueprintBlock (minechem.item.blueprint.BlueprintBlock)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1