Forums - Open Redstone Engineers
MCsim (pre-alpha release) - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html)
+--- Forum: Programming (https://forum.openredstone.org/forum-8.html)
+--- Thread: MCsim (pre-alpha release) (/thread-1606.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


RE: Redstone lab (Functional release) - CX gamer - 04-11-2014

(04-11-2014, 01:11 AM)AFtExploision Wrote: .tar.gz FTW! So, I have to have a schematic to load?

Yes, I have included some in the .zip if you want, or you can also make your own. Smile

EDIT: I've made entities kinda work. The simulator won't crash when they are created (so water will wash things away), but the entities themselves aren't saved yet, so pistons won't work just yet.


RE: Redstone lab (Functional release) - CX gamer - 05-02-2014

Hello again!

When I previously said that tile entities were working, I said it because they didn't crash the sim anymore and comparators appeared to be working. However though there was still a bug, so I'll explain the timeline taking off from my last post. That bug is that there were tileEntities getting duplicated when going to the sim and back.

First, comparators work, hoppers don't, why? They weren't loaded properly, I loaded them in the chunk and in the world. So it disregarded my imported tileEntities and created new ones when they were updated. I noticed they would be put into world by chunk, so I removed the part of putting them into the world.

Then, when debugging I noticed no tile entities were sent back at all. I commented out the tickEntities of World, which would remove tileEntities is they were invalid. Same result still. At this time I was at a pause and needed some time to think, whilst also casually reading through the ins and outs of the minecraft code, after which I stumbled upon onChunkLoad. So then I called it when loading it in my own ChunkProvider class.

After doing so, still got the same effect. I noticed that Chunk would just store TileEntities in a chunkTileEntityMap and a few things can do wrong. Instead, I just run onChunkLoad right after instancing.

Now, I believe that the tileEntities that are loaded, are loaded in properly, that because TileEntities don't duplicate anymore. However, not all of them are loaded, as you can see here in this simple hopper clock:

Going into the Sim

Code:
TAG_Compound("Schematic"): 9 entries
{
   TAG_Short("Height"): 3
   TAG_Short("Length"): 2
   TAG_Short("Width"): 3
   TAG_List("Entities"): 0 entries of type TAG_Byte
   }
   TAG_List("TileEntities"): 4 entries of type TAG_Compound
      TAG_Compound: 5 entries
      {
         TAG_String("id"): Comparator
         TAG_Int("OutputSignal"): 1
         TAG_Int("x"): 1
         TAG_Int("y"): 1
         TAG_Int("z"): 1
      }
      TAG_Compound: 6 entries
      {
         TAG_List("Items"): 1 entries of type TAG_Compound
            TAG_Compound: 4 entries
            {
               TAG_String("id"): minecraft:redstone_torch
               TAG_Short("Damage"): 0
               TAG_Byte("Count"): 1
               TAG_Byte("Slot"): 0
            }
         }
         TAG_String("id"): Hopper
         TAG_Int("TransferCooldown"): 6
         TAG_Int("x"): 2
         TAG_Int("y"): 1
         TAG_Int("z"): 1
      }
      TAG_Compound: 6 entries
      {
         TAG_List("Items"): 0 entries of type TAG_Byte
         }
         TAG_String("id"): Hopper
         TAG_Int("TransferCooldown"): 6
         TAG_Int("x"): 2
         TAG_Int("y"): 1
         TAG_Int("z"): 0
      }
      TAG_Compound: 5 entries
      {
         TAG_String("id"): Comparator
         TAG_Int("OutputSignal"): 0
         TAG_Int("x"): 1
         TAG_Int("y"): 1
         TAG_Int("z"): 0
      }
   }
   TAG_String("Materials"): Alpha
   TAG_Byte_Array("Data"): [18 bytes]
   TAG_Byte_Array("Biomes"): [6 bytes]
   TAG_Byte_Array("Blocks"): [18 bytes]
}

Coming back from the Sim:

