Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] addEnchantment() result only visible on reopen inventory


OsHeaven
 Share

Recommended Posts

Hi,

im using the onCreated() method to enchant some Tools and Armor on different  conditions...

some of these conditions are working how expected and the item is already enchanted by taking the item out of the result Slot of the craftingtable...

others dont work like this, i have to close and reopen the inventory first, to see the enchantment and the glowing texture on the item...

what is the case for this behaivor? do i need packethandling? but why not for the other condition?

 

with this, the enchantment is showing up instant:

float moonPhaseFactor = Dimension.MOON_PHASE_FACTORS[world.dimension.getMoonPhase(world.dimension.getWorldTime())];
if (world.getDimension().getType() == DimensionType.OVERWORLD && moonPhaseFactor == 1.0f) {
   stack.addEnchantment(Enchantments.BINDING_CURSE ,1);
}

 

and with this, i Need to reopen the inventory:

BlockPos pos = new BlockPos(player);
if (world.getBiome(pos).hasStructure(Structures.PILLAGER_OUTPOST)) {
   if (Structures.PILLAGER_OUTPOST.isPositionInsideStructure(world, pos)) {
      stack.addEnchantment(Enchantments.PROJECTILE_PROTECTION, 1);
   }
}

 

thx for any hints

Edited by OsHeaven
Link to comment
Share on other sites

Hm... if it were me, I would start by commenting out the code on the BlockPos method, and replacing it with an exact copy of the moonPhaseFactor method. That way, you can narrow it down a bit. Either 1) the error will still exist when creating the moonPhaseFactor item, in which case you know it has to do with how the method is called, or 2) the error will not exist, in which case the error is definitely with your BlockPos method, though I can't see why that would be giving you issues, as it is.

 

Keep us updated.

Link to comment
Share on other sites

11 minutes ago, StitchNChill said:

That way, you can narrow it down a bit

...that's the version that he says works...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

7 minutes ago, Draco18s said:

...that's the version that he says works...

Correct. OP is saying that he has multiple methods in his code, and that some work as expected while others don't. I'm suggesting he takes the working method, inserts it in place of the misbehaving method, and checks the output.

 

If the output is still incorrect even with the working method, the issue is not with the method(s), rather something else with the code.

If the output is correct using the working method, the issue is indeed with the original misbehaving method. However, the 'misbehaving' method looks spot-on to me, which is why I'm making this suggestion.

Edited by StitchNChill
Link to comment
Share on other sites

i found some weird behaivor… if i add an isDaytime() check like this:

float moonPhaseFactor = Dimension.MOON_PHASE_FACTORS[world.dimension.getMoonPhase(world.dimension.getWorldTime())];
if (world.getDimension().getType() == DimensionType.OVERWORLD && moonPhaseFactor == 1.0f && world.isDaytime()) {
   stack.addEnchantment(Enchantments.BINDING_CURSE, 1);
}

 

on daytime: the crafted item Shows the enchantment like expected...

on nighttime: the crafted item Shows the enchantment, BUT after reopen the invontory, the enchantment and the glowing effect is gone

Edited by OsHeaven
Link to comment
Share on other sites

8 minutes ago, OsHeaven said:

on nighttime: the crafted item Shows the enchantment, BUT after reopen the invontory, the enchantment and the glowing effect is gone

This is on the moonPhaseFactor, which was originally the working method, correct? So by what your code says here , because world.isDaytime() returns FALSE, it should never get to the stack.addEnchantment(...) line:

 

8 minutes ago, OsHeaven said:

if (world.getDimension().getType() == DimensionType.OVERWORLD && moonPhaseFactor == 1.0f && world.isDaytime()) {

 

I would insert parentheses to deterministically decclare the order of operations. While your code seems to look fine, there may be something I'm not catching. Just a quick change, maybe it'll solve your issues.

 

((world.getDimension().getType() == DimensionType.OVERWORLD) && (moonPhaseFactor == 1.0f) && (world.isDaytime()))

 

EDIT: there could be a compiler bug that doesn't appropriately perform the order of operations. here is how precedence should occur (https://introcs.cs.princeton.edu/java/11precedence/) but maybe your compiler doesn't want to play nice.

Edited by StitchNChill
Link to comment
Share on other sites

6 minutes ago, StitchNChill said:

This is on the moonPhaseFactor, which was originally the working method, correct? So by what your code says here , because world.isDaytime() returns FALSE, it should never get to the stack.addEnchantment(...) line:

 

 

I would insert parentheses to deterministically decclare the order of operations. While your code seems to look fine, there may be something I'm not catching. Just a quick change, maybe it'll solve your issues.

 


((world.getDimension().getType() == DimensionType.OVERWORLD) && (moonPhaseFactor == 1.0f) && (world.isDaytime()))

 

EDIT: there could be a compiler bug that doesn't appropriately perform the order of operations. here is how precedence should occur (https://introcs.cs.princeton.edu/java/11precedence/) but maybe your compiler doesn't want to play nice.

 

isDaytime() Returns false…. so it shouldnt add the enchantment… yep.. BUT it does…

till reopening the inventory, then its removed...

im working with intellij…i dont think so, that a bug like this exists here

Link to comment
Share on other sites

1 minute ago, OsHeaven said:

isDaytime() Returns false…. so it shouldnt add the enchantment… yep.. BUT it does…

Which is why I'm suggesting you add parentheses to see if it fixes the error. It could be a compiler issue within intellij.

 

2 minutes ago, OsHeaven said:

i dont think so, that a bug like this exists here

I can't help you unless you try.

Link to comment
Share on other sites

Hm.. try outputting each of the values individually and see what happens. See if any of them output as false whenever you execute the method. If you need help on system.out.println, you can read up on it a little first: https://docs.oracle.com/javase/tutorial/essential/io/formatting.html

 

float moonPhaseFactor = Dimension.MOON_PHASE_FACTORS[world.dimension.getMoonPhase(world.dimension.getWorldTime())];

System.out.println("is overworld? " + (world.getDimension().getType() == DimensionType.OVERWORLD));
System.out.println("is moonphasefactor? " + (moonPhaseFactor == 1.0f)); 
System.out.println("is daytime? " + world.isDaytime());

if (world.getDimension().getType() == DimensionType.OVERWORLD && moonPhaseFactor == 1.0f && world.isDaytime()) {
   stack.addEnchantment(Enchantments.BINDING_CURSE, 1);
}
Edited by StitchNChill
Link to comment
Share on other sites

on daytime:

[22:06:34.727] [Client thread/INFO] [minecraft/Biome]: is Daytime:true
[22:06:34.730] [Server thread/INFO] [minecraft/Biome]: is Daytime:true

 

on night, only:

[22:06:52.652] [Client thread/INFO] [minecraft/Biome]: is Daytime:true

 

so, i think its a Server/Client synch issue...

how to synch the Client with the Server, when i take an item from the crafting result Slot?

i dont know anythingabout packethandling, and all documentations are pre 1.14 unfortunately

Edited by OsHeaven
  • Like 1
Link to comment
Share on other sites

59 minutes ago, StitchNChill said:

It could be a compiler issue within intellij.

If an issue ever arises where someone suspects a bug in very popular software vs. their code, I will always assume its "their code" and not the popular software. Are there bugs in Intellij? Probably. But something like this would get noticed and fixed before it ever got released.

 

38 minutes ago, StitchNChill said:

System.out.println("is daytime? " + world.isDaytime());

This was literally the only helpful thing you said in this thread.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

20 minutes ago, diesieben07 said:

The problem is that onCrafting is called on server and client. You'll probably need to do some forced synchronization if the condition is only determinable on the server.

some world.isRemote checks? or @OnlyIn() ? Maybe not...

forced synchronization… exists any Information about that somewhere?

Link to comment
Share on other sites

2 minutes ago, Draco18s said:

This was literally the only helpful thing you said in this thread.

Third time's the charm ?

 

Just now, OsHeaven said:

forced synchronization… exists any Information about that somewhere?

There's some older threads about it floating around. For example, googling something like "force craft synchronization server client forge" I was able to find this. I haven't read it yet, and it looks like it has to do with TileEntitys, so take that with a grain of salt - but maybe it'll help get you on the right path. 

 

Link to comment
Share on other sites

4 minutes ago, StitchNChill said:

Third time's the charm ?

 

There's some older threads about it floating around. For example, googling something like "force craft synchronization server client forge" I was able to find this. I haven't read it yet, and it looks like it has to do with TileEntitys, so take that with a grain of salt - but maybe it'll help get you on the right path. 

 

yeah, ive found some older threads too… it is often not really helpful, if all the used classes and methods are renamed, removed or replaced in 1.14 ^^

but thx

Link to comment
Share on other sites

3 hours ago, OsHeaven said:

yeah, ive found some older threads too… it is often not really helpful, if all the used classes and methods are renamed, removed or replaced in 1.14 ^^

If you need a bit more direction you need to create a custom packet using the SimpleImpl

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

18 hours ago, Animefan8888 said:

If you need a bit more direction you need to create a custom packet using the SimpleImpl

Thx, ive looked at it and some older mod codes… ive a first idea what to do, but ive some Questions now...

what type of package do i have to create? and what data to send? i need to synch the Client.. so the Server data of daytime, respectively the structure data? or the container data?

and it seems IMessage doesnt exists anymore… what type do i have to extends for my custom one? 

Link to comment
Share on other sites

1 hour ago, OsHeaven said:

it seems IMessage doesnt exists anymore… what type do i have to extends for my custom one? 

You don't need to implement or extend anything.

https://github.com/Draco18s/ReasonableRealism/tree/1.14.4/src/main/java/com/draco18s/harderores/network

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

On 8/14/2019 at 11:19 PM, Draco18s said:

thx for showing your Code. i will try to implement something to synch the structures data on Client...

for the isDaytime check, i simply use world.dimension.getWorldTime() == 13000 instead of !isDaytime()… it works on Client as well

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Every time when i close my inventory in search mode the game crashes. i have many mods installed, but it has nothing to do with the mods.   here is the crash report: pastebin
    • I have a problem and that when I open forge it stays loading in the model manager and there it stays until I close the game then the game appears to have ended incorrectly Exit code 1
    • forge-1.16.4-35.1.4-installer.jar will not install. My 11 y/o son has been working on a world for months and all the mods need this specific version. Is there a way to get the missing files and install them manually? Please review this log file and reply with links if possible:   JVM info: Oracle Corporation - 12.0.2 - 12.0.2+10 java.net.preferIPv4Stack=true Found java version 12.0.2 Extracting json Considering minecraft client jar Downloading libraries Considering library net.minecraftforge:forge:1.16.4-35.1.4   File exists: Checksum validated. Considering library org.ow2.asm:asm:7.2   File exists: Checksum validated. Considering library org.ow2.asm:asm-commons:7.2   File exists: Checksum validated. Considering library org.ow2.asm:asm-tree:7.2   File exists: Checksum validated. Considering library org.ow2.asm:asm-util:7.2   File exists: Checksum validated. Considering library org.ow2.asm:asm-analysis:7.2   File exists: Checksum validated. Considering library cpw.mods:modlauncher:8.0.6   File exists: Checksum validated. Considering library cpw.mods:grossjava9hacks:1.3.0   File exists: Checksum validated. Considering library net.minecraftforge:accesstransformers:2.2.0-shadowed   Downloading library from https://maven.creeperhost.net/net/minecraftforge/accesstransformers/2.2.0-shadowed/accesstransformers-2.2.0-shadowed.jar java.io.FileNotFoundException: https://maven.creeperhost.net/net/minecraftforge/accesstransformers/2.2.0-shadowed/accesstransformers-2.2.0-shadowed.jar     at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)     at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)     at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1969)     at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1964)     at java.base/java.security.AccessController.doPrivileged(AccessController.java:552)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1963)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1531)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)     at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:251)     at net.minecraftforge.installer.DownloadUtils.download(DownloadUtils.java:146)     at net.minecraftforge.installer.DownloadUtils.download(DownloadUtils.java:134)     at net.minecraftforge.installer.DownloadUtils.downloadLibrary(DownloadUtils.java:123)     at net.minecraftforge.installer.actions.Action.downloadLibraries(Action.java:79)     at net.minecraftforge.installer.actions.ClientInstall.run(ClientInstall.java:108)     at net.minecraftforge.installer.InstallerPanel.run(InstallerPanel.java:428)     at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:170)     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:143) Caused by: java.io.FileNotFoundException: https://maven.creeperhost.net/net/minecraftforge/accesstransformers/2.2.0-shadowed/accesstransformers-2.2.0-shadowed.jar     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1915)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)     at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)     at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:335)     at net.minecraftforge.installer.DownloadUtils.getConnection(DownloadUtils.java:203)     at net.minecraftforge.installer.DownloadUtils.download(DownloadUtils.java:144)     ... 7 more Considering library net.minecraftforge:eventbus:3.0.5-service   Downloading library from https://maven.creeperhost.net/net/minecraftforge/eventbus/3.0.5-service/eventbus-3.0.5-service.jar java.io.FileNotFoundException: https://maven.creeperhost.net/net/minecraftforge/eventbus/3.0.5-service/eventbus-3.0.5-service.jar     at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)     at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)     at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1969)     at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1964)     at java.base/java.security.AccessController.doPrivileged(AccessController.java:552)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1963)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1531)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)     at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:251)     at net.minecraftforge.installer.DownloadUtils.download(DownloadUtils.java:146)     at net.minecraftforge.installer.DownloadUtils.download(DownloadUtils.java:134)     at net.minecraftforge.installer.DownloadUtils.downloadLibrary(DownloadUtils.java:123)     at net.minecraftforge.installer.actions.Action.downloadLibraries(Action.java:79)     at net.minecraftforge.installer.actions.ClientInstall.run(ClientInstall.java:108)     at net.minecraftforge.installer.InstallerPanel.run(InstallerPanel.java:428)     at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:170)     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:143) Caused by: java.io.FileNotFoundException: https://maven.creeperhost.net/net/minecraftforge/eventbus/3.0.5-service/eventbus-3.0.5-service.jar     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1915)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)     at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)     at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:335)     at net.minecraftforge.installer.DownloadUtils.getConnection(DownloadUtils.java:203)     at net.minecraftforge.installer.DownloadUtils.download(DownloadUtils.java:144)     ... 7 more Considering library net.minecraftforge:forgespi:3.2.0   File exists: Checksum validated. Considering library net.minecraftforge:coremods:3.0.0   File exists: Checksum validated. Considering library net.minecraftforge:unsafe:0.2.0   File exists: Checksum validated. Considering library com.electronwill.night-config:core:3.6.2   File exists: Checksum validated. Considering library com.electronwill.night-config:toml:3.6.2   File exists: Checksum validated. Considering library org.jline:jline:3.12.1   File exists: Checksum validated. Considering library org.apache.maven:maven-artifact:3.6.0   File exists: Checksum validated. Considering library net.jodah:typetools:0.8.1   File exists: Checksum validated. Considering library org.apache.logging.log4j:log4j-api:2.11.2   File exists: Checksum validated. Considering library org.apache.logging.log4j:log4j-core:2.11.2   File exists: Checksum validated. Considering library net.minecrell:terminalconsoleappender:1.2.0   File exists: Checksum validated. Considering library net.sf.jopt-simple:jopt-simple:5.0.4   File exists: Checksum validated. Considering library org.spongepowered:mixin:0.8.2   File exists: Checksum validated. Considering library com.github.jponge:lzma-java:1.3   File exists: Checksum validated. Considering library com.google.code.findbugs:jsr305:3.0.2   File exists: Checksum validated. Considering library com.google.code.gson:gson:2.8.0   File exists: Checksum validated. Considering library com.google.errorprone:error_prone_annotations:2.1.3   File exists: Checksum validated. Considering library com.google.guava:guava:20.0   File exists: Checksum validated. Considering library com.google.guava:guava:25.1-jre   File exists: Checksum validated. Considering library com.google.j2objc:j2objc-annotations:1.1   File exists: Checksum validated. Considering library com.nothome:javaxdelta:2.0.1   File exists: Checksum validated. Considering library commons-io:commons-io:2.4   File exists: Checksum validated. Considering library de.oceanlabs.mcp:mcp_config:1.16.4-20201102.104115@zip   File exists: Checksum validated. Considering library de.siegmar:fastcsv:1.0.2   File exists: Checksum validated. Considering library net.md-5:SpecialSource:1.8.5   File exists: Checksum validated. Considering library net.minecraftforge:binarypatcher:1.0.12   File exists: Checksum validated. Considering library net.minecraftforge:forge:1.16.4-35.1.4:universal   File exists: Checksum validated. Considering library net.minecraftforge:installertools:1.1.11   File exists: Checksum validated. Considering library net.minecraftforge:jarsplitter:1.1.2   File exists: Checksum validated. Considering library net.sf.jopt-simple:jopt-simple:4.9   File exists: Checksum validated. Considering library net.sf.jopt-simple:jopt-simple:5.0.4   File exists: Checksum validated. Considering library net.sf.opencsv:opencsv:2.3   File exists: Checksum validated. Considering library org.checkerframework:checker-qual:2.0.0   File exists: Checksum validated. Considering library org.codehaus.mojo:animal-sniffer-annotations:1.14   File exists: Checksum validated. Considering library org.ow2.asm:asm-analysis:6.1.1   File exists: Checksum validated. Considering library org.ow2.asm:asm-commons:6.1.1   File exists: Checksum validated. Considering library org.ow2.asm:asm-tree:6.1.1   File exists: Checksum validated. Considering library org.ow2.asm:asm:6.1.1   File exists: Checksum validated. Considering library trove:trove:1.0.2   File exists: Checksum validated. These libraries failed to download. Try again. net.minecraftforge:accesstransformers:2.2.0-shadowed net.minecraftforge:eventbus:3.0.5-service
    • Sad, so there isnt any working 1.8 ones not 1.8.9
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.