This should be fixed now, at least in terms of throwing exceptions unexpectedly. I don't understand what this code is supposed to do, so I don't know if your problem will be fully fixed or not.
Version 1.3.2 is now available, which includes a few bug fixes and some Minecraft 1.3 updates.
- Fix: ChunkManager.SetChunk did not set chunks at the requested location correctly.
- Fix: ResetLava in BlockFluid could possibly convert lava blocks into water.
- Fix: BlockManager could not set blocks above 127. BlockManager is now abstract and split into two concrete classes for Alpha and Anvil.
- Block, item, and player data updates for Minecraft 1.3.
Sorry for the confusion, what I was trying to do was storing multiple chunks in a list, doing changes to them and then putting them back into the chunkManager when done.
Did you change anything in the way worlds are opened? Trying to open a world now throws me an exception every time.
I cannot reproduce this. I opened an older beta world and a brand new anvil world just fine. You'll need to send a sample world and project.
I've got an IChunk object, but I'm not sure how to get the data into a format that I can send.
It's not going to be straightforward. IChunk is not a good abstraction for the network packets. They are closer to the raw NBT data, and as such I think you should work with the NBT tree instead. You can get the NBT data from the chunk (but you may need to cast down to a concrete type like AnvilChunk). You will need to carefully lay out the byte arrays as required by the packet format, and then you can use the included Zlib API to compress it.
You should probably look to see if there is another up-to-date SDK that will give you a better abstraction for building these packets. You may be able to use it in conjunction with Substrate if it does not already provide everything you need.
It does not. I haven't seen the spec for it, nor do I have any sample files for it. At this point, I don't think I have the time to add support for it.
If you want to try adding support for this, I can answer questions you have about the architecture of the library and give you some general guidelines. My gut feeling is if the worlds are fixed size and they do not use NBT as the underlaying data format, then you should treat this as an importer/exporter like schematic files, and use an NBT tree as an intermediate representation between an AlphaBlockCollection and the raw dat file. That is assuming of course that the same information is being represented.
Also I should note, you can use that code as a baseline for gracefully handling map errors in your own code. You should even be able to make the verifier ignore errors if you think it's safe to do so.
That code should have been sufficient to catch it if it were being caught by the normal verification process.
Could you please send me a sample world? You can delete all but one region files if the remaining file still raises the error. I need to know which key it's failing on.
Thank you. The problem was some extra data I added to the player class. It was being treated as a group when the new fields should have been treated as being optional.
A 1.3.3 release is now available which should fix that bug.
I am using Substrate with TPL Dataflow on .NET 4.5, and with more than one thread I get lots of errors that look a lot like concurrency problems.
Here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Substrate;
using Substrate.Core;
namespace AirCounter
{
class Program
{
static void Main(string[] args)
{
var dest = args[0];
AnvilWorld world = AnvilWorld.Open(dest);
RegionChunkManager cm = world.GetChunkManager();
int n = 0;
ExecutionDataflowBlockOptions executionDataflowBlockOptions = new ExecutionDataflowBlockOptions
{
MaxDegreeOfParallelism = 2,
};
var counter = new TransformBlock<ChunkRef, int>((chunk) =>
{
int iN = 0;
int xdim = chunk.Blocks.XDim;
int ydim = chunk.Blocks.YDim;
int zdim = chunk.Blocks.ZDim;
for (int x = 0; x < xdim; x++)
{
for (int z = 0; z < zdim; z++)
{
for (int y = 0; y < ydim; y++)
{
// Replace the block with after if it matches before
if (chunk.Blocks.GetID(x, y, z) == 0)
{
iN++;
}
}
}
}
return iN;
}, executionDataflowBlockOptions);
var aggregator = new ActionBlock<int>((elem) => { n += elem; });
counter.LinkTo(aggregator);
foreach (ChunkRef chunk in cm)
{
counter.Post(chunk);
}
while (!counter.Completion.IsCompleted) { }
}
}
}
And an exception:
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Substrate
StackTrace:
at Substrate.AnvilChunk.CreateVerified(NbtTree tree)
at Substrate.AnvilRegion.CreateChunkVerifiedCore(NbtTree tree)
at Substrate.Core.Region.GetChunk(Int32 lcx, Int32 lcz)
at Substrate.ChunkRef.GetChunk()
at Substrate.ChunkRef.get_Blocks()
at AirCounter.Program.<Main>b__1(ChunkRef chunk) in c:\Users\Ben Chung\Documents\Visual Studio 2012\Projects\AirCounter\AirCounter\Program.cs:line 30
at System.Threading.Tasks.Dataflow.TransformBlock`2.ProcessMessage(Func`2 transform, KeyValuePair`2 messageWithId)
Am I doing something wrong, or is this just a limitation of the library?
As a fellow .NET developer, well done on the library (although the lack of unit tests is a bummer).
Have you given any thought to creating a NuGet package for Substrate? It would solve a lot of the issues people have building it, and allows you to create one package for mono, NET20, and NET40.
Substrate was my first foray into .NET and I was not introduced to the various unit testing frameworks until later. At this point I have too many other projects on the table to justify going back and trying to achieve meaningful test coverage, although anyone is welcome to start such an initiative. If I was starting over today, I would be writing them from the beginning.
As for NuGet, I've never heard of it. I'm not too surprised though, because until about 2 days ago I've only had access to C# Express outside of work, and NuGet appears to be for professional grade VS or web development, neither of which I think applies to most Substrate users.
*EDIT 2* I've had it confirmed by a friend that the express edition of Visual Studio 2012 has nuget built into it. So getting a NuGet package for Substrate looks more and more attractive now.
Do you think you could add support for editing world saves using the 4096 block-id patch mod? This would be extremely useful for me and anyone else that wants to edit a world with a lot of mods.
The 4bit data value on blocks isn't a damage value per se.
There's some enums defined to help you out (see LeafState). You need to set the 0x4 bit on the data value to 1 to make them permanent. You'd do that something like
chunk.Blocks.SetData(x, y, z, data | (int)LeafState.PERMANENT);
Version 1.3.2 is now available, which includes a few bug fixes and some Minecraft 1.3 updates.
- Fix: ChunkManager.SetChunk did not set chunks at the requested location correctly.
- Fix: ResetLava in BlockFluid could possibly convert lava blocks into water.
- Fix: BlockManager could not set blocks above 127. BlockManager is now abstract and split into two concrete classes for Alpha and Anvil.
- Block, item, and player data updates for Minecraft 1.3.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
This is a great toolkit for C#. I do have a question though
How would I encode a chunk from this toolkit for use in the SMP Packet 0x33 (Chunk Data). http://wiki.vg/Protocol#Chunk_Data_.280x33.29
I've got an IChunk object, but I'm not sure how to get the data into a format that I can send.
I cannot reproduce this. I opened an older beta world and a brand new anvil world just fine. You'll need to send a sample world and project.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
It's not going to be straightforward. IChunk is not a good abstraction for the network packets. They are closer to the raw NBT data, and as such I think you should work with the NBT tree instead. You can get the NBT data from the chunk (but you may need to cast down to a concrete type like AnvilChunk). You will need to carefully lay out the byte arrays as required by the packet format, and then you can use the included Zlib API to compress it.
You should probably look to see if there is another up-to-date SDK that will give you a better abstraction for building these packets. You may be able to use it in conjunction with Substrate if it does not already provide everything you need.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
If not, I am wiling to help add in support and start a new fork...
If you want to try adding support for this, I can answer questions you have about the architecture of the library and give you some general guidelines. My gut feeling is if the worlds are fixed size and they do not use NBT as the underlaying data format, then you should treat this as an importer/exporter like schematic files, and use an NBT tree as an intermediate representation between an AlphaBlockCollection and the raw dat file. That is assuming of course that the same information is being represented.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Your sample works fine for me, but my world was created with one of the weekly snapshots. The problem is probably to do with a specific map version.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Could you please send me a sample world? You can delete all but one region files if the remaining file still raises the error. I need to know which key it's failing on.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
A 1.3.3 release is now available which should fix that bug.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Here's my code:
And an exception:
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Substrate
StackTrace:
at Substrate.AnvilChunk.CreateVerified(NbtTree tree)
at Substrate.AnvilRegion.CreateChunkVerifiedCore(NbtTree tree)
at Substrate.Core.Region.GetChunk(Int32 lcx, Int32 lcz)
at Substrate.ChunkRef.GetChunk()
at Substrate.ChunkRef.get_Blocks()
at AirCounter.Program.<Main>b__1(ChunkRef chunk) in c:\Users\Ben Chung\Documents\Visual Studio 2012\Projects\AirCounter\AirCounter\Program.cs:line 30
at System.Threading.Tasks.Dataflow.TransformBlock`2.ProcessMessage(Func`2 transform, KeyValuePair`2 messageWithId)
Am I doing something wrong, or is this just a limitation of the library?
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Have you given any thought to creating a NuGet package for Substrate? It would solve a lot of the issues people have building it, and allows you to create one package for mono, NET20, and NET40.
As for NuGet, I've never heard of it. I'm not too surprised though, because until about 2 days ago I've only had access to C# Express outside of work, and NuGet appears to be for professional grade VS or web development, neither of which I think applies to most Substrate users.
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
Having said that NuGet can still be used outside of Visual Studio.
I must say I was a bit shocked to find you didn't know about it, but not having access makes sense.
If you'd like, I can write up a build script to make a NuGet package for you. I'll submit it as a PR on Github.
*EDIT* Pull Request done. https://github.com/j...ubstrate/pull/4
*EDIT 2* I've had it confirmed by a friend that the express edition of Visual Studio 2012 has nuget built into it. So getting a NuGet package for Substrate looks more and more attractive now.
chunk.Blocks.SetData(x,y,z, data) changes only the damagevalue.
There's some enums defined to help you out (see LeafState). You need to set the 0x4 bit on the data value to 1 to make them permanent. You'd do that something like
chunk.Blocks.SetData(x, y, z, data | (int)LeafState.PERMANENT);
Mods I Develop: Garden Stuff -- Storage Drawers -- Hunger Strike
Tools I Develop: NBTExplorer -- Substrate
like its said in here http://www.minecraftwiki.net/wiki/Data_values