use of arekkuusu.implom.api.capability.INBTDataTransferable in project Solar by ArekkuusuJerii.
the class ItemBoundPhoton method pickSource.
@SubscribeEvent(priority = EventPriority.LOWEST)
public void pickSource(PlayerInteractEvent.RightClickBlock event) {
ItemStack stack = event.getItemStack();
if (stack.getItem() == this) {
if (!event.getWorld().isRemote) {
TileEntity tile = event.getWorld().getTileEntity(event.getPos());
if (tile instanceof INBTDataTransferable) {
NBTTagCompound compound = stack.getOrCreateSubCompound(Constants.NBT_BOUND);
String key = ((INBTDataTransferable) tile).group();
NBTTagCompound tag = compound.getCompoundTag(key);
if (!compound.hasKey(key))
compound.setTag(key, tag);
EnumActionResult result = ((INBTDataTransferable) tile).init(tag);
if (result != EnumActionResult.FAIL) {
TextComponentTranslation bound = new TextComponentTranslation("tlp." + key + ".group", TextFormatting.DARK_GRAY);
TextComponentTranslation action = new TextComponentTranslation("status.bound", bound, TextFormatting.BLACK);
event.getEntityPlayer().sendStatusMessage(action, true);
}
}
}
event.setCanceled(true);
}
}
Aggregations