Gaprosys Posted August 4, 2016 Posted August 4, 2016 Hello, I have I mod which adds a world type for starting and staying in the nether. The player respawns there. I want to set the players spawn location to a uncovered netherrack block, but the methods return always the highest block, which is bedrock. In 1.7.10 I used world.provider.getEntrancePortalLocation(). Is there any way to do this in 1.9.4? Quote
Matryoshika Posted August 4, 2016 Posted August 4, 2016 I'm guessing that you are using a WorldProvider. Override WorldProvider#getSpawnPoint(), to return a suitable spawn-point. Checking if it is suitable, you'd best create another method that checks in blocks through x, y & z coords in for-loops. As far as I can see, the WorldProvider no longer provides anything like the getEntrancePortalLocation method, and the Teleporter#makePortal method checks for suitable locations directly. I'm forcing a spawn-point to an already cleared area here: https://github.com/Matryoshika/Underworld/blob/master/src/main/java/se/Matryoshika/Underworld/WorldGen/WorldProviderCaves.java#L41 Bit messy, but been meaning to clear it up since I managed to figure out how to force a spawn-point. Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
Gaprosys Posted August 4, 2016 Author Posted August 4, 2016 Thanks! That helped. Yes, I'm using a own world provider to change the respawn dimension etc. My other problem with this world type is that every time the player creates a new world he starts in the overworld. This seems to be standard so I wrote a method which is called by the net.minecraftforge.event.entity.EntityJoinWorldEvent: In this method the player is send to the nether with the player.changeDimension(-1) method and it crashes every first time of a world. After the first time the player spawns correct. I think that might is a "hard" teleport so that the dimension change doesn't get properly done. Quote
Matryoshika Posted August 4, 2016 Posted August 4, 2016 What is the cause of the crash? Nullpointer? What is your exact code for sending the player to the Nether? Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
Gaprosys Posted August 5, 2016 Author Posted August 5, 2016 The cause of the crash is a Ticking Memory Exception. The Code for my World Handler first spawn event method: package mod.nethertweaks.world; import java.io.*; import mod.chaust.ChaustItems; import mod.nethertweaks.BucketLoader; import mod.nethertweaks.Config; import mod.nethertweaks.ForgeSubscribe; import mod.nethertweaks.RecipeLoader; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.DimensionType; import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldProviderEnd; import net.minecraft.world.WorldProviderHell; import net.minecraft.world.WorldProviderSurface; import net.minecraft.world.WorldType; import net.minecraft.world.gen.layer.GenLayer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.terraingen.WorldTypeEvent; import net.minecraftforge.event.terraingen.BiomeEvent.GetWaterColor; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class WorldHandler{ boolean isHellworldType; @SubscribeEvent public void changeDimensionByWorldType(WorldTypeEvent event) throws IOException, FileNotFoundException, ArrayIndexOutOfBoundsException { if(event.getWorldType() instanceof WorldTypeHellworld) { this.isHellworldType = true; DimensionManager.unregisterDimension(0); DimensionType.register("Overworld", "Provider", 0, WorldProviderSurfaceNTM.class, true); DimensionManager.registerDimension(0, DimensionType.getById(0)); DimensionManager.unregisterDimension(-1); DimensionType.register("Nether", "Provider", -1, WorldProviderNetherNTM.class, true); DimensionManager.registerDimension(-1, DimensionType.getById(-1)); DimensionManager.unregisterDimension(1); DimensionType.register("End", "Provider", 1, WorldProviderEndNTM.class, true); DimensionManager.registerDimension(1, DimensionType.getById(1)); } } @ForgeSubscribe @SubscribeEvent public void perfectJoin(net.minecraftforge.event.entity.EntityJoinWorldEvent event){ if(event.getEntity() instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) event.getEntity(); if(player.dimension != -1 && isHellworldType == true) { //player.preparePlayerToSpawn(); player.changeDimension(-1); } if(isHellworldType == false){ if(player.dimension == 0){ player.changeDimension(Config.nethDim); } if(player.dimension == 1){ player.changeDimension(Config.endDim); } } } } } Crashlog http://pastebin.com/6i21c8ar Quote
Animefan8888 Posted August 5, 2016 Posted August 5, 2016 The error is happening in your Teleporter class on line 134/38 Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Ugdhar Posted August 5, 2016 Posted August 5, 2016 The error is happening in your Teleporter class on line 134/38 Isn't that referencing the Vanilla Teleporter class? Also, to the OP, it's more helpful if you upload your code to github so we can see line numbers and such. Quote
Gaprosys Posted August 5, 2016 Author Posted August 5, 2016 My Code is now on Github here: https://github.com/BarelyAlive/Nether-Tweaks. Quote
Matryoshika Posted August 5, 2016 Posted August 5, 2016 Navigate to the referenced line that gets a nullpointer (at net.minecraft.world.Teleporter.placeInExistingPortal(Teleporter.java:134)) Place a breakpoint on that line, and test it. You should get all the information passed to that method, before the method itself is run, which should allow you to see exactly what being passed to it, is null. A guide for placing breakpoints in Eclipse: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-add_line_breakpoints.htm If you are using any other IDE, you gotta lookup their breakpoint placement yourself. Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
Gaprosys Posted August 5, 2016 Author Posted August 5, 2016 It seems to be the teleporter class wants the last position of the player in the overworld to get his entrance position for the nether. Can I make the method wait until the player has a overworld position? Or something different? Quote
Animefan8888 Posted August 5, 2016 Posted August 5, 2016 Maybe LivingSpawnEvent not sure if that gets called for the player though. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Gaprosys Posted August 5, 2016 Author Posted August 5, 2016 I tried the LivingSpawn Event but it didn't work. When I looked into the sub events, it seemed that it is for mobs not players. Quote
Recommended Posts
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.