use of net.minecraft.nbt.CompoundNBT in project AgriCraft by AgriCraft.
the class AgriGenome method readFromNBT.
@Override
@SuppressWarnings("unchecked")
public boolean readFromNBT(@Nonnull CompoundNBT tag) {
if (tag.contains(AgriNBT.GENOME)) {
ListNBT list = tag.getList(AgriNBT.GENOME, 10);
for (int i = 0; i < list.size(); i++) {
CompoundNBT geneTag = list.getCompound(i);
AgriGeneRegistry.getInstance().get(geneTag.getString(AgriNBT.GENE)).ifPresent(gene -> {
this.geneMap.put(gene, this.generateGenePairFromNBT(gene, geneTag));
});
}
return this.getPlant().isPlant();
}
return false;
}
use of net.minecraft.nbt.CompoundNBT in project AgriCraft by AgriCraft.
the class IrrigationNetworkLayer method writeToTag.
public CompoundNBT writeToTag() {
CompoundNBT tag = new CompoundNBT();
tag.putDouble(AgriNBT.Y1, this.getMin());
tag.putDouble(AgriNBT.Y2, this.getMax());
tag.putInt(AgriNBT.LEVEL, this.getVolume());
return tag;
}
use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.
the class BlockInsulatedAlloyWire method getCloneItemStack.
@Override
public ItemStack getCloneItemStack(IBlockReader world, BlockPos pos, BlockState state) {
TileEntity tileentity = world.getBlockEntity(pos);
ItemStack stack = ItemStack.EMPTY;
if (tileentity instanceof TileBPMultipart) {
tileentity = ((TileBPMultipart) tileentity).getTileForState(state);
}
if (tileentity instanceof TileInsulatedWire) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("color", ((TileInsulatedWire) tileentity).getColor().name());
stack = new ItemStack(this, 1, nbt);
}
return stack;
}
use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.
the class BlockBPMicroblock method getCloneItemStack.
@Override
public ItemStack getCloneItemStack(IBlockReader world, BlockPos pos, BlockState state) {
TileEntity tileentity = world.getBlockEntity(pos);
ItemStack stack = ItemStack.EMPTY;
if (tileentity instanceof TileBPMultipart) {
tileentity = ((TileBPMultipart) tileentity).getTileForState(state);
}
if (tileentity instanceof TileBPMicroblock) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", ((TileBPMicroblock) tileentity).getBlock().getRegistryName().toString());
stack = new ItemStack(this);
stack.setTag(nbt);
stack.setHoverName(new TranslationTextComponent(((TileBPMicroblock) tileentity).getBlock().getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(this.getDescriptionId())));
}
return stack;
}
use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.
the class BluePowerAPI method loadSilkySettings.
@Override
public void loadSilkySettings(World world, BlockPos pos, ItemStack stack) {
TileEntity te = world.getBlockEntity(pos);
BlockState blockState = world.getBlockState(pos);
if (te == null)
throw new IllegalStateException("This block doesn't have a tile entity?!");
if (stack.isEmpty())
throw new IllegalArgumentException("ItemStack is empty!");
if (stack.hasTag()) {
CompoundNBT tag = stack.getTag();
if (tag.contains("tileData")) {
if (te instanceof IAdvancedSilkyRemovable) {
((IAdvancedSilkyRemovable) te).readSilkyData(world, pos, tag.getCompound("tileData"));
} else if (blockState.getBlock() instanceof IAdvancedSilkyRemovable) {
((IAdvancedSilkyRemovable) blockState.getBlock()).readSilkyData(world, pos, tag.getCompound("tileData"));
} else {
CompoundNBT tileTag = tag.getCompound("tileData");
tileTag.putInt("x", pos.getX());
tileTag.putInt("y", pos.getY());
tileTag.putInt("z", pos.getZ());
te.load(blockState, tileTag);
}
}
}
}
Aggregations