congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
slimeknights.mantle.client.book
Code IndexAdd Tabnine to your IDE (free)

How to use slimeknights.mantle.client.book

Best Java code snippets using slimeknights.mantle.client.book (Showing top 20 results out of 315)

origin: SlimeKnights/TinkersConstruct

 public static void init() {
  BookLoader.registerPageType(ContentMaterial.ID, ContentMaterial.class);
  BookLoader.registerPageType(ContentModifier.ID, ContentModifier.class);
  BookLoader.registerPageType(ContentModifierFortify.ID, ContentModifierFortify.class);
  BookLoader.registerPageType(ContentTool.ID, ContentTool.class);
  BookLoader.registerPageType(ContentSingleStatMultMaterial.ID, ContentSingleStatMultMaterial.class);
  BookLoader.registerPageType(ContentImageText2.ID, ContentImageText2.class);
  INSTANCE.addRepository(new FileRepository(Util.resource("book")));
  INSTANCE.addTransformer(new ToolSectionTransformer());
  INSTANCE.addTransformer(new MaterialSectionTransformer());
  INSTANCE.addTransformer(new ModifierSectionTransformer());
  INSTANCE.addTransformer(new BowMaterialSectionTransformer());
  INSTANCE.addTransformer(BookTransformer.IndexTranformer());
 }
}
origin: SlimeKnights/Mantle

@Override
public IMessage handleServer(NetHandlerPlayServer netHandler) {
 if (netHandler.player != null && pageName != null) {
  EntityPlayer player = netHandler.player;
  ItemStack is = player.getHeldItem(EnumHand.MAIN_HAND);
  if(!is.isEmpty()) {
   BookHelper.writeSavedPage(is, pageName);
  }
 }
 return null;
}
origin: SlimeKnights/Mantle

public void step() {
 int start = blockIndex;
 do {
  if(++blockIndex >= maxBlockIndex) {
   blockIndex = 0;
  }
 } while(isEmpty(blockIndex) && blockIndex != start);
}
origin: SlimeKnights/Mantle

initialized = true;
sections.clear();
appearance = new AppearanceData();
itemLinks.clear();
  List<SectionData> repoContents = repo.getSections();
  sections.addAll(repoContents);
  SectionData error = new SectionData();
  error.name = "errorenous";
  PageData page = new PageData(true);
  page.name = "errorenous";
  page.content = new ContentError("Failed to load repository " + repo.toString() + ".", e);
  error.pages.add(page);
  sections.add(error);
 ResourceLocation appearanceLocation = repo.getResourceLocation("appearance.json");
 if(repo.resourceExists(appearanceLocation)) {
  try {
   appearance = BookLoader.GSON
     .fromJson(repo.resourceToString(repo.getResource(appearanceLocation)), AppearanceData.class);
  } catch(Exception e) {
   e.printStackTrace();
 appearance.load();
 ResourceLocation itemLinkLocation = repo.getResourceLocation("items.json");
origin: SlimeKnights/Mantle

/**
 * Adds a book to the loader, and returns a reference object
 * Be warned that the returned BookData object is not immediately populated, and is instead populated when the resources are loaded/reloaded
 *
 * @param name               The name of the book, modid: will be automatically appended to the front of the name unless that is already added
 * @param appendIndex        Whether an index should be added to the front of the book using a BookTransformer
 * @param appendContentTable Whether a table of contents should be added to the front of each section using a BookTransformer
 * @param repositories       All the repositories the book will load the sections from
 * @return The book object, not immediately populated
 */
public static BookData registerBook(String name, boolean appendIndex, boolean appendContentTable, BookRepository... repositories) {
 BookData info = new BookData(repositories);
 books.put(name.contains(":") ? name : Loader.instance().activeModContainer().getModId() + ":" + name, info);
 if(appendIndex) {
  info.addTransformer(BookTransformer.IndexTranformer());
 }
 if(appendContentTable) {
  info.addTransformer(BookTransformer.contentTableTransformer());
 }
 return info;
}
origin: SlimeKnights/Mantle

 IResource pageInfo = source.getResource(source.getResourceLocation(data));
 if(pageInfo != null) {
  String data = source.resourceToString(pageInfo);
  if(!data.isEmpty()) {
   Class<? extends PageContent> ctype = BookLoader.getPageType(type);
    content = new ContentError(ctype == null ? "Failed to create a page of type \"" + type + "\", perhaps the type is not registered?" : "Failed to create a page of type \"" + type + "\", perhaps the page file \"" + this.data + "\" is missing or invalid?", e);
  content = BookLoader.getPageType(type).newInstance();
 } catch(InstantiationException | IllegalAccessException | NullPointerException e) {
  content = new ContentError("Failed to create a page of type \"" + type + "\", perhaps the type is not registered?");
 content.load();
} catch(Exception e) {
 content = new ContentError("Failed to load page " + parent.name + "." + name + ".", e);
 e.printStackTrace();
     swap.swap(source, ob);
    Object o = f.get(content);
    swap.swap(source, o);
   } catch(IllegalAccessException e) {
    e.printStackTrace();
origin: SlimeKnights/Mantle

  int fullPageCount = book.getFullPageCount(advancementCache);
  if((page < fullPageCount - 1 || fullPageCount % 2 != 0) && page < fullPageCount) {
   drawModalRectWithCustomSizedTexture(width / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
 nextArrow.visible = page < book.getFullPageCount(advancementCache) - (book.getPageCount(advancementCache) % 2 != 0 ? 0 : 1);
 backArrow.visible = oldPage >= -1;
  indexArrow.visible = book.findSection("index") != null && (page - 1) * 2 + 2 > book.findSection("index")
                                            .getPageCount();
public void actionPerformed(GuiButton button) {
 if(button instanceof GuiBookmark) {
  openPage(book.findPageNumber(((GuiBookmark) button).data.page, advancementCache));
  int fullPageCount = book.getFullPageCount(advancementCache);
  if(page > fullPageCount - (fullPageCount % 2 != 0 ? 0 : 1)) {
   page = fullPageCount - 1;
  openPage(book.findPageNumber("index.page1"));
 PageData page = this.page == 0 ? book.findPage(0, advancementCache) : book.findPage((this.page - 1) * 2 + 1, advancementCache);
  page = book.findPage((this.page - 1) * 2 + 2, advancementCache);
  BookLoader.updateSavedPage(mc.player, item, "");
 } else if(page != null && page.parent != null) {
  BookLoader.updateSavedPage(mc.player, item, page.parent.name + "." + page.name);
origin: SlimeKnights/Mantle

public BookLoader() {
 wrapper.registerPacketServer(PacketUpdateSavedPage.class);
 // Register page types
 registerPageType("blank", ContentBlank.class);
 registerPageType("text", ContentText.class);
 registerPageType("image", ContentImage.class);
 registerPageType("image with text below", ContentImageText.class);
 registerPageType("text with image below", ContentTextImage.class);
 registerPageType("text with left image etch", ContentTextLeftImage.class);
 registerPageType("text with right image etch", ContentTextRightImage.class);
 registerPageType("crafting", ContentCrafting.class);
 registerPageType("smelting", ContentSmelting.class);
 registerPageType("smithing", ContentSmithing.class);
 registerPageType("block interaction", ContentBlockInteraction.class);
 registerPageType("structure", ContentStructure.class);
 // Register action protocols
 StringActionProcessor.registerProtocol(new ProtocolGoToPage());
 StringActionProcessor.registerProtocol(new ProtocolGoToPage(true, ProtocolGoToPage.GO_TO_RTN));
}
origin: SlimeKnights/Mantle

 if(structureData.canStep() || ++fullStructureSteps >= 5) {
  structureData.step();
  fullStructureSteps = 0;
structureData.reset();
structureData.setShowLayer(9);
origin: SlimeKnights/Mantle

public StructureInfo(int length, int height, int width, BlockData[] blockData) {
 this.structureWidth = width;
 this.structureHeight = height;
 this.structureLength = length;
 IBlockState[][][] states = new IBlockState[height][length][width];
 for(int y = 0; y < height; y++) {
  for(int x = 0; x < length; x++) {
   for(int z = 0; z < width; z++) {
    for(BlockData data : blockData) {
     if(inside(x, y, z, data.pos, data.endPos)) {
      states[y][x][z] = convert(data);
      break;
     }
    }
   }
  }
 }
 data = states;
 maxBlockIndex = blockIndex = structureHeight * structureLength * structureWidth;
}
origin: SlimeKnights/Mantle

public void init(int[] size, BlockData[] data) {
 int yOff = 0;
 structureData = new StructureInfo(size[0], size[1], size[2], data);
 blockAccess = new StructureBlockAccess(structureData);
origin: SlimeKnights/Mantle

public GuiBook(BookData book, @Nullable ItemStack item) {
 this.book = book;
 this.item = item;
 this.mc = Minecraft.getMinecraft();
 this.fontRenderer = mc.fontRenderer;
 init();
 advancementCache = new AdvancementCache();
 this.mc.player.connection.getAdvancementManager().setListener(advancementCache);
 openPage(book.findPageNumber(BookHelper.getSavedPage(item), advancementCache));
}
origin: SlimeKnights/Mantle

/**
 * Adds a book to the loader, and returns a reference object
 * Be warned that the returned BookData object is not immediately populated, and is instead populated when the resources are loaded/reloaded
 *
 * @param name         The name of the book, modid: will be automatically appended to the front of the name unless that is already added
 * @param repositories All the repositories the book will load the sections from
 * @return The book object, not immediately populated
 */
public static BookData registerBook(String name, BookRepository... repositories) {
 return registerBook(name, true, true, repositories);
}
origin: SlimeKnights/Mantle

@Override
public void preInit() {
  bookLoader = new BookLoader();
}
origin: SlimeKnights/Mantle

public static BookTransformer contentTableTransformerForSection(String sectionName) { return new ContentTableTransformer(sectionName); }
origin: SlimeKnights/Mantle

if(z >= 0 && z < structure[y][x].length) {
 int index = y * (data.structureLength * data.structureWidth) + x * data.structureWidth + z;
 if(index <= data.getLimiter()) {
  return structure[y][x][z] != null ? structure[y][x][z] : Blocks.AIR.getDefaultState();
origin: SlimeKnights/Mantle

private IBlockState convert(BlockData data) {
 Block block = Block.getBlockFromName(data.block);
 if(block == null) {
  return Blocks.AIR.getDefaultState();
 }
 IBlockState state;
 if(data.state == null || data.state.isEmpty()) {
  state = block.getStateFromMeta(data.meta);
 }
 else {
  state = block.getDefaultState();
  for(Map.Entry<String, String> entry : data.state.entrySet()) {
   Optional<IProperty<?>> property = state.getPropertyKeys().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst();
   if(property.isPresent()) {
    state = setProperty(state, property.get(), entry.getValue());
   }
  }
 }
 return state;
}
origin: SleepyTrousers/EnderIO

public static void integrate() {
 INSTANCE.addRepository(new FileRepository(EnderIO.DOMAIN + ":eiobook"));
 INSTANCE.addTransformer(BookTransformer.IndexTranformer());
}
origin: SlimeKnights/Mantle

public static void updateSavedPage(EntityPlayer player, ItemStack item, String page) {
 if(player == null) {
  return;
 }
 if(player.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
  return;
 }
 BookHelper.writeSavedPage(item, page);
 wrapper.network.sendToServer(new PacketUpdateSavedPage(page));
}
origin: SlimeKnights/Mantle

public boolean canStep() {
 int index = blockIndex;
 do {
  if(++index >= maxBlockIndex) {
   return false;
  }
 } while(isEmpty(index));
 return true;
}
slimeknights.mantle.client.book

Most used classes

  • BookTransformer
  • BookData
  • FileRepository
  • BookLoader
  • StringActionProcessor
  • TextData,
  • BookHelper,
  • BookTransformer$ContentTableTransformer,
  • StructureBlockAccess,
  • StructureInfo,
  • ActionProtocol,
  • ProtocolGoToPage,
  • AppearanceData,
  • PageData$ValueHotswap,
  • SectionData,
  • ContentBlockInteraction,
  • ContentError,
  • ContentImage,
  • ContentImageText
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now