#help-development
1 messages · Page 999 of 1
server.properties
make sure pack.mcmeta is at the root of your .zip
also, if you're doing that - just scrap doing it via plugin, and rather do it via the server.properties
That was it
i zipped it wrong lol
personally i use my custom cdn, or just a file host and upload my pack there, then hash it on server load
like it was inside the zip a folder then the resource pack
Yeah but i want to publish this plugin
I will do the hash manually as if i update the resource pack i will also have to publish it anyway 🤷♂️
Quick question, does this check if the held item is null?
your ide is warning you, hover over it
If its null, calling equals on it will throw npe
not just that, they're calling gettype on what might be null
How do i put the hash in my code?
What
@EventHandler
public void playerEntered(PlayerJoinEvent event){
Player player = event.getPlayer();
String texturePack = "https://download.mc-packs.net/pack/63af22dfb70aab544ae338f8687bf17d8423761a.zip";
player.setResourcePack(texturePack,63af22dfb70aab544ae338f8687bf17d8423761a, "Please download this resourcepack for Legendary Swords to work!", true);
}```
string
although having a plugin depend on its own pack can cause all sorts of issues
like pack conflicts, as it overwrites the server pack
version issues
What way is checking null(in my case)?
(pre-1.19.3(i think .3?))
.isEmpty()?
multiple resource packs were only added in 1.20.3 I believe
What would u tell me to do?
getItemInUse() != null ? wtf bro
I think making the server owner put manually the resource pack as the server resource pack is a bit much
I'm still quite new to java👀
Thanks for helping though
Also it tells me my hash has to be 20 bytes and i think the mcpack.net generated is like 40
That string you have looks like hex, you might need to decode it https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/HexFormat.html
declaration: module: java.base, package: java.util, class: HexFormat
I broke intellij and now i cant push files into github.
What i should do?
well I wouldn't like to be pushed either
you prob broke git not intellij
nevermind
did you try forking something? maybe a merge conflict? does it say "failed to push unreleated histories" or smth
merge conflict
"it broke" is a bit too generic
then it isn't broken you just have to address the merge conflicts and select which part of the code to keep
study how merge and rebase work with git and you should be fine
ah, was .20 then
Hii, what wrong with my method? Sections are not being created and i dont understand why
@Override
public void set(String path, Object value) {
if (path == null || path.isEmpty()) return;
int index = path.indexOf(".");
if (index != -1) {
Object object = this.values.get(path.substring(0, index));
//if (!(object instanceof ConfigSection)) return;
newSection(path.substring(0, index)).set(path.substring(index + 1), value);
System.out.println("section= " + path.substring(0, index) + " created");
return;
}
if (value == null) {
this.values.remove(path);
return;
}
if (value instanceof Map) {
//
return;
}
System.out.println("route=" + path + " created");
this.values.put(path, value);
}```
what do you mean sections are not being created?
you are trying to store an object without serializing it
Let say i call my function set("path.child", "test") then section "path" should be created. And inside section should exist a child called "child" with value "test"
what? Im confused sorry
the problem is that the section system does not work, because when you indicate a set a route within a section, it does not create the section or parent section nor the route within that section. Do I explain better now?
That is exactly the issue Frost
Section is map i think
Section in my case is an object called MemorySection similar to like yaml spigot works
what was the link to spigots patch changes again
need to know what Particle.REDSTONE has been replaced with
what u want to code?
ok well you are obviously going to have to show your implementation and not just this little method of yours
a section-based configuration system. It allows the creation of configuration values, configuration sections, and configuration settings. Like the spigot system does, but I do it because I need it to be platform independent (works no matter if I use Spigot or Bungeecord api).
because here in this method you are using generics and you can't expect generics to magically work
right, let me finish debugging smth and i send it via paste
anyone know what Particle.REDSTONE was replaced with in 1.20.5
?jd-s
is it just DUST now or what
yes
ah cool
or DUST_COLOR_TRANSITION if you want it to be changing colors
ooo fancy
then what is it
okay this now is working, idk what happened. Just reloaded IDE and worked perfectly haha
im confused what happened with the explosion particle type, there were previously 3 different sizes for explosion and now theres just EXPLOSION and EXPLOSION_EMITTER
what do you do to control the size of it
no datatype is documented for it
Why .gitignore is not working
Those files are probably already added to git
you need to git rm them
# Gradle
.gradle/
/.gradle
**/gradle/
**/build/
!src/**/build/
use --cached to just remove from git
hey the spawned item sometimes changes direction of rotation
Math stuff
if im studying math will i be learning this in university/college or in school?
Is it possible to define custom translation strings in the language files? Eg.
"custom.potatoes.in.farmland": "Potatoes growing in farmland. "
I tried
var inspectionText = new TextComponent(new TranslatableComponent(translationString));
But it didn't work.
Maybe with a ressource pack
Well, yes. I tried it with a resource pack.
do u have any idea why its sometimes rotating back
i mean it changes rotation direction
and in a few moments it changes back
only create a translatable
don't explicitly create a text component
I'm making a plugin that uses money so players can hold money and send money and stuff, what would be the best way to store how much money each player has? I was just going to use a variable but all the variables in the plugin reset when I reload the plugin and I need it to remember how much money everyone has
do i need to increase that ?
or?
All right .. but I'm still getting only the translation string thrown back at me.
what lang file did you add it in
are you sure you're sending it correctly?
Afaik, it's a linear interpolation between the previous matrix and the new one
Try 179 degrees maybe
Might fix it
en_au.json, en_ca.json, en_gb.json, en_us.json and fi_fi.json.
Mind you it's a completely custom string and not part of Minecraft.
Sorry, sending where?
to the player
player.spigot().sendMessage(inspectionText);
thats the 1.16 one if it could be of any use https://gist.github.com/LoneDev6/1df03fd853b2b244a7348216c8fa909d
that looks fine
me when mcasset.cloud
Right. Are you sure I can add my own custom translation keys and texts in the translation files?
never heard of
yea, that's what the negative space font I use does too
do you use any other method to rotate it?
ok
just checked, it uses a custom namespace for the lang file
Ok, so doing:
var inspectionText = new TranslatableComponent("custom.potatoes.in.farmland");
Should work in theory?
Oh. So I might need to move that into its own namespace?
try it, just going through mypack atm
Do they need to be prefixed, eg. mynamespace:custom.potatoes.in.farmland?
nope
Nop
nope 179 is still doing same thing
Id have to pass ItemMeta meta to them, not ItemStack item and take meta from that stack, right?
I think the "cleanest" way to do it is:
- rotate is up to 179 degree
- reset the transformation by applying without interpolation the default one
- Repeat the process
Okay, I tried moving them to their own namespace. But that made no difference. How would it find it in the correct namespace without prefixing it with the namespace, though?
you mean like this?
I tried prefixing it, but that didn't work either.
Nope
All the default Minecraft translations work, though, with TranslatableComponent.
that's odd, it works here: https://github.com/AmberWat/NegativeSpaceFont/blob/master/assets/space/lang/en_us.json. fabric has a good explanation, just to verify you've done everything correctly: https://fabricmc.net/wiki/tutorial:lang
can you teleport block displays?
i'm considering using block displays instead of falling blocks for hide and seek
Could someone link me about new things called translatable i wanna learn about them. Tahnks
Yes they are normal entities
so what do you mean by "reset the transformation by applying without interpolation the default one"
Each time in the runnable
You first apply the default transformation after setting the interpolation duration to zero
Then you call inside the runnable scheduler.runTask()
With the previous scheduler inside
To do it on the next tick
is there any way to get body's rotation?
do you mean interpolation delay?
To apply the default transformation instantly
Yeah
Wait I'm playing valorant I anwser you after the game x)
hi guys is there any bug with spigot plugin in 1.20,5?
Stay in #help-server
(and ask a question that makes more sense)
is there an event for when a villager cancels the breeding process or villager breeding in general
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
entity.setInterpolationDuration(0);
entity.setTransformation(defaultTransformation);
Bukkit.runTask(plugin, () -> {
/* insert the content of the previous runnable */
});
}, speed);
Something like that
like this?
Yes
ok lemme analyze this code a sec
not realted but why for rotations you use radians? is it for something special
can we reset the transformation once current rotation ends instead?
hmmmm
idk, i have trouble understanding Quaternionf s (language barrier ) and someone wrote sample code and im trying to read it
It will just be harder with the code
How do you check if an EntityType would implement the Mob interface?
Without actually creating an instance of an entity of that entity type
another question. is this the part that does the actual rotation quaternion.rotateY((float) Math.toRadians(179))); or is this the one? new Quaternionf(0,0,0,1);
The first one
getEntityClass()
The second is useless it's overwritten
x)
i didnt find anything so any other idea how i could retrieve data on why a villager breeding session or what ever one would call it coudl fail?
Thanks man
how to get string from messages.yml file?
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
"trying to understand"
i didnt say i understood it xd
thanks
(i couldnt)
this one is repeating the issue more times
honestly they shouldve put a link to the bukkit page about config there
Then I will investigate this tomorrow, now I'm playing x)
ok i can wait
wait uh
you're going to find this dumb, but how do I work with that?
like
im just confused how to figure out of 'java.lang.Class<capture<? extends org.bukkit.entity.Entity>' is of the Mob class
do i try to cast it?
Mob.class.isAssignableFrom(otherClass) iirc.
oh thanks
could be the other way around, i never remember the order
!!!
should be called isAssignableWith
radians are the standard unit when working with rotations
ohh okay, but is startand unit in europe? or all world
everywhere
have you not heard of radians?
nop, we always have used grades / grados
its possible the repeatable task overlaps the translation by 1 tick, which is why I had to use 181
I'll check
i see, radians are easier to work with mathematically because it is related to the radius of the circle.
oh okay, that makes more sense now. Thanks retrooper
No problem, in radians 2pi is one rotation (360 degrees)
Nope no overlap
Whats the difference between isSet and contains? Specific when working with spigot yaml api - Thanks
read the javadocs, contains will return true as fallback for default values
I cant 💀
im banned from spigot again
it seems that spigot anti proxy are working better now
either that or my proxy is working for the trash
To expand on what retrooper said, if you have a circle with radius of 1, the perimeter is 2*pi*r = 2*pi (r=1), which is sort of the first reasonable argument for why we use radians
What is it???
private static final CachedValue<BetterGUI> INSTANCE_CACHE = CachedValue.of(() -> (BetterGUI)JavaPlugin.getPlugin(BetterGUI.class));
public static BetterGUI getInstance() {
return (BetterGUI)INSTANCE_CACHE.get();
}
a circle with a radius of 1 is interesting because it holds a lot of mathematical properties, relations and discoveries
looks like a lazy singleton
But rather useless
They probably wanted to erase the generic type, thus having some sort of dynamic/lazy resource loader
thankks!!
I solved the reversing. It was due to the minor inaccuracy of Math.toRadians. The slightest floating point error results in an incomplete translation
right, so the reason is mathematical.Degrees lost properties from what i read
oh
well degrees is not as mathematically convenient
so i should increase it?
just quat.rotateY((float) Math.round(Math.toRadians(180))))); // right rotation will fix it
ok ill test it
right really thanks Conclure
yep works. If you want it to rotate the other way use -180
annoying FP errors
-180 = clockwise rotation
ok
is there direct method to make this display fly up and down like the dropped item does?
you could add a sin of its rotation
to its height
or position
not sure how though
i could do it with some runnable?
not really
Just add a translation to the transformation
as its dependant upon the translation
why
while it might work, it would be defeating the whole purpose of translations/transformations
let me have a think
well i didn't know you could make objects move with that other than rotating them
whats translation
its the vector passed in the constructor
Translation is just ... a translation
You set it
It will go from the original point
it sounds like a language translation to me
makes sense
and 0, 1, 0 would do one block above the original location right?
how would that create hovering effect?
x)
wow now it makes sense
First you set translation to (0, 0.5, 0)
It travels up
Then the next iteration of the runnable
You set translation to (0, 0, 0)
It will travel down
Boom
Hovering effect
?
wouldnt it just teleport 0.5 up and then -0.5 ?
oh i have duration
eh why boolean array
You should move up in the lambda
To avoid using an array
But for testing it's fine
is it used in outer lambda?
no
then u got the answer
I got it floating, but it's not really fast enough
as it takes half a rotation to reach it's apex
what if someone needs different speeds for floating/rotating?
new Runnable () {
private boolean up;
void run() {
/* content of the lambda */
}
}
You can adjust it by doing a ratio between the rotation and the translation
And add to the angle
adjust the speed?
looks like MC reaches its apex in 45 degrees
MC?
Minecraft bounce on dropped objects
45 degree of what
rotation
How can I refactor this code to work properly with setting up PersistentDataType?
not quite 2pi is a full rotation. The minecraft bounce is double the speed of this graph
so what does it use
generic
what height does minecraft use?
You're always returning a string. Why is data type a string
He took an pdc type by its name, I don't understand why he did that.
I dont understand how to do it at all
throwing one word answer isnt really helping
I need expression that will split my string correctly.
My string: {123:5123, LoL:[aboba, test, jmot], kapa:[opa, shopa, koka], lel:[test, boba, iba]}
Result would be: 123:5123 LoL:[aboba, test, jmot] kapa:[opa, shopa, koka] lel:[test, boba, iba]
Are you so lazy that you can't directly use the type you need?
Can you explain more what that string is please. Why does it need to be in that format
My expression that not works rn "(?<=^|,)\s*(?:\{([^:]+):([^,\]]+)}|([^:]+):\[([^]]+)])"
Result: 123:5123, ,
Ah he doesn't know how to use generics.
because {} is map, and in map i need to store arrays, array is []
from string in chat, player will text it
i know, but i convert string into boolean, int and other data types
How i can convert string into map with yaml
Use SnakeYaml or gson. This needs a parser not a regex
private Object convert(String message) {
if (message.equals("null")) {
return null;
}
if (message.startsWith("{") && message.endsWith("}")) {
Map<String, Object> objectMap = new HashMap<>();
String[] split = message.substring(1, message.length() - 1)
.split("(?<=^|,)\\s*(?:\\{([^:]+):([^,\\]]+)}|([^:]+):\\[([^]]+)])");
plugin.getLOGGER().info("Splited: " + Arrays.toString(split));
for (String messages : split) {
String[] splitted = messages.split(":");
objectMap.put(splitted[0], convert(splitted[1]));
}
return objectMap;
}
if (message.startsWith("[") && message.endsWith("]")) {
ArrayList<Object> objects = new ArrayList<>();
for (String messages : message.substring(1, message.length() - 1).split(", ")) {
objects.add(convert(messages));
}
return objects;
}
if ((message.startsWith("\"") && message.endsWith("\"")) || (message.startsWith("'") && message.endsWith("'"))) {
return message.substring(1, message.length() - 1);
}
if (NumberUtils.isNumber(message)) {
return NumberUtils.createNumber(message);
}
if (message.equalsIgnoreCase("true")) {
return true;
}
if (message.equalsIgnoreCase("false")) {
return false;
}
return message;
}
I have no idea how to specify data type of persistent data type
I cant figure out what T and Z stand for
t and z are generics
<T, Z> PersistentDataType<T, Z>
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
final ItemDisplay display = player.getWorld().spawn(player.getLocation(), ItemDisplay.class);
display.setItemStack(new ItemStack(Material.CHEST));
final Vector3f floating = new Vector3f(0f, 0.4f, 0f);
final Transformation transformation = display.getTransformation();
final int numberOfTicksForHalfHover = 5;
final float angleForHalfHover = 1.5f;
Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
@Override
public void run(){
display.setInterpolationDelay(0);
display.setInterpolationDuration(numberOfTicksForHalfHover);
transformation.getTranslation().set(floating);
floating.mul(-1);
transformation.getLeftRotation().rotateY(angleForHalfHover);
display.setTransformation(transformation);
}
}, 2L, numberOfTicksForHalfHover);
I've been playing with it but its not so easy
Too bad
Hey, is it possible to use custom fonts in inventory names? Like with the AdventureAPI? (Component.text(<text>).font(Key.key(<key>));)
If you want to control the mvt that much, teleport the entity, it will be way easier x)
Or use the transform every tick
Does not matter
nah I'm only playing around as the issue interested me
transform every 45 degrees is what MC does
but theres no way to apply a sin wave to the transformation
Yeah
I fixed problems with generic method syntax but I still have no idea how to retrieve specific enum from PersistentDataType, I read up documentation on it and still have no clue what to do
bro
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataContainer.html#get(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType)
look at the signature of the get method
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
this helper method should've even be necessary because your keys should be constants
yeah with no sin wave teh bounce looks bad
:x
teleport is the only option for a smooth bounce
You can apply the transformation every tick with no delay
It avoid teleporting it
As you need to apply the rotation anyway
you could but that would be more load
could become really bad with many entities
I mean, if you teleport it or transform it every tick it does not matter
I see how it looks like in the documentation, but I still don't understand how to properly set up that type
just copy the method in the documentation
<P, C> C getPDC .... PersistentDataType<P,C> type
but as I said, this method doesn't need to exist because your keys should be constants
like enums or what
you just put your key name in a field as a Namespacedkey and this method is one line...
I think you need to learn more java
like that?
what did I say about P and C
I don't understand what .... stand for
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
I really recommend learning about generics because i dont think you are understand correctly
Type Parameters:
P - the generic type of the stored primitive
C - the generic type of the eventually created complex object
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
P and C are types stored and outputted and I want to store and retrieve same type T that I specify
P and C are nothing specific, they are just a placeholder
do I create two enums for keys and types now
damn he got learnjava'd by md
or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...
folow a tutorial // learn java
you keep saying the word enum without knowing what it means
public static final Map<String, PersistentDataType<?, ?>> PDC_MAPPINGS = Map.of(
"Integer", PersistentDataType.INTEGER,
"String", PersistentDataType.STRING
);
public static final PersistentDataType<String, Object> JSON_CONVERTER = ...; // Make your own impl
:)
gson encode that bitch
Sounds like you need to learn java
i dont think, he is coding great. Dont be like that 🫴
why does that hand emoji look like it's gonna do something suggestive
I tried reading into Spigot's api, Oracle documentation into generic and looking at examples of generic methods, but I dont understand whats the deal with PersistentDataType
pattern matching?
it's a variable that contains the primitive type (what is stored on the NBT) and the complex type (what is used in java). For something like PersistentDataType.STRING these are the same
Probably, idk they call everything pattern matching
JEP 394: Pattern Matching for instanceof + JEP 441: Pattern Matching for switch
I get that part, that if my type T were String I would end up with PresistentDataType<String, String> and could thus retrieve only STRING from that, but I dont know how to make it generalized into getting desired constant that's sitting in here
<P, C> C getPDC .... PersistentDataType<P,C> type
could you explain what .... is supposed to mean in that case?
it is the method signature you need, fill in the dots with your other stuff
copied straight from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataContainer.html#get(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType)
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
it declares a method with two type variables P,C; returns C; and has an argument of PersistentDataType<P,C>
ask chatgpt or something
you need to learn more java
wouldnt I need key and metadata too in arguments?
we told him already multiple times, always ignored
it is the method signature you need, fill in the dots with your other stuff
why am I just repeating myself
😭
I didnt totally get what other stuff is supposed to mean
or how to copy method signature from this section
for real bro
genius
lol
Its not 1:1 copy from what you sent, I thought that by "copied straight from" you meant that what you processed is explicitly written somewhere and I got confused
I dont understand the part about my keys being constants, how should I declare them?
static final NamespacedKey MY_PDC_KEY = ...
I'd say it is irrelevant - unless you wish to call the method, then it is something else. Should be reading this convo a bit better I guess
I was calling keys from string names because I found it more convenient for me
but as far as I am concerned I should avoid using strings as much as possible
so calling keys with fromString method isnt advised in general?
calling keys fromString is fine, just randomly putting that in your code isnt
eg having 1 NamespacedKey.fromString in a constants class is fine, but calling it 900 times all over the place isnt
yeah thats what im thinking about
but should I hardcode an array of keynames and then loop over it to initialize them or would it there be a much better way to create constants?
Use the constructor that takes two strings
im kinda out of context, but enums?
Or use a static reference to your plugin I guess
why two strings in specific?
Whats my mistake? I tried simplifying and it now rotates really fast, accellerating and slowing down. I see a pattern to the acceleration.```java
ItemDisplay entity = player.getWorld().spawn(player.getEyeLocation().add(player.getEyeLocation().getDirection().multiply(3)), ItemDisplay.class);
entity.setItemStack(new ItemStack(Material.ACACIA_BOAT));
entity.setInterpolationDelay(0);
entity.setInterpolationDuration(1);
Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
int angle = 0;
@Override
public void run() {
float rotation = (float) Math.round(Math.toRadians(angle));
Transformation transform = entity.getTransformation();
transform.getRightRotation().rotateY(rotation);
entity.setTransformation(transform);
angle += 1;
if (angle > 360) angle = 0;
if (angle < 0) angle = 360;
}
}, 2, 1);```
that could work
You keep rotating it by angle, but angle keeps increasing
yes
So you rotate it 1 degree, then 2, then 3, etc
ah I see
thanks
I only need the incrementing angle for the sin
I thought it was absolute rotation not relative
seems that wasn;t it. it no longer rotates at all
okay, so I want to utilize enums to store my statistics anyways, so I was thinking about implementing them into key names, so that I could iterate over enums and create keys on server enable, should I make Data Access Object class for them and store in something such as list?
if I rotate to 1, it will point in one specific direction. if I rotate 180 it points the opposite
who keeps crashing my discord
me!
smh
okay, does this make a proper use of generic methods?
if so then I only have to figure out way to create keys
ah I see. I was originally resetting the quaternions each pass, but changed to fetching them and modifying
however, that shoudl have worked passing in a toRadians of 1
creating a new Transformation object every time works, but using teh current one seems to mess me up
do I make something like that and then iterate over it in a method to create keys?
create a class, dont use enum
like a class that holds Map<String, NamespacedKey> data structure?
no wait I could use NamespacedKey[] Keys and just use enums with bitwise OR to find them
the issue with this is poor scalability
what if I wanted to have, let's say, 70 keys
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
we're really not getting anywhere here
no
enums would be used to determine what index of array it is
i won't use the getKey() method xd
lets say I'd have a 6 bit number, 3 higher bits would be used to determine Elemental damage types, 3 low bits would be used to determine stat flavor, I'd have space for 8 of each since thats how many different numbers I can store in 3 bit numbers, using OR bitwise operator would allow me to store those keys in very nicely put spots, I'd only have to set up enum values corresponding to those binary numbers in decimal format
in that case it'd be 16 constants in enum at worst
which I'd be using not only for indexing stored keys but also statistics, so it wouldnt go to waste
That’s quite over engineered for something like this
Storing a few extra bytes isn’t going to matter
I mean
I'd use that type of indexing all over my plugin for retrieving enemy statistics, weapon statistics, player base statistics, changing or applying PDCs
and I could make a general way to index it properly
for keys I'd just have to get that enum and lowercase it with method
I’d just make a custom type adapter that can read and write all the data you need for an item as one object
to each their own I guess
I could just do something like keys[FIRE | DAMAGE_RESISTANCE] or enemyStats[ICE | RESISTANCE_REDUCTION] utilizing the same structure, so I think it'd be neat
damn it I got another 1-star review from a false positive virus on spigot
I really wish mojang added some kind of cubic bezier curve for animating those things 😔
yeah really annoying
does it loop
I think I might know what you did wrong there
it does all kinds of wierd things, speeding up, slowing down
yeah it's up to how you're resetting, also are you reading its current rotation?
It works perfectly if I create a new Transformation each time
yeah you are
and due to the interpolation you are probably getting the drag effect that I had trouble with working on fmm
possibly
if I get teh current Quaternion it goes bad
I was just hoping to simplify by using teh current values
wait what
rotate Y rotates by an amount
it doesn't set the rotation
you're doing it wrong
you probably don't even need a reset in the first place
yes but if you get right quat and rotateY by toRadians(1) it doesn;t rotate at all
and by might I mean you definitely did
I rounded because before toRadians was too inaccurate to rotate teh same direction reliably
I don't even know what that means nor do I really want to spend time thinking about it
if you use toRadians(180) you can easily get a rounding error, as such when you do the next translation it would go clockwise not anti
nope Math.PI suffers the same issue
reversing
but rounding does fix it using toRadians
what do you mean by reversing
spins left then right, random direction due to fp math
this value works final float direction = (float) Math.round(Math.toRadians(-180));
without the round it behaves teh same as Math.PI, random rotation direction
post the full math of what you're doing with this value
?paste
this works https://paste.md-5.net/votozafana.java
a continuously rotating ItemDisplay
replace direction with Math.PI and the rotation randomly reverses
I was attempting to use the existing quat values on teh object to rotate every tick so I could add a Math.sin bounce to it
via the Translation vector
however getLeftQuaternion().rotateY(Math.toRadians(1)) does not rotate at all
I'll give it a try later.
it works using teh joml Math class
https://paste.md-5.net/wixuxewire.java why for example, when I hit a zombie, doesnt it eject it from the boat?
@pearl forge what's your command registered as?
like, in main.java?
sorry im stupid
Thats wierd, Minecrafts spinning item animation is noy syncronized to ticks
Hey elgarl are you in the review mega thread?
and BukkitScheduler::runTaskTimer(lambda) instead of new BukkitRunnable::runTaskTimer
Do you by chance have an example of this way I could have a look at?
Does anyone know how to add cooldowns for custom items like chorus fruits or swords where you right click them and it gives effects?
I can show you what I mean, I’ve tried many tutorials, and looked all through forums, anyone know?
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
//do code here.
}, delay, repeatSpeed);```
Lambdas always give me the jitters
?cooldowns
Is there a better way to explain it, because I’ve tried a lot of things and even tried this already it rlly doesn’t work
my sword is when i right click it gives me speed3, but if I hold right click I just keep speed 3 forever
It seems the Minecraft rotation animation on dropped items is very close to 2.9 degrees per tick. It's not quite 3
But what if it doesn’t work though
alright ima try it and update you
I think I did the same thing but on another website idk
give me a couple minutes
How would I go about making a new entry to Itemstack.r (PatchedDataComponentMap object) in 1.20.5 whereas previously using NBTTagCompound for versions 1.20.3 and below.
Would I have to create a new implementation of DataComponentType<T> and if I do, how would I do that?
So this:
Bukkit.getScheduler().runTaskTimer(seasons, () -> {
for (Player player : Bukkit.getOnlinePlayers()){
temperatureCache.computeIfAbsent(player.getUniqueId(), uuid -> {
double defaultTemp = temperatureSystem.getDefaultTemperature(seasonsManager.getCurrentSeason());
emitTemperatureChange(player, defaultTemp, defaultTemp);
return defaultTemp;
});
double currentTemp = temperatureSystem.calculatePlayerTemperature(player.getWorld().getBiome(player.getLocation()), seasonsManager.getCurrentSeason(), player);
temperatureCache.put(player.getUniqueId(), currentTemp);
}
}, 0, 100);
as opposed to this:
temperatureCacheTask = new BukkitRunnable() {
@Override
public void run(){
for (Player player : Bukkit.getOnlinePlayers()){
temperatureCache.computeIfAbsent(player.getUniqueId(), uuid -> {
double defaultTemp = temperatureSystem.getDefaultTemperature(seasonsManager.getCurrentSeason());
emitTemperatureChange(player, defaultTemp, defaultTemp);
return defaultTemp;
});
double currentTemp = temperatureSystem.calculatePlayerTemperature(player.getWorld().getBiome(player.getLocation()), seasonsManager.getCurrentSeason(), player);
temperatureCache.put(player.getUniqueId(), currentTemp);
}
}
}.runTaskTimer(seasons, 5, 100);
To avoid overuse of anonymous methods?
You may want a method reference with that much code
public void startTemperatureCacheTask(){
i didn't include it in those pastes
It starts onEnable
I like the first way, a bit less bloated
lambda 🤑
@charred blaze @frail pilot Finally got the simplest I can do. 99.9% matches Minecrafts rotating item with bobbing. https://paste.md-5.net/uqobuwutok.java
Just have to remember to use import org.joml.Math;
put it in the paste and bookmark the tab
edited, thanks.
If you're just wanting to add custom data to an ItemStack, you should make use of the PersistentDataContainer which will make use of the item's custom data component
If you make a new data component type, you're going to have to register it to a frozen registry, and then you have undefined behaviour with the client. You're probably just wanting custom data, so Bukkit has API for this. The PDC
I see. I was scrambling quite a bit and found an object called CustomData, does that have anything to do with this as CustomData.a(NBTTagCompound) would convert a NBTTagCompound to a CustomData.
Why are you insistent on using internals for this?
It's new. I haven't looked too much into how it's implemented but there is a data component that's just an arbitrary map of NBT data for item stacks
Also for the reason that the vars I get passed in looks like this
public net.minecraft.world.item.ItemStack applyTag(@NotNull net.minecraft.world.item.ItemStack itemStack, NBTTagCompound tag) {
// todo - fix this
// itemStack.c(tag);
return itemStack;
}
itemstacks don't hold NBT anymore in memory, they have a component map, a component describing stuff like enchantments, lore, potion contents etc
mojang was aware people stored non-vanilla tags in item NBT, and so they moved all foreign tags to this "custom_data" component, it holds a tag where all non-vanilla data should go
you are not meant to implement data components or types yourself
private void emitTemperatureChange(Player player, double oldTemp, double tempTarget) {
Bukkit.getScheduler().runTaskTimer(seasons, () -> {
double updatedTemp = oldTemp;
double increment = (tempTarget > oldTemp) ? 1.0 : -1.0;
temperatureEffects.displayTemperature(player, updatedTemp);
updatedTemp += increment;
if (increment > 0 && updatedTemp >= tempTarget || increment < 0 && updatedTemp <= tempTarget){
temperatureEffects.displayTemperature(player, tempTarget);
}
}, 0, 10);
}```
I'm thinking it's fine for this to run constantly, though when a new temperature would need to be emitted how do I cancel this task?
and/or assign a task id
I see.
runTaskTimer() returns you a BukkitTask object which has a cancel() method
Store that somewhere, wherever you need to
Okay definitly this is not normal, like this i have around 5k lines with the same text:
com.fasterxml.jackson.databind.JsonMappingException: Document nesting depth (1001) exceeds the maximum allowed (1000, from `StreamWriteConstraints.getMaxNestingDepth()`) (through reference chain: dev.alex.net.library.config.utilities.ConfigData["section"]->dev.alex.net.library.config.section.MemorySection["parent"]->dev.alex.net.library.config.files.YamlHandler["values"]->java.util.LinkedHashMap["section"]->dev.alex.net.library.config.section.MemorySection["parent"]->dev.alex.net.library.config.files.YamlHandler["values"]->java.util.LinkedHashMap["section"]->dev.alex.net.library.config.section.MemorySection["parent"]->dev.alex.net.library.config.files.YamlHandler["values"]->java.util.LinkedHashMap["section"]->dev.alex.net.library.config.section.MemorySection["parent"]->dev.alex.net.library.config.files.YamlHandler["values"]->java.util.LinkedHashMap["section"]->dev.alex.net.library.config.section.MemorySection["parent"]->dev.alex.net.library.config.files.YamlHandler["values"]->java.util.LinkedHashMap["section"]->dev.alex.net.library.config.section
I wonder if config sections contain their parent
okayy
look this
something is getting weird
😂
lmao something cause an infinite loop or somthing similar
okay @echo basalt from what i read is caused because of Circular References
Yeah that's where I was getting at
No worries
In short let's say A points to B
And B points back to A
What happens if you try to encode either?
right i now understand the concept
It says "A[value = B[value = A...]]"
but why would be caused? there i will need to get an idea why getting caused
let me send you my codes
testing code - https://paste.md-5.net/mipugedoce.java
configs - https://paste.md-5.net/pehivaruve.java
section - https://paste.md-5.net/ejiripajev.java
there are all the code im using for what im coding
because of section
Yeah but why
Yeah
ohh lamoo, how would it be so?
Or you can just create the path in the parent and inject it in the constructor
could you write a psecode simple, im a bit nightmare sorry man. I havent code in java for along
You really like to overcomplicate things
I have my own config system that looks a bit like spigot's / yours
public interface ConfigurationProvider {
ConfigurationSection load(File file);
void writeTo(ConfigurationSection section, File file);
}
public interface ConfigurationSection {
String getName();
String getFullPath();
<T> T getObject(String path, Class<T> type);
<T> T getObject(String path, T def);
Object getObject(String path);
String getString(String path);
String getString(String path, String def);
..
}
public class MemoryConfigurationSection implements ConfigurationSection {
private final String fullPath;
private final Map<String, Object> backbone;
public MemoryConfigurationSection(String fullPath, Map<String, Object> backbone) {
this.backbone = new LinkedHashMap<>(backbone);
this.fullPath = fullPath;
}
@Override
public String getName() {
int lastIndex = this.fullPath.lastIndexOf(".");
return this.fullPath.substring(Math.max(0, lastIndex));
}
...
}
oh okay
Hello!
I wasn't able to find any information about this in any of the forums on SpigotMC.
So I turned to this discord chat.
Essentially I took over maintenance of a plugin, but as far as I and the previous owner/maintainer are aware, there isn't any way to give me access to the SpigotMC resource.
Is this correct? Is there any process where this can be done in any way?
Thanks!
(Wasn't able to verify because apparently bot is rate limited)
192.168.1.14
Hey that’s my IP!
I have 2 questions.
- How do you add a cooldown for a chorus fruit? So you can’t eat it (while on cooldown)
- Is it possible to add a custom texture to a sword using lore? Like instead of custom model data it’s lore? If anyone needs screenshots or any extra information, please; ask.
You might be able to get away with the second one with optifine, not sure
For the first one there's Player#setCooldown pretty sure
It’s a public server, wdym use optifine 😭
In which case just use model data ???
I’m tryna make it so everyone sees the texture pack ofc, I was just wondering if it was possible to use lore instead of custom model data
That's literally why it was made
https://paste.md-5.net/ufinogoxiy.cs
How do we feel about this calculation?
is that the only way?
like no other way
Can be a little heavy if the search radius is huge
Yeah I'll make it known to keep it relatively low, also i think I'm cooked...
If it's bigger than like 32 I'd start making chunk snapshots and processing async
This is basically a light engine
private double calculateDistanceEffect(double distance) {
double maxDistance = seasons.getConfig().getInt("season.util.heat_detection_radius");
return Math.max(0, 1 - distance / maxDistance);
Why am I making a new double for max distance when I'm setting it to the same as distance
what’s that? is there a forum explaining it or sm?
declaration: package: org.bukkit.entity, interface: HumanEntity
Wait disregard
I mean possibly later on but for now I'm just trying to get it smooth
- clean
I wonder how fast you would have this project completed illusion, I've been working on it for nearly 3 weeks lol
Well yeah this is basically a light engine so you can just hijack one and change stuff
¯_(ツ)_/¯
I worked on a bedrock modelengine thing for work yesterday
Took me about 2 hours
(geyser's API is dogshit)
geyser is relatively new aint it?
Been around for a couple years
I suppose it depends more on the dev or just actual dogshit?
Bedrock has a system to send animations on entities
It also allows you to register custom entity types on the resourcepack
there's no wrapper for anything
They use the animation packet about once in a huge switch statement for offhand swing
I had to do some packet magic :)
Oh boy I'm sure I'll come across packet magic later on when I try to do fake biomes for overcasts, fog, etc
Basically I made a system to wrap custom entities :)
Autumn colors for trees and what not as well
It's in kotlin because I was forced to :(
Damn kt
Basically the end goal is to make your own entity types, wrap entities and override animations
¯_(ツ)_/¯
Where do the animations come from?
wait
You spawn a zombie, wrap it as a modeled entity and override the attack animation to scratch the player, for example
3 lines of code and that's about it
Could I use a resourcepack to do this and change the biomes sent during wtv season?
But yeah the new api at work looks a bit like this :)
public void modelZombie(Zombie zombie) {
ModeledEntity modeled = modeledEntityTracker.getOrCreate(zombie, "custom_zombie");
Animation animation = new Animation("animation.zombie.attack");
modeled.getAnimationController().play(animation);
modeled.getAnimationController().addProcessor((context) -> {
context.setAnimation(animation);
}, "animation.attack"); // Optional
}
I might make a premium plugin that ports modelengine bbmodels to bedrock not sure
That sounds really useful
just curious, what could possibly be the reason for not using custom model data?
If only I ever messed with meg maybe I'd be building a premium plugin too lol
My friend wanted to use lore to give the item the ability, so if an item had a exact type of text and color for the lore the ability would work
but that seems like a bad idea anyway
...so if it has that lore then give it the corresponding model data
he just wanted to practice his coding and honestly I was just wondering
well as far as im aware that definitely is not possible at least without mods
yup that’s what we’re working on right now 👍
@echo basalt do you wanna look at the seasons project by chance?
you’d be surprised 😂
idk how tf he did it
anyway
I gtg sleep
eh no
i know you said youre leaving but i just reread this - ideally you shouldnt really rely on the lore for that sort of thing
yeah ik
defo won’t happen again ofc
but he just wanted to find out how lore works
ok cool
@torn shuttle What can you tell me about bbmodel files?
🤮
they will surprise you in ways that are !!fun!!
like how animation keys are not, in fact, stored linearly in time
Everyone chill until exponential time
nah they're just not ordered by time, they're ordered by date of creation in the program
which you would think is a bit of a weird way of storing data but whatever
💀
I need a "cooldown" project of sorts, any ideas?
Will check it out thanks
can some1 give me an command cooldown
float angle = 0; what angle is this?
thats just a counter used to calculate the up/down sin wave
I could probably have used teh ticksLived value of the entity for that, but the math woul dnot have been so clean
sin(angle)?
when an item bounces up/down it doesn't instantly change from traveling down to up. it's a smooth transition. it follows a sin curve.
in Minecraft thats double the rotational angle.
not really. it's just the angle doubled to produce a sin wave. you can see it in game when an item bounce slows at its apex
Hey guys, I have a problem, when I listen to the PluginMessageEvent(Bungee), I find that some information is output like
proxy.console.sendMessage(TextComponent(event.tag + " -> " + event.data))
minecraft:brand -> [B@4c8d14c2
if I register a custom channel, may hackers send custom messages to use it?
proxy.registerChannel("custom:channel")
angle %= 360;
}```
so here you are just adding 2x of 2.87 till you get to 360 or more and then make angle division remainder of 360?
so 2.87 is just a 0.5x number of how many it increases each time in angle?
but a straight sin is too slow. it bounces at double that speed
aham so you increase angle 2.87x2 on each task
well 2.87 is a magic number. MC doesnt actually match its animations to sync with the server ticks
ok
Yes, the client can send whatever they want through plugin messages
how can i do an command cooldown
Hey, I have this code for creating a world
But sometimes when i restart the server all that was inside that world dissapears...
how can i solve this?
So bungee exposes a "BungeeCord" channel, why do I see almost no hackers trying to exploit that communication?
its teh degrees rotated in 1 tick of the server (blue line)
also if we are not modifying stepSize why dont we keep Math.toRadians(stepSIze) outside of the runnable?
you can
so we convert angle stepSize in scale of radians. radian is approx. 57 so 2.87 will be 2.87 / 57 radians right?
and we do that because rotateY method requires radians instead of angle
yes
radians is just values of pi
I believe that’s an outgoing channel
mhm ok
not sure if it's 57, i think 4pi is the fourth quadrant?
(R / 2PiR) * 360
2PI is a full circle, so 360 degrees
aint it
I wrote a fabricmod. When it tries to send clientPlayNetworking.send(Identifier("BungeeCord", ""), packetBuf), the client crashes because the name is capitalized.
What I'm confused about now is if I want to use a plugin channel, is it safe to use "BungeeCord", or is it equally safe to use a custom channel "custom:channel"
just use teh math not magic (hard coded) numbers
how can i do this sign on keyboard: '
teh stepSize is purely to sync the animation speed to server ticks
yeah, usually it's best to have the above an not 57
Math.cos(Math.toRadians(angle))/10 why
the compiler will most likely simplify it
i thought we were using sin
you don't have an apostrophe key?
sin is for the up/down translation
oh its simmilar
cos is just teh inverse of sin
like yin and yang
compiler will input the number directly if its able to when it compiles
otherwise yes, it will simplify some of it
the only thing to worry about is rounding
usually for such math you would ensure that doesn't happen by having some cut off point
has anyone else had issues with the buildtools gui infinitely loading? i tried using the jar but keep getting an error when trying to compile (https://pasteb.in/?bf0fbee2266df2e2#ALvgE5wmARm6xcyJAFw8tnPsNcX3ruV1Eu9sdxDSNk25)
this is supposed to be less laggy than rotating items with armorstands right?
yes
as it uses Transformations
Nice. and it should have 90% less errors probably
Are you sending the component properly
which one is pitch?
Oh, I see where I went wrong! I've been focused on .. I'll show you.
Pitch is up/down
which number is pitch
oh ill figure that out
Well, look up and down, what changes
I've been focused on the line above that I didn't notice it was actually using the one at the bottom!
Thanks @young knoll !
is there a guava map that has a value view as keys?
i think i saw it somewhere, forgot where exactly
treemultimap?
i'll try, thank you
because every fork fixes it
What I'm confused about now is if I want to use a plugin channel, is it safe to use "BungeeCord", or is it equally safe to use a custom channel "custom:channel"
bungee is safe
Even if this channel is registered through Bungee? proxy.registerChannel("custom:channel")
and Bukkit
server.messenger.registerOutgoingPluginChannel(this, "custom:channel") server.messenger.registerIncomingPluginChannel(this, "custom:channel", this)
Does itemdisplays have ClickEvent or something?
what exactly are you trying to do?
click commands on item displays
ItemDisplay is an entity
so PlayerInteractEntityEvent should work right?
will test it a sec
yea it doessnt work
:(
so what should i spawn
armorstand?
No idea. AS or a no AI slime as a passenger
no clue
3
bump
I tried removing some of the directories in .m2/respository/org/spigotmc but unfortunately this did not help
it looks to be a path issue
delete everything and start fresh. No space in your folder name
my dumbass didn't even think i made the mistake of putting a space in my folder and spent the past 3 hours trying to research my issue 😂 thanks for including that at the end to remind me -_-
Hello, is there a way to use something like Components with Font Options in inventories? Like i have a ASCII Char that is in a Texturepack a GUI and it is defined under fonts/inventories.json and i want to display the ASCII Char in the Font in a GUI.
Nice. But does it really need interpolation? (Afaik the interpolation is made on the game loop)
you have JRE installed not JDK I reckon
to maintain a smooth transformation, yes
Strange, when I looked at the display nms class, it looked like each step of the animation were calculated by the game loop on one tick.
2.87 degrees was as close as I could get to match the animation speed
How do I start a project for the version 1.20.6?
I thought it might be since I have both JDK and JRE installed but even after uninstalling JRE it didn't fix it, just a silly oversight on the folder name causing me lots of pain
[13:13:49] [Server thread/INFO]: TranslatableComponent(format=%(?:(\d+)\$)?([A-Za-z%]|$), translate=custom.potatoes.in.farmland, with=[TextComponent{text=. , BaseComponent(style=net.md_5.bungee.api.chat.ComponentStyle@3d3af72, insertion=null, extra=null, clickEvent=null, hoverEvent=null, reset=false)}, TranslatableComponent(format=%(?:(\d+)\$)?([A-Za-z%]|$), translate=custom.ageable.almost_ripe, with=null, fallback=null), TextComponent{text=., BaseComponent(style=net.md_5.bungee.api.chat.ComponentStyle@3d3af72, insertion=null, extra=null, clickEvent=null, hoverEvent=null, reset=false)}], fallback=null)
So this is the TranslatableComponent when I print it out. Looks OK to me.
But when I do:
player.spigot().sendMessage(inspectionText);
I only get the first element out.
Do I need to do something extra... ?
probably would help to show code?
TranslatableComponent inspectionText = new TranslatableComponent("custom.potatoes.in.farmland");
inspectionText.addWith(". ");
// Check if it can be cast as Ageable.
if (!(clickedBlock.getBlockData() instanceof Ageable ageable)) {
System.out.println("Block data is not Ageable!");
player.spigot().sendMessage(inspectionText);
return;
}
// Check if it's fully grown.
TranslatableComponent suffixGrowthMessage;
var maxAge = ageable.getMaximumAge();
var age = ageable.getAge();
System.out.println("Block data is Ageable. Age: " + age + " Max age: " + maxAge);
System.out.println(inspectionText);
if (age == maxAge) {
suffixGrowthMessage = new TranslatableComponent("custom.ageable.ripe");
} else if (age == maxAge - 1) {
suffixGrowthMessage = new TranslatableComponent("custom.ageable.almost_ripe");
} else if (age == 0) {
suffixGrowthMessage = new TranslatableComponent("custom.ageable.recently_planted");
} else if (age == 1) {
suffixGrowthMessage = new TranslatableComponent("custom.ageable.sprouting");
} else {
suffixGrowthMessage = new TranslatableComponent("custom.ageable.not_fully_mature");
}
System.out.println(suffixGrowthMessage);
inspectionText.addWith(suffixGrowthMessage);
inspectionText.addWith(".");
System.out.println(inspectionText);
player.spigot().sendMessage(inspectionText);
So, like I explained the ispectionText seems to contain all the elements that it should contain.
But when I do:
player.spigot().sendMessage(inspectionText);
It only prints the first element out.
So that would be the custom.potatoes.in.farmland
May I ask how .sendTitle works? I noticed it had s and s1 will it display a message like this?
TEST
TEST
or do I need to add \n?
declaration: package: org.bukkit.entity, interface: Player
I'm guessing S is the title and S1 is the subtitle?
that is what you set it to o.O
That javadoc does tell you
I recommend you read it
I mean, it is the thing that is in translate, I don't imagine translatable would affect all the other settings?
Yes. That's the first element. But if you read the code a bit further you should see that I'm combining it with suffixGrowthMessage and the rest which is shown in the raw message I printed out. It's all there.
if your goal is to send all of the string I imagine you would need to send it differently
How exactly?
well, does it need to be a translatable component, not entirely sure what that is exactly and would have to look
Right so what I'm doing in practice is I take two translations from the resource pack.
I smash them together. And I add also some formatting like ". " etc.
Are we sure that addWith mutates the component
And then I try to send the built message.
Olivo beat me to it
https://www.spigotmc.org/wiki/the-chat-component-api/
I'm reading this doc page.
It doesn't seem to explicitly say that I need to do anything extra.
anyways, while it makes sense what you are doing, do you still need to send it as a translatable at the end?
I think the example it has is exactly what I have done.
How would I process it into another format?
Would that be TextComponent ?
Yes
So using a StringBuilder or something?
And then
player.spigot().sendMessage(new TextComponent(messageBuilder.toString()));
?
What are you even trying to achieve
also it seems you misinterpreted the addWith
To send a message to player.
I know, what exactly
Oh. Can you explain what I need to do?
Why do you need a translatable component and stuff
Because the texts are in the resource pack as translations. English, Finnish, etc.
I mean this example seemed simple enough.
But that doesn't seem to work like that.