Jump to content

Player Tick Event on Serverside [Problem] [1.12]


#ÖCT
 Share

Recommended Posts

Hey

I have a problem with the server compatiblility.

Both Sides starts, but I can`t connect to the server...

 

I used the common PlayerTickEvent

Spoiler

 

 


package oect.lwaltens.luckyblockoect.utils;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import oect.lwaltens.luckyblockoect.registeries.LuckyBlockOect_Potions;

public class ServerEvents 
{

	@SubscribeEvent
	public void PotionFakeBlockAll(TickEvent.PlayerTickEvent event) 
	{
		Minecraft mc = Minecraft.getMinecraft();
		EntityPlayer player = event.player;
		World world = player.getEntityWorld();
		if(player.isPotionActive(LuckyBlockOect_Potions.fakeblockall)) 
		{
			if(!world.isRemote) 
			{
				BlockPos pos = player.getPosition();
				BlockPos pos1 = new BlockPos(pos.getX(), pos.getY()-1, pos.getZ());
				
				IBlockState state = world.getBlockState(pos1);
				
				
				if(state != null) 
				{
					EntityFallingBlock modelblock = new EntityFallingBlock(world, (int)player.posX+0.5, (int)player.posY, (int)player.posZ-0.5, state);
					world.spawnEntity(modelblock);
				}
				
				
			}
		}
	}
}

I register the EventHandler, like this in my preInit:

MinecraftForge.EVENT_BUS.register(new ServerEvents());

 

I think i must to change something only for server/client side, but what??

 

Thank you for help!

Link to comment
Share on other sites

8 minutes ago, #ÖCT said:

Minecraft mc = Minecraft.getMinecraft();

You can't reference client-side only code like that from your common code, use proxies. Or delete that line entirely since you do nothing with the mc local anyway.

9 minutes ago, #ÖCT said:

I can`t connect to the server

What do you mean by "can't connect"? Is there an error in your log?

  • Thanks 1
Link to comment
Share on other sites

Just now, V0idWa1k3r said:

You can't reference client-side only code like that from your common code, use proxies. Or delete that line entirely since you do nothing with the mc local anyway.

What do you mean by "can't connect"? Is there an error in your log?

Spoiler

[12:48:10] [main/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1161) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:436) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.lang.NullPointerException
    at net.minecraft.client.network.NetHandlerPlayClient.handleWorldBorder(NetHandlerPlayClient.java:1699) ~[NetHandlerPlayClient.class:?]
    at net.minecraft.network.play.server.SPacketWorldBorder.processPacket(SPacketWorldBorder.java:123) ~[SPacketWorldBorder.class:?]
    at net.minecraft.network.play.server.SPacketWorldBorder.processPacket(SPacketWorldBorder.java:11) ~[SPacketWorldBorder.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 15 more
[12:48:10] [main/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1161) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:436) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.lang.NullPointerException
    at net.minecraft.client.network.NetHandlerPlayClient.handleTimeUpdate(NetHandlerPlayClient.java:1039) ~[NetHandlerPlayClient.class:?]
    at net.minecraft.network.play.server.SPacketTimeUpdate.processPacket(SPacketTimeUpdate.java:58) ~[SPacketTimeUpdate.class:?]
    at net.minecraft.network.play.server.SPacketTimeUpdate.processPacket(SPacketTimeUpdate.java:10) ~[SPacketTimeUpdate.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 15 more
[12:48:10] [main/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1161) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:436) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.lang.NullPointerException
    at net.minecraft.client.network.NetHandlerPlayClient.handleSpawnPosition(NetHandlerPlayClient.java:1046) ~[NetHandlerPlayClient.class:?]
    at net.minecraft.network.play.server.SPacketSpawnPosition.processPacket(SPacketSpawnPosition.java:45) ~[SPacketSpawnPosition.class:?]
    at net.minecraft.network.play.server.SPacketSpawnPosition.processPacket(SPacketSpawnPosition.java:11) ~[SPacketSpawnPosition.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 15 more
[12:48:10] [main/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1161) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:436) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.lang.NullPointerException
    at net.minecraft.client.network.NetHandlerPlayClient.handleWindowItems(NetHandlerPlayClient.java:1308) ~[NetHandlerPlayClient.class:?]
    at net.minecraft.network.play.server.SPacketWindowItems.processPacket(SPacketWindowItems.java:68) ~[SPacketWindowItems.class:?]
    at net.minecraft.network.play.server.SPacketWindowItems.processPacket(SPacketWindowItems.java:13) ~[SPacketWindowItems.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 15 more
[12:48:10] [main/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1161) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:436) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.lang.NullPointerException
    at net.minecraft.client.network.NetHandlerPlayClient.handleSetSlot(NetHandlerPlayClient.java:1236) ~[NetHandlerPlayClient.class:?]
    at net.minecraft.network.play.server.SPacketSetSlot.processPacket(SPacketSetSlot.java:33) ~[SPacketSetSlot.class:?]
    at net.minecraft.network.play.server.SPacketSetSlot.processPacket(SPacketSetSlot.java:11) ~[SPacketSetSlot.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 15 more

 

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

 Share



×
×
  • Create New...

Important Information

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