#help-development
1 messages · Page 965 of 1
will
How do I have multiple version support with the remapped NMS? I am currently doing this in my build.gradle to get the remapped NMS, however this only supports 1 version, and since it is remapped on any other version it doesnt work. Is there out of the box support, or am I out of luck?:
compileOnly 'org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:remapped-mojang'
Most of the time people opt for multi-module projects when supporting multiple NMS versions
You need to build every single version using BuildTools, then create a multi-module project, create one module for every version,
in your core you shade all modules in, detect the server version, and load the implementation for that version or throw an exception
if there is none.
Would that look like this?
├── versions
| ├── V1_20_4
| | ├── src
| | └── build.gradle
| └── V1_20_3
| ├── src
| └── build.gradle
├── common
| ├── src
| └── build.gradle
├── build.gradle
└── settings.gradle
Yeah pretty much
Sure, if you have the proper gradle knowledge for this
You'd need a build gradle in the versions sub folder though if you wanted to maximize gradle
so this alone should already create the folder right?
because I tried it and it didnt
No
I dont, but I am gonna figure it out 👍
You need to call mkdir/mkdirs
A File is an in-memory facade for IO methods.
If you dont call methods on this, then there is nothing happening on your storage medium.
java nio >>
But what’s the memory overhead of a Path vs a File!!!!111
Path is slightly more iirc
I use File, because Spigot uses it 😄
so this then?
File directory = new File(Main.getPlugin().getDataFolder(), "plots");
if (!directory.exists()) {
System.out.println("testtt");
directory.mkdir();
}
I always convert file to path xD
its still doesnt work 😦
I just removed it for now, to just get the create folder thing working
public PlotHandler() {
File directory = new File(Main.getPlugin().getDataFolder(), "plots");
if (!directory.exists()) {
directory.mkdir();
}
}
thats the whole code rn
is your parent dir exists?
yeah thats where the plugin is no?
okayy so this works: if (!Main.getPlugin().getDataFolder().exists()) Main.getPlugin().getDataFolder().mkdir();
but this doesnt, why?
if (!Main.getPlugin().getDataFolder().exists()) directory.mkdir();
dont need to check for your parent dir, just call .mkdirs
thank you, it was the s behind the mkdir all the time, works now thx
When you wanna ask why your shit is breaking, but you wrote it
people still using notepad++
I just found the stupidest shit
ever
like holy shit
Woops
And im wondering, why its only assigning using the same location for both of em
extract common code
tbh, only real improvement you can make there is using an elseif
tahts true
if (p1 == null) {
forcePoint(location, Point.ONE);
} else if (p2 == null) {
forcePoint(location, Point.TWO);
}
return this;
That's about it ¯_(ツ)_/¯
I have so many questions
Why is it only getting called once?
and why is it re-using the coordinate
your p1 is null forcePoint then return
Quite litteraly, the function generatePoint is only being called once
how do i calc a 2d circle or 3d ball with blocks?
sin and cos and plonk that into setBlock and you're done
i wasnt paying attention when sin and cos was a topic class 😔
nooo
it only really started making sense to me when I saw that image haha
yeah
but you can just do it multiple times with decreasing radii
so can you show me a simple impl, i get was sin and cos does but im not sure what number is responsible to this point left or right
https://hastebin.skyra.pw/acutagocen.ts
does anyone have an idea why my eventhandler isn't triggering? It does open the inventory, but the inventoryClick event seemingly never triggers
nothing in the console eitehr
make it public
method needs to be public
and i hope you have registered your listener
Hey, so I have this method to get a random object from a collection, but the method is flawed because when the total chances exceed 100 the first methods in the collection have a higher chance, and when the chances don't up to 100 there is a chance the method returns null (which I don't want).
I think the solution is to do math to increase or decrease the numbers so the total still adds up to 100, but idk how I would even do this or if there isn't a better way to do this. Can someone help me with this?
public Object chooseRandomObject() {
double random = Math.random() * 101;
for (Object object : myObjects) {
if (random <= object.getChance) { //chance = int 0-100
return object;
}
}
return null;
}```
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void inventoryClose(InventoryCloseEvent e) {
HandlerList.unregisterAll(this);
}
peepostare
something similar has worked wonders
I think it's pretty sleek, when it works of course
bruh, the close event is called when I open the inventory
what the hell
yeah well that's preventing it from working due to how inventories work
ugh, I guess I'll have to catch the first inventory close manually
Hello, how to disable the movement of an Entity ?
bungeeCord has similar logic to bukkit api?
.setai false
i can listen events
with #setAi, they can't be pushed by players
do u have mythic mobs
I just want them to be static
yes
Make your pv field private and final and use a more descriptive name for it.
Define your constructor as public
Increase the visibility of your EventHandler methods to public as well.
Spigots event system uses reflections to invoke those methods and there are tests
suggesting that lower method visibility decreases performance before JIT optimizes them.
Dont let a Listener self-register. Constructors should exclusively used to initialize the fields of an object
without any side effects.
Dont use underscores as prefixes for fields.
Define your fields as private (eg the _items field), and use getters/setters for the appropriate visibility.
Dont use abbreviations for variables like e or m. Importance of choosing descriptive variable names is often underestimated.
You should prevent (un)registering Listeners during runtime. Rebaking the handler list can get quite expensive.
Chill out this isn't #1100941063058894868
AH that still exists
I'm pretty sure you can use java.util.Random.
Random rand = new Random();
// Random number beetwen 1 and 100
int randomNum = rand.nextInt(1,100);
yeah but I want to choose a random object from the collection using the object's int chance without having to make sure the total chance equals 100
how do i lower heart particles when you deal alot of damage
I don't get what's your problem here
?
You mean from the texture pack
or?
THe crit particles
It never shows hearts?
dms
Texture pack or A plugin making them
idk, it's vanilla
none of this should be in the constructor
Turn off your texture packs and try agian
same thing
Ver?
1.20.4
lets say I have a list of objects with chances. Object: Chance
A: 25
B: 25
C: 50
This would work fine, because my method generates a random number from 0-100 and if the number is less than the chance it chooses that (I just realized this gives priority to objects early in the list so its even more flawed than I thought...)```
A: 100
B: 100
This would always choose A, while it should be a 50/50 between A and B```
A: 10
B: 40
This would give a 50% chance for the method to return null while I need it to always return something.```
so I need to normalize the chances so it adds up to 100, and stop giving priority to numbers early in the list
but idk how
I'd say the total weight should not always be 100 but rather the sum of all individual weights
Other than that I have nothing to add, I haven't done weighted random in a while
use a sword
im dealing like 10000 dmg in that message
i want to lower the heart particles
it can be wayy higher
hi , how does Annonation work?
lets say can it work like this ?
i have a main user class :
with sub classes in it :
public class User ..
@LoadUser // this will execute a method from another class to load the user
privite UserStats stats;
is this possible?
It seems like you get more hearts the more damage you deal, it also looks clientbount so you would probably have to mess with packets
Or if its server side you're gna have to cancle a packet
oof
In what language
Java
Look at ms ss soemthing like this?
Dont work much with annotations, gonna have to get somebody else to answer xD
yes it's possible
But basically you want an annotation to load the userdata?
public class User{
here is an annonation :
@LoadUser(UserStats.class)
privite UserStats userstats
}
that's how the EventHandler annotation works for example
so this way i can load the data directly from the user when he join , or he needs it can i ?
Annotations are quite powerful
I wish it was easier to work with them at compile time though
Gotta read into em, found em a bit to annoying and complicated xD
can you give me a tutorial page or smth?
or docs on how to do it?
I litteraly just pulled that up and was abt to send
Digital Ocean usually has decent explanations + tutorials aswell
Annotation-based anything is fun to create because you get to use reflection
I created this method with the help of ChatGPT, and this would probably work but I'm not sure if it will be a problem if I end up creating thousands of new objects to put in the list
public Object chooseRandomObject() {
List<Object> list = new ArrayList<>();
for (Object object : myObjects) {
for (int i = 0; i < object.getChance; i++) {
list.add(object.clone);
}
}
return list.get(new Random().nextInt(list.size() - 1));
}```
1 sec I'll take a look at how I do weighted
thanks
What type is myObjects
Most likely an array of Objects
Just whatever custom object I want to use, in this case I'm using it to get a random Attack object to use for a boss
?
Nvm I don't seem to do weighted random at all in this project lol, thought I did
is there a gui builder app or whatever that turns your gui into spigot code
that'd be really cool
Weighted randoms can be achieved with a NavigableMap or a RangeMap from guava
oh you meant type not object, I'll probably use List or Set
eh, it's fine. I know about those underscores but I wanted to mark it as obviously different. I have a class with a static list of instances of itself, so yeah I just wanted to make that clear.
The self-registering part isn't too wrong imo. The class only works when registered, so I think that should be part of the constructor (also it's very compact)
The private and whatnot stuff could be added of course, but I don't really care about any access modifiers here and I think they just clutter up the code a bunch
Do you want certain abilities to have a higher chance of being selected? Or just a random element from a List.
Certain abilities a higher chance
Then you need weighted
Yep, let me try to explain the idea of a weighted random.
Isn't it just like
Add entries at a given weight, roll a number between 0-weight and get the top entry
Hey guys, I am a bit puzzled by my custom item behavior and wonder if anybody can help me out. Here is the handler code.
https://paste.md-5.net/vayosiyehe.cs
Where I check if the item is an interactable block and return early if that is the case, seems to work fine for chests and crafting tables, but other things like jukeboxes, cauldrons, etc still "use" the item. Am I missing something here?
?paste
In essence you have a range of numbers as a key, and a total value which is the sum of all keys.
Eg you have 3 objects:
X -> Weight = 5
Y -> Weight = 10
Z -> Weight = 10
Then your keys will have the following distribution:
| 0-4 | 5-14 | 15-24 |
Meaning your top is 5 + 10 + 10 = 25 and your bottom is 0
You now roll a random number between 0 inclusive and 25 exclusive.
This Will land anywhere in the distribution:
Eg you rolled an 11:
↓
| 0-4 | 5-14 | 15-24 |
Which is in the second range. Meaning you select Y in this case.
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK)
return;
Oh
hm
yea
wait
I think I understand, but how would I turn X = 5, Y = 10, Z = 10 into | 0-4 | 5-14 | 15-24 |
How is the item "used" on them
So in this context, its a custom item where the base item being used is an ender pearl
When I right click the cauldron or the jukebox, the ender pearl just gets thrown as normal
rather than using the custom logic
Great idea
I could give you a simple implementation if you want. Or explain how to implement it using a RangeMap
the problem there is
I want to be able to interact with chests and stuff like normal when the item is being held
Whichever works for you please
which chests and stuff DO work, but something seems to be different about jukeboxes and cauldrons
Alright ill write something simple. One minute.
So the pearl gets thrown when you rightclick a Jukebox?
yup, thats right. But when right clicking a chest it opens the custom inventory as expected
?paste
I dont think im quite understading the final Goal?
You want an enderpearl, to not be thrown at all, but when you click a chest withit, it still opens the chest normally?
I want an ender pearl that will open the custom inventory in all cases except when a player is looking at an interactable block, in which case it will NOT throw the pearl but interact with the block
I'm not sure if its even possible
I do notice other "interactable" items in the base game do not trigger when right clicking the jukebox
https://paste.md-5.net/wutixevico.cpp
Example usage:
WeightedMap<ItemStack> weightedMap = new WeightedMap<>();
weightedMap.add(new ItemStack(Material.DIAMOND), 5);
weightedMap.add(new ItemStack(Material.IRON_INGOT), 10);
weightedMap.add(new ItemStack(Material.GOLD_INGOT), 20);
ItemStack randomItem = weightedMap.selectRandom();
since you can remove water etc
or cauldron, so it must be possible
just add a check
if its cauldron, or something that doesnt open an ivnetory, but is iteractable, cancel it
Hmm see originally that is how I was handling it, I was checking for individual block ids
But then people keep finding new ones, cauldron, fence posts, etc
and the list is getting BIG lol
Oh wow I didn't expect it to be that simple, thank you 🙏
Do I need to order it from lowest to highest or will the weightedMap do that for me?
Just throw them in with your weight. Order is irrelevant
@EventHandler
private void onRightClick(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
ItemStack item = event.getItem();
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK)
return;
if (item == null || !itemManager.isEnderBag(item))
return;
if (player.hasPermission("enderbag.use")) {
Block clickedBlock = event.getClickedBlock();
if (clickedBlock != null) {
Material mat = clickedBlock.getType();
if(!allowedBlocks.contains(mat)) return;
}
event.setCancelled(true);
itemManager.openInventory(player);
} else {
player.sendMessage(String.format("§cYou do not have permission to use the %s", config.itemName));
}
}
@trail lintel
Then make an Arraylist, with the blocks that do open inventories
Yeah thats not a bad idea, just maintain a big ol list of allowed blocks
which should be alot less
That might just be the solution ill go with =]
Maybe Set would be (negligibly) more performant?
What am i reading 
dw
I have the navigablemap and the rangemap but not the weightedmap
that's custom class
or should I use one of these
WeightedMap is the class ive written and pasted...
Oh I thought the link was the same as the code you sent in here 🤦
Yes. I always post codeblocks, links to paste and then i do a twitter post of the code for good measure.
Smile you're almost at 50k messages
I mean a function like
#.getAttachedInventory()
or
#.hasAttachedInventory()
would be pretty useful

That's why it looked so simple xd, cause you did all the math in the background. Thanks again
Would you mind showing your isEnderBag method?
For sure =]
as the matter of fact, would a github link be better?
for the whole code
Whatever works for you
and heres the handler in question https://github.com/mries92/EnderBag/blob/main/EnderBag/src/main/java/org/mries/enderbag/event/EventListener.java#L29
Alright looks fine. PDC is a good choice.
Btw i would probably make this a bit more expandable.
Your value in the PDC currently has no actual meaning besides 'existing'.
Its probably a good idea to give it some meaning. For example you could create an enum for your custom items:
public enum CustomItemType {
ENDER_BAG,
FIRE_WAND,
WHATEVER,
NONE
}
And then rewrite your
public boolean isEnderBag(ItemStack stack)
method to
public CustomItemType getCustomItemType(ItemStack stack)
which then returns either one of your types or CustomItemType.NONE if its none of your custom items.
Then store your CustomItemType in a pdc key like itemtype : "ENDER_BAG"
This lets you be a bit more dynamic. Otherwise you would have to create a new isXYZ() method for every custom item.
Ohh yeah thats a good idea. I had been meaning to revisit that logic to make it a bit more extensible.
Hmm, testing it with just a base ender eye I notice the behavior is to open chests and craftin tables, then to use the item when you try to interact with cauldrons etc
I think maybe this might not just be possible with using the ender eye as the base item, I can cancel the event but that prevents interaction with proper blocks as well
can't you check whether it's with a proper block or not
I suppose I could do that yeah, it seems weird to have to manually maintian a list of blocks that should or should not work though
But maybe when you doing something like this a little bit of jenk is inevitable
what time is it?
raydan
i need the current time
?
18:39
thanks raydan i appreciate it
Sometimes simple answer is probably best, I think I will just switch it to use a base item that doesn't have an interact event =]
An emerald seems like a good compromise for people without the texture pack
what's the path for plugin.getConfig() or saveDefaultConfig is it just plugins/<pluginname>/config.yml?
thanks
<plugin-folder>/<plugin-name>/config.yml
server owners can actually change the plugin folder iirc so that could deviate from plugins
did spigot disable loading jars at runtime?
eh nobody likes server owners anyway
well thanks!
oh also 🤓 if you're on windows its actually <plugin-folder\<plugin-name>\config.yml
java shouldn't care about that
and even if it did, I don't care if it doesn't run on windows haha
if you're running a server on windows you're not allowed near a computer
wow what a savage
i run windows 7 home pro on all my servers
at least windows 7 but still I will end you one day
I love how they put ads into the terminal
I run arch on my server, and it just about works becaues I'm using docker for everything haha
ubuntu server, how crazy do you think i am
nvm, i'm dumb, wrong path
ugh do I need to add anything to my maven config to make it include the config.yml into the jar? I created the file and it's not adding it
where is it
right next to plugin.yml
run a clean package
anyone good With Annonation can tell me if this is possible?
maybe do @LoadCustomUser(UserClass.class)?
simple yes or no xD can be good :p
idk if what iam trying to do is even possible
I haven't worked with annotations yet, just hoped it'd help you. I might need to work on some though because manually configuring config files is ugly and annoying
yeah i had to make my own config lib ...
i can help you with that if you need help 🙂
annotations by themselves do nothing its up to you to process them with reflection
it support any primitive type
i just don't know how to do that yet :p , that's why iam asking
if i can make a annonation then use them in the way i asked
you reflect it by getting the annotation on whatever element
and then run the code?
yes you can do anything with annotations if your processor is good enough
oh so it take some cpu usage?
should i be good with my current system or use annonation to load the other data of the user?
well yeah annotations are just metadata
that aside any computation takes CPU usage
you can't compute without a CPU
my current system :
it load the data when a user join
my idea was to have a annonation above this 2 classes
so i can load the user data :p
real coders load configs on the main thread
that just seems like a horrible idea why not just load the data upon initialization
i don't understand your point?
so just load them when a user join ?
because it doesn't scale?
how will an annotation help you here?
I'm just confused how an annotation helps here, sure loading everything doesn't scale but what are the annotations goal then
seems like a hack in part to something that could just be designed better
iam just seeing all options , not sticking to only one of loading
you can actually do this though, you'd have to consider if you'd want a preprocessor, this writes bytecode at compile time to transform those annotations into code or on startup a reflective scan all fields of every class in your class loader which then has some of registration process
what you have to consider is, is it even worth it or is it an over-engineered mess in my opinion it will become the latter
yeah thanks , i will not consider make this , it seems complicated and waste of resources of cpu ..
I am trying to implement a multi module gradle system, and currently I am running the build script, and then in my gradle.settings I include each of the modules, which each have a shadow jar task which is tasks.build.dependsOn(shadowJar). The finished jar is 1 kb and has nothing in it, and it compiles a bunch of individual jars for each of the modules. How do I make one that is all of them combined?
build.gradle = https://paste.helpch.at/raw/wefataxuja
If it's similar to the maven multi module system, then you need to create a module that has all of the other modules.
compileOnly != implementation
You need to make a dependencies block in your root module with all the modules as sub projects
its better than the maven system imho. you can do much more with it
dependencies {
implementation project(":api")
...
}
So shadowjar can go over and shade everything
Ah, that makes sense
I also wouldn't shade lombok
does anyone know if you can just get a list of all items in a specific category with the yaml config handler? Currently I have to maintain two lists, which I can get with "getStringList", because I can't figure out how to just get all keys in a category, and that's ugly
e.g.
foo:
bar: a
baz: b
cruz: c
and then get everything inside foo
foo is a section with 3 strings
so I just getStringList?
That's not a string list
ConfigurationSection fooSection = config.getConfigurationSection("foo");
for(String key : fooSection.getKeys(false)) {
String value = fooSection.getString(key);
}
Does spigot by itself include it?
You'd have to iterate over the section using #getConfigurationSection.getKeys(false)
getKeys, taht's what I've been searching for, thanks!
No, it's mostly compiler-level, you shouldn't shade it
A string list in yaml is as follows.
section: "String"
section2:
- "This is a list"
- "of strings that"
- "can be grabbed using"
- "#getStringList()"
yes
@Override
public void onEnable() {
PluginManager pm = getServer().getPluginManager();
this.pdfFile = getDescription();
basicUtils.setSuffix("[Minecraft.COM] ");
// init command
this.getCommand("say").setExecutor(new Say());
// init listeners
this.getServer().getPluginManager().registerEvents(new PlayerJoin(), this);
this.getServer().getPluginManager().registerEvents(new PlayerLeave(), this);
this.getLogger()
.info(this.pdfFile.getName() + " - Version " + this.pdfFile.getVersion() + " - has been enabled!");
try {
runServer();
this.getLogger().info(basicUtils.getSuffix()+"WEBSITE RUNNING");
} catch (Exception e) {
this.getLogger().info(basicUtils.getSuffix()+"WEBSITE FAILED THROWING ERROR NOW : \n "+e);
}
new BukkitRunnable() {
@Override
public void run() {
msg.addFields("Online",players+"");
try {
setMessage(msg.getMessage());
System.out.println(msg.getMessage());
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}.runTaskTimer(this, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
}```
when my server starts completly my server logging stops
I'd really recommend making a codec
Maybe it isn't a good idea to do IO on the main thread
Make a new thread or use an executor
?executor
There's no guide for that, this is core java
my b
Executor executor = anExecutor;
executor.execute(new RunnableTask1()); so id put this instead?
nvm this exists.runTaskAsynchronously
Is there a simple way to delay execution of the next line(s) until after a void method returns or ends without changing the parameters?
I can do it by returning a boolean and just putting the method in an ifstatement and execute the code for true and false, or put a Runnable in the parameters but I kinda don't want to change the parameters or the return type, is this possible?
method() -> {
});```
or does java already go through the entire method until it goes to the next line unless it's async
i'm tripping
Sounds like futures
guess i was tripping https://stackoverflow.com/questions/19644054/how-does-java-read-code
I was confused cause sometimes it didn't wait for the method above to complete but that was just when creating threads 💀
a
those are the id and ids printed
why is giving error when trying to remove id from ids?
Show error
yea mb
Isn't that going to try and remove index 2
Which is out of bounds for a list with size 2
oh
Is it only possible to use remove for its index?
if the object is a number
or could i parse it to string?
No idea how it works in that case tbh
I tried using set but i need to grab a value from it so didn't work
You probably need to pass it as the wrapper type
Yeah i think you're right
he is
some languages or frameworks have an erase method that takes in an object and removes the first occurrence from the list
then ids.remove(id-1);
or is id not an index but a key that should stay the same
i don't want to remove like that, as it could be in an order i wouldn't want
oh wait i see the issue
Java does have this
classic java uses overloads
uuh
you can probably try to parse it to string like you said
this is the problem
which is effectively a wrapper of sorts
your object is an integer
yes
so you can't control which one it uses
yeah java didnt think this far ahead I guess..
even though a list of ints is the like the most basic programmer example for learning arrays haha
I mean, that would work
yeah
what are the ways to make a gui
theres actionbar
the sidebar??
the bossbar?
are there other options
/ways to render items
Inventories (like a large chest)
oh right
Ig I mean during gameplay
and i assume u can't show that while the player is in control
So you want text, items or entities to show while you can still move?
or which one
im pretty sure its not super possible but yeah
so thats what im trying rn but I cant get it to look right
it doesn't move with the camera bob
Camera bob is unfortunately a client side thing.
yeah
im just trying to understand all my options
basically I want the player to be able to see the last 3 foods they've eaten
Resource pack allowed?
🥩
Shader magic to the rescue
yes
I was just thinking action bar and fonts
idk much about shaders
You could have an invisible armorstand holding the food/having it on their head. But that's probably similar to display entities
yep
Might as well just use the display entities.
They are really just an improved armorstand.
Tbf I think it's either a pack or display entities @proven musk
a pack?
resourcepack
I think you could achieve that with a resource pack if I'm not mistaken
how
Display entities would also be an option
And a fun one at that
they aren't unless u can fix display bob
and lighting
what are the capabilities of shaders
Isn't lightning handled automatically for those things?
Yes
Pretty much infinite as long as you can write it
how do they work
You can get text displays to work resonably well, idk about the other ones
and what would the best way to do it for this method
learning them is the hardest part
can I have a shader that renders a specific item display but makes sure the verteices are locked to the camera view?
True 😮💨
if its anything like hlsl I could probably handle it
ive written shaders before for games
I'm still wondering how that works to this day.
they aren't walking around tho
thats how it works
Text display on the player with a super high Z offset
no maid skin?
It also sticks to their screen when the move right?
mhm
So it is passengers?
But view bobbing does make it look a bit weird
yes
Hmm, I wonder why we couldn't remove them for that one person who had a similar issue a while back.
if I can get it to render on top of everything else it work work...
How do you set the offset?
Is bobbing a packet that can be manipulated?
translation
I need to mess around with them some more.
So much potential with them.
damn that looks cool
item displays dont on their own I dont think
but again shaders might do it
idk anything about them tho
does anybody have knowledge or resources
hows it so smooth
is it teleported every tick?
It's a passenger
thats how im doing it
ok
I get u could make it smoother with core shaders tho
yes
also yeah I want to use the action bar for other things
is that why it turns dark when looking at water? cause the text is underwater
mhm
it would look worse on land
since text displays dont looks the same even if they show through blocks
Yea, text has that property, but I don't know about display entities.
sadly only text display has the see through option
What issue does placing it that far solve? cause now you get the layering issues
Now, you could maybe do some shader stuff with the gui elements.
Like, render a character that translates to an image sprite of the item you want
Makes it follow the camera better
Oooo
ah
You could maybe send a title packet and offset it to the right value
If you place it closer it shifts around the screen
Yes but now you've taken up the title slot
thanks i'll remember it if I ever need to use this
ok so
Titles can be manipulated easily though
does anybody here actually know how to use shaders
If needed by something else, let it, then return to the normal state.
Another weird possibility is manipulating the subtitle gui box
But then your icons disapear
This does require the user to enable subtitles though
because im confused
Hmmm, another out of the box idea.
What about manipulating the elder guardian effect?
I think we are going off the rails ere
all I need to do now is figure out how to modify the rendering of the item display
its good to use TreeSet to create list of top players?
but idk enough about mc shaders to know where to even start
idk how id write a shader that changes JUST the item display
i cant even figure out what shader renders them
Depends a bit on your use case and how the stats are stored in general.
Usually there is little usage for a TreeSet when your data is queried externally.
ohhh
is there a way to know whether im rendering an itemdisplay
or am i kinda screwed
I've heard that manipulation of shaders can be a messy process so have fun!
there must be somebody who knows about this stuff
If you have GLSL knowledge then its not too bad. Otherwise it takes quite a while to learn.
I do
I'm not sure there are a lot of people here who mess with shaders, I mean I feel like most at this point would rather just make a pack
just not minecraft resource packs
shaders are a pack
I just kinda realized what you were doing
I thought you were hard coding manipulations to the shaders kek
This repo helps
I think you'll have fun with this project, it already looks pretty cool
i think i found something that might help
ok
so I made every entity pitch black except the one I wanted to change
which actually might be good news
tyty
So is the point only to show the last three food items you ate?
no its like
im recreating a mod which is recreating the valheim food system
where u have food slots
and each different food fills up a slot and gives you bonuses
so like when you eat "hearty bread" it gives you health and food or something of the sort
I've never played valheim so I wouldn't really know haha
I would probably wait for 1.20.5 with that. Custom food will be much easier then.
What's going to make it easier?
its already pretty easy
You can set any ItemStack to have any nutritional value, and you can make them consumable even when you are full.
Any ItemStack can have a custom stack size up to 99. Can have custom durability up to 2 billion, and much more.
All ItemStacks will be composed of components.
instead of filling a hunger bar each food item gives you a bit more max hp for a certain amount of time
Myeah, but you wont be able to have the vanilla eating animation.
That sounds amazing
why not
Well unless you fix the hunger bar to a certain value.
sounds pretty easy to do that ngl
You cant consume food if you are full otherwise.
Ah that's awesome, custom items are gonna be blowing up haha
Hey @lost matrix, I needed a remove method in the WeightedMap (so i can use it for rewards without giving the same reward twice)
I modified the class, does this look good? https://pastes.dev/8eNrFPho6U
Sure, if you are willing to just throw away the hunger bar and system, then its easy.
thats exactly what im doing
im doing a new system
but even if I wasn't it would be easy right
just manually edit the food bar
imo smile is right to wait for 1.20.5, in case you might want to rewrite optimizations... plus it seems 1.20.5 is gonna have a lotta cool stuff for itemstacks
Nope, removing elements like this will mess up the RangeMap and throw an exception
it seems good for datapacks
but plugins u can already do most of the stuff
I already did custom durability
True custom durability is currently impossible
wdym
I mean you don't have to, but it just becomes a lot easier next update
oh, is there a way to remove elements without messing it up, or should I just create a new RangeMap without the element want to remove every time?
You have to smack a durability system on the ItemStack and hope that the player doesnt look too close at the vanilla value.
With this implementation you need to recalculate the entire RangeMap
Alright ty
What am I missing?
If my calculation for getting the weight is correct this should work right?
https://pastes.dev/8Okz81ifVB
is there any way to detect right click without an item in hand? (in the air) I believe it doesn't send packets so it's impossible but i don't know
do someone know?
It would still call
Cause if a person has an empty hand and right clicks a chest
it isn't working for me
it would still open the chest
I would just use a Map<T, Integer> and simply create a new instance of RangeMap
yea but in the air
No
you could add an invisible armorstand for the event
uh
like just spawn it at the same loc the player is?
That wouldn't scale you'd need an armor stand following each player the entire time they're on
I could just do it when the event is fired
ig
The event won't be fired though
The client doesn't send a packet
true lmao
so is it just not possible?
I mean, i wouldn't make an armor stand follow the player
You just can't do what you want basically and there isn't much you can do about it without it being hacky
ah smart, and I think rangeMap = TreeRangeMap.create(); creates a new instance
Could you do Left click?
I mean yea, but i wanted right
I think it works with Left
it does, but that wasn't the point xd
At what number does a collection size start?
Okay
}, 60L, 20L * 60 * plugin.getConfig().getLong("koth-timer"));
why is this runtasktimer spamming?
koth-timer is 0.2
20 x 60 = 1200 x 0.2 = 240
== Sending message every 1.04 seconds
or smth like that
smth with 1second
That answer your question?
oh shit
i just failed basic math
Then its every 10.4 seconds
0.2 as long is just 0
Doesnt long have floating ends?
source?
that is not a source
where is Google taking it from
and does it refer to java?
because I'm sure it doesn't
(I know it doesn't)
you'd have to get the value as a double/float, multiply, and then cast the result to a long
open up the website it's taking it from and read the article
I'm sure it'll say
he could also just take a float afaik?
but 0.2 is still like 10.4s delay
Which i dont think is what he wants to achieve
I mean it'll be a fifth of a minute, but that isn't spamming
using a period of 0 will use a period of 1 (tick), and that will be spamming lmao
true
im still so confused what shader renders itemdisplays
this is in a class that extends Command. the usage message doesnt print even though it exists and the method returns false
So i decided to use nms , and refliction to spawn entites , and it does work kind of .. my problem now :
- it does not remove the old ones , so this case it keep spawning on top of each other for the player ..
- how would i rotate it? using packets and nms
it keep spawning ..
now its super dark
- Spawn it only once
- You can change its metadata with the matadata packet and its rotation with the location-and-position packet
oky 🙂
this seems to fix it :
i add the entity id , after i spawn it
not sure if its the best way , but it works for now
You are spawning the entity to every single player on the server. No matter if they are near the entity, near the chunk, or even in the same world.
Is that wanted?
If you have a temporary setup, then program against an interface you can easily swap out later on without having to write a bunch of
internal changes. "Its just for now" mentality will always lead to patchy code with a bunch of temporary pieces that turn out to be quite permanent later on.
Unless this is a completely clean testing plugin. In which case "just for testing" is fine.
good point ..
Hey, I'm trying to create something, I want to summon a boat with an armour stand riding it, which is fine. But is there anyway to lock the rotation of the armour stand so it is always facing the same direction as the boat. I know I can set rot when summoning, but I'd like it to stay.
An ArmorStand shouldnt randomly move, right? doesnt it have the same direction of the boat on default?
no it just spins
Nope, this will only send the entity if the player is directly inside the same chunk as the entity. That will look really bad.
oh i see , so what i need to do then?
Set the AI of the ArmorStand to false.
ohhh didn't think of that
Track which chunk is sent to which player using a packet listener.
Then when the entity spawns, send the packet to all players which can currently see this chunk.
When a player gets send this chunk, send your custom entity as well.
When a player gets sent a chunk unload packet, unload the entity for this player as well.
I don't think the armour stand has a no ai option, but will try a different entity
so the entity will be on diffrent islands , its not a whole world , its 12 island or less big island , its only 1 world [small one] ..
do i still need to implement this?
Yes
for example :
Unless all players see all islands at all times
idk do they?
Which would be a weird server concept
You can also inject your own listener into the netty pipeline. Thats up to you.
if anybody knows anything about core shaders, how would you isolate a specific itemdisplay? or an item in the inventory?
When creating a new instance of an object, does it save the entire class to memory, or only the relevant parts (aka the instance + constructor).
The reason I'm asking is cause I want to know if I'll have worse performance if I put methods inside an object class (of which multiple instances are created) instead of in a manager class (which only has one instance)
also how do I get the depth
pretty sure in java it doesn't create new methods for each object
since then youd be able to change them per object
yea methods are stored once. its the entire reason methods exist
so you don't have to write / save the same code twice
Alright thanks 👍
how do I also remap the nms modules? In their build.gradle I am saying task.shadowJar.finalizedBy(remap) which in the console outputs that it successfully remapped, but then when I run the plugin it isnt. What am I missing?
eh I mean
u have a virtual lookup table
cuz like polymorphism
which is why object oriented languages generally tend to be slower when it comes to method invocation
but thats for instance methods
static methods are fast since they compile down to invokestatic
and then u have functional interfaces which are fast also since they compile down to invokedynamic, altho they technically are just (abstract) instance methods
You're severely overoptimizing at this point
Don't micromanage your memory to this degree
oh
unless u have some insane functional requirements to abide by, listen to Choco
yeah I'm just asking cause I don't know what has micro or meso impact
yeah java has it figured out
If you're not noticing any performance issues, you probably don't have anything to fix
I'm probably not even optimizing in the things that have major impact on performance cause I simply don't know
thats fair
I mean if you're new to this entire programming thingy, the first thing that you will likely come across as less performant is gonna be database calls and reading and writing files
that is, noticeable performance impact sources
yeah I was told to do those async so that's what I do
generally speaking, don't bother or care with that stuff, write code that works first, then if you notice a performance hit, profile, and optimise based on your profile results
👍
unless it's a blatantly obvious thing, like, idk, reading a 2gb file on the server thread and calculating the checksum for whatever god forsaken reason
xd
Weird you mention that, Emily. I just finished implementing that into Hypixel today 
I was like "Hmmm, we could optimize the ban list by just reading in the whole database on server load"
And then of course I linearly iterate through the list of player names to ensure that the person joining isn't banned
but I'm not stupid. I don't want to have a memory leak. That would be disasterous
So I hashed and salted the usernames
100x developer right here
Can’t believe he’s leaking hypixel’s system
Oh well it's still a work in progress so
sounds like something I would do 💀
Once I PR it, then it's NDA
So shhh don't tell anybody
I don't want to have a memory leak ... So I hashed and salted the usernames
Also come on, I thought this was hilarious D:
i can give you a pat on the back
reading and cashing the entire database onEnable isn't gonna be a problem right 😅 unless ofcourse I am hypixel
Eh it'll be fine. That's for someone else to figure out
Just store it in redis
Smart
god
if I was smarter I could totally make a custom gui but I cannot wrap my head around shaders
its just so hard with so little information
No shaders required. Just some hacky abuse of inventory titles and custom textures
ShaderLabs discord server might be able to help
There's no way you're the first person that's trying to use displayentities to display text without it getting weird behind blocks, there's probably a solution somewhere in this discord or on spigotmc.org
I tried so hard to look
idk if I have the time for that either
Much easier to learn at least
wdym inventory titles
You add custom characters to the inventory title to change the texture of the inventory
When you say GUI people think you are talking about inventories, not floating food items
Anyone know why i could be getting a "cannot access net.minecraft.EnumChatFormat" when using net.minecraft.ChatFormatting
ok this is way easier to do with the action bar
ill just have to copy every food item into a custom character
even air? 🤔
How do I add multiple scores to an objective at once?
why do you need to do it at once
like on the same tick?
just use multiple lines of code right
Air isn’t a real item
how would I add libraries in intellj
specifically this one
what would I put in the version-here
I tried 1.20.4 but thats not it
... the lib version
idk wh
yes
duh
idk what that is
ive never used maven before
like 24.2?
nope
yes
doesn't work
means you did smth else wrong
I probably did
where are you putting this
in my pom.xml
looks fine to me
:/
what does a team do in a scoreboard?
teams are kinda seperate to scoreboards ngl
oh ok
Score score = objective.getScore("" + i);
if i have this line of code, will i have to replicate it 15 times to have 15 custom lines on the scoreboard? that doesn't seem like a good solution. is there any method to add multiple?
for (int i = 0; i < 15; i++) {
Score score = objective.getScore("" + i);
simple for loop
what if i wanted to have different text though?
hmm
A list i suppose
Although you'd need to have different lines regardless
Well kinda
so there's no good way to do it?
alr lol
but yeah if you want to do 15 different lines of code then ur gonna have to have 15 different lines of code
if u told us more about what ur trying to do with 15 different lines that would help
ur trying to get the score of... what?
I am trying to create a scoreboard builder, and a scoreboard can render a maximum of 15 lines on the client
But I am not sure on how I can set each line of the scoreboard provided when building it to the content
youd want a list of lines then
and a for loop
how familiar with programming are you
List<Score> scores = new ArrayList<>();
for (int i = 0; i < 15; i++) {
scores.add(objective.getScore(""));
}
like this?
don't you have to get the scores to put the text underneath the objective title thing?
like you could do
Score score = objective.getScore(ChatColor.WHITE + "asdasd");
i would assume u set the score
but honestly ive never messed around with scoreboards
In terms of efficiency, checking a 2 blocks pattern based where player is between in a playermoveevent would be lighter to implement using just a first check on the player if it has moved on a new block and then checking the pattern, or adding a middle condition to check for a per player cooldown and then checking the pattern
I mean overhead a 2 blocks pattern check isn't that bad
creating an empty EntityEquipment?
EntityEquipment e = null; ?
thats not how java works
what are you trying to achieve i believe its not meant to be instantiated
i am trying to create an empty equipment that gets filled by random stuff inside a method
?xy
because i am creating an entity creating a class. before creating that class i do not have any entity from which i can access the inventory
so i want to assign that entity's equipment in the entity's class constructor
Theres no way to set EntityEquipment anyway, you can only get it
through LivingEntity
can you not explicity define the equipment items
what do you mean?
i have first to create the entity, then i need to get it and then i need to give him the equipment?
all in the class constructor?
Like even if you did have an empty EntityEquipment class, you can't apply it to the entity.
In your constructor can you not just pass the Items explicity for each slot
or a wrapper for it
i could. let me try
sup
just came here to ask abt something in scoreboards and found someone having a problem with scoreboards
is there a way to implement noclip, with the api?
ANYWAYS, how tf do i set a below name objective without the number
you cant
ok then show me
i cant send images
they most likely create their own nametags
check dms
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
yes they created their own nametah system
Just a map or a set of player uuid to keep a trace of the last check was done on that player and if it happened recently it skips it
scoreboards are not the way
how do i make a nametag system
armorstands on the players head
I mean just checking if a player stepped on a new block is nice but I'm trying to get further since the server feels it
no
yes
bro you never did this so why are you telling me whats possible?
wait im dumb, i want it to show only if ur afk
no flippin way, i didnt know that!!
i want it BELOW the name
not ABOVE
i will not spoonfeed
this is what neede to create everything you want
i did it too
i aint asking for u to spoonfeed me, im just asking if theres a way to do it without passengers cuz passengers are above name
have you thought about just disabling the nametag and replacing it with armorstands?
armorstands cant have 2 line names
btw textdisplays can be used too unless you want to support bedrock
you know what if you dont want to listen or try i will not help you anymore i can send you a screenshot of my nametags if you want
@dawn flower what version do you support
is it 1.20.3+ ?
why tf cant i tab out with lightshot
1.20.4
Take a look at scoreboard changes in
https://minecraft.wiki/w/Java_Edition_23w46a
API should support this somehow
what was changed?
ok, for the lazy
but where is the part with below name nametag stuff
/scoreboard objectives setdisplay belowName afk-tag
for whatever reason 'belowName' isn't a valid display slot even tho i used minecraft's official tab completion for belowName
minecraft's official tab completion
sounds funny
just create your own nametag system, as you can see it works with armor stands
if they already made a way to do it why would i do that
Don't over-engineer something when you don't have to
with a nametag system you can later to cool stuff
like add more to it
below_name, not belowName
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(60), event -> {
if (currentTime <= END_TIME) {
double[] point = LinePoint.getUpdatedPoint(currentTime);
XYChart.Data<Number, Number> dataPoint = new XYChart.Data<>(point[0], point[1]);
series.getData().add(dataPoint);
// Set the color of the data point
String color = "#ff0000";
if(dataPoint.getNode() != null) {
dataPoint.getNode().setStyle("-fx-background-color: " + color + "; -fx-background-radius: 5px;");
} else {
System.out.println("null"); // why is this shi always null
}
currentTime += DELTA_T;
}
}));```
do you guys know why the node is always null? 😭 im using a LineChart with javafx
how do i use numberformat
/scoreboard objectives modify afk-tag numberformat blank doesnt work
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
gimme a sec
can i use packets
Don't jump to packets bru
oka
/scoreboard objectives add test dummy
/scoreboard objectives modify test numberformat blank
/scoreboard objectives setdisplay below_name test
/scoreboard objectives modify test displayname {"text":"Hello World"}
try this on spigot server
if it doesn't work, try it on a fresh spigot server
if it still doesn't work, make a bug report
We are not paper
their support sucks doe
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
If you want good support here, use spigot :)
paper is faster doe
in some situations it is
Just gonna confirm one thing, you did do the exact same commands and used second account to look at a player, right ?
You can't see the nametag thing if you use F5.
yes
Try spigot, if it doesn't work there, make a bug report at the appropriate place
anyone know if there's a hack for making several resource pack textures for armor without only using the helmet trick?
maybe with leather armor or something?
- what is the helmet trick
- Fancy Pants (gimme a sec for link)
https://github.com/Godlander/lessfancypants
It has not been updated in a bit, not sure how well it works in latest versions
so someone figured out how to do it with shaders then
hm
I might just have to use optifine
If you don't care about supporting vanilla, you could probably just make custom trims
and make one armor completely transparent and change it with trims
Yes, using core shaders
I really don't know if I would rather use shaders or optifine here
it's between a resourcepack which server can automatically apply
or a mod the player has to manually download
I would go with RP
optifine requires the player to have it installed, core shaders always work
yeah but core shaders might interfere with other shaders and they come with a client-side overhead
https://github.com/Ancientkingg/fancyPants?tab=readme-ov-file
Here. This has already written all the shaders. All you need to do is go in your texture file and add more armor textures downwards.
This shader then shifts the texture by an index. Its explained in the readme.
I already sent fancypants here :(
why u ignoring me smile 😢
there's also the other thing which is long-term support, sure hope mc didn't change how these work for 1.20+...
hello how do i added yaml comments inline like this in code:
Settings
AllowTP: true #set to true of you allow players to teleport to their death position
didnt see, woops
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
says so on the page you linked
so I have to pick either something that works on optifine or something that works on everything else as well on top of the rest
since optifine breaks all sorts of things, I am not surprised
trims don't work for you ?
never looked at trims, does that require losing one of the base game armors?
it adds texture on top of existing armor
so you lose layer2
what is it capped by, how many armor trims there are or something?
you can create your own trims