This ended up being what works
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
ChunkCoordinates bed = par3EntityPlayer.getBedLocation(par3EntityPlayer.dimension);
if(bed == null) {
bed = par3EntityPlayer.worldObj.getSpawnPoint();
}
par3EntityPlayer.setPositionAndUpdate(bed.posX, bed.posY, bed.posZ);
return par1ItemStack;
}
This fixed it
ChunkCoordinates bed = par3EntityPlayer.getBedLocation(par3EntityPlayer.dimension);
par3EntityPlayer.setPositionAndUpdate(bed.posX, bed.posY, bed.posZ);
return par1ItemStack;
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
Yes, it is imported.
The reason it's in "food" is because that's where the other "Crystals" are. One crystal heals you, one crystal is an antidote like milk, and this one is supposed to teleport you. None are really food but the other two are treated like it so I put this one in the same package with those. It's supposed to be based off the Anime, Sword Art Online (SAO). My little brother is obsessed with it so I am making this for him.
There's an error on "new TeleportCrystalClass()" because it's "Undefined". I'm guessing that means it needs the "int par1" from my class file? I'm not sure what those are
The start entity id was placed there by eclipse, not sure why.
As for the rest of the code, I just copied it from an earlier reply suggesting what I should do. I'm trying to make an item that teleports me to my spawn point.
The start entity ID was used to make a mob, but that's how the error corrector fixed it when I clicked it.
I have about 15 other items with textures labeled the exact same way in this mod and they all work fine, so I don't think that's part of it
Yes, I am developing for 1.7.2
Sorry for my lack of experience with code, but what would you recommend I put in "new TeleportCrystalClass()"?
Here is my complete Class File
And this is what I currently have in my MainClass:
public static Item TeleportCrystal = new TeleportCrystalClass(startEntityId).setUnlocalizedName("TeleportCrystal").setCreativeTab(saoTab);
and regarding what you said about startEntityId, this is also in my main class. Would that change anything?
private static int startEntityId = 300;
public static int getUniqueEntityId() {
do {
startEntityId++;
}
while(EntityList.getStringFromID(startEntityId) != null );
return startEntityId++;
I got rid of the error in my Main Class by making it
new TeleportCrystalClass(startEntityId)
but the error on super(par1); is still causing my game to crash
I get two errors with this:
on "super(par1)" that says "The constructor Item(int) is undefined"
and another in my Main Class where I declared it,
public static Item TeleportCrystal = new TeleportCrystalClass().setUnlocalizedName("TeleportCrystal").setCreativeTab(saoTab);
the error is on "new TeleportCrystalClass()" and it says "The constructor TeleportCrystalClass() is undefined"
Where did I go wrong?
I can't figure out where exactly to put this in my food class file or what parameters. Could someone give an example of how to do it? I also need to change the itemUseDuration