Code:
TAG_Compound("Schematic"): 7 entries
{
   TAG_Short("Height"): 3
   TAG_Short("Length"): 2
   TAG_Short("Width"): 3
   TAG_String("Materials"): Alpha
   TAG_Byte_Array("Data"): [18 bytes]
   TAG_Byte_Array("Blocks"): [18 bytes]
   TAG_List("TileEntities"): 4 entries of type TAG_Compound
      TAG_Compound: 5 entries
      {
         TAG_String("id"): Comparator
         TAG_Int("OutputSignal"): 1
         TAG_Int("z"): 1
         TAG_Int("y"): 1
         TAG_Int("x"): 1
      }
      TAG_Compound: 6 entries
      {
         TAG_List("Items"): 0 entries of type TAG_End
         }
         TAG_String("id"): Hopper
         TAG_Int("TransferCooldown"): 5
         TAG_Int("z"): 1
         TAG_Int("y"): 1
         TAG_Int("x"): 2
      }
      TAG_Compound: 6 entries
      {
         TAG_List("Items"): 0 entries of type TAG_End
         }
         TAG_String("id"): Hopper
         TAG_Int("TransferCooldown"): 5
         TAG_Int("z"): 0
         TAG_Int("y"): 1
         TAG_Int("x"): 2
      }
      TAG_Compound: 5 entries
      {
         TAG_String("id"): Comparator
         TAG_Int("OutputSignal"): 0
         TAG_Int("z"): 0
         TAG_Int("y"): 1
         TAG_Int("x"): 1
      }
   }
}

As you may notice, the item disappears from into the hoppers. So that's the next problem to tackle. Anyway, some progress has been made, so just wanted to let that know for the ones following this. Smile


RE: Redstone lab (Functional release) - CX gamer - 05-21-2014

I had a little pause from the sim and worked on the GUI for a bit to get new ideas. The idea is to map images with XML and load them in at run time like that instead of drawing them manually. So it should then be possible to add your own graphics to provide alternatives or draw modded blocks.

As for the simulator itself, my mind has been refreshed and I started looking at Item, because that's what's wrong. I noticed it had some kind of register function, so I executed it, but the problem was not fixed yet. I went a level higher and found the Bootstrap class, which takes care of registering all that needs to be registered in one go (i.e. burnable blocks, statistics list, blocks and items and apparently dispenser behavior). So up next is trying that instead of doing it manually for everything, then the sim will be even more resilient against updates as well.

I need to go now, but I can try it in a couple of hours. Looking forward to that.

EDIT: Nope that did not fix it, continuing searching for new clues.


RE: Redstone lab (Functional release) - Chibill - 05-21-2014

I would look in the NBT saving system in the minecraft code for clues to fix it. Because to me its running a function that you are not.


RE: Redstone lab (Functional release) - CX gamer - 05-26-2014

Alright here goes rubber duck problem solving. I have been debugging for way too long.

I have printed all items which were inside the containers...

Code:
{id:"Chest",Items:[0:{id:"minecraft:redstone_torch",Damage:0s,Count:1b,Slot:1b,},],Lock:"",z:0,y:0,x:0,}
Inventory: container.chest
Size:      27
{id:"Hopper",Items:[0:{id:"minecraft:repeater",Damage:0s,Count:1b,Slot:0b,},],TransferCooldown:0,Lock:"",z:0,y:0,x:1,}
Inventory: container.hopper
Size:      5
{id:"Trap",Items:[0:{id:"minecraft:comparator",Damage:0s,Count:1b,Slot:4b,},1:{id:"minecraft:comparator",Damage:0s,Count:1b,Slot:7b,},],Lock:"",z:0,y:0,x:3,}
Inventory: container.dispenser
Size:      9
{id:"Dropper",Items:[0:{id:"minecraft:wooden_button",Damage:0s,Count:1b,Slot:4b,},],Lock:"",z:0,y:0,x:4,}
Inventory: container.dropper
Size:      9
{id:"Furnace",Items:[0:{id:"minecraft:comparator",Damage:0s,Count:1b,Slot:0b,},],BurnTime:0s,CookTimeTotal:200s,Lock:"",z:0,y:0,CookTime:0s,x:5,}
Inventory: container.furnace
Size:      3

...to learn that there are no items in the said container. The NBT tags you see here are just loaded as NBTTagCompound. So I can say for a definite fact that the items get lost between these, which means everything inside the TileEntity.createAndLoadEntity method.

The TileEntity itself gets loaded succesfully, because we get it back and it doesn't print a stack trace. So we know that we can reach the method readFromNBT for each subclasses of TileEntity. I look at TileEntityChest's method in particular, since it's the most stripped down version of my problem, as its only function is to contain items.
  • The super.readFromNBT works, because we get those back.
  • Minecraft's NBT classes all seem to work, because I've pulled the item compound tags out that way.
  • Nothing is wrong with the size of the array of ItemStack, because I have debugged it up above.
  • CustomName is not present so we can skip it safely.

I've tried loading items from the working item NBT's, but they return nulls, which means the bug is contained within ItemStack.loadItemStackFromNBT. I try to call readFromNBT, but it returns nulls as well.

Code:
{id:"Chest",Items:[0:{id:"minecraft:redstone_torch",Damage:0s,Count:1b,Slot:1b,},],Lock:"",z:0,y:0,x:0,}
Loading item: {id:"minecraft:redstone_torch",Damage:0s,Count:1b,Slot:1b,}
Loaded item:  null
{id:"Hopper",Items:[0:{id:"minecraft:repeater",Damage:0s,Count:1b,Slot:0b,},],TransferCooldown:0,Lock:"",z:0,y:0,x:1,}
Loading item: {id:"minecraft:repeater",Damage:0s,Count:1b,Slot:0b,}
Loaded item:  null
{id:"Trap",Items:[0:{id:"minecraft:comparator",Damage:0s,Count:1b,Slot:4b,},1:{id:"minecraft:comparator",Damage:0s,Count:1b,Slot:7b,},],Lock:"",z:0,y:0,x:3,}
Loading item: {id:"minecraft:comparator",Damage:0s,Count:1b,Slot:4b,}
Loaded item:  null
{id:"Dropper",Items:[0:{id:"minecraft:wooden_button",Damage:0s,Count:1b,Slot:4b,},],Lock:"",z:0,y:0,x:4,}
Loading item: {id:"minecraft:wooden_button",Damage:0s,Count:1b,Slot:4b,}
Loaded item:  null
{id:"Furnace",Items:[0:{id:"minecraft:comparator",Damage:0s,Count:1b,Slot:0b,},],BurnTime:0s,CookTimeTotal:200s,Lock:"",z:0,y:0,CookTime:0s,x:5,}
Loading item: {id:"minecraft:comparator",Damage:0s,Count:1b,Slot:0b,}
Loaded item:  null

And this is where I had rubber duck's "aha" moment. Inside readFromNBT we see:

Code:
Item.getItemById(par1NBTTagCompound.getShort("id"));

And as far as I know, "minecraft:redstone_torch" is not a short value. I guess the tools are more up to date than MCP, therefore this discrepency. Either way, I'm going to remove this mountain of debugging code and just waiting for MCP to update, rather than make a fragile workaround.


RE: Redstone lab (Functional release) - Chibill - 05-27-2014

It's upto date for 1.7.2 or at lest with its stable release. But I am working on a program to map the classes myself so I can debug and find things in snapshots.

Also Ids are still in the save files of the game because it uses them internally for everything except a few spots but in 1.8 that might change.

Also if they were removed the save files of snapshots and 1.7 would not work on 1.6


RE: Redstone lab (Functional release) - CX gamer - 05-27-2014

Quote:I am working on a program to map the classes myself so I can debug and find things in snapshots.

That would be immensely helpful! How will it work? Big Grin


RE: Redstone lab (Functional release) - Chibill - 05-27-2014

It's looking for key strings in some classes that will not change.


RE: Redstone lab (Functional release) - CX gamer - 06-03-2014

So when attempting to make entities load properly, I noticed that I had a similar situation with ids vs names, so I decided to work on the GUI for a bit.

Here's a preview of the new icons along with the way to map them in XML:

[Image: NSsMkmV.png]

So now it's easily extendable and allows for replacement graphics and graphics for mods. I still have only draw a small bit, but most technical blocks are in it, except for weighted plates. Those, I will draw dead last.

It should be noted that I based some designs off mordritch's simulator. He doesn't have comparators, so my version is a stab in the dark. Still some work to get the export fixed, otherwise I'd have shown a nice gif of it.


RE: Redstone lab (Functional release) - CX gamer - 06-05-2014

Have been drawing some more graphics, enjoy this view of the storage room:

[Image: rvyf4jK.gif]

Also layer markers are mostly working once more. I'm also entering a period of having much free time, so that's looking good for the sim. Big Grin