Jump to content

Recommended Posts

Posted

Edit: This first question is resolved. Scroll down to see my later questions.

 

I created an entity (EntityPMPlayer) that extends EntityPlayerMP. When I tried spawning it in the exact same way I spawned an EntityPlayerMP the console spat out an error that it was missing the method <init>(net.minecraft.world.World). Why does it do this with my entity but not with EntityPlayerMP, and how can I fix it?

 

EntityPMPlayer:

 

 

public class EntityPMPlayer extends EntityPlayerMP {

 

public EntityPMPlayer(MinecraftServer server, WorldServer world,GameProfile profile, ItemInWorldManager interactionManager) {

super(server, world, profile, interactionManager);

 

}

 

}

 

 

 

Error:

 

 

[21:20:18] [Client thread/ERROR] [FML]: A severe problem occurred during the spawning of an entity

java.lang.NoSuchMethodException: com.playermod.entity.playermob.EntityPMPlayer.<init>(net.minecraft.world.World)

at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_45]

at java.lang.Class.getConstructor(Class.java:1825) ~[?:1.8.0_45]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.spawnEntity(EntitySpawnHandler.java:93) [EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.process(EntitySpawnHandler.java:56) [EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.access$000(EntitySpawnHandler.java:31) [EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler$1.run(EntitySpawnHandler.java:46) [EntitySpawnHandler$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_45]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_45]

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:709) [FMLCommonHandler.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1070) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]

at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

[21:20:18] [Client thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.playermod.entity.playermob.EntityPMPlayer.<init>(net.minecraft.world.World)

java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.playermod.entity.playermob.EntityPMPlayer.<init>(net.minecraft.world.World)

at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_45]

at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_45]

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:710) [FMLCommonHandler.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1070) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]

at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.playermod.entity.playermob.EntityPMPlayer.<init>(net.minecraft.world.World)

at com.google.common.base.Throwables.propagate(Throwables.java:160) ~[guava-17.0.jar:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.spawnEntity(EntitySpawnHandler.java:142) ~[EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.process(EntitySpawnHandler.java:56) ~[EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.access$000(EntitySpawnHandler.java:31) ~[EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler$1.run(EntitySpawnHandler.java:46) ~[EntitySpawnHandler$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_45]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_45]

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:709) ~[FMLCommonHandler.class:?]

... 11 more

Caused by: java.lang.NoSuchMethodException: com.playermod.entity.playermob.EntityPMPlayer.<init>(net.minecraft.world.World)

at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_45]

at java.lang.Class.getConstructor(Class.java:1825) ~[?:1.8.0_45]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.spawnEntity(EntitySpawnHandler.java:93) ~[EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.process(EntitySpawnHandler.java:56) ~[EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.access$000(EntitySpawnHandler.java:31) ~[EntitySpawnHandler.class:?]

at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler$1.run(EntitySpawnHandler.java:46) ~[EntitySpawnHandler$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_45]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_45]

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:709) ~[FMLCommonHandler.class:?]

... 11 more

 

 

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

Here is the code I use to spawn the player.

 

 

 

//create profile

ServerConfigurationManager scm = MinecraftServer.getServer().getConfigurationManager();

 

String username = "Player_" + (scm.playerEntityList.size() + 1);

UUID uuid = UUID.nameUUIDFromBytes(username.getBytes(Charsets.UTF_8));

GameProfile profile = new GameProfile(uuid, username);

 

// login

WorldServer overworldServer = MinecraftServer.getServer().worldServerForDimension(0);

 

ItemInWorldManager worldItemManager = new ItemInWorldManager(overworldServer);

 

//this works

// EntityPlayerMP player = new EntityPlayerMP(MinecraftServer.getServer(), overworldServer, profile, worldItemManager);

 

//this doesn't

EntityPMPlayer player = new EntityPMPlayer(MinecraftServer.getServer(), overworldServer, profile, worldItemManager);

 

SocketAddress address = Minecraft.getMinecraft().getIntegratedServer().getNetworkSystem().addLocalEndpoint();

NetworkManager netManager = NetworkManager.provideLocalClient(address);

 

NetHandlerPlayServer nhps = new NetHandlerPlayServer(scm.getServerInstance(), netManager, player);

 

scm.initializeConnectionToPlayer(netManager, player, nhps);

 

 

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

It does this because the constructor is missing.

Explicit constructors need to be defined by the child class.

See Java constructor rules.

 

I know. The only problem is that I can't do a constructor with super(world) because EntityPlayerMP doesn't have that constructor either, but for some reason it works. I don't know how to do a constructor that just has one parameter (World world) while still referring to the EntityPlayerMP constructor (super(server, world, profile, interactionManager)) without making up lots of hard coded things to fill in the blanks.

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

When entity is spawned on server a packet is sent to client telling to spawn client-sided representation of that entity. Those 2 entities are bound by entityId.

All entities should have constructor that has one arg: World, because that is how they will be spawned on client (internally using that constructor).

 

Now - EntityPlayer is different. While all other entities have one shared class, a player has class for Client and Server:

Server: EntityPlayerMP

Client: EntityPlayerSP + EntityOtherPlayerMP

It is obvious that player is a special entity.

 

So solution: DON'T EXTEND EntityPlayer!

Make goddamn entity that behaves like player - it is much simpler and works better.

 

And if you really want to make extension to players - you will need sided implementations (MP and OtherSP probably) and some ASM to make it work NICE. Without ASM you will messup a lot of things. It is not possible to spawn player like a normal mob. You need handlers that handle EntityPlayer (INetHandler).

 

1.7.10 is no longer supported by forge, you are on your own.

  • 2 weeks later...
Posted

Ok, so I've found a few problems that I can't seem to handle in the past few days. At first I kept trying to use the entity that extended from EntityPlayerMP, but there were so many things to override that I decided to just have a custom net handler only (extends from NetHandlerPlayServer, I called it NetHandlerPMPlayServer). I can link it with a player just fine, but for some reason EntityPlayerMP only updates(super.onUpdate()) when its net handler recieves a packet from the client (C03PacketPlayer), which is sent every tick in EntityPlayerSP's onUpdate(). Of course, my players don't have a client (except for the EntityOtherPlayerMP, which doesn't really count), so they aren't being updated. I tried to make my net handler "send itself" the packet in it's update() method, but that wasn't being called either. Instead I tried using the event PlayerTickEvent to call NetHandlerPMPlayer.update() whenever the EntityOtherPlayerMP version of my player ticked. This worked fine, but when I created an sent the packet in NetHandlerPMPlayer.update() MC crashes with a net.minecraft.network.ThreadQuickExitException.

 

If you don't read ALL the above you might get confused, so just read it.

 

In the end I have two questions:

-Why isn't NetHandlerPMPlayServer.update() being called in vanilla code somewhere?

-How can I make my net handler "send" itself packets?

 

GitHub Source: https://github.com/Vitridax/PlayerMod.git

Sorry if the files are a bit messy with all the comments everywhere. If you can't find something just ask.

 

Edit:

Crash. Sorry I forgot about it earlier.

 

 

[09:49:44] [Client thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.TickEvent$PlayerTickEvent@5db94eaf:

net.minecraft.network.ThreadQuickExitException

[09:49:44] [Client thread/ERROR] [FML]: Index: 1 Listeners:

[09:49:44] [Client thread/ERROR] [FML]: 0: NORMAL

[09:49:44] [Client thread/ERROR] [FML]: 1: ASM: com.playermod.event.PlayerModFMLEventHandler@4f3d49e4 playerTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V

 

(some stuff omitted about unloading world)

 

[09:49:51] [Client thread/FATAL]: Reported exception thrown!

net.minecraft.util.ReportedException: Ticking entity

at net.minecraft.world.World.updateEntities(World.java:1830) ~[World.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2176) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]

at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: net.minecraft.network.ThreadQuickExitException

 

 

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

Bump

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

For your first question, you could override EntityLivingBase's onEntityUpdate

 

For what Entity? I can't change any vanilla classes and I'm trying not to use my old entity (EntityPMPlayerServer) because of all the problems it causes. Instead I'm just using the NetHandlerPMPlayServer. Or are you talking about the very first question I asked on March 2nd? That's resolved because I'm not using EntityPMPlayerServer anymore.

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

Bump.

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

Posted

I managed to solve my problems by myself. It took a week of many tests and crashes, but at least it was very informative.

 

For the first question, my NetHandler wasn't being updated because it's manager was a client side manager. The server side manager it was connected to was stored in a private list in the NetworkSystem, so I got it using reflection, and used it for my NetHandler instead.

 

For the second question, right now I'm just creating packets in NetHandlerPMPlayServer.update() and calling the correct method to handle the packet. I'm not sure if this will cause problems later, but for now it works.

I am very busy on the weekdays so don't expect me to make more than one post per day.

 

If you curse in your responses to me I will smite you. It's as simple as that.

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.