Search in sources :

Example 1 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class MinerStats method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbt) {
    nbt.setInteger("Point", getPoint());
    nbt.setInteger("Rank", getRank());
    nbt.setInteger("MiningAssist", getMiningAssist());
    NBTTagList list = new NBTTagList();
    for (Entry<BlockMeta, Integer> record : records.entrySet()) {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setString("Name", record.getKey().getBlockName());
        tag.setInteger("Meta", record.getKey().getMeta());
        tag.setInteger("Count", record.getValue().intValue());
        list.appendTag(tag);
    }
    nbt.setTag("Records", list);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockMeta(cavern.util.BlockMeta)

Example 2 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class MinerStats method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbt) {
    setPoint(nbt.getInteger("Point"), false);
    setRank(nbt.getInteger("Rank"), false);
    setMiningAssist(nbt.getInteger("MiningAssist"), false);
    NBTTagList list = nbt.getTagList("Records", NBT.TAG_COMPOUND);
    for (int i = 0; i < list.tagCount(); ++i) {
        NBTTagCompound tag = list.getCompoundTagAt(i);
        records.put(new BlockMeta(tag.getString("Name"), tag.getInteger("Meta")), tag.getInteger("Count"));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockMeta(cavern.util.BlockMeta)

Example 3 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class MiningRecordsMessage method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    records = Maps.newHashMap();
    int size = buf.readInt();
    for (int i = 0; i < size; ++i) {
        IBlockState state = GameData.getBlockStateIDMap().getByValue(buf.readInt());
        int count = buf.readInt();
        records.put(new BlockMeta(state), count);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockMeta(cavern.util.BlockMeta)

Example 4 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class ConfigBlocks method refreshBlocks.

public void refreshBlocks() {
    blocks.clear();
    Arrays.stream(getValues()).filter(value -> !Strings.isNullOrEmpty(value)).forEach(value -> {
        value = value.trim();
        if (OreDictionary.doesOreNameExist(value)) {
            for (ItemStack stack : OreDictionary.getOres(value, false)) {
                if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) {
                    Block block = ((ItemBlock) stack.getItem()).getBlock();
                    if (block != null) {
                        blocks.add(new BlockMeta(block, stack.getMetadata()));
                    }
                }
            }
        } else {
            if (!value.contains(":")) {
                value = "minecraft:" + value;
            }
            BlockMeta blockMeta;
            if (value.indexOf(':') != value.lastIndexOf(':')) {
                int i = value.lastIndexOf(':');
                blockMeta = new BlockMeta(value.substring(0, i), value.substring(i + 1));
            } else {
                blockMeta = new BlockMeta(value, 0);
            }
            if (blockMeta.getBlock() != null) {
                blocks.add(blockMeta);
            }
        }
    });
}
Also used : Strings(com.google.common.base.Strings) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) Arrays(java.util.Arrays) Block(net.minecraft.block.Block) OreDictionary(net.minecraftforge.oredict.OreDictionary) Set(java.util.Set) ItemBlock(net.minecraft.item.ItemBlock) Sets(com.google.common.collect.Sets) BlockMeta(cavern.util.BlockMeta) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) BlockMeta(cavern.util.BlockMeta)

Example 5 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class ConfigMiningPoints method refreshPoints.

public void refreshPoints() {
    MinerStats.MINING_POINTS.clear();
    for (String value : values) {
        if (!Strings.isNullOrEmpty(value) && value.contains(",")) {
            value = value.trim();
            int i = value.indexOf(',');
            String str = value.substring(0, i).trim();
            int point = NumberUtils.toInt(value.substring(i + 1));
            if (OreDictionary.doesOreNameExist(str)) {
                MinerStats.setPointAmount(str, point);
            } else {
                if (!str.contains(":")) {
                    str = "minecraft:" + str;
                }
                BlockMeta blockMeta;
                if (str.indexOf(':') != str.lastIndexOf(':')) {
                    i = str.lastIndexOf(':');
                    blockMeta = new BlockMeta(str.substring(0, i), str.substring(i + 1));
                } else {
                    blockMeta = new BlockMeta(str, 0);
                }
                if (blockMeta.isNotAir()) {
                    MinerStats.setPointAmount(blockMeta, point);
                }
            }
        }
    }
}
Also used : BlockMeta(cavern.util.BlockMeta)

Aggregations

BlockMeta (cavern.util.BlockMeta)21 CaveVein (cavern.config.manager.CaveVein)7 File (java.io.File)7 CaveBiome (cavern.config.manager.CaveBiome)5 Biome (net.minecraft.world.biome.Biome)4 Block (net.minecraft.block.Block)3 IBlockState (net.minecraft.block.state.IBlockState)3 ItemStack (net.minecraft.item.ItemStack)3 Strings (com.google.common.base.Strings)2 Sets (com.google.common.collect.Sets)2 IOException (java.io.IOException)2 List (java.util.List)2 Set (java.util.Set)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 ConfigCategory (net.minecraftforge.common.config.ConfigCategory)2 IIceEquipment (cavern.api.IIceEquipment)1 IMinerStats (cavern.api.IMinerStats)1 IMiningData (cavern.api.IMiningData)1 CaveConfigGui (cavern.client.config.CaveConfigGui)1