Jump to content

Recommended Posts

Posted

Hi!

 

I just started making my first really big mod (already got blocks, items, really scary textures...) but now 2 problems turned up.

I want to "teleport" a selected part of the world (+all entities+player) to other coordinates and dimension(passed as arguments).

 

In order to do so i first need to mark a part of the world.(either by marking every block/mob/player that touches the main controlling block/a block that touches the main controlling bock... or by simply selecting a sphere)

Then i would have to move every selected block to the new location. Since im pretty that there is no "move" command(is there?) i think that it would be the best to copy it to the new location, delete the old blocks and finally to teleport the players. (is there any simple way to create a schematic file ingame?)

 

 

Can someone link me an example or a tutorial? would be really great if you could help me :D

thx in advance, Jacky2611

 

Ps: Im to 99.99% sure that this is the wrong section... :( pls move this topic

Here could be your advertisement!

Posted

I have written a couple of mods that do pretty much what you're asking (both teleportation and volume manipulation). However, the approach I'm taking is more like 3D copy & paste. But others have pointed out that I'm doing both character and matter teleportation in a sense. I also provide a way to archive an arbitrary volume as a JSON file that you can reload later, perhaps into another world.

 

My approach to copying is to define a boundary cuboid, and copy all of the blocks I find in that cuboid into an internal representation. I use JSON serialization to save, and deserialization to load. To save the contents of chests, etc. you have to serialize the contents of TileEntity objects. Generalizing to a sphere is certainly doable, but a cuboid is usually good enough.

Posted

I have written a couple of mods that do pretty much what you're asking (both teleportation and volume manipulation). However, the approach I'm taking is more like 3D copy & paste. But others have pointed out that I'm doing both character and matter teleportation in a sense. I also provide a way to archive an arbitrary volume as a JSON file that you can reload later, perhaps into another world.

 

My approach to copying is to define a boundary cuboid, and copy all of the blocks I find in that cuboid into an internal representation. I use JSON serialization to save, and deserialization to load. To save the contents of chests, etc. you have to serialize the contents of TileEntity objects. Generalizing to a sphere is certainly doable, but a cuboid is usually good enough.

 

Yeah thx, this is exactly what i want for the beginning.

 

Can u link me a tutorial/example/documentation to learn from?

I never die something linke this before.

Next step would be to get only blocks that are somehow connected to my main Block. Any idea how to do this?

Here could be your advertisement!

  • 4 weeks later...
Posted

Wow.

I missed this thread.

Only a week after you started it, look at what I did:

 

http://binarymage.com/forum/viewtopic.php?f=10&t=1882

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

lol...

I managed it with a lot of help from the_clyde to copy metadata and entities.

How do you move the blocks? can u think of somezhing thats faster than a simple get block and set block loop? (Speeded it up by using a thread and a 1ms pause after every block, but it still takes a few seconds until everything is moved.)

Here could be your advertisement!

Posted

I sliced across time.  Rather than using a loop, I had a variable that incremented every time the entity got an update, and that was the Z value (or X or Y, depending on how you want to do it) for that time slice.

 

Essentially, first I'd read, taking an approximated "height" of the landscape (so looking for known-natural blocks like dirt, stone, and sand).  Next I'd wait for player input for the destination (actually, a direction to look, whereupon it would scan farther and farther away looking for a valid place to plop things down; ie. above water), then I'd scan the destination for landscape height (the same way), then the blending on those two matricies, then I'd place the old blocks in the new location, then I'd go back and delete the old blocks.  Last, I attempted to teleport non-block entities.

 

It wasn't perfect though.  Due to the fact that I couldn't build bottom up (the place-blocks to achieve desired landscape in the blended areas only had a height value and stopped placing blocks by going down on Y until a stop condition) and that my time slices were across Z, it had trouble placing torches (and other can-stay-here blocks like rails), gravity effected blocks (top down, remember?), and pistons.  If the piston head was copied/deleted before the base I wouldn't get a base.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Have you managed to teleport doors (my function only teleports 50% the rest is dropped 3-4x) and torches?

And how do you teleport entities? Do they keep their effects (potions...)?

Here could be your advertisement!

Posted

You guys might be interested in taking a look at my Structure Generation API; not exactly the same, but I faced a lot of similar issues such as placing torches, pistons, etc., which I solved by storing them separately and placing them after the rest of the blocks were finished.

 

I was using static arrays, but it would work just the same if you build an array out of the blocks you were going to move, whether a two-dimensional array only for a line of blocks at a time (one array index for the blocks data: id and meta, at the very least), or you could fool around with 4-dimensional arrays like I did ;P

Posted

Torches, doors, pistons all tended to fail more often than not.

 

As for entities, there's a function something along the lines of setPositionAndUpdate.

 

Given that I was just doing it because I could, I didn't care if it failed in some situations.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You guys might be interested in taking a look at my Structure Generation API; not exactly the same, but I faced a lot of similar issues such as placing torches, pistons, etc., which I solved by storing them separately and placing them after the rest of the blocks were finished.

 

I was using static arrays, but it would work just the same if you build an array out of the blocks you were going to move, whether a two-dimensional array only for a line of blocks at a time (one array index for the blocks data: id and meta, at the very least), or you could fool around with 4-dimensional arrays like I did ;P

 

so you checked for isOpaqueBlock and placed pistons, toches... after normal blocks? Should have came up with this on my own...

Here could be your advertisement!

Posted

Random question:

Does your structure API handle sand held up by torches?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You know, I've never tried that, but it should be able to. I use flag 2 when setting blocks so it doesn't update neighbors, meaning the sand should not fall. I've placed torches hanging in mid-air this way.

 

I used Flag 2 as well, but that didn't stop doors and pistons from breaking. :P

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

My doors and pistons work just fine; it's not an issue of flag 2 for those, it's an issue of when you place them. Doors, for instance, will break if there isn't a block underneath them, so you have to place the lower layers first. As for pistons, you can place the base first, then after it's placed, you have to manually set the metadata once again to get the correct rotation / head state. Same goes for any block that auto-sets metadata when placed; e.g. chests and the like.

 

EDIT: Actually, for piston heads, I set those as a separate block and then, like the base, manually set the metadata after it's placed. That's only necessary if you want it extended right away without needing a redstone update.

Posted
EDIT: Actually, for piston heads, I set those as a separate block and then, like the base, manually set the metadata after it's placed. That's only necessary if you want it extended right away without needing a redstone update.

 

Yes, but if you set the piston head to air before you've copied the base, the base won't get copied (it drops).  Flag 2 be damned.

 

Rails are also a bitch to copy, but I think doing them during a second pass would be sufficient.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Yes, but if you set the piston head to air before you've copied the base, the base won't get copied (it drops).  Flag 2 be damned.

 

Rails are also a bitch to copy, but I think doing them during a second pass would be sufficient.

Rails I just set the metadata manually on a second pass; I store all such blocks in a temporary array of BlockData objects (stores position, id, meta) so I can go back and fix them after all is said and done.

 

Guess I've never had to worry about the piston base dropping, as I'm usually either just setting or removing, never copying. Seems you're stuck on that one with either doing a 3rd pass (1 - copy, 2 - set, 3 - erase) or checking for those blocks as you go and, when encountered, scanning the adjacent neighboring blocks to pick up the data you need.

Posted

Probably.  I was just doing a proof of concept thing.  I didn't need the copy to be perfect, as the "concept" part was being able to blend the edges of the copy with the destination, so that it looked natural.

 

Here's the only set of screenshots I took of one such teleport.

 

width=800 height=449http://s16.postimg.org/d0vp5qjid/2014_01_24_23_09_54.png[/img]

width=800 height=449http://s23.postimg.org/q9poehyt7/2014_01_25_01_52_15.png[/img]

width=800 height=449http://s27.postimg.org/5t6vwu11f/2014_01_25_02_04_16.png[/img]

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have used mixins once before, and it was with @At RETURN, so it worked fine. Now im trying to use it as INVOKE, and the compilation is successful, but the client crashes almost on startup (just a couple seconds after running runClient)   Im trying to inject the method finishConversion inside the ZombieVillager class. This is my Mixin class important stuff:   import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.monster.ZombieVillager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ZombieVillager.class) public class ZombieVillagerCures { @Inject(method = "finishConversion", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/entity/LivingEntity;addEffect(Lnet/minecraft/world/effect/MobEffectInstance;)Z")) private void addZombieVillagerCuredAmmount(ServerLevel level, CallbackInfo info) { System.out.println("The Mixin Worked!!! " + level); } // Lnet/minecraft/world/entity/LivingEntity;addEffect(Lnet/minecraft/world/effect/MobEffectInstance;)Z } I'm sure the issue lies in the @At cuz other @At values work fine. Its probably the fully qualified name thing. idk how to get it in VS code
    • I'm wayy less skilled than you i bet, but maybe u could try to just convert one into the other?
    • wildbackport is not working
    • Through Betafort Recovery, Bitcoin scam victims can retrieve their money. I recommend Betafort Recovery to anyone who has fallen victim to a scam and has been looking for methods and techniques to recover their lost cryptocurrency or wallets. Betafort Recovery is a reliable cryptocurrency recovery firm that assists victims in recovering their stolen cryptocurrency and offers secure solutions to protect your wallets from online scammers. I must admit that I was deeply melancholy and had given up on life until these experts could restore my $23,400 to my wallet. If you've lost your cryptocurrency and you are helpless about it, contact Betafort Recovery to get your money back. One key aspect that makes Betafort Recovery stand out is its focus on providing secure solutions to protect wallets from online scammers. It's not just about recovering lost funds; it's also about preventing future incidents and ensuring that clients' digital assets are safeguarded against potential threats. This proactive approach demonstrates their commitment to the long-term financial security of their clients. Furthermore, for individuals who have lost their cryptocurrency and are feeling helpless, reaching out to Betafort Recovery could be a turning point in their situation. The reassurance that they are legitimate for seeking help and recovering lost funds can provide much-needed relief and a sense of empowerment. Betafort Recovery as a reliable cryptocurrency recovery firm is certainly well-founded. Their ability to assist scam victims in recovering stolen cryptocurrency, their focus on providing secure solutions, and their commitment to supporting clients through challenging situations make them a valuable resource for individuals navigating the complex world of digital currencies. If you or someone you know has fallen victim to a cryptocurrency scam, contacting Betafort Recovery could be the first step towards reclaiming lost funds and regaining peace of mind.  
    • Idk how i didn't notice that, but I deleted it and fixed some other issues and now I get this https://mclo.gs/YsWacqq
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.