Jump to content

Recommended Posts

Posted

Hello,

 

I am a beginner for programming mods for minecraft but I have some Java basics.

I'm from Germany, so my english is not really good  ;) - I followed this (

) tutorial (it's in german!) and now I have a problem.

The things I did:

 

- downloaded (and installed) the latest Java SDK

- downloaded the latest recommended eclipse (Eclipse Standard/SDK Luna Release 4.4.0)

- downloaded the for 1.7.10 recommended forge sources (http://adf.ly/673885/http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1180/forge-1.7.10-10.13.0.1180-src.zip)

 

- I unzipped the forge sources in a new folder

- I opened a CMD-window (with Admin) and navigated to my new folder wish includes the forge sources

- Executed the following command: gradlew setupDecompWorkspace --refresh-dependencies

- I had no errors up to this step (BUILD SUCCESSFUL), so I continued

- I executed the command: gradlew eclipse (This were successful too)

 

Then I opened eclipse and set the workspace to the "eclipse" folder of the forge sources - but now, I have a problem!

Eclipse say:

"The import net cannot be resolved"

"The import cpw cannot be resolved"

"Mod cannot be resolved to a type"

...

Here a screenshot:

j7vgdu8f.png

 

I think that there is something missing!? Some classes...!?

 

I also found a *.txt file in the .gradlew folder:

"The assetDir is deprecated!  Use runDir instead! runDir set to eclipse/assets/..The assetDir is deprecated!  Use runDir instead! runDir set to eclipse/assets/..

 

****************************

Powered By MCP:           

http://mcp.ocean-labs.de/ 

Searge, ProfMobius, Fesh0r,

R4wk, ZeuX, IngisKahn     

MCP Data version : unknown

****************************

 

FAILURE: Build failed with an exception.

 

* What went wrong:

Task 'runDir' not found in root project 'Minecraft Mod erstellen'.

 

* Try:

Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

 

BUILD FAILED

 

Total time: 10.315 secs"

 

 

Any ideas what to do?

 

Posted

Hmm sorry, I have the same problem, but I did what you said...

This time, I used the latest forge sources and executed the command without the "--refresh-dependencies" (and then I executed gradlew eclipse), but I have the same problem!

Eclipse shows me now 59 errors:

Description	Resource	Path	Location	Type
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\minecraft\net\minecraftforge\forge\1.7.10-10.13.0.1208\forgeSrc-1.7.10-10.13.0.1208.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\minecraft\net\minecraftforge\forge\1.7.10-10.13.0.1208\start'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.2.4\a60a5e993c98c864010053cb901b7eab25306568\gson-2.2.4.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\17.0\9c6ef172e8de35fd8d4d8783e4821e57cdef7445\guava-17.0.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.ibm.icu\icu4j-core-mojang\51.2\63d216a9311cca6be337c1e458e587f99d382b84\icu4j-core-mojang-51.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.mojang\authlib\1.5.16\ef1582b11fd0943d069cdcb72e99008ac209a283\authlib-1.5.16.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.mojang\realms\1.3.1\f78f5a841b1cf9d50c3382acdbeb7d3078e454d6\realms-1.3.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.paulscode\codecjorbis\20101023\c73b5636faf089d9f00e8732a829577de25237ee\codecjorbis-20101023.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.paulscode\codecwav\20101023\12f031cfe88fef5c1dd36c563c0a3a69bd7261da\codecwav-20101023.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.paulscode\libraryjavasound\20101123\5c5e304366f75f9eaa2e8cca546a1fb6109348b3\libraryjavasound-20101123.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.paulscode\librarylwjglopenal\20100824\73e80d0794c39665aec3f62eee88ca91676674ef\librarylwjglopenal-20100824.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.paulscode\soundsystem\20120107\419c05fe9be71f792b2d76cfc9b67f1ed0fec7f6\soundsystem-20120107.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.typesafe.akka\akka-actor_2.11\2.3.3\ed62e9fc709ca0f2ff1a3220daa8b70a2870078e\akka-actor_2.11-2.3.3.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\com.typesafe\config\1.2.1\f771f71fdae3df231bcd54d5ca2d57f0bf93f467\config-1.2.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec\1.9\9ce04e34240f674bc72680f8b843b1457383161a\commons-codec-1.9.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\commons-io\commons-io\2.4\b1b6ea3b7e4aa4f492509a4952029cd8e48019ad\commons-io-2.4.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\commons-logging\commons-logging\1.1.3\f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f\commons-logging-1.1.3.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\io.netty\netty-all\4.0.10.Final\9e50bd52ffe257a0e2cd8d971688d6ce7d174325\netty-all-4.0.10.Final.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\java3d\vecmath\1.3.1\a0ae4f51da409fa0c20fa0ca59e6bbc9413ae71d\vecmath-1.3.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\lzma\lzma\0.0.1\521616dc7487b42bef0e803bd2fa3faf668101d7\lzma-0.0.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput-platform\2.0.5\385ee093e01f587f30ee1c8a2ee7d408fd732e16\jinput-platform-2.0.5-natives-windows.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput-platform\2.0.5\53f9c919f34d2ca9de8c51fc4e1e8282029a9232\jinput-platform-2.0.5-natives-osx.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput-platform\2.0.5\7ff832a6eb9ab6a767f1ade2b548092d0fa64795\jinput-platform-2.0.5-natives-linux.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput\2.0.5\39c7796b469a600f72380316f6b1f11db6c2c7c4\jinput-2.0.5.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.java.jutils\jutils\1.0.0\e12fe1fda814bd348c1579329c86943d2cd3c6a6\jutils-1.0.0.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.minecraft\launchwrapper\1.9\116f2aad5b0c68353ebed66cd463517db6522f7e\launchwrapper-1.9.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.sf.jopt-simple\jopt-simple\4.5\6065cc95c661255349c1d0756657be17c29a4fd3\jopt-simple-4.5.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\net.sf.trove4j\trove4j\3.0.3\42ccaf4761f0dfdfa805c9e340d99a755907e2dd\trove4j-3.0.3.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.8.1\a698750c16740fd5b3871425f4cb3bbaa87f529d\commons-compress-1.8.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-lang3\3.3.2\90a3822c38ec8c996e84c16a3477ef632cbc87a3\commons-lang3-3.3.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.3.3\18f4247ff4572a074444572cee34647c43e7c9c7\httpclient-4.3.3.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.3.2\31fbbff1ddbf98f3aa7377c94d33b0447c646b6e\httpcore-4.3.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.0-beta9\1dd66e68cccd907880229f9e2de1314bd13ff785\log4j-api-2.0-beta9.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-core\2.0-beta9\678861ba1b2e1fccb594bb0ca03114bb05da9695\log4j-core-2.0-beta9.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl_util\2.9.1\290d7ba8a1bd9566f5ddf16ad06f09af5ec9b20e\lwjgl_util-2.9.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl-platform\2.9.1\2d12c83fdfbc04ecabf02c7bc8cc54d034f0daac\lwjgl-platform-2.9.1-natives-osx.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl-platform\2.9.1\4c517eca808522457dd95ee8fc1fbcdbb602efbe\lwjgl-platform-2.9.1-natives-windows.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl-platform\2.9.1\aa9aae879af8eb378e22cfc64db56ec2ca9a44d1\lwjgl-platform-2.9.1-natives-linux.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl\2.9.1\f58c5aabcef0e41718a564be9f8e412fff8db847\lwjgl-2.9.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm-debug-all\4.1\dd6ba5c392d4102458494e29f54f70ac534ec2a2\asm-debug-all-4.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang.modules\scala-parser-combinators_2.11\1.0.1\f05d7345bf5a58924f2837c6c1f4d73a938e1ff0\scala-parser-combinators_2.11-1.0.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang.modules\scala-xml_2.11\1.0.2\820fbca7e524b530fdadc594c39d49a21ea0337e\scala-xml_2.11-1.0.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang.plugins\scala-continuations-library_2.11\1.0.2\e517c53a7e9acd6b1668c5a35eccbaa3bab9aac\scala-continuations-library_2.11-1.0.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang.plugins\scala-continuations-plugin_2.11.1\1.0.2\f361a3283452c57fa30c1ee69448995de23c60f7\scala-continuations-plugin_2.11.1-1.0.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-actors-migration_2.11\1.1.0\dfa8bc42b181d5b9f1a5dd147f8ae308b893eb6f\scala-actors-migration_2.11-1.1.0.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-actors\2.11.0\8ccfb6541de179bb1c4d45cf414acee069b7f78b\scala-actors-2.11.0.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-compiler\2.11.1\56ea2e6c025e0821f28d73ca271218b8dd04926a\scala-compiler-2.11.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-library\2.11.1\e11da23da3eabab9f4777b9220e60d44c1aab6a\scala-library-2.11.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-parser-combinators_2.11\1.0.1\f05d7345bf5a58924f2837c6c1f4d73a938e1ff0\scala-parser-combinators_2.11-1.0.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-reflect\2.11.1\6580347e61cc7f8e802941e7fde40fa83b8badeb\scala-reflect-2.11.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-swing_2.11\1.0.1\b1cdd92bd47b1e1837139c1c53020e86bb9112ae\scala-swing_2.11-1.0.1.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-xml_2.11\1.0.2\7a80ec00aec122fba7cd4e0d4cdd87ff7e4cb6d0\scala-xml_2.11-1.0.2.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\tv.twitch\twitch-external-platform\4.5\18215140f010c05b9f86ef6f0f8871954d2ccebf\twitch-external-platform-4.5-natives-windows-32.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\tv.twitch\twitch-external-platform\4.5\c3cde57891b935d41b6680a9c5e1502eeab76d86\twitch-external-platform-4.5-natives-windows-64.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\tv.twitch\twitch-platform\5.16\39d0c3d363735b4785598e0e7fbf8297c706a9f9\twitch-platform-5.16-natives-windows-64.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\tv.twitch\twitch-platform\5.16\62503ee712766cf77f97252e5902786fd834b8c5\twitch-platform-5.16-natives-osx.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\tv.twitch\twitch-platform\5.16\7c6affe439099806a4f552da14c42f9d643d8b23\twitch-platform-5.16-natives-windows-32.jar'	Minecraft		Build path	Build Path Problem
Project 'Minecraft' is missing required library: 'C:\Users\MYUSERNAME\.gradle\caches\modules-2\files-2.1\tv.twitch\twitch\5.16\1f55f009c61637c10c0acfb8b5ffc600f30044b4\twitch-5.16.jar'	Minecraft		Build path	Build Path Problem
The project cannot be built until build path errors are resolved	Minecraft		Unknown	Java Problem

 

But this makes me confused, because my folder, which contains the forge sources is not on 'C:\Users\MYUSERNAME\.gradle\...', it's here: 'C:\Users\ANOTHERUSERNAME\Desktop\MyMcMod\.gradle\...'

The pathes in the eclipse error messages pointing to my first account on my Windows 8.1 PC, but at this time I am working on my second account... I think i should try all this on my first account now!?

Posted

The solution is soooo simple....

I looked in the folder 'C:\MYUSERNAME\.gradle' and the missing libraries are there!

So, I startet Eclipse with Admin rights - and the missing libraries are there!

 

Thanks for help!

 

Edit: But, when I press "play" it dosen't start - this is because I installed JDK 8, but gradle is'nt compatible with Java 8 (I read somewhere in the internet), so I must "downgrade" to JDK 7

  • 5 years later...
  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.