I've solved it, but it seems awfully complicated for such as basic task.
Here's my solution:
@Override
protected void dropBlockAsItem(World p_149642_1_, int p_149642_2_, int p_149642_3_,
int p_149642_4_, ItemStack p_149642_5_) {
System.out.println("dropBlockAsItem");
// super.dropBlockAsItem(p_149642_1_, p_149642_2_, p_149642_3_, p_149642_4_, p_149642_5_);
// TODO: TEST
try {
TileEntityBaseScanner tile =
TileEntityHelper.getTileEntityBaseScannerFromCoords(p_149642_1_, p_149642_2_,
p_149642_3_, p_149642_4_);
ItemStack itemstack = new ItemStack(this, 1);
itemstack.setTagCompound(tile.getNBTTagCompound());
itemstack.setStackDisplayName("Test: "
+ tile.getNBTTagCompound().getInteger("test"));
Entity item = new EntityItem(p_149642_1_, p_149642_2_, p_149642_3_, p_149642_4_, itemstack);
p_149642_1_.spawnEntityInWorld(item);
} catch (Exception e) {
System.out.println("NO entity dropped!");
e.printStackTrace();
}
}
@Override
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_,
EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {
if (p_149689_1_.isRemote)
return;
try {
NBTTagCompound nbt = p_149689_6_.getTagCompound();
if(nbt != null){
TileEntityBaseScanner tile = new TileEntityBaseScanner();
//tile.writeToNBT(nbt);
tile.writeToParByNBT(nbt);
System.out.println(tile.test);
p_149689_1_.setTileEntity(p_149689_2_, p_149689_3_, p_149689_4_, tile);
}
else {
System.out.println("No NBT");
}
} catch (Exception e) {
System.out.println("NO entity dropped!");
e.printStackTrace();
}
}
// tile-class
/**
* Write values from NBT to this
* bit of an awkward solution, but since we ain't got no pointers making this more flexible is a pain, so I wrote it static for the time being
* @param par1: NBTTagCompound
*/
public void writeToParByNBT(NBTTagCompound par1){
this.test= (par1.hasKey("test")) ? par1.getInteger("test") : test;
}