Jump to content

getBedLocation() not working


Achilleus

Recommended Posts

I made an item that is supposed to teleport me to my bed location using getBedLocation() but instead it keeps teleporting me to my original spawn point. Anyone know how to fix this?

 

Here's the complete class file

 

 

package achilleus.sao.food;

 

import achilleus.sao.MainClass;

import net.minecraft.entity.player.EntityPlayer;

import achilleus.sao.Item.GateSetClass;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ChunkCoordinates;

import net.minecraft.world.World;

 

public class TeleportCrystalClass extends Item {

 

public TeleportCrystalClass() {

 

setTextureName(MainClass.MODID + ":TeleportCrystal");

 

}

 

 

 

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

{

ChunkCoordinates spawn = par3EntityPlayer.getBedLocation();

 

 

par3EntityPlayer.setPosition(spawn.posX, spawn.posY, spawn.posZ);

 

return par1ItemStack;

}

 

}

 

 

Link to comment
Share on other sites

Try:

ChunkCoordinates spawn = par3EntityPlayer.getBedLocation(player.dimension);
spawn = EntityPlayer.verifyRespawnCoordinates(par2World, spawn, true);
par3EntityPlayer.setPosition(spawn.posX, spawn.posY, spawn.posZ);

Although it doesn't seem to check whether the bed is still there.

Link to comment
Share on other sites

None of those method calls should change anything around spawn, and they definitely shouldn't obliterate it.

 

I am interested: How did it obliterate the area? What was the effect? Can you reproduce this effect?

Link to comment
Share on other sites

I want the same action but obviously I can't do that in [X].

How should I go about it in this case ?

 

 

@SubscribeEvent

    public void checkDimension(PlayerEvent.PlayerChangedDimensionEvent event) {

        int dimension = event.player.dimension;

        System.out.println("player dimension is: " + event.player.dimension);

        if (dimension == -1){[X]}

 

 

    }

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.