Package org.spoutcraft.api.block.design

Examples of org.spoutcraft.api.block.design.GenericBlockDesign


  }

  public static void loadDesign(File file) {
    short customId = -1;
    byte data = 0;
    GenericBlockDesign design = null;

    try {
      final FileInputStream stream = new FileInputStream(file);
      final FileChannel read = stream.getChannel();
      final MappedByteBuffer buffer = read.map(FileChannel.MapMode.READ_ONLY, 0, read.size());
      stream.close();
      customId = buffer.getShort();
      data = buffer.get();
      design = new GenericBlockDesign();
      design.read(new SpoutInputStream(buffer));

    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (design != null && design.isReset()) {
        design = null;
      }
      if (customId != -1) {
        CustomBlock block = MaterialData.getCustomBlock(customId);
        if (block != null) {
View Full Code Here


                for (int dy = y; dy < sizeYOffset; ++dy) {
                  int id = chunkCache.getBlockId(dx, dy, dz);
                  if (id > 0) {
                    String customTexture = null;
                    String customTextureAddon = null;
                    GenericBlockDesign design = null;
                    CustomBlock mat = null;

                    if (customBlockIds != null) {
                      int key = ((dx & 0xF) << 12) | ((dz & 0xF) << 8) | (dy & 0xFF);
                      if (customBlockIds[key] != 0) {
                        mat = MaterialData.getCustomBlock(customBlockIds[key]);
                        if (mat != null) {
                          design = (GenericBlockDesign) mat.getBlockDesign(customBlockData == null ? 0 : customBlockData[key]);
                        }
                      }
                    }

                    if (design != null) {
                      customTexture = design.getTextureURL();
                      customTextureAddon = design.getTextureAddon();
                    }

                    if (customTexture != null){
                      boolean found = false;

                      // Search for the custom texture in our list
                      for(int i = 0; i < hitTextures.size(); i++){
                        if(hitTextures.get(i).equals(customTexture) && hitTexturesPlugins.get(i).equals(customTextureAddon)) {
                          found = true;
                          break;
                        }
                      }
                      // If it is not already accounted for, add it so we do an additional pass for it.
                      if (!found) {
                        hitTextures.add(customTexture);
                        hitTexturesPlugins.add(customTextureAddon);
                      }

                      // Do not render if we are using a different texture than the current one
                      if (!hitTextures.get(currentTexture).equals(customTexture) || !hitTexturesPlugins.get(currentTexture).equals(customTextureAddon)) {
                        continue;
                      }
                    // Do not render if we are not using the terrain.png and can't find a valid texture for this custom block
                    } else if (currentTexture != 0) {
                      continue;
                    }

                    Block block = Block.blocksList[id];

                    if (block != null) {
                      if (renderPass == 0 && block.hasTileEntity()) {
                        TileEntity var20 = chunkCache.getBlockTileEntity(dx, dy, dz);
                        if (TileEntityRenderer.instance.hasSpecialRenderer(var20)) {
                          this.tileEntityRenderers.add(var20);
                        }
                      }

                      // Determine which pass this block needs to be rendered on
                      int blockRenderPass = RenderPass.getBlockRenderPass(block);

                      if (design != null) {
                        blockRenderPass = design.getRenderPass();
                      }

                      if (blockRenderPass != renderPass) {
                        skipRenderPass = true;
                      } else {
                        if (design != null) {
                          oldBounds[0] = (float) block.minX;
                          oldBounds[1] = (float) block.minY;
                          oldBounds[2] = (float) block.minZ;
                          oldBounds[3] = (float) block.maxX;
                          oldBounds[4] = (float) block.maxY;
                          oldBounds[5] = (float) block.maxZ;
                          block.setBlockBounds(design.getLowXBound(), design.getLowYBound(), design.getLowZBound(), design.getHighXBound(), design.getHighYBound(), design.getHighZBound());
                          rendered |= design.renderBlock(mat, dx, dy, dz);
                          block.setBlockBounds(oldBounds[0], oldBounds[1], oldBounds[2], oldBounds[3], oldBounds[4], oldBounds[5]);
                        } else {
                          rendered |= blockRenderer.renderBlockByRenderType(block, dx, dy, dz);
                        }
                      }
View Full Code Here

  }

  public void readData(SpoutInputStream input) throws IOException {
    customId = input.readShort();
    data = (byte) input.read();
    design = new GenericBlockDesign();
    design.read(input);
    if (design.isReset()) {
      design = null;
    }
  }
View Full Code Here

  public PacketType getPacketType() {
    return PacketType.PacketCustomBlockDesign;
  }

  public int getVersion() {
    return new GenericBlockDesign().getVersion() + 3;
  }
View Full Code Here

TOP

Related Classes of org.spoutcraft.api.block.design.GenericBlockDesign

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.