Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;

}

 

}

 

 

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.

  • Author

This fixed it

 

ChunkCoordinates bed = par3EntityPlayer.getBedLocation(par3EntityPlayer.dimension);

par3EntityPlayer.setPositionAndUpdate(bed.posX, bed.posY, bed.posZ);

return par1ItemStack;

That didn't work, but it completely obliterated the area around my original spawn

...obliterate? It shouldn't change anything about the world. I guess it's not very important though.

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?

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]}

 

 

    }

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.