Jump to content

Recommended Posts

Posted

Hello,

I'm trying to launch my game but when i do i get this error 

The game crashed whilst initializing game Error: java.lang.NoSuchMethodError: net.minecraft.item.ItemStack.getItem()Lnet/minecraft/item/Item;

 

Quote

---- Minecraft Crash Report ----

WARNING: coremods are present:
  IELoadingPlugin (ImmersiveEngineering-core-0.12-98.jar)
  ForgelinPlugin (Forgelin-1.8.4.jar)
  HCASM (HammerLib-1.12.2-12.2.47.jar)
  llibrary (llibrary-1.7.9-1.12.2.jar)
  CoreMod (Aroma1997Core-1.12.2-2.0.0.2.b167.jar)
  TransformerLoader (OpenComputers-MC1.12.2-1.8.3+274990f.jar)
  CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)
  EnderCorePlugin (EnderCore-1.12.2-0.5.78-core.jar)
Contact their authors BEFORE contacting forge

// You should try our sister game, Minceraft!

Time: 2/6/24 5:36 PM
Description: Initializing game

java.lang.NoSuchMethodError: net.minecraft.item.ItemStack.getItem()Lnet/minecraft/item/Item;
    at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
    at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:962)
    at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:987)
    at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1390)
    at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1746)
    at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
    at org.cyclops.commoncapabilities.IngredientComponents.<clinit>(IngredientComponents.java:38)
    at org.cyclops.commoncapabilities.CommonCapabilities.onRegister(CommonCapabilities.java:187)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_33_CommonCapabilities_onRegister_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:857)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:630)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


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

-- Head --
Thread: Client thread
Stacktrace:
    at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
    at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:962)
    at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:987)
    at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1390)
    at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1746)
    at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
    at org.cyclops.commoncapabilities.IngredientComponents.<clinit>(IngredientComponents.java:38)
    at org.cyclops.commoncapabilities.CommonCapabilities.onRegister(CommonCapabilities.java:187)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_33_CommonCapabilities_onRegister_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:857)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:630)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_51, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 584943896 bytes (557 MB) / 2147483648 bytes (2048 MB) up to 6442450944 bytes (6144 MB)
    JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx6G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2860 81 mods loaded, 81 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID                                | Version           | Source                                              | Signature                                |
    |:----- |:--------------------------------- |:----------------- |:--------------------------------------------------- |:---------------------------------------- |
    | LCH   | minecraft                         | 1.12.2            | minecraft.jar                                       | None                                     |
    | LCH   | mcp                               | 9.42              | minecraft.jar                                       | None                                     |
    | LCH   | FML                               | 8.0.99.99         | forge-1.12.2-14.23.5.2860.jar                       | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | LCH   | forge                             | 14.23.5.2860      | forge-1.12.2-14.23.5.2860.jar                       | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | LCH   | opencomputers|core                | 1.8.3             | minecraft.jar                                       | None                                     |
    | LCH   | aroma1997core                     | 2.0.0.2.b167      | Aroma1997Core-1.12.2-2.0.0.2.b167.jar               | dfbfe4c473253d8c5652417689848f650b2cbe32 |
    | LCH   | aroma1997sdimension               | 2.0.0.2.b96       | Aroma1997s-Dimensional-World-1.12.2-2.0.0.2.b96.jar | dfbfe4c473253d8c5652417689848f650b2cbe32 |
    | LCH   | betteradvancements                | 0.1.0.77          | BetterAdvancements-1.12.2-0.1.0.77.jar              | None                                     |
    | LCH   | biomesoplenty                     | 7.0.1.2445        | BiomesOPlenty-1.12.2-7.0.1.2445-universal.jar       | None                                     |
    | LCH   | bookshelf                         | 2.3.590           | Bookshelf-1.12.2-2.3.590.jar                        | d476d1b22b218a10d845928d1665d45fce301b27 |
    | LCH   | codechickenlib                    | 3.2.3.358         | CodeChickenLib-1.12.2-3.2.3.358-universal.jar       | f1850c39b2516232a2108a7bd84d1cb5df93b261 |
    | LCH   | redstoneflux                      | 2.1.1             | RedstoneFlux-1.12-2.1.1.1-universal.jar             | None                                     |
    | LCH   | brandonscore                      | 2.4.20            | BrandonsCore-1.12.2-2.4.20.162-universal.jar        | None                                     |
    | LCH   | ctm                               | MC1.12.2-1.0.2.31 | CTM-MC1.12.2-1.0.2.31.jar                           | None                                     |
    | LCH   | jei                               | 4.16.1.1000       | jei_1.12.2-4.16.1.1000.jar                          | None                                     |
    | LCH   | chisel                            | MC1.12.2-1.0.2.45 | Chisel-MC1.12.2-1.0.2.45.jar                        | None                                     |
    | LCH   | cofhcore                          | 4.6.6             | CoFHCore-1.12.2-4.6.6.1-universal.jar               | None                                     |
    | LCH   | cofhworld                         | 1.4.0             | CoFHWorld-1.12.2-1.4.0.1-universal.jar              | None                                     |
    | LCH   | cyclopscore                       | 1.6.7             | CyclopsCore-1.12.2-1.6.7.jar                        | bd0353b3e8a2810d60dd584e256e364bc3bedd44 |
    | LCH   | commoncapabilities                | 2.4.8             | CommonCapabilities-1.12.2-2.4.8-deobf.jar           | None                                     |
    | LCH   | thermalfoundation                 | 2.6.7             | ThermalFoundation-1.12.2-2.6.7.1-universal.jar      | None                                     |
    | LCH   | draconicevolution                 | 2.3.28            | Draconic-Evolution-1.12.2-2.3.28.354-universal.jar  | None                                     |
    | LCH   | elevatorid                        | 1.3.14            | ElevatorMod-1.12.2-1.3.14.jar                       | None                                     |
    | LCH   | endercore                         | 1.12.2-0.5.78     | EnderCore-1.12.2-0.5.78.jar                         | None                                     |
    | LCH   | thermalexpansion                  | 5.5.7             | ThermalExpansion-1.12.2-5.5.7.1-universal.jar       | None                                     |
    | LCH   | enderio                           | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderiointegrationtic             | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderiobase                       | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderioconduits                   | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderioconduitsappliedenergistics | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | opencomputers                     | 1.8.3             | OpenComputers-MC1.12.2-1.8.3+274990f.jar            | None                                     |
    | LCH   | enderioconduitsopencomputers      | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | refinedstorage                    | 1.6.16            | refinedstorage-1.6.16.jar                           | 57893d5b90a7336e8c63fe1c1e1ce472c3d59578 |
    | LCH   | enderioconduitsrefinedstorage     | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | forestry                          | 5.8.2.422         | forestry_1.12.2-5.8.2.422.jar                       | None                                     |
    | LCH   | enderiointegrationforestry        | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderiointegrationticlate         | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderioinvpanel                   | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderiomachines                   | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | enderiopowertools                 | 5.3.72            | EnderIO-1.12.2-5.3.72.jar                           | None                                     |
    | LCH   | valkyrielib                       | 1.12.2-2.0.20.1   | valkyrielib-1.12.2-2.0.20.1.jar                     | None                                     |
    | LCH   | environmentaltech                 | 1.12.2-2.0.20.1   | environmentaltech-1.12.2-2.0.20.1.jar               | None                                     |
    | LCH   | fastfurnace                       | 1.3.1             | FastFurnace-1.12.2-1.3.1.jar                        | None                                     |
    | LCH   | forgelin                          | 1.8.4             | Forgelin-1.8.4.jar                                  | None                                     |
    | LCH   | gravestone                        | 1.10.3            | gravestone-1.10.3.jar                               | None                                     |
    | LCH   | gunpowderlib                      | 1.12.2-1.1        | GunpowderLib-1.12.2-1.1.jar                         | 4ffa87db52cf086d00ecc4853a929367b1c39b5c |
    | LCH   | hammercore                        | 12.2.47           | HammerLib-1.12.2-12.2.47.jar                        | 9f5e2a811a8332a842b34f6967b7db0ac4f24856 |
    | LCH   | tesla                             | 1.0.63            | Tesla-1.12.2-1.0.63.jar                             | d476d1b22b218a10d845928d1665d45fce301b27 |
    | LCH   | teslacorelib                      | 1.0.18            | tesla-core-lib-1.12.2-1.0.18.jar                    | d476d1b22b218a10d845928d1665d45fce301b27 |
    | LCH   | industrialforegoing               | 1.12.2-1.12.2     | industrialforegoing-1.12.2-1.12.13-237.jar          | None                                     |
    | LCH   | integrateddynamics                | 1.1.11            | IntegratedDynamics-1.12.2-1.1.11.jar                | bd0353b3e8a2810d60dd584e256e364bc3bedd44 |
    | LCH   | integrateddynamicscompat          | 1.0.0             | IntegratedDynamics-1.12.2-1.1.11.jar                | None                                     |
    | LCH   | integratedtunnels                 | 1.6.14            | IntegratedTunnels-1.12.2-1.6.14.jar                 | bd0353b3e8a2810d60dd584e256e364bc3bedd44 |
    | LCH   | integratedtunnelscompat           | 1.0.0             | IntegratedTunnels-1.12.2-1.6.14.jar                 | None                                     |
    | LCH   | mcjtylib_ng                       | 3.5.4             | mcjtylib-1.12-3.5.4.jar                             | None                                     |
    | LCH   | rftools                           | 7.73              | rftools-1.12-7.73.jar                               | None                                     |
    | LCH   | immersiveengineering              | 0.12-98           | ImmersiveEngineering-0.12-98.jar                    | None                                     |
    | LCH   | integrationforegoing              | 1.12.2-1.11       | IntegrationForegoing-1.12.2-1.11.jar                | 4ffa87db52cf086d00ecc4853a929367b1c39b5c |
    | LCH   | ironchest                         | 1.12.2-7.0.67.844 | ironchest-1.12.2-7.0.72.847.jar                     | None                                     |
    | LCH   | journeymap                        | 1.12.2-5.7.1p1    | journeymap-1.12.2-5.7.1p1.jar                       | None                                     |
    | LCH   | jeresources                       | 0.9.3.203         | JustEnoughResources-1.12.2-0.9.3.203.jar            | None                                     |
    | LCH   | llibrary                          | 1.7.9             | llibrary-1.7.9-1.12.2.jar                           | None                                     |
    | LCH   | lostcities                        | 2.0.22            | lostcities-1.12-2.0.22.jar                          | None                                     |
    | LCH   | lostsouls                         | 1.1.4             | lostsouls-1.12-1.1.4.jar                            | None                                     |
    | LCH   | morpheus                          | 1.12.2-3.5.106    | Morpheus-1.12.2-3.5.106.jar                         | None                                     |
    | LCH   | mowziesmobs                       | 1.5.8             | mowziesmobs-1.5.8.jar                               | None                                     |
    | LCH   | reborncore                        | 3.19.5            | RebornCore-1.12.2-3.19.5-universal.jar              | None                                     |
    | LCH   | quantumstorage                    | 4.7.0             | QuantumStorage-1.12-4.7.0.jar                       | None                                     |
    | LCH   | rebornstorage                     | 1.0.0             | RebornStorage-1.12.2-3.3.4.1.jar                    | None                                     |
    | LCH   | rftoolscontrol                    | 2.0.2             | rftoolsctrl-1.12-2.0.2.jar                          | None                                     |
    | LCH   | rftoolsdim                        | 5.71              | rftoolsdim-1.12-5.71.jar                            | None                                     |
    | LCH   | rftoolspower                      | 1.2.0             | rftoolspower-1.12-1.2.0.jar                         | None                                     |
    | LCH   | rftpwroc                          | 0.1               | rftpwr_oc-0.2.jar                                   | None                                     |
    | LCH   | thermaldynamics                   | 2.5.6             | ThermalDynamics-1.12.2-2.5.6.1-universal.jar        | None                                     |
    | LCH   | simplyjetpacks                    | 1.12.2-2.2.20.0   | SimplyJetpacks2-1.12.2-2.2.20.0.jar                 | None                                     |
    | LCH   | solarflux                         | 12.4.11           | SolarFluxReborn-1.12.2-12.4.11.jar                  | 9f5e2a811a8332a842b34f6967b7db0ac4f24856 |
    | LCH   | stg                               | 1.12.2-1.2.3      | stg-1.12.2-1.2.3.jar                                | None                                     |
    | LCH   | thermalcultivation                | 0.3.6             | ThermalCultivation-1.12.2-0.3.6.1-universal.jar     | None                                     |
    | LCH   | thermalinnovation                 | 0.3.6             | ThermalInnovation-1.12.2-0.3.6.1-universal.jar      | None                                     |
    | LCH   | universalmodifiers                | 1.12.2-1.0.16.1   | valkyrielib-1.12.2-2.0.20.1.jar                     | None                                     |
    | LCH   | teslacorelib_registries           | 1.0.18            | tesla-core-lib-1.12.2-1.0.18.jar                    | None                                     |

    Loaded coremods (and transformers): 
IELoadingPlugin (ImmersiveEngineering-core-0.12-98.jar)
  blusunrize.immersiveengineering.common.asm.IEClassTransformer
ForgelinPlugin (Forgelin-1.8.4.jar)
  
HCASM (HammerLib-1.12.2-12.2.47.jar)
  com.zeitheron.hammercore.asm.HammerCoreTransformer
llibrary (llibrary-1.7.9-1.12.2.jar)
  net.ilexiconn.llibrary.server.core.plugin.LLibraryTransformer
  net.ilexiconn.llibrary.server.core.patcher.LLibraryRuntimePatcher
CoreMod (Aroma1997Core-1.12.2-2.0.0.2.b167.jar)
  
TransformerLoader (OpenComputers-MC1.12.2-1.8.3+274990f.jar)
  li.cil.oc.common.asm.ClassTransformer
CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)
  team.chisel.ctm.client.asm.CTMTransformer
EnderCorePlugin (EnderCore-1.12.2-0.5.78-core.jar)
  com.enderio.core.common.transform.EnderCoreTransformer
  com.enderio.core.common.transform.SimpleMixinPatcher
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 546.33' Renderer: 'NVIDIA GeForce RTX 3070/PCIe/SSE2'
    Ender IO: No known problems detected.
    Authlib is : /C:/Users/Ugo/AppData/Roaming/.minecraft/libraries/com/mojang/authlib/1.5.25/authlib-1.5.25.jar

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!You are looking at the diagnostics information, not at the crash.       !!!
    !!!Scroll up until you see the line with '---- Minecraft Crash Report ----'!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    HammerCore Debug Information: 
        Dependent Mods: None.

    RebornCore: 
        Plugin Engine: 0
        RebornCore Version: 3.19.5
        Runtime Debofucsation 1
        Invalid fingerprint detected for RebornCore!
        RenderEngine: 0
    Launched Version: 1.12.2-forge-14.23.5.2860
    LWJGL: 2.9.4
    OpenGL: NVIDIA GeForce RTX 3070/PCIe/SSE2 GL version 4.6.0 NVIDIA 546.33, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: Faithful+64x.zip (incompatible), VisibleOres2.10.zip (incompatible)
    Current Language: Français (France)
    Profiler Position: N/A (disabled)
    CPU: 12x AMD Ryzen 5 2600 Six-Core Processor 

 

Posted (edited)
2 minutes ago, TileEntity said:

Make a test without commoncapabilities

 

I did and it says that i need commoncapabilities 2.4.4 or above for Integrated Dynamics

Edited by karnagee
Posted
16 minutes ago, TileEntity said:

Maybe create a new modpack instance and start with cyclopscore, commoncapabilities and Integrated Dynamics - try different builds until you find a working combination - then add the rest of your mods

I found why it wasnt working i had commonacapabilities in developper version, sorry for bothering and thank you

  • Like 1

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.