Jump to content

Recommended Posts

Posted

I am trying to use a fake player for a mob grinder so that the mobs it kills drop xp and player only loot such as wither skulls but i have run into a problem.

 

First of all i couldn't find anything about how to use the forge fake player so i would like to confirm that i am using it rite.

mob.attackEntityFrom(DamageSource.causePlayerDamage(FakePlayerFactory.getMinecraft(MinecraftServer.getServer().worldServerForDimension(((EntityLiving) mob).dimension))), 50000F);

 

This works fine but i am experiencing a problem when infernal mobs is installed. Some of the infernal mobs add potion effects to their attacker and when it tries to add an effect to the fake player it crashes the game.

 

 

java.lang.NullPointerException: Ticking block entity
at net.minecraft.entity.player.EntityPlayerMP.onNewPotionEffect(EntityPlayerMP.java:1006)
at net.minecraft.entity.EntityLivingBase.addPotionEffect(EntityLivingBase.java:724)
at atomicstryker.infernalmobs.common.mods.MM_Wither.onHurt(MM_Wither.java:30)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Vengeance.onHurt(MM_Vengeance.java:30)
at atomicstryker.infernalmobs.common.EntityEventHandler.onEntityLivingHurt(EntityEventHandler.java:126)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_118_EntityEventHandler_onEntityLivingHurt_LivingHurtEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:288)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1271)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:880)
at net.minecraft.entity.monster.EntityMob.attackEntityFrom(EntityMob.java:84)
at net.minecraft.entity.monster.EntityZombie.attackEntityFrom(EntityZombie.java:253)
at net.minecraft.entity.monster.EntityPigZombie.attackEntityFrom(EntityPigZombie.java:143)
at com.brandon3055.draconicevolution.common.tileentities.TileGrinder.killNextEntity(TileGrinder.java:153)
at com.brandon3055.draconicevolution.common.tileentities.TileGrinder.updateEntity(TileGrinder.java:103)
at net.minecraft.world.World.updateEntities(World.java:2115)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:517)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:713)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)

 

 

from what i can tell this is a problem with forge fake player not being able to handle potion effects but i want to get a second opinion. And if it is a problem with the forge fake player how can i create my own?

I am the author of Draconic Evolution

Posted

Override addPotionEffect() in your fake player class and leave an empty method body (not even call the super method)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Well i was using the forge fake player so that wasnt possible but i think i have my custom fake player working now there is just one thing i am not clear on.

 

The forge FakePlayerFactory has an unloadWorld method i assume i need to make something similar and call it on WorldEvent.Unload?

 

Here are my fake player classes i would appreciate it if you could take a quick look and tell me if i have missed anything.

 

Fake Player

 

public class DEFakePlayer extends FakePlayer {
public DEFakePlayer(WorldServer world, GameProfile name) {
	super(world, name);
}

@Override
public void addPotionEffect(PotionEffect p_70690_1_) {
	return;
}

@Override
protected void onNewPotionEffect(PotionEffect p_70670_1_) {
	return;
}
}

 

Fake Player Factury

 

public class DEFakePlayerFactory {
private static GameProfile DE = new GameProfile(UUID.randomUUID(), "[DEFakePlayer]");
private static DEFakePlayer DE_PLAYER = null;

public static DEFakePlayer getPlayer(WorldServer world)
{
	if (DE_PLAYER == null)
	{
		DE_PLAYER = new DEFakePlayer(world, DE);
	}
	return DE_PLAYER;
}
}

 

Implementation

mob.attackEntityFrom(DamageSource.causePlayerDamage(DEFakePlayerFactory.getPlayer(MinecraftServer.getServer().worldServerForDimension(((EntityLiving) mob).dimension))), 50000F);

 

Thank you for your help!

I am the author of Draconic Evolution

Posted

Probably? I never worked with the FakePlayer stuff before, but sounds like it.

 

Another note, you can shorten your attackEntityFrom() call by replacing

MinecraftServer.getServer().worldServerForDimension(((EntityLiving) mob).dimension)

with

(WorldServer) mob.worldObj

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I just encountered another crash but i think this may be a bug with Infernal Mobs but im not sure... It seems to be a network problem but im not sure exactly.

 

Description: Ticking entity

java.lang.NullPointerException: Ticking entity
at cpw.mods.fml.common.network.FMLOutboundHandler$OutboundTarget$4.selectNetworks(FMLOutboundHandler.java:109)
at cpw.mods.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:273)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115)
at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:626)
at io.netty.channel.DefaultChannelPipeline.write(DefaultChannelPipeline.java:878)
at io.netty.channel.AbstractChannel.write(AbstractChannel.java:229)
at io.netty.channel.embedded.EmbeddedChannel.writeOutbound(EmbeddedChannel.java:195)
at atomicstryker.infernalmobs.common.network.NetworkHelper.sendPacketToPlayer(NetworkHelper.java:111)
at atomicstryker.infernalmobs.common.InfernalMobsCore.sendAirPacket(InfernalMobsCore.java:767)
at atomicstryker.infernalmobs.common.mods.MM_Choke.updateAir(MM_Choke.java:101)
at atomicstryker.infernalmobs.common.mods.MM_Choke.onUpdate(MM_Choke.java:37)
at atomicstryker.infernalmobs.common.MobModifier.onUpdate(MobModifier.java:259)
at atomicstryker.infernalmobs.common.MobModifier.onUpdate(MobModifier.java:259)
at atomicstryker.infernalmobs.common.EntityEventHandler.onEntityLivingUpdate(EntityEventHandler.java:210)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_121_EntityEventHandler_onEntityLivingUpdate_LivingUpdateEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:277)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1775)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250)
at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47)
at net.minecraft.entity.monster.EntityCreeper.onUpdate(EntityCreeper.java:176)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2253)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:686)
at net.minecraft.world.World.updateEntity(World.java:2213)
at net.minecraft.world.World.updateEntities(World.java:2063)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:517)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:713)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at cpw.mods.fml.common.network.FMLOutboundHandler$OutboundTarget$4.selectNetworks(FMLOutboundHandler.java:109)
at cpw.mods.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:273)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115)
at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:626)
at io.netty.channel.DefaultChannelPipeline.write(DefaultChannelPipeline.java:878)
at io.netty.channel.AbstractChannel.write(AbstractChannel.java:229)
at io.netty.channel.embedded.EmbeddedChannel.writeOutbound(EmbeddedChannel.java:195)
at atomicstryker.infernalmobs.common.network.NetworkHelper.sendPacketToPlayer(NetworkHelper.java:111)
at atomicstryker.infernalmobs.common.InfernalMobsCore.sendAirPacket(InfernalMobsCore.java:767)
at atomicstryker.infernalmobs.common.mods.MM_Choke.updateAir(MM_Choke.java:101)
at atomicstryker.infernalmobs.common.mods.MM_Choke.onUpdate(MM_Choke.java:37)
at atomicstryker.infernalmobs.common.MobModifier.onUpdate(MobModifier.java:259)
at atomicstryker.infernalmobs.common.MobModifier.onUpdate(MobModifier.java:259)
at atomicstryker.infernalmobs.common.EntityEventHandler.onEntityLivingUpdate(EntityEventHandler.java:210)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_121_EntityEventHandler_onEntityLivingUpdate_LivingUpdateEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:277)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1775)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250)
at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47)
at net.minecraft.entity.monster.EntityCreeper.onUpdate(EntityCreeper.java:176)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2253)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:686)
at net.minecraft.world.World.updateEntity(World.java:2213)

-- Entity being ticked --
Details:
Entity Type: Creeper (net.minecraft.entity.monster.EntityCreeper)
Entity ID: 31179279
Entity Name: Creeper
Entity's Exact location: 23.70, 70.78, 20.70
Entity's Block location: World: (23,70,20), Chunk: (at 7,4,4 in 1,1; contains blocks 16,0,16 to 31,255,31), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Entity's Momentum: 0.00, 0.28, 0.00
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:2063)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:517)

-- Affected level --
Details:
Level name: Minning Layers
All players: 1 total; [EntityPlayerMP['ForgeDevName'/47, l='Minning Layers', x=23.49, y=73.75, z=23.54]]
Chunk stats: ServerChunkCache: 1089 Drop: 0
Level seed: 3446051860655676810
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 2;7,10x1,10x13,10x3,10x12,10x5,10x35:15,10x159:14;1;village
Level spawn location: World: (0,71,0), Chunk: (at 0,4,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 10989255 game time, 6000 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 57850 (now: false), thunder time: 63621 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:713)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)

 

 

Edit: I just got a slightly different one that seems to be related to the same thing. I would really like to know if these crashes are something i can fix or a bug with Infernal Mobs...

 

ava.lang.NullPointerException: Ticking block entity
at cpw.mods.fml.common.network.FMLOutboundHandler$OutboundTarget$4.selectNetworks(FMLOutboundHandler.java:109)
at cpw.mods.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:273)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115)
at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:626)
at io.netty.channel.DefaultChannelPipeline.write(DefaultChannelPipeline.java:878)
at io.netty.channel.AbstractChannel.write(AbstractChannel.java:229)
at io.netty.channel.embedded.EmbeddedChannel.writeOutbound(EmbeddedChannel.java:195)
at atomicstryker.infernalmobs.common.network.NetworkHelper.sendPacketToPlayer(NetworkHelper.java:111)
at atomicstryker.infernalmobs.common.InfernalMobsCore.sendKnockBackPacket(InfernalMobsCore.java:750)
at atomicstryker.infernalmobs.common.mods.MM_Gravity.tryAbility(MM_Gravity.java:86)
at atomicstryker.infernalmobs.common.mods.MM_Gravity.onHurt(MM_Gravity.java:51)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Cloaking.onHurt(MM_Cloaking.java:48)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Ender.onHurt(MM_Ender.java:37)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Vengeance.onHurt(MM_Vengeance.java:30)
at atomicstryker.infernalmobs.common.EntityEventHandler.onEntityLivingHurt(EntityEventHandler.java:126)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_117_EntityEventHandler_onEntityLivingHurt_LivingHurtEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:288)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1271)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:880)
at net.minecraft.entity.monster.EntityMob.attackEntityFrom(EntityMob.java:84)
at com.brandon3055.draconicevolution.common.tileentities.TileGrinder.killNextEntity(TileGrinder.java:152)
at com.brandon3055.draconicevolution.common.tileentities.TileGrinder.updateEntity(TileGrinder.java:103)
at net.minecraft.world.World.updateEntities(World.java:2115)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:517)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:713)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at cpw.mods.fml.common.network.FMLOutboundHandler$OutboundTarget$4.selectNetworks(FMLOutboundHandler.java:109)
at cpw.mods.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:273)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115)
at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:626)
at io.netty.channel.DefaultChannelPipeline.write(DefaultChannelPipeline.java:878)
at io.netty.channel.AbstractChannel.write(AbstractChannel.java:229)
at io.netty.channel.embedded.EmbeddedChannel.writeOutbound(EmbeddedChannel.java:195)
at atomicstryker.infernalmobs.common.network.NetworkHelper.sendPacketToPlayer(NetworkHelper.java:111)
at atomicstryker.infernalmobs.common.InfernalMobsCore.sendKnockBackPacket(InfernalMobsCore.java:750)
at atomicstryker.infernalmobs.common.mods.MM_Gravity.tryAbility(MM_Gravity.java:86)
at atomicstryker.infernalmobs.common.mods.MM_Gravity.onHurt(MM_Gravity.java:51)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Cloaking.onHurt(MM_Cloaking.java:48)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Ender.onHurt(MM_Ender.java:37)
at atomicstryker.infernalmobs.common.MobModifier.onHurt(MobModifier.java:213)
at atomicstryker.infernalmobs.common.mods.MM_Vengeance.onHurt(MM_Vengeance.java:30)
at atomicstryker.infernalmobs.common.EntityEventHandler.onEntityLivingHurt(EntityEventHandler.java:126)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_117_EntityEventHandler_onEntityLivingHurt_LivingHurtEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:288)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1271)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:880)
at net.minecraft.entity.monster.EntityMob.attackEntityFrom(EntityMob.java:84)
at com.brandon3055.draconicevolution.common.tileentities.TileGrinder.killNextEntity(TileGrinder.java:152)
at com.brandon3055.draconicevolution.common.tileentities.TileGrinder.updateEntity(TileGrinder.java:103)

-- Block entity being ticked --
Details:
Name: draconicevolution:TileGrinder // com.brandon3055.draconicevolution.common.tileentities.TileGrinder
Block type: ID #169 (tile.draconicevolution:grinder // com.brandon3055.draconicevolution.common.blocks.machine.Grinder)
Block data value: 0 / 0x0 / 0b0000
Block location: World: (26,71,25), Chunk: (at 10,4,9 in 1,1; contains blocks 16,0,16 to 31,255,31), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Actual block type: ID #169 (tile.draconicevolution:grinder // com.brandon3055.draconicevolution.common.blocks.machine.Grinder)
Actual block data value: 0 / 0x0 / 0b0000
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:2115)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:517)

-- Affected level --
Details:
Level name: Minning Layers
All players: 1 total; [EntityPlayerMP['ForgeDevName'/963, l='Minning Layers', x=25.64, y=76.11, z=26.43]]
Chunk stats: ServerChunkCache: 1089 Drop: 0
Level seed: 3446051860655676810
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 2;7,10x1,10x13,10x3,10x12,10x5,10x35:15,10x159:14;1;village
Level spawn location: World: (0,71,0), Chunk: (at 0,4,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 10999037 game time, 6000 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 48068 (now: false), thunder time: 53839 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:713)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)

 

 

Edit 2: Iv tracked it down to "playerNetServerHandler" in my fake player class being null but so far i havent figured out how to fix it.

I am the author of Draconic Evolution

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

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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