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);
}
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"));
}
}
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);
}
}
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);
}
}
});
}
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);
}
}
}
}
}
Aggregations