Jump to content

World Type Nether


Gaprosys

Recommended Posts

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?

Link to comment
Share on other sites

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.

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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.

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



×
×
  • Create New...

Important Information

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