Error Loading Schematic Data
Contents |
sequituri) » Worldgeneration with schematic files[1.7.10] « previous next » Print Pages: [1] 2 All Go Down Author Topic: Worldgeneration with schematic files[1.7.10] (Read 12110 times) 0 Members worldedit api and 1 Guest are viewing this topic. Androm Stone Miner Posts:
Mcedit
57Karma: +0/-0Thank You- Given: 1- Receive: 0Gender: "I am a little forge modder" Worldgeneration with schematic files[1.7.10] « on: July 08, 2014, 03:14:50 pm » Hello modders,I need help with my mod. Can you read schematic files and generate them randomly in the world without converting schematic to java code ? Maybe it is good to read the schematic file into bytes and then set arrays or HashMaps ? Or best with inputStream? And how would you do it ? If you have an idea and a code for the beginning please help me. Thank you. Logged MultiMote Forge Modder Creeper Killer Posts: 248Karma: +63/-4Thank You- Given: 14- Receive: 52Gender: Re: Worldgeneration with schematic files[1.7.10] « Reply #1 on: July 08, 2014, 03:37:09 pm » Code: [Select]public Schematic get(String schemname){
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("assets/mymod/schem/"+schemname);
NBTTagCompound nbtdata = CompressedStreamTools.readCompressed(is);
short width = nbtdata.getShort("Width");
short height = nbtdata.getShort("Height");
short length = nbtdata.getShort("Length");
byte[] blocks = nbtdata.getByteArray("Blocks");
byte[] data = nbtdata.getByteArray("Data");
System.out.println("schem size:" + width + " x " + height + " x " + length);
NBTTagList tileentities = nbtdata.getTagList("TileEntities", 10);
is.close();
return new Schematic(tileentities, width, height, length, blocks, data);
} catch (Exception e) {
System.out.println("I
Sign in Pricing Blog Support Search GitHub This repository Watch 3 Star 5 Fork 1 Elecs-Mods/ElecCore Code Issues 13 Pull requests 1 Projects 0 Pulse Graphs Permalink Branch: master Switch branches/tags Branches Tags 1.7.10 1.8-initial 1.8.9 1.9 1.9.4 master Nothing to show Nothing http://www.minecraftforge.net/forum/index.php?topic=21045.0 to show Find file Copy path ElecCore/src/main/java/elec332/core/world/schematic/SchematicHelper.java Fetching contributors… Cannot retrieve contributors at this time Raw Blame History 181 lines (167 sloc) 7.11 KB package elec332.core.world.schematic; import com.google.common.collect.Maps; import elec332.core.main.ElecCore; import elec332.core.util.FileHelper; import elec332.core.util.NBT; import elec332.core.world.WorldHelper; import net.minecraft.block.Block; import net.minecraft.init.Blocks; https://github.com/Elecs-Mods/ElecCore/blob/master/src/main/java/elec332/core/world/schematic/SchematicHelper.java import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameData; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Map; /* * This was originally created by Lumaceon, rewritten by Elec332. * You can find the original here: https://github.com/Lumaceon/ClockworkPhase2/blob/master/src/main/java/lumaceon/mods/clockworkphase2/util/SchematicUtility.java */ public class SchematicHelper { public static final SchematicHelper INSTANCE = new SchematicHelper(); public Schematic loadSchematic(File file){ try { return loadSchematic(new FileInputStream(file)); } catch (IOException e){ ElecCore.logger.fatal("Error loading schematic at: "+file); ElecCore.logger.fatal(e); return null; } } public Schematic loadSchematic(ResourceLocation rl){ try { return loadSchematic(FileHelper.getFromResource(rl)); } catch (IOException e){ ElecCore.logger.fatal("Error loading schematic at: "+rl); ElecCore.logger.fatal(e); return null; } } public Schematic loadSchematic(InputStream is){ try { NBTTagCompound tag = CompressedStreamTools.readCompressed(is); is.close(); return loadModSchematic(tag); } catc
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta http://stackoverflow.com/questions/24101928/setting-block-data-from-schematic-in-bukkit Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/2298932-schematic-to-command-block-command Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like error loading you, helping each other. Join them; it only takes a minute: Sign up Setting Block Data from Schematic in Bukkit? up vote 3 down vote favorite 2 I am trying to load and paste a .schematic file (without hooking the MCEdit API) in bukkit. Below is the function/method i use to paste the schematic. While pasting, i error loading schematic keep getting a NullPointerException in the pasting process. When i logged what items were getting placed, i see grass blocks, stone, but not my chests, anything in the chests, or beacons (Maybe even more blocks). The error occurs on this line: block.setData(blockData[index], true); I think this has to do something with the metaData, but how would i get that information from the schematic file and apply it to each of the blocks? Question: How can i paste items with metaData like (Chest with contents, torches, beacons, etc.? @SuppressWarnings("deprecation") public void pasteSchematic(World world, Location loc, Schematic schematic) { byte[] blocks = schematic.getBlocks(); byte[] blockData = schematic.getData(); short length = schematic.getLenght(); short width = schematic.getWidth(); short height = schematic.getHeight(); for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { for (int z = 0; z < length; ++z) { int index = y * width * length + z * width + x; Block block = new Location(world, x + lo
App Mods on Curse Rules Chat Desktop View Home Minecraft Forum Minecraft Discussion Redstone Discussion and Mechanisms .schematic to command block command ? Command Block Search Search all Forums Search this Forum Search this Thread Tools Jump to Forum .schematic to command block command ? #1 Dec 11, 2014 TroZ_Shack TroZ_Shack View User Profile View Posts Send Message Tree Puncher Join Date: 3/3/2012 Posts: 21 Member Details Hi, Is there any existing utility that can convert a .schematic file to a series of command block commands that can import the schematic into a world? This could be useful if you have creative access to a server and want to import a schematic, but you can't download, edit and re-upload the world file. I'm starting to work on a proof of concept of this idea, to see if it is possible. My current idea for this would be limited to schematics that are smaller than about 30x30x30 blocks, but it would take quite a few command blocks to import a schematic that large. I was inspired to try this after seeing what JL2579 and some of the other Zip Krowd guys were doing with single command blocks. Here is an example that I've been working on: a single command that creates a 5x5x5 starter house. It's 14754 characters, so a bit under 1/2 of the max command length. summon FallingSand ~ ~3 ~ {Block:redstone_block,Time:1,DropItem:0,Riding:{id:FallingSand,Block:command_block,TileEntityData:{Command:"fill ~ ~1 ~ ~ ~-14 ~ air"},Time:1,DropItem:0,Riding:{id:FallingSand,Block:redstone_block,Time:1,DropItem:0,Riding:{id:FallingSand,Block:command_block,TileEntityData:{Command:"summon FallingSand ~ ~1 ~1 {Block:redstone_block,Time:1,DropItem:0,Riding:{id:FallingSand,Block:command_block,TileEntityData:{Command:\"fill ~ ~1 ~ ~ ~-10 ~ air\"},Time:1,DropItem:0,Riding:{id:FallingSand,Block:redstone_block,Time:1,DropItem:0,Riding:{id:FallingSand,Block:command_block,TileEntityData:{Command:\"summon FallingSand ~1 ~ ~ {Block:redstone_block,Time:1,DropItem:0,Riding:{id:FallingSand,Block:command_block,TileEntityData:{Command:\\\"fill ~ ~1 ~ ~ ~-4 ~ air\\\"},Time:1,DropItem:0,Riding:{id:FallingSand,Block:redstone_block,Time:1,DropItem:0,Riding:{id:FallingSand,Block:command_block,TileEntityData:{Command:\\\"fill ~-1 ~ ~ ~4 ~-8 ~4 air 0 replace barrier\\\"},Time:1,DropItem:0,Riding:{id:Fal