Jump to content

Recommended Posts

Posted

ISSUE FIXED

So i am making an Item in tribute to the Terrarian Magic Mirror that teleports you to either your spawn point or your bed depending if you have slept in the bed else if your bed is missing/obstructed, or just for reasons you cannot spawn at your bed, just spawn at the world's spawn location.

 

I got it working for a while but it would only spawn me to the spawn chunks but now since i have added if(!world.isRemote), it doesnt want to teleport at all.

 

NEW ISSUE

Hello :) i got my old issue fixed but to bring up a new issue now. The inverse is happening now to where if i havnt slept in a bed at all, the item flat out doesnt work but if i sleep in a bed then destroy it, it shall teleport me to spawn like it should.

 

Basically: if i start a new world, use the item, i get an error and it doesnt teleport me to my original spawn. If i sleep, it will teleport me to my bed. If i destroy the bed, It teleports me to spawn.

issue to fix is the item not working if you have not used a bed at all.

 

I updated the code down below for eyes to view.

 

UPDATED CODE:

 

 

@Override
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer user)
{	
	if(!world.isRemote)
	{
		System.out.println("\n\n\nWorld: " + world + "\nWorldtoString: " + world.toString() + "\nforce spawnr: " + user.forceSpawn + "\nPlayer: " + user.toString() + "\nBedSpawnLocation: " + user.getBedSpawnLocation(world, user.getBedLocation(0), false) + "\nBed Location: " + user.getBedLocation(0) + "\nSpawn Location: " + world.getSpawnPoint() + "\nSpawn top point: " + world.getTopSolidOrLiquidBlock(world.getSpawnPoint()).getY() + "\n\n\n");

		if(user.getBedSpawnLocation(world, user.getBedLocation(0), false) == null)
		{
			((EntityPlayerMP) user).playerNetServerHandler.setPlayerLocation(world.getSpawnPoint().getX(), 
																			 world.getTopSolidOrLiquidBlock(world.getSpawnPoint()).getY(), 
																			 world.getSpawnPoint().getZ(), 
																			 user.getRotationYawHead(), 
																			 user.getDefaultEyeHeight());
		}
		else
		{
			((EntityPlayerMP) user).playerNetServerHandler.setPlayerLocation(user.getBedSpawnLocation(world, user.getBedLocation(0), false).getX(), 
																			 user.getBedSpawnLocation(world, user.getBedLocation(0), false).getY(), 
																			 user.getBedSpawnLocation(world, user.getBedLocation(0), false).getZ(), 
																			 user.getRotationYawHead(), 
																			 user.getDefaultEyeHeight());
		}
	}

	return item;
}
}

 

 

ERROR:

I get this with the new stated issue above.

 

 

[14:37:26] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_45]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_45]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
Caused by: java.lang.NullPointerException
at net.minecraft.world.World.isValid(World.java:260) ~[World.class:?]
at net.minecraft.world.World.getBlockState(World.java:896) ~[World.class:?]
at net.minecraft.entity.player.EntityPlayer.getBedSpawnLocation(EntityPlayer.java:1715) ~[EntityPlayer.class:?]
at zed.ztools.items.MagicMirror.onItemRightClick(MagicMirror.java:40) ~[MagicMirror.class:?]
at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:168) ~[itemStack.class:?]
at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:378) ~[itemInWorldManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:607) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:67) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:114) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_45]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_45]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]
... 5 more

 

 

My System.out statement doesn't seem to output so i am quite worried where the code is actually messing up.

Possible solution would be to use a try catch statement for null pointers in my if statement checking for bed spawn point for null.

 

will that work?

 

Any other suggestions?

 

OLD OUTPUT

with an output of:

World: net.minecraft.world.WorldServer@74fababf

WorldtoString: net.minecraft.world.WorldServer@74fababf

EntityPlayer: EntityPlayerMP['Player61'/164, l='New World', x=-133.69, y=66.00, z=-52.32]

Player: EntityPlayerMP['Player61'/164, l='New World', x=-133.69, y=66.00, z=-52.32]

Bed Location: null

Spawn Location: BlockPos{x=-124, y=64, z=-45}

Spawn top point: 64

Posted

Which version?

Because this works for me in 1.8

teleporter.playerNetServerHandler.setPlayerLocation
			(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);

 

Where teleporter is the player to get teleported, and player is the player that he gets teleported to

Posted

yes? well i am coding in 1.8 forge-1.8-11.14.3.1446

should i use

teleporter.playerNetServerHandler.setPlayerLocation
			(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);

 

like... what is the difference from what i am doing to teleport the user?

?

 

EDIT:

 

bvyVOio.png

i get this :( and i checked it's declaration but it doesnt seem to be declared anywhere.

Posted

not really. since you are triing to teleport the player calling methods from the player, and I am using methods from the NetHandlerPlayServer, holded by the player (I forgot to mention that I casted the player to EntityPlayerMP)

Posted

so like this:

0vuJ6KB.png

i found the declaration for this but why can it still not be resolved? so far this is what i believe you have done right? or i could be entirely misinterpreting you.

 

removing the NetHandlerPlayServer makes setPlayerLocation an error saying it needs a different cast

 

EDIT:

((EntityPlayerMP) user).playerNetServerHandler.setPlayerLocation(world.getSpawnPoint().getX(), 
				world.getTopSolidOrLiquidBlock(world.getSpawnPoint()).getY(), 
				world.getSpawnPoint().getZ(), 
				user.getRotationYawHead(), 
				user.getDefaultEyeHeight());

seems to have no errors. ima try this out and see if it works

Posted

not really. since you are triing to teleport the player calling methods from the player, and I am using methods from the NetHandlerPlayServer, holded by the player (I forgot to mention that I casted the player to EntityPlayerMP)

 

Welp :) i got that situation sorted. thanks that worked. only problem now is that i need to update my if statement to check if the bed is missing soo.... i should be able to do that my self but i will report to this post if i have any more trouble.

  • 2 weeks later...
Posted

ISSUE UPDATED

 

NEW ISSUE

Hello :) i got my old issue fixed but to bring up a new issue now. The inverse is happening now to where if i havnt slept in a bed at all, the item flat out doesnt work but if i sleep in a bed then destroy it, it shall teleport me to spawn like it should.

 

Basically: if i start a new world, use the item, i get an error and it doesnt teleport me to my original spawn. If i sleep, it will teleport me to my bed. If i destroy the bed, It teleports me to spawn.

issue to fix is the item not working if you have not used a bed at all.

 

I updated the code down below for eyes to view.

 

UPDATED CODE:

 

 

@Override
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer user)
{	
	if(!world.isRemote)
	{
		System.out.println("\n\n\nWorld: " + world + "\nWorldtoString: " + world.toString() + "\nforce spawnr: " + user.forceSpawn + "\nPlayer: " + user.toString() + "\nBedSpawnLocation: " + user.getBedSpawnLocation(world, user.getBedLocation(0), false) + "\nBed Location: " + user.getBedLocation(0) + "\nSpawn Location: " + world.getSpawnPoint() + "\nSpawn top point: " + world.getTopSolidOrLiquidBlock(world.getSpawnPoint()).getY() + "\n\n\n");

		if(user.getBedSpawnLocation(world, user.getBedLocation(0), false) == null)
		{
			((EntityPlayerMP) user).playerNetServerHandler.setPlayerLocation(world.getSpawnPoint().getX(), 
																			 world.getTopSolidOrLiquidBlock(world.getSpawnPoint()).getY(), 
																			 world.getSpawnPoint().getZ(), 
																			 user.getRotationYawHead(), 
																			 user.getDefaultEyeHeight());
		}
		else
		{
			((EntityPlayerMP) user).playerNetServerHandler.setPlayerLocation(user.getBedSpawnLocation(world, user.getBedLocation(0), false).getX(), 
																			 user.getBedSpawnLocation(world, user.getBedLocation(0), false).getY(), 
																			 user.getBedSpawnLocation(world, user.getBedLocation(0), false).getZ(), 
																			 user.getRotationYawHead(), 
																			 user.getDefaultEyeHeight());
		}
	}

	return item;
}
}

 

 

ERROR:

I get this with the new stated issue above.

 

 

[14:37:26] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_45]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_45]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
Caused by: java.lang.NullPointerException
at net.minecraft.world.World.isValid(World.java:260) ~[World.class:?]
at net.minecraft.world.World.getBlockState(World.java:896) ~[World.class:?]
at net.minecraft.entity.player.EntityPlayer.getBedSpawnLocation(EntityPlayer.java:1715) ~[EntityPlayer.class:?]
at zed.ztools.items.MagicMirror.onItemRightClick(MagicMirror.java:40) ~[MagicMirror.class:?]
at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:168) ~[itemStack.class:?]
at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:378) ~[itemInWorldManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:607) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:67) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:114) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_45]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_45]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]
... 5 more

 

 

My System.out statement doesn't seem to output so i am quite worried where the code is actually messing up.

Possible solution would be to use a try catch statement for null pointers in my if statement checking for bed spawn point for null.

 

will that work?

 

Any other suggestions?

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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