Jump to content

Recommended Posts

Posted

I had in my mod a player tick event when i running this on my test server the player will kick form the server and i get this error:

 

java.lang.NoSuchMethodError: net.minecraft.entity.player.PlayerInventory.func_70440_f(I)Lnet/minecraft/item/ItemStack;
	at net.luis.cave.events.server.entity.OnPlayerTick.PlayerTick(OnPlayerTick.java:27)
	at net.minecraftforge.eventbus.ASMEventHandler_19_OnPlayerTick_PlayerTick_PlayerTickEvent.invoke(.dynamic)
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85)
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297)
	at net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPreTick(BasicEventHooks.java:85)
	at net.minecraft.entity.player.PlayerEntity.func_70071_h_(PlayerEntity.java:195)
	at net.minecraft.entity.player.ServerPlayerEntity.func_71127_g(ServerPlayerEntity.java:393)
	at net.minecraft.network.play.ServerPlayNetHandler.func_73660_a(ServerPlayNetHandler.java:194)
	at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:226)
	at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:133)
	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:866)
	at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:286)
	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:788)
	at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:643)
	at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:230)
	at java.lang.Thread.run(Unknown Source)

 

and this is the tick event:

 

package net.luis.cave.events.server.entity;

import net.luis.cave.Cave;
import net.luis.cave.init.CaveEnchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid=Cave.Mod_Id, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.DEDICATED_SERVER)
public class OnPlayerTick {

	@SubscribeEvent
	public static void PlayerTick(TickEvent.PlayerTickEvent event) {

		ServerPlayerEntity player = (ServerPlayerEntity) event.player;
		World world = player.getEntityWorld();
		BlockPos pos = new BlockPos(player.getPosX(), player.getPosY() - 1, player.getPosZ());
		
		if (player instanceof ServerPlayerEntity) {
			
			if (EnchantmentHelper.getEnchantmentLevel(CaveEnchantment.ELYTRA_FALLING.get(), player.inventory.armorItemInSlot(2)) == 1) {
				
				player.fallDistance = 0f;
				
			}
			
			if (EnchantmentHelper.getEnchantmentLevel(CaveEnchantment.VOID_WALKER.get(), player.inventory.armorItemInSlot(0)) == 1) {
				
				if (!player.isSneaking()) {
			
					if (!world.getBlockState(pos).isSolid()) {
						
						if (player.getMotion().getY() < 0) {
							
							player.setMotion(player.getMotion().getX(), 0, player.getMotion().getZ());
							
						}
						
					}
				}
				
			}
			
		}
		
	}

}

 

Posted
ServerPlayerEntity player = (ServerPlayerEntity) event.player; // you first cast player to ServerPlayerEntity
		World world = player.getEntityWorld();
		BlockPos pos = new BlockPos(player.getPosX(), player.getPosY() - 1, player.getPosZ());
		
		if (player instanceof ServerPlayerEntity) // and here check if the player is a instance of ServerPlayerEntity thats wrong

 

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.