Jump to content

Recommended Posts

Posted (edited)

Hi,

 

So I was trying to make a custom entity and spawning it in the world and I had some trouble figuring out why the entity wasn't registered. Now it is and I can spawn it using "/summon" and with a spawn egg I made but it loads pretty much every minecraft png around my player and stays there. I'm guessing I have an issue with my entity model but can't find how to solve it.

 

If anyone can help I would be very greatfull, Thank you.

 

Here is my gitHub Repository.

 

This is my EntityInit,

this is my Entity,

this is my EntityRender,

this is my EntityModel,

this is my RenderHandler,

and this is my Main.

 

I don't really see any errors in the Logs whenever I try spawning the Entity but here they are anyways:

Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_211, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 852072136 bytes (812 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13397 Compatibility Profile Context 15.200.1055.0' Renderer: 'AMD Radeon(TM) R3 Graphics'
[10:16:45] [main/INFO] [FML]: MinecraftForge v14.23.5.2768 Initialized
[10:16:45] [main/INFO] [FML]: Starts to replace vanilla recipe ingredients with ore ingredients.
[10:16:46] [main/INFO] [FML]: Replaced 1036 ore ingredients
[10:16:47] [main/INFO] [FML]: Searching C:\Users\Dan\Desktop\Minecraft Modding\PixelmonMod\run\.\mods for mods
[10:16:48] [Thread-3/INFO] [FML]: Using alternative sync timing : 200 frames of Display.update took 1219406462 nanos
[10:16:56] [main/INFO] [FML]: Forge Mod Loader has identified 5 mods to load
[10:16:58] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, pm] at CLIENT
[10:16:58] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, pm] at SERVER
[10:17:01] [main/INFO] [minecraft/SimpleReloadableResourceManager]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Pixelmon Mod
[10:17:02] [main/INFO] [FML]: Processing ObjectHolder annotations
[10:17:02] [main/INFO] [FML]: Found 1168 ObjectHolder annotations
[10:17:02] [main/INFO] [FML]: Identifying ItemStackHolder annotations
[10:17:02] [main/INFO] [FML]: Found 0 ItemStackHolder annotations
[10:17:03] [main/INFO] [FML]: Configured a dormant chunk cache size of 0
[10:17:03] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[10:17:03] [main/INFO] [FML]: OBJLoader: Domain pm has been added.
[10:17:03] [main/INFO] [FML]: Applying holder lookups
[10:17:03] [main/INFO] [FML]: Holder lookups applied
[10:17:03] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Found status: UP_TO_DATE Target: null
[10:17:03] [main/INFO] [FML]: Applying holder lookups
[10:17:03] [main/INFO] [FML]: Holder lookups applied
[10:17:03] [main/INFO] [FML]: Applying holder lookups
[10:17:03] [main/INFO] [FML]: Holder lookups applied
[10:17:04] [main/INFO] [FML]: Applying holder lookups
[10:17:04] [main/INFO] [FML]: Holder lookups applied
[10:17:04] [main/INFO] [FML]: Injecting itemstacks
[10:17:04] [main/INFO] [FML]: Itemstack injection complete
[10:17:23] [Sound Library Loader/INFO] [minecraft/SoundManager]: Starting up SoundSystem...
[10:17:24] [Thread-5/INFO] [minecraft/SoundManager]: Initializing LWJGL OpenAL
[10:17:24] [Thread-5/INFO] [minecraft/SoundManager]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[10:17:24] [Thread-5/INFO] [minecraft/SoundManager]: OpenAL initialized.
[10:17:24] [Sound Library Loader/INFO] [minecraft/SoundManager]: Sound engine started
[10:18:09] [main/INFO] [FML]: Max texture size: 16384
[10:18:12] [main/WARN] [minecraft/TextureMap]: Texture pm:textures/items/pokeballs/pokeball/greatball.png with size 18x18 will have visual artifacts at mip level 4, it can only support level 1. Please report to the mod author that the texture should be some multiple of 16x16.
[10:18:13] [main/WARN] [minecraft/TextureMap]: Texture pm:textures/items/pokeballs/pokeball/ultraball.png with size 18x18 will have visual artifacts at mip level 4, it can only support level 1. Please report to the mod author that the texture should be some multiple of 16x16.
[10:18:15] [main/INFO] [minecraft/TextureMap]: Created: 512x512 textures-atlas
[10:18:18] [main/WARN] [minecraft/ModelBlock]: Unable to resolve texture due to upward reference: #all in minecraft:models/block/cube_all
[10:18:21] [main/WARN] [minecraft/ModelBlock]: Unable to resolve texture due to upward reference: #all in minecraft:models/block/cube_all
[10:18:26] [main/INFO] [FML]: Applying holder lookups
[10:18:26] [main/INFO] [FML]: Holder lookups applied
[10:18:26] [main/INFO] [FML]: Injecting itemstacks
[10:18:26] [main/INFO] [FML]: Itemstack injection complete
[10:18:27] [main/INFO] [FML]: Forge Mod Loader has successfully loaded 5 mods
[10:18:27] [main/WARN] [minecraft/GameSettings]: Skipping bad option: lastServer:
[10:18:27] [main/INFO] [mojang/NarratorWindows]: Narrator library for x64 successfully loaded
[10:18:30] [Realms Notification Availability checker #1/INFO] [mojang/RealmsClient]: Could not authorize you against Realms server: Invalid session id
[10:21:36] [Server thread/INFO] [minecraft/IntegratedServer]: Starting integrated minecraft server version 1.12.2
[10:21:36] [Server thread/INFO] [minecraft/IntegratedServer]: Generating keypair
[10:21:37] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance
[10:21:38] [Server thread/INFO] [FML]: Registry Block: Found a missing id from the world pm:ore_nether
[10:21:38] [Server thread/INFO] [FML]: Registry Block: Found a missing id from the world pm:ore_overworld
[10:21:38] [Server thread/INFO] [FML]: Registry Block: Found a missing id from the world pm:ore_end
[10:21:41] [Server thread/INFO] [FML]: Applying holder lookups
[10:21:41] [Server thread/INFO] [FML]: Holder lookups applied
[10:21:44] [Server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@5cb11b48)
[10:21:48] [Server thread/INFO] [minecraft/AdvancementList]: Loaded 488 advancements
[10:21:48] [Server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@5cb11b48)
[10:21:49] [Server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@5cb11b48)
[10:21:49] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing start region for level 0
[10:21:52] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 0%
[10:21:53] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 16%
[10:21:54] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 34%
[10:21:55] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 50%
[10:21:56] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 67%
[10:21:57] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 85%
[10:21:59] [Server thread/INFO] [FML]: Unloading dimension -1
[10:21:59] [Server thread/INFO] [FML]: Unloading dimension 1
[10:21:59] [Server thread/INFO] [minecraft/IntegratedServer]: Changing view distance to 2, from 10
[10:22:09] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2
[10:22:09] [Netty Server IO #1/INFO] [FML]: Client protocol version 2
[10:22:09] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[10:22:09] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 2398ms behind, skipping 47 tick(s)
[10:22:09] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established
[10:22:09] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[10:22:09] [Server thread/INFO] [minecraft/PlayerList]: Player459[local:E:00bc6c5e] logged in with entity id 197 at (224.7461617830892, 64.0, 213.11517458230804)
[10:22:09] [Server thread/INFO] [minecraft/MinecraftServer]: Player459 joined the game
[10:22:17] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[10:22:25] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/overworld
[10:22:26] [pool-2-thread-1/WARN] [mojang/YggdrasilMinecraftSessionService]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@15ee4109[id=9e4b41fd-b698-3086-96f0-585499a2673a,name=Player459,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
	at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:79) ~[YggdrasilAuthenticationService.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:180) [YggdrasilMinecraftSessionService.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:60) [YggdrasilMinecraftSessionService$1.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:57) [YggdrasilMinecraftSessionService$1.class:?]
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3716) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2424) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2298) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2211) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache.get(LocalCache.java:4154) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4158) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5147) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5153) [guava-21.0.jar:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:170) [YggdrasilMinecraftSessionService.class:?]
	at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3181) [Minecraft.class:?]
	at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [SkinManager$3.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_211]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_211]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_211]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_211]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
[10:22:28] [main/INFO] [minecraft/AdvancementList]: Loaded 2 advancements
[10:22:31] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 2959ms behind, skipping 59 tick(s)
[10:22:32] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[10:22:33] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/overworld
[10:32:00] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[10:32:00] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/overworld

 

And this is what it looks like in game:

 

 

2019-04-26_10.33.13.png

2019-04-26_10.33.20.png

Edited by Thegametutor101
Posted
13 hours ago, V0idWa1k3r said:

This is the method you need to call to bind the texture and you need to do this before rendering the model

It still doesn't work.. Am I doing it correctly?

 

	@Override
	protected boolean bindEntityTexture(P25Pikachu entity) {
		return super.bindEntityTexture(entity);
	}

 

Posted
3 hours ago, V0idWa1k3r said:

I explicitly told you NOT to override the method, but CALL it before rendering the model, yet you decide to override it anyway and not call it

Oh..sorry you didn't say not to override it..but ok i'll change it.

So do I leave it as is and simply remove the Override tag?

Posted (edited)
On 4/27/2019 at 6:17 PM, V0idWa1k3r said:

This is the method you need to call to bind the texture and you need to do this before rendering the model

This means "call the method; that's it".

You were not told to override anything at any point.

 

25 minutes ago, Thegametutor101 said:

So do I leave it as is and simply remove the Override tag?

That would still be overriding the method.

Delete your bindEntityTexture completely.

Call the already existing method before you render the model.

 

Unrelated:

10 hours ago, Thegametutor101 said:

 


	@Override
	protected boolean bindEntityTexture(P25Pikachu entity) {
		return super.bindEntityTexture(entity);
	}

 

This does nothing, as you are basically returning the result from the super method.

The point of overriding is to do something different from its super method.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
2 minutes ago, DavidM said:

This means "call the method; that's it".

You were not told to override anything at any point.

 

That would still be overriding the method.

Delete your bindEntityTexture completely.

Call the already existing method before you render the model.

 

Unrelated:

This does nothing, as you are basically returning the result from the super method.

But that was the already existing method I don't understand what you mean..?

What do I replace it by exactly? 

Could you show me how, please?

Posted

@DavidM

Ok so now am I doing it correctly?

    @Override
    public void doRender(P25Pikachu entity, double x, double y, double z, float entityYaw, float partialTicks) {
    	bindEntityTexture(entity);
    	bindTexture(TEXTURES);
        model.render(entity, 0F, 0F, 0F, 0F, 0F, 1F);
    }

this is in my renderEntity Class..

Posted
On 4/27/2019 at 6:17 AM, V0idWa1k3r said:

This is the method you need to call to bind the texture and you need to do this before rendering the model

@V0idWa1k3r It worked!! Really sorry if I annoyed you..Thank you!

Took me some time to understand but now the model is loading completely and with the correct texture! Thank you!

 

I was wondering if you knew a post that talks about using a .obj model for the entity.. That's my next objective! :)

Again sorry if I was rude before, i really wasn't sure what to do..

 

    @Override
    public void doRender(P25Pikachu entity, double x, double y, double z, float entityYaw, float partialTicks) {
    	GlStateManager.pushMatrix();
		GlStateManager.translate(x, y, z);
		GlStateManager.rotate(180, 1, 0, 0);
        GlStateManager.rotate(entity.rotationPitch, 1, 0, 0);
		GlStateManager.translate(0, -1.5, 0);
		this.bindEntityTexture(entity);
		this.model.render(entity, 0.0F, 0.0F, -0.1F, entity.rotationYaw, entity.rotationPitch, 0.0625F);
		GlStateManager.popMatrix();
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
    }

 

2019-04-30_13.04.42.png

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.