Jump to content

1.12 Mod Dimension from pre-made map


DougLazy

Recommended Posts

I'm toying with adding a dimension to my mod. I'd like the dimension to be from an existing limited map, no seed/generation rules needed. Picture a sky island, for example.

 

Before I start writing a custom IWorldGenerator to solve this, I thought there might be a solution, or a way to simplify the process.

 

One thought I had was to use a structure_block, maybe subclassed to bypass the 32x32x32 limit.

 

Thanks in advance.

0d

 

Link to comment
Share on other sites

  • 1 year later...

I just tried doing that, but instead got stuck in a unreal dimension with not any sun or moon, while being console-spammed of that:

[File IO Thread/ERROR] [minecraft/AnvilChunkLoader]: Failed to save chunk

Escaping the dimension and re-entering it results in a complete blank world.

 

Here's the line for getSaveFolder:

@Override
public String getSaveFolder()
{
	return Reference.MODID + ":worlds/wol";
}

Here's the entire dimension file and the world folder.

2018-12-27_17_03_33.thumb.png.598fa8dce389095b2110890f0a56a650.png

Edited by Hugman
Precision
Link to comment
Share on other sites

I've done this FileMover class:

public class FileMover
{
	public static Path createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs)
	throws IOException
	{
		return dir;
	}
}

But then? How do I get the path to the world file itself, at dir in FileMover.createTempDirectory(dir, prefix, attrs);?

Link to comment
Share on other sites

11 hours ago, diesieben07 said:

That would be the default location, provided your dimension ID is 64 (it should be configurable).

Yes, sure, that's what I want.

public final class CopyFiles
{
	public static void toWorld(String FROM_s) throws IOException
	{
	    Path FROM = Paths.get(FROM_s);
	    Path TO = DimensionManager.getCurrentSaveRootDirectory().toPath();
	    CopyOption[] options = new CopyOption[]
	    {
	      StandardCopyOption.REPLACE_EXISTING,
	      StandardCopyOption.COPY_ATTRIBUTES
	    }; 
	    Files.copy(FROM, TO, options);
	}
}

I've made this class, but now I must get the path to my map in the .jar for the var Path, how can I do this?

Edited by Hugman
Link to comment
Share on other sites

Hey again!

I actually progressed very well since yetersday and found a way to do it properly, but I still need to solve an issue.

Firstly, here's my new method:

public final class CopyFiles
{	
	public static void toWorld(String dir, String file, int dim) throws IOException
	{
	    Path FROM = new File(new ResourceLocation(Reference.MODID + ":worlds/" + dir + "/" + file).getPath()).toPath();
	    Path TO = new File(DimensionManager.getCurrentSaveRootDirectory(), "DIM-64/" + file).toPath();
	    CopyOption[] options = new CopyOption[]
	    {
	      StandardCopyOption.COPY_ATTRIBUTES
	    }; 
	    Files.copy(FROM, TO, options);
	}
}

But upon loading the world, the game crashes and reports: java.nio.file.NoSuchFileException: worlds\wol\region\r.0.0.mca which I interpretate as an error with the FROM variable. Anything helping would be very cool, thanks in advance.

 

EDIT: Woops, didn't saw the thread had a second page, currently looking at what you said, this very comment is useless, do like if you didn't saw it.

Edited by Hugman
Link to comment
Share on other sites

Following what you've said,here's my new-new method:

public final class CopyFiles
{	
	public static void toWorld(String dir, String file, int dim) throws IOException
	{
	    InputStream FROM = CopyFiles.class.getResourceAsStream("assets/mubble/worlds" + dir + "/" + file);
	    //Path FROM = new File(new ResourceLocation(Reference.MODID + ":worlds/" + dir + "/" + file).getPath()).toPath();
	    Path TO = new File(DimensionManager.getCurrentSaveRootDirectory(), "DIM-64/" + file).toPath();
	    CopyOption[] options = new CopyOption[]
	    {
	      StandardCopyOption.COPY_ATTRIBUTES
	    }; 
	    Files.copy(FROM, TO, options);
	}
}

The game crashes, FROM is null.

I don't think I understood how to use getResourceAsStream, could you explain please?

Link to comment
Share on other sites

You should use a resource location and look at how vanilla turns them into real paths. You should also use the ResourceLocation constructor that takes a domain and a path, not put it together manually with domain + ":" + path

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

9 hours ago, diesieben07 said:

So at the end, how the FROM variable will look like? I'm sorry, I still don't really understand from which class I must do the getResourceAsStream neither what to put in it.

 

Also, my region folder is located here:

image.png.4ff7c94887e72f8f4776241980868629.png

Edited by Hugman
Link to comment
Share on other sites

Okay so apparently InputStream FROM = CopyFiles.class.getClassLoader().getResourceAsStream("assets/mubble/worlds/" + dir + "/" + file); seems to work, but now the game crashes because the StandardCopyOption.COPY_ATTRIBUTES is not supported, should I just remove it?

Link to comment
Share on other sites

Okay, it works now. For anyone interested, here's my class:

public final class MoveFiles
{	
	public static void copyToWorld(String dir, String file, int dim) throws IOException
	{
	    InputStream FROM = MoveFiles.class.getClassLoader().getResourceAsStream("assets/mubble/worlds/" + dir + "/" + file);
	    Path TO = new File(Minecraft.getMinecraft().gameDir + "/saves/" + Minecraft.getMinecraft().getIntegratedServer().getFolderName(), "/DIM" + dim + "/" + file).toPath();
	    CopyOption[] options = new CopyOption[] { };
	    Path parentDir = TO.getParent();
	    if (!Files.exists(parentDir)) Files.createDirectories(parentDir);
	    if (Files.exists(TO)) return;
	    
	    Files.copy(FROM, TO, options);
	}
}

 

Edited by Hugman
Link to comment
Share on other sites

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

    • Slot deposit 3000 adalah situs slot deposit 3000 via dana yang super gacor dimana para pemain dijamin garansi wd hari ini juga hanya dengan modal receh berupa deposit sebesar 3000 baik via dana, ovo, gopay maupun linkaja untuk para pemain pengguna e-wallet di seluruh Indonesia.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT 3000 ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan. DAFTAR OLXTOTO DISINI <a href="https://imgbb.com/"><img src="https://i.ibb.co/GnjSVpx/daftar1-480x480.webp" alt="daftar1-480x480" border="0" /></a> Keamanan Sebagai Prioritas Utama Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah. Beragam Permainan yang Menarik Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar. Layanan Pelanggan yang Responsif Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien. Kesimpulan OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain. Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!
    • Slot deposit dana adalah situs slot deposit dana yang juga menerima dari e-wallet lain seperti deposit via dana, ovo, gopay & linkaja terlengkap saat ini, sehingga para pemain yang tidak memiliki rekening bank lokal bisa tetap bermain slot dan terbantu dengan adanya fitur tersebut.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit dana adalah situs slot deposit dana minimal 5000 yang dijamin garansi super gacor dan gampang menang, dimana para pemain yang tidak memiliki rekening bank lokal tetap dalam bermain slot dengan melakukan deposit dana serta e-wallet lainnya seperti ovo, gopay maupun linkaja lengkap. Agar para pecinta slot di seluruh Indonesia tetap dapat menikmati permainan tanpa halangan apapun khususnya metode deposit, dimana ketersediaan cara deposit saat ini yang lebih beragam tentunya sangat membantu para pecinta slot.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit pulsa adalah situs slot deposit pulsa tanpa potongan apapun yang dijamin garansi terpercaya, dimana kamu bisa bermain slot dengan melakukan deposit pulsa dan tanpa dikenakan potongan apapun sehingga dana yang masuk ke dalam akun akan 100% utuh. Proses penarikan dana juga dijamin gampang dan tidak sulit sehingga kamu tidak perlu khawatir akan kemenangan yang akan kamu peroleh dengan sangat mudah jika bermain disini.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT PULSA TANPA POTONGAN ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
  • Topics

×
×
  • Create New...

Important Information

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