use of mcjty.rftoolscontrol.network.PacketItemNBTToServer in project RFToolsControl by McJty.
the class ProgramCommand method loadProgram.
private void loadProgram(ICommandSender sender, String arg, ItemStack item) {
// File file = new File("." + File.separator + "rftoolscontrol" + File.separator + arg);
File file = new File(arg);
String json;
try (FileInputStream stream = new FileInputStream(file)) {
byte[] data = new byte[(int) file.length()];
stream.read(data);
json = new String(data, "UTF-8");
} catch (IOException e) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Error opening file for reading!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
ProgramCardInstance program = ProgramCardInstance.readFromJson(json);
program.writeToNBT(item);
RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketItemNBTToServer(item.getTagCompound()));
ITextComponent component = new TextComponentString("Loaded program!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
}
use of mcjty.rftoolscontrol.network.PacketItemNBTToServer in project RFToolsControl by McJty.
the class GuiCraftingCard method createSelectionEvent.
private BlockRenderEvent createSelectionEvent(final int idx) {
return new BlockRenderEvent() {
@Override
public void select(Widget parent) {
ItemStack itemstack = mc.player.inventory.getItemStack();
slots[idx].setRenderItem(itemstack);
ItemStackList stacks = getStacks();
if (!stacks.isEmpty()) {
stacks.set(idx, itemstack);
ItemStack cardItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
CraftingCardItem.putStacksInItem(cardItem, stacks);
RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketItemNBTToServer(cardItem.getTagCompound()));
}
}
@Override
public void doubleClick(Widget parent) {
}
};
}
Aggregations