CrucibleMC / Crucible

Crucible, a fork of Thermos, is a CraftBukkit and Forge server implementation for 1.7.10, providing the ability to load both Forge mods and Bukkit plugins alongside each other.
https://discord.gg/jWSTJ4d
GNU General Public License v3.0
184 stars 63 forks source link

Patching failed #47

Closed Ghostlyr closed 2 years ago

Ghostlyr commented 3 years ago
Patching failed: net/minecraft/network/NetHandlerPlayServer.java Cannot find hunk target
  41: Cannot find hunk target @ 0
  42: Cannot find hunk target @ 0
  2/47 failed
  Rejects written to C:\Develop\crucible123\patches\net\minecraft\network\NetHandlerPlayServer.java.patch.rej
++++ REJECTED PATCH 41

             try
             {
-                itemstack = packetbuffer.readItemStackFromBuffer();
+                push = packetbuffer.readItemStackFromBuffer();

-                if (itemstack == null)
+                if (push == null)
                 {
                     return;
                 }

-                if (!ItemWritableBook.func_150930_a(itemstack.getTagCompound()))
+                if (!ItemWritableBook.func_150930_a(push.getTagCompound()))
                 {
                     throw new IOException("Invalid book tag!");
                 }

-                itemstack1 = this.playerEntity.inventory.getCurrentItem();
+                stack = this.playerEntity.inventory.getCurrentItem();

-                if (itemstack1 != null)
+                if (stack != null)
                 {
-                    if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem())
+                    if (push.getItem() == Items.writable_book && push.getItem() == stack.getItem())
                     {
-                        itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
+                        //nouveau = stack.copy();
+                        //ItemWritableBook.shadowUpdate(nouveau, push, false);
+                        //CraftEventFactory.handleEditBookEvent(playerEntity, nouveau); // CraftBukkit
+                        //this.playerEntity.inventory.setInventorySlotContents(this.playerEntity.inventory.currentItem, nouveau);
+                        ItemWritableBook.shadowUpdate(stack, push, false);
+                        CraftEventFactory.handleEditBookEvent(playerEntity, stack); // CraftBukkit
                     }
+                    else
+                    {
+                        throw new RuntimeException("Bogey book-user! Stop using AllUWant");
+                    }

                     return;
                 }
             }
-            catch (Exception exception4)
+            // CraftBukkit start
+            catch (Throwable throwable)
             {
-                logger.error("Couldn\'t handle book info", exception4);
-                return;
+                logger.error("Couldn\'t handle book info", throwable);
+                if (throwable instanceof RuntimeException && !(throwable instanceof IOException))
+                {
+                    this.kickPlayerFromServer(throwable.getMessage());
+                }
+                else
+                {
+                    this.kickPlayerFromServer("Invalid book data!");
+                }
+                // CraftBukkit end
             }
             finally
             {
++++ END PATCH
++++ REJECTED PATCH 42

             try
             {
-                itemstack = packetbuffer.readItemStackFromBuffer();
+                push = packetbuffer.readItemStackFromBuffer();

-                if (itemstack != null)
+                if (push != null)
                 {
-                    if (!ItemEditableBook.validBookTagContents(itemstack.getTagCompound()))
+                    if (!ItemEditableBook.validBookTagContents(push.getTagCompound()))
                     {
                         throw new IOException("Invalid book tag!");
                     }

-                    itemstack1 = this.playerEntity.inventory.getCurrentItem();
+                    stack = this.playerEntity.inventory.getCurrentItem();

-                    if (itemstack1 == null)
+                    if (stack == null)
                     {
                         return;
                     }

-                    if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book)
+                    if (push.getItem() == Items.written_book && stack.getItem() == Items.writable_book)
                     {
-                        itemstack1.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName()));
-                        itemstack1.setTagInfo("title", new NBTTagString(itemstack.getTagCompound().getString("title")));
-                        itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
-                        itemstack1.func_150996_a(Items.written_book);
+                        nouveau = stack.copy();
+                        nouveau.func_150996_a(Items.written_book);
+                        nouveau.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName()));
+                        ItemWritableBook.shadowUpdate(nouveau, push, true);
+                        this.playerEntity.inventory.setInventorySlotContents(this.playerEntity.inventory.currentItem, nouveau);
+                        CraftEventFactory.handleEditBookEvent(playerEntity,nouveau);
                     }

                     return;
                 }
             }
-            catch (Exception exception3)
+            // CraftBukkit start
+            catch (Throwable throwable)
             {
-                logger.error("Couldn\'t sign book", exception3);
-                return;
+                logger.error("Couldn\'t sign book", throwable);
+                if (throwable instanceof RuntimeException && !(throwable instanceof IOException))
+                {
+                    this.kickPlayerFromServer(throwable.getMessage());
+                }
+                else
+                {
+                    this.kickPlayerFromServer("Invalid book data!");
+                }
+                // CraftBukkit end
             }
             finally
             {
++++ END PATCH
juanmuscaria commented 3 years ago

The project is incompatible on windows unfortunately.

Ghostlyr commented 3 years ago

But same on linux:

Patching failed: net/minecraft/network/NetHandlerPlayServer.java Cannot find hunk target
  41: Cannot find hunk target @ 0
  42: Cannot find hunk target @ 0
  2/47 failed
  Rejects written to /home/ghostlyr/Crucible/patches/net/minecraft/network/NetHandlerPlayServer.java.patch.rej

Seems you have another decompiled minecraft sources and we have a differences =\

juanmuscaria commented 3 years ago

Are you using the same project you used on windows? in this case, the same files or a clean clone of the repo? Windows adds some invisible characters that makes the project break.

Ghostlyr commented 3 years ago

Absolutely clean cloned repo from master fork. Also changing EOL git settings on Windows doesn't give effect. Just compare rejected patch and my decompiled source side-by-side:

if ("MC|BEdit".equals(p_147349_1_.func_149559_c()))
        {
            packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()));

            try
            {
                itemstack = packetbuffer.readItemStackFromBuffer();

                if (itemstack != null)
                {
                    if (!ItemWritableBook.func_150930_a(itemstack.getTagCompound()))
                    {
                        throw new IOException("Invalid book tag!");
                    }

                    itemstack1 = this.playerEntity.inventory.getCurrentItem();

                    if (itemstack1 == null)
                    {
                        return;
                    }

                    if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem())
                    {
                        itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
                    }

                    return;
                }
            }
            catch (Exception exception4)
            {
                logger.error("Couldn\'t handle book info", exception4);
                return;
            }
            finally
            {
                packetbuffer.release();
            }

            return;
        }
        else if ("MC|BSign".equals(p_147349_1_.func_149559_c()))
        {
            packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()));

            try
            {
                itemstack = packetbuffer.readItemStackFromBuffer();

                if (itemstack == null)
                {
                    return;
                }

                if (!ItemEditableBook.validBookTagContents(itemstack.getTagCompound()))
                {
                    throw new IOException("Invalid book tag!");
                }

                itemstack1 = this.playerEntity.inventory.getCurrentItem();

                if (itemstack1 != null)
                {
                    if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book)
                    {
                        itemstack1.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName()));
                        itemstack1.setTagInfo("title", new NBTTagString(itemstack.getTagCompound().getString("title")));
                        itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
                        itemstack1.func_150996_a(Items.written_book);
                    }

                    return;
                }
            }
            catch (Exception exception3)
            {
                logger.error("Couldn\'t sign book", exception3);
                return;
            }
            finally
            {
                packetbuffer.release();
            }

            return;
        }

There some inconsistencies.

juanmuscaria commented 3 years ago

What's your environment? I never had that problem before on linux and it builds just fine on my TeamCity https://juanmuscaria.beta.teamcity.com/project/Crucible

Ghostlyr commented 3 years ago

I doubt that this is a POSIX CR LF or environment problem.

Just for unknown reasons I have different decompiled source. Specifically: reverted and shifted if (itemstack1 != null) conditions. So here my fixed patch: https://github.com/Ghostlyr/Crucible/commit/c650eafc189807012880193fc7acdbb53634d2a0

juanmuscaria commented 3 years ago

With your patch version I get that error

Applying Cauldron patches
Patching failed: net/minecraft/network/NetHandlerPlayServer.java Cannot find hunk target
  41: Cannot find hunk target @ 0
  42: Cannot find hunk target @ 0
  2/47 failed
  Rejects written to /home/juan/Área de Trabalho/Pasta sem título/Crucible/patches/net/minecraft/network/NetHandlerPlayServer.java.patch.rej

that's the only patch that breaks for some reason. Either it's an environment problem or some gradle inconsistency because of how old the version is.

EverNife commented 3 years ago

Our default source does not work for me.

We used a custom NetHandlerPlayServer.java since always, so i never bothered to understand and try to fix this issue. (probably the same source as you?)

Your changes fixed the issue on my pc, tried on windows (clean git clone, setup and jar) and worked.

EverNife commented 3 years ago

Before we merge, i will try to understand why the error ocurred in first place.

How have you solved it? I was going to try to just genPatches from our correct version of NetHandlerPlayServer.java, have you just done that?

juanmuscaria commented 3 years ago

Merging that will break TeamCity auto build setup and probably break with my current work in the dev branch. So yeah the only solution is actually finding out why that happens in the first place.

EverNife commented 3 years ago

Tested on Ubuntu, same steps, (clean git clone, setup and jar) and got the error i used to get on Windows.

It has the correct patch:

image

But does not have the correct generated file: image

wohaopa commented 3 years ago

I met this issue, too.Please bear with my poor English I guess it's the library file problem, because I found that the libraries packaged by ./gradlew jar are incomplete, such as server.jar Only a few dozen KB I don't know much about the process of decompiling MCP, but I can be sure that there is a problem with the decompiler source, and the problem is solved by deleting /home/.gradle/ But why can incomplete files be decompiled successfully? I'm not really sure

juanmuscaria commented 3 years ago

Can you test if the issue persists with the build system change and update?

spannerman79 commented 2 years ago

This issue will need to be re-opened or addressed.

In a LXD container

OS:

            .-/+oossssoo+/-.                                                                                                                                                                                                                                                             s
        `:+ssssssssssssssssss+:`           ---------------------
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.3 LTS x86_64
    .ossssssssssssssssssdMMMNysssso.       Kernel: 5.10.60-qnap
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Uptime: 2 days, 4 hours, 31 mins
  +ssssssssshmydMMMMMMMNddddyssssssss+     Packages: 463 (dpkg)
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Shell: bash 5.0.17
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Terminal: /dev/pts/0
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   CPU: AMD Ryzen 7 PRO 1700 (16) @ 3.000GHz
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   Memory: 2458MiB / 15960MiB
ossyNMMMNyMMhsssssssssssssshmmmhssssssso
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
  +sssssssssdmydMMMMMMMMddddyssssssss+
   /ssssssssssshdmNNNNmyNMMMMhssssss/
    .ossssssssssssssssssdMMMNysssso.
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`
            .-/+oossssoo+/-.

git clone -b v5.3 https://github.com/CrucibleMC/Crucible.git - testing to build tag v5.3

 ./gradlew setupCrucible
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.6.4/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing

> Configure project :
Etag download for http://export.mcpbot.bspk.rs/versions.json failed with code 522
[Fatal Error] argo-2.25.pom:3:10: Already seen doctype.
[Fatal Error] argo-2.25.pom:3:10: Already seen doctype.
#################################################
         ForgeGradle 1.2-1.3.3-SNAPSHOT-994b613d
  https://github.com/juanmuscaria/ForgeGradle
#################################################
               Powered by MCP 9.08
             http://modcoderpack.com
         by: Searge, ProfMobius, Fesh0r,
         R4wk, ZeuX, IngisKahn, bspkrs

                  Reissued by:
            juanmuscaria, Aizistral
#################################################

> Task :getAssets
Current status: 5/686   0%
Current status: 29/686   4%
Current status: 53/686   7%
Current status: 91/686   13%
Current status: 132/686   19%
Current status: 185/686   26%
Current status: 251/686   36%
Current status: 306/686   44%
Current status: 364/686   53%
Current status: 420/686   61%
Current status: 474/686   69%
Current status: 510/686   74%
Current status: 553/686   80%
Current status: 597/686   87%
Current status: 641/686   93%
Current status: 686/686   100%
Current status: 686/686   100%
Current status: 686/686   100%
Current status: 686/686   100%
Current status: 686/686   100%
Current status: 686/686   100%
Current status: 686/686   100%
Current status: 686/686   100%

> Task :deobfuscateJar
Applying SpecialSource...
Applying Exceptor...

> Task :forgePatchJar
Injecting fml files
Applying fml patches
Injecting forge files
Applying forge patches
Injecting bukkit files

> Task :cauldronPatchJar
Applying Cauldron patches
Patching failed: net/minecraft/network/NetHandlerPlayServer.java Cannot find hunk target
  42: Cannot find hunk target @ 0
  1/47 failed
  Rejects written to /home/spannerman/Crucible/patches/net/minecraft/network/NetHandlerPlayServer.java.patch.rej

> Task :eclipseCauldron
:eclipse:cauldron:eclipseJdt
:eclipse:cauldron:eclipseProject
:eclipse:cauldron:eclipseClasspath
:eclipse:cauldron:eclipseProject
:eclipse:cauldron:eclipse

> Task :eclipseClean
:eclipse:Clean:eclipseJdt
:eclipse:Clean:eclipseProject
:eclipse:Clean:eclipseProject
:eclipse:Clean:eclipseClasspath
:eclipse:Clean:eclipse

BUILD SUCCESSFUL in 5m 48s
31 actionable tasks: 31 executed

Contents of /home/spannerman/Crucible/patches/net/minecraft/network/NetHandlerPlayServer.java.patch.rej

++++ REJECTED PATCH 42

             try
             {
-                itemstack = packetbuffer.readItemStackFromBuffer();
+                push = packetbuffer.readItemStackFromBuffer();

-                if (itemstack != null)
+                if (push != null)
                 {
-                    if (!ItemEditableBook.validBookTagContents(itemstack.getTagCompound()))
+                    if (!ItemEditableBook.validBookTagContents(push.getTagCompound()))
                     {
                         throw new IOException("Invalid book tag!");
                     }

-                    itemstack1 = this.playerEntity.inventory.getCurrentItem();
+                    stack = this.playerEntity.inventory.getCurrentItem();

-                    if (itemstack1 == null)
+                    if (stack == null)
                     {
                         return;
                     }

-                    if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book)
+                    if (push.getItem() == Items.written_book && stack.getItem() == Items.writable_book)
                     {
-                        itemstack1.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName()));
-                        itemstack1.setTagInfo("title", new NBTTagString(itemstack.getTagCompound().getString("title")));
-                        itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
-                        itemstack1.func_150996_a(Items.written_book);
+                        nouveau = stack.copy();
+                        nouveau.func_150996_a(Items.written_book);
+                        nouveau.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName()));
+                        ItemWritableBook.shadowUpdate(nouveau, push, true);
+                        this.playerEntity.inventory.setInventorySlotContents(this.playerEntity.inventory.currentItem, nouveau);
+                        CraftEventFactory.handleEditBookEvent(playerEntity,nouveau);
                     }

                     return;
                 }
             }
-            catch (Exception exception3)
+            // CraftBukkit start
+            catch (Throwable throwable)
             {
-                logger.error("Couldn\'t sign book", exception3);
-                return;
+                logger.error("Couldn\'t sign book", throwable);
+                if (throwable instanceof RuntimeException && !(throwable instanceof IOException))
+                {
+                    this.kickPlayerFromServer(throwable.getMessage());
+                }
+                else
+                {
+                    this.kickPlayerFromServer("Invalid book data!");
+                }
+                // CraftBukkit end
             }
             finally
             {
++++ END PATCH
EverNife commented 2 years ago

I once was capable of building on Windows, but after that, juan was not able to build his linux.

I will try again on a near future

juanmuscaria commented 2 years ago

That's it, the patching now should be a lot more reliable across systems, there may be some hiccups here and there, but compared to the horrors it was before it should not be a problem