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

Sandblock - Property Question.


Recommended Posts

1 hour ago, DePhoegon said:

Easier to read, maybe... but it's checking for KB inputs each game tick for that item... which isn't something I believe is helpful.  

Your original code was doing that anyway. And again, premature optimization.

1 hour ago, DePhoegon said:

I'd rather not have 4 kb checks a tick per item hovered over.  (2 each for Shift & Cntrl) 

So instead of 2 checks per key, you have...6 for shift and 8 for control. The two methods do the same thing, except that mine uses a minimum number of checks to arrive at the desired result.

1 hour ago, DePhoegon said:

Because ..  This mod is made with intents of being with other mods, and I will fully admit I do not trust other mods and 'fake players',  I don't know what will happen & haven't gotten my mod to a stage where I can viably test it in a variety pack with matters I'm worried about.

If the object isn't null and conforms to a given type, then you can assign it to a local variable of that type and operate on it as if it was that type.

If any of that is not true, crash and die, because it wasn't valid Java code or a cosmic ray corrupted RAM. You don't design your code to fail safely in this situation because the situation is not safe. FakePlayers are still Players.

1 hour ago, DePhoegon said:

eh, first thing I thought of if I where to be honest...  use null object that can become the item compare to a specific thing.
_-  as well, object work straight out of the gate so I didn't bother to look for better.

Item is still a nullable Type...There's almost no reason to use ever Object as a declared type. The only time it really gets used is when the actual Type doesn't matter and could be anything. You aren't dealing with an anything, you're dealing with ItemStacks and Items.

1 hour ago, DePhoegon said:

"It would never fail in an unexpected way"  ....   Minecraft literally can crash because an event built for it will trigger  on entities that can't be cast into the event for what it was intended for.  A tiny bit of caution wouldn't go amis.

(1) Vanilla doesn't use events, it's a Forge syste.
(2) Forge code won't crash in that case, the modder that Did a Bad causes the crash. Forge does proper type checking and enforces it.
(3) It is not your job to save the game from a modder that Did a Bad.

Quote

 

Don’t catch fatal exceptions; nothing you can do about them anyway, and trying to generally makes it worse.

Fix your code so that it never triggers a boneheaded exception – an “index out of range” exception should never happen in production code.

Always handle exceptions that indicate unexpected exogenous conditions; generally it is not worthwhile or practical to anticipate every possible failure. Just try the operation and be prepared to handle the exception.

 

https://ericlippert.com/2008/09/10/vexing-exceptions/

Other modders doing bad things do not count as exogenous conditions, exogenous is your code checks to see if a file exists, then before it can read it, another program or system deletes it (disc ejected from drive, internet disconnects, system goes into read-only mode). Other modders doing bad things is fatal.

(And Java lacks the non-vexing try-versions of functions the article talks about (eg. int.Parse vs. int.TryToParse), so I removed that point).

Edited by Draco18s

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 post
Share on other sites
Posted (edited)

Just going to reply in order, snip bits..   snip bits drive me bitty.

1. perhaps a bit of premature optimization...  though truth be told, I am done with that 'tooltip section' so I'd not want to leave it loose.

2. perhaps I don't understand the deeper methods of the keyboard hooks, and I assumed things that weren't true.. 
-- worth looking at, but honestly  alot more so for understanding and curiosity sake.

3.  You're just being nit picky and bitchy on the 'Item' object.    I swapped it as soon as you brought it up (and tested it, I've just not had it commited yet, still on altcolor sand texture work atm)
-  to be frank i just didn't know about it or if I did wasn't on my mind.

4.  I wasn't aware it was a 'forge' only thing,  
- Eh...   It wasn't a 'crash', so much as a sudden 'controlled' shutdown of the game.  ( I went to fix that as soon as I found out what did it)
- Not my job to save other moders (in bad code), but it is mine to not leave an odd vulnerability up in the air.

5. Point taken on 'exogenous'  code, It's something I have to work on & is why I'm doing what I'm doing... even if it doesn't seem like it is.

 

I've actually done what I can to ensure the code I write is stable and functional X.x  though  That new method for blockstates for 'stairs'   is still beating me around I need to look into it after I get this texture stuff done. 

 

also.. pretty stairs X}  (heavy decoration theme with mine)  https://1drv.ms/u/s!AhaK1Af-119XnsFu2cYGq670HI4APQ?e=MPQ4If  (Left side is 'sand' & 'red sand' stairs,  and the right is the minecraft smooth sandstone stairs for comparison)   I'm a huge fan of how it looks and underwater build ideas for it.

---------

Also I KNOW,   there are unfinished textures..  that's what I'm working on atm.. X} 

Edited by DePhoegon
Cutting off the Purple/Black box coments.
Link to post
Share on other sites
29 minutes ago, DePhoegon said:

2. perhaps I don't understand the deeper methods of the keyboard hooks, and I assumed things that weren't true.. 
-- worth looking at, but honestly  alot more so for understanding and curiosity sake.

Uh, dude. This has nothing to do with the deeper methods.

Your code had 8 instances of kb.HCtrl and 6 of kb.HShift.image.png.ec5abdb535699be336791fecfa47397b.png

image.png.4f861d7baebff0b6e1c470e025176312.png

There's only 3 scenarios your code needs to consider:

  • No keys pressed
  • Control pressed
  • Shift pressed

Checking control before shift insures that tip2 appears above tip1 and each scenario has two states that have no bearing on the other scenarios: whether or not the given string is present. If the string is empty, draw nothing, it doesn't matter if tip0 is empty and the user is pressing shift, we aren't displaying tip0.

That's literally it.

The only other check you might consider is if you added no tips (i.e. even though shift is pressed, tip1 is empty) then display tip0. But that's just a matter of removing the if(no keys) and replacing it with int oriignalSize = tooltip.size; and then a new last line of if(tooltip.size == oriignalSize && !tip0.isEmpty()) tooltip.add(tip0).

29 minutes ago, DePhoegon said:

- Eh...   It wasn't a 'crash', so much as a sudden 'controlled' shutdown of the game.  ( I went to fix that as soon as I found out what did it)

That is a crash.

Just because Minecraft did some processing before it actually exited doesn't matter. The game still encountered a fatal error and terminated. It was just writing log files, closing streams, and shutting down network channels.

30 minutes ago, DePhoegon said:

5. Point taken on 'exogenous'  code, It's something I have to work on & is why I'm doing what I'm doing... even if it doesn't seem like it is.

No. Exogenous exceptions are external to the program (in this case, Minecraft + all mods).

Quote

Exogenous exceptions are the result of untidy external realities impinging upon your beautiful, crisp program logic.

Any issues that crop up as the result of your code and another mod somehow not playing nice is almost certainly Boneheaded. Who's at fault depends on who made an assumption that wasn't true. If the method you are calling says it returns an object of a given type, you can be assured that it is of that type and has the methods it says it has.

If it doesn't, then someone else made a boneheaded decision to violate the Type contract. Do not assume that someone else might do this, because it isn't your problem to clean up after their mistake if they do. It's a bug, they need to fix it.

If your IDE and compiler aren't telling you to surround code with a try-catch, then do not surround code with a try-catch. Do not assume that variables mysteriously become null between one line and another. Use the most specific type you can when you can.

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 post
Share on other sites

I honestly, view it differently, but I can see how you'd classify what 'external' is.  

What bothered me is I got no errors from Intellij  about what I did casting, or even warning about it.    Though was just tired & used a try catch to get what the exact error was & why, then never cleaned it up. (well till recently)

 

Umm  3Cntrl checks & 2 shift checks if all 3 tooltips are in use (or if shift & cntrl are used).. & 2 for either one.   X.x  umm  perhaps I didn't plan it out & lead it to check each tooltip once, rather than keypressed >.>   How embarrassing.   Umm I think I may ahve got my minimizing backwards >>.>> woops.

 

Don't be such a stick in the mud..    I did mean code to deal with 'Exogenous exceptions'   >.>  i'm sorry for getting that wrong..  Yes yes.. there is a reason I quadriple check anything I post as a 'guide' or informative, and have my anal friend look over for nitpicks.

 

welll forge needs to fix that event handler, or I need to understand way more about it (likely the 2nd one),  though I tend to build a tiny bit of caution, because at times I've found some stupid...  in what I did when I review it for a sanity reason. X}
--- gotten 100x better with naming conventions,  X.X  I'd show my batch code  but  the naming suxxx and it taught me to be cautious with values taken in, because I primarily dealt  a stupid varierty of names on files/folders, and after more then a few days debugging something that broken 5 layers in because some rogue fucking name that caused an issue the 4th  or 8th method/call/w.e, in because some / wasn't handled or some character that didn't bother the others got to it...  ...  putting some sanitation methods inside internal method calls is very close to breathing for myself.  X}

 

ol habits, and I still need to learn naming schemes better...  it's proving easier to read & understand, and I am kinda sad it's taken me that long to use more understadning naming schemes.

Link to post
Share on other sites
18 hours ago, DePhoegon said:

welll forge needs to fix that event handler, or I need to understand way more about it (likely the 2nd one)

Almost certainly the second one. The problem with attack events is that there are multiple types of attacks with varying sources and varying targets. Figure out if the event is relevant, and if so, do things. Don't muddle things up with checking if you can get data out that's relevant, then check if you got data out.

If(!(event.getTarget() instanceof LivingEntity)) return;
if(event.getPlayer() == null) return;
 

Done. Now you can get the target and the player, casting the target into a local variable, and check anything you'd care to check.

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



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I found a strange bug that can be reproduced by steps: Create empty gradle project(without any plugins) (by intellij idea) Create submodule `app` which contain regular forge mdk Create submodule `common` which contain annotation `Mark` and class `ClassFromSubmodule`  Create submodule `annotation-processor` which contain anootation processor which generate simple companion class for each class annotated with `@Mark` Add some code: //Test.java, `app` submodule //annotation processor will generate TestCompanion for it(and he doing it) @Mark public class Test { } //Main.java, `app` submodule @Mod("strange_bug") public class Main { public Main() { try { System.out.println("Main successful: " + Class.forName("hohserg.strange.bug.TestCompanion")); } catch (ClassNotFoundException e) { System.out.println("Main failed: "); e.printStackTrace(); } ClassFromSubmodule.test(); } } //ClassFromSubmodule.java, `common` submodule public class ClassFromSubmodule { public static void test() { try { System.out.println("ClassFromSubmodule successful: " + Class.forName("hohserg.strange.bug.TestCompanion")); } catch (Throwable e) { System.out.println("ClassFromSubmodule failed: "); e.printStackTrace(); } } } Run `gradle :app:genIntellijRuns` Try run client Got follow log (time mark removed): [modloading-worker-0/INFO] [STDOUT/]: [hohserg.strange.bug.Main:<init>:9]: Main successful: class hohserg.strange.bug.TestCompanion [modloading-worker-0/INFO] [STDOUT/]: [hohserg.strange.bug.ClassFromSubmodule:test:8]: ClassFromSubmodule failed: [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: java.lang.ClassNotFoundException: hohserg.strange.bug.TestCompanion [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.net.URLClassLoader.findClass(URLClassLoader.java:382) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.lang.Class.forName0(Native Method) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.lang.Class.forName(Class.java:264) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at hohserg.strange.bug.ClassFromSubmodule.test(ClassFromSubmodule.java:6) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at hohserg.strange.bug.Main.<init>(Main.java:14) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.lang.Class.newInstance(Class.java:442) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1640) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [modloading-worker-0/INFO] [STDERR/]: [hohserg.strange.bug.ClassFromSubmodule:test:9]: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) So, class which generated by annotation processor is accessible from Main class(main class of mod) and isn't accessible from class from submodule. Bug is preserved in built jar of mod if it's added as dependency to another mdk project. Bug isn't preserved in built jar of mod if it's running at regular game client. I checked, it's bug does not appears if `app` submodule is simply java application (without mdk) I checked some other cases and resultative limits of bug: Attempt to access to class which generated by annotation processor by `Class.forName` from class from other submodule in dev workspace perform `ClassNotFoundException`  Running game with `.\StrangeBugRoot\gradlew.bat --project-dir ./StrangeBugRoot/ :app:runClient` does not produce bug. Full source code: https://github.com/hohserg1/StrangeBug
    • Depends on your needs. Why do you need the data on the client?
    • Looks like it works now, thanks  
    • Or PlayerLoggedIn is fine too?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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