#help-development
1 messages ¡ Page 906 of 1
(not use getBlockAt)
just fyi, some of us have been using java longer then you been alive
sure but having no idea that FAST_INVOKEVFINAL is an real instruction
well it isn't, only you think it is
okay please show me how to use it in my language compiler
you cant
you need to code an java class file lib on your own
So that is Java 17 full list of bytecodes
yeah I mean my experimental language compiles to bytecode, 227 is certainly I can write to the classfile
why can your classfile use it but mine can't
it is not documented there
it is quite possible the obfuscator is the key here
it is most likely an obfuscator specific thing and not the compiler
yeah :p
pretty sure if they looked at the class file after compiling, they would see that bytecode doesn't exist in the class đ
are you stupid as well? xd

Well considering I am considered one of the most versed on the JVM as well as Emily
I highly doubt you would know more then either of us
case Opcodes.FAST_ILOAD:
add(new VariableInstruction(opcode, in.readUnsignedByte()));
break;
Those are not bytecodes just fyi
Bro its bytecode xd
I got better things to do like earn money
Ah right, a former Bukkit Dev staff member wouldn't understand
Its not nice
As i understand, you do not understand right
you haven't shown a single bytecode
Emily can u return and update the 1.8 api
not even the appropriate formats for them either
send a class file that uses the instruction and passes the verifier
I have showed you the fast iload instruction with the value
In some jvms you need to enable noverify
How do java read and execute it if its not in the bytecode
it's a hotspot thing
if hotspot without verifier runs it, it doesn't mean it works everywhere else
You can run it as every other instruction
Test it yourself
You dont need to believe me
Im just telling you it will work
how to get input from sign in spigot 1.20
there is a lot of things you can put in the class file that the jvm will just ignore
you literally turn off the verifier and rely on an implementation detail
Yeah
you can't just use it like any other class
You dont need the verifier at all
Why not
clearly shows you don't even know what verify does
you have to explicitly turn off the verifier on the command line
for those that don't know, I highly recommend not using that jvm arg at all
and even then, people might have a different jvm impl, which will explode
Yeah or you do it with the unsafe
You shouldnt thats right
but the fact you need to disable the verifier to make your code work, already means that whatever you are doing is not part of the specifications
But in fact you can
Thats right
As i said
Its not documented as valid instruction
no as the experts have said, it doesn't exist whatever you are talking about in the official JVM
so either what you are doing is being ignored by the JVM or you are running a non-official or non-speced JVM
It will execute the code
Please try it yourself
Thanks, I needed that verification
I have no interest proving something that doesn't exist in the official specs. I already know the outcome on my system of what will happen or two possibilities
either my JVM dies or the JVM is going to ignore it
no
it loads an int value from the LVT
I temporarily timeoutâd the user, given their extremely inappropriate behavior for now
which user o.O
the one that asked about the bytecode?
oh the other person
anyways, if I recall FAST just dictates the interpreter to use but I really don't want to go find all my java documents in regards to fast
myea
iload is integer load, which loads from local variable table (LVT) or as it states in some of the documentation local variable index
spigot literally 1984



how does bukkit have a listener class that doesnt look like this?

you can
not for spigot

like
is the same than https://www.spigotmc.org/wiki/using-the-event-api/
Bukkit Plugin for in-game player tutorials. Contribute to frostalf/ServerTutorial development by creating an account on GitHub.
yes but
I have custom events in that plugin
i know how to do that
then?
but i want to know why thats empty
so you can extend it
an interface sometimes just exists for clarification and not that it needs to add anything
also helps with casting
depends what you are doing, but if all you want is just custom events then as the above no need
guava has an event bus
you just have to remember that with your custom events you need to invoke said event yourself in your code otherwise it will never be heard by anything listening for it đ
is this from a cheat client 
yeah
smelled it
What is better when creating an api, passing copies of objects or giving them directly?
How large is your code base?
why this question
It can sometimes be more reasonable for larger code bases, to split certain module layers with a separate api layer where the api isnât directly implemented, but instead it wraps around whatever it needs to serve its contract
I mean that an object is registered through a special class and I donât know what will happen if the developer works directly with the object without registering it, but at the same time nothing will happen if the registration class does not directly link the object data and the object itself
what do you mean, what does this have to do with it, are you telling me about the interface?
You asked about passing copies or direct objects, maybe I interpreted it wrongly, if you just meant the collections in particular
I'm talking about getting and setting data objects directly or through a copy
Does bukkit have an Eventhandler for every Event or does the event get published to one which then proceeds to Check which method is looking for what Event?
Well it sort of depends, like both has advantages and disadvantages
so i did some digging and the only non-hotspot related mention of "FAST" instructions are in an internal class presumably relating to the Verifier
JDK main-line development https://openjdk.org/projects/jdk - openjdk/jdk
Like ZlataOvce said I believe
Tho I do think going by immutability by default is a good mindset unless you need mutability for w/e reason (which implies copies to some degree)
im personally going to start using _shouldnotreachhere in my bytecode
That's why I'm asking what is better when creating an api, provided that the object is registered through a class that binds and hashes the object data
nah, reflection = slow
jk
(kind of)
theres always weird hackery to alleviate perceived slowness for it though, like MethodHandles and that godforsaken LambdaMetaFactory class
methodhandles are pretty fast
the chain is like,
Method, MethodHandles, LambdaMetaFactory, Direct Invoke
iirc
"slowest" to "fastest" that is
not a big fan of LMF itself though, im a little stupid and getting MethodHandles to work is a feat in and of itself for me sometimes
sometimes the param types just DO NOT like me
Wasnât reflection also reimplemented with method handles or something like that in a newer jep
yes
a lot of my knowledge is still based off of java 8 and mc 1.8 sadly
đ
so what i say IS most likely usually outdated to an extent
its where i did my most work :V
should change that
workin on it
my non spigot related projects utilize java 17 at least
my spigot ones are still on java 8 just to try and keep a wide support range
yea thatâs understandable
Gen zgc is pretty cool, has quite the potential
do you WANT depression?
well no clue relism does my backend
just dont close the Socket
/sar
string joinPacket = string.Join(";", secret, "join", userName, password); // client sends this
string allowJoinPacket = string.Join(";", secret, "allow_join"); // server answers with this```
```c#
public class Server {
public void OnInfoReceivedFromClient(TCPClient client) {
client.GetStream().Read(); // i should read a join packet
if (userPassword == password) { // if password matches
client.GetStream().Write(); // i should write allow join packet
}
}
}
public class Client {
public void OnInfoReceivedFromServer(TCPClient server) {
server.GetStream().Write(); // i should write a join packet
server.GetStream().Read(); // i read the answer from the server
if (serverAnswer == allowJoin) {// i should connect and everything is good
}
}
}
Soon â˘ď¸

wtff C#?
idk about how to work with streams and buffers at all
yea ;p
you need a buffer of fixed length in both languages
do it the unsafe way! xd
which you use to read and write data
well, you can use object = null and then call System.gc()
not like it actually does that
isnt this possible with weak references or something?
but at least it's close
That doesnât really force it
it also calls finalize() so you can have a "destructor" code
not force but i till be gced very fast
I think java has the foreign mem and func api in j22
and evry weak ref would be collected
it doesnât really force
so ist acctually forced
its more like a request
well it does, but it requests to gc, not performs it
And a lot of apps disable system gc
i mean this would work fine:
meanwhile the Minecraft client calls System.gc() in at least 7 different locations fairly frequently (jesus fucking christ mojank WHY)
public static void main(String[] args) {
MyClass m = new MyClass();
m = null;
System.gc();
}
public class MyClass {
@Override
public void finalize() {
System.out.println("I'm erased");
}
}```
that doesnt clear the object
it just suggests to gc
50/50 chance that it does
thats why a said you could use weak references only xd
Not always
this exact code always works
and i get the console message
it also works without the System.gc because its the end of the program
yeah but thats agasinst the use of weak references lol
yeah but anyways
if you want it to get gced you can code it that way
lol
afair i din't have finalize message without calling System.gc() before the end
you do
Easier said than done when u run some software that is composed of code written by a diverse set of devs
once the gc collects your object it gets called
but finalize is a bad practice anyways
yeah but it wasn't printed to eclipse console
isnt it deprecated anyways
Yea
it is
you use cleaners now
i just showed finalize output in my java blog to show that it's kinda like cpp
what
which has a destructor system
I men there are a lot of issues with finalize
just that cpp is 100% manually
yeah
and java is managed
but nobody uses finalize() anyways
because you shouldnt
can somebody help me with buffers here?
i suck at tcp
my last attempt gave me a string with length 999
?gpt
where actual characters were only like 20
i'm from russia đ
dont you guys have gpt
what about bard aka gemini
What?
No Spotify in russia?
yes
using System;
using System.IO;
using System.Net.Sockets;
using System.Text;
public class Server
{
private const string Password = "your_password";
public void OnInfoReceivedFromClient(TcpClient client)
{
NetworkStream stream = client.GetStream();
// Read join packet
byte[] joinPacketBuffer = new byte[1024];
int bytesRead = stream.Read(joinPacketBuffer, 0, joinPacketBuffer.Length);
string joinPacket = Encoding.ASCII.GetString(joinPacketBuffer, 0, bytesRead);
// Assuming joinPacket contains user password
if (joinPacket.Trim() == Password)
{
// Write allow join packet
byte[] allowJoinPacket = Encoding.ASCII.GetBytes("AllowJoinPacket");
stream.Write(allowJoinPacket, 0, allowJoinPacket.Length);
}
}
}
public class Client
{
public void OnInfoReceivedFromServer(TcpClient server)
{
NetworkStream stream = server.GetStream();
// Write join packet
byte[] joinPacket = Encoding.ASCII.GetBytes("ClientPassword");
stream.Write(joinPacket, 0, joinPacket.Length);
// Read the answer from the server
byte[] serverAnswerBuffer = new byte[1024];
int bytesRead = stream.Read(serverAnswerBuffer, 0, serverAnswerBuffer.Length);
string serverAnswer = Encoding.ASCII.GetString(serverAnswerBuffer, 0, bytesRead);
// Assuming serverAnswer contains "AllowJoinPacket"
if (serverAnswer.Trim() == "AllowJoinPacket")
{
// Connect and everything is good
Console.WriteLine("Connected to the server.");
}
}
}
gpt output
lmao
"hey you guys started a war so we take spotify away"
copilot, bing chat, google shit, spotify, facebook, instagram, snapchat, paypal, access to foreign banking
i can't even get paid for making plugins
and can't by any đ
ÂŻ_(ă)_/ÂŻ
we also have no ads on YT
since russian youtubers would get money otherwise
I apologize if there's any confusion in my response. It appears that there might be an issue with my interpretation or the code example provided. Let me clarify and correct any mistakes.
In network programming, when you read from a stream, you typically get back the number of bytes read, which can be used to determine the length of the received data. However, in the example provided, the specific values for lengths and content are arbitrary and simplified for illustration.
If you have specific concerns or questions about certain parts of the code or if you could provide more details about what you find confusing, I'd be happy to help clarify and address any issues.
thats so dumb
ask him what do 0 and length in the end mean
I apologize for any confusion. The 0 and length in the code snippet I provided are placeholders for actual values that you need to determine based on your specific implementation.
Let's take a closer look at the relevant parts:
csharp
// Read join packet
byte[] joinPacketBuffer = new byte[1024];
int bytesRead = stream.Read(joinPacketBuffer, 0, joinPacketBuffer.Length);
string joinPacket = Encoding.ASCII.GetString(joinPacketBuffer, 0, bytesRead);In the Read method, 0 represents the offset within the joinPacketBuffer array where the data should be placed, and joinPacketBuffer.Length represents the maximum number of bytes to read. The bytesRead variable then holds the actual number of bytes read from the stream.
Similarly, in the Write method:
csharp
// Write allow join packet
byte[] allowJoinPacket = Encoding.ASCII.GetBytes("AllowJoinPacket");
stream.Write(allowJoinPacket, 0, allowJoinPacket.Length);Here, 0 is the offset within the allowJoinPacket array from where to start writing, and allowJoinPacket.Length is the number of bytes to write.
These values depend on the specific requirements of your protocol and the data you are exchanging between the client and server. You may need to adjust these values based on your actual packet format and size.
is that like length of the message to read
and 0 is smth i don't know about
why do i need an offset?
isn't stream flushed or smth?
ask if i can flush stream every time so i don't use offset?
since ig if stream is not flushed, i would once reach the end of byte array
Flushing the stream won't eliminate the need for an offset. The offset parameter in the Read and Write methods indicates the position in the buffer from which to start reading or writing data. It is crucial when you're dealing with partial reads or writes.
If you're always reading or writing the entire buffer, you can set the offset to 0, and it will work effectively as if you didn't use an offset. However, if you have scenarios where you're reading or writing a portion of the buffer, the offset becomes significant.
Here's an example with the offset set to 0:
csharp
// Read join packet
byte[] joinPacketBuffer = new byte[1024];
int bytesRead = stream.Read(joinPacketBuffer, 0, joinPacketBuffer.Length);
string joinPacket = Encoding.ASCII.GetString(joinPacketBuffer, 0, bytesRead);// Write allow join packet
byte[] allowJoinPacket = Encoding.ASCII.GetBytes("AllowJoinPacket");
stream.Write(allowJoinPacket, 0, allowJoinPacket.Length);In this example, it's assumed that the entire buffer is being used, so the offset is effectively 0.
Remember that flushing a stream is a different concept; it's about ensuring that all the data in a buffer is written to the underlying stream. It doesn't eliminate the need for an offset in the Read and Write methods, which is more about specifying where in the buffer to start the operation.
so i won't be able to send or receive any more messages
alr so i can just use 0 all of the time for my purpose
but is stream flushing automatically?
since i can't find a Flush() method
I am making custom enchantments. Is it possible to give the enchantment multiple EnchantmentTargets? I want it for Tools and Weapons.
@Override
public @NotNull EnchantmentTarget getItemTarget() {
return EnchantmentTarget.TOOL;
}
Ah right thank you, I wasnt thinking :)
What are the annotations called that prohibit compiling code under certain conditions?
what exactly?
Those donât have a particular name, but one term commonly used is âpredefined annotationsâ
apparently they are called compiler directives
Ah interesting
Well Override also but yea
spring seems to have some
@Conditional or @AspectJ
supresswarnings probably as well
Isnât that just annotation processing
^
Yes I want create custom
tell us more about it
otherwise we will clutter you with many bs you probably dont even need
Thenks
otherwise baeldung always got your back
Sorry, I am pretty new to java, but I cant seem to make the EnchantmentTarget work. In every possible way I have to make the public EnchantmentTarget getItemTarget() a list which isnt possible. I am making custom enchantments and want to add multiple enchantmenttargets
?paste
My guess would be that they are overriding/implementing some class, which means he can't change the return type of a method.
And anyways, you should not implement spigot/bukkit classes.
This is what I was trying (formatting weird)
public ArrayList<EnchantmentTarget> EnchantmentTargets() {
ArrayList<EnchantmentTarget> enchantmentTargets = new ArrayList<>();
enchantmentTargets.add(EnchantmentTarget.TOOL);
enchantmentTargets.add(EnchantmentTarget.WEAPON);
return enchantmentTargets;
}
@Override
public EnchantmentTarget getItemTarget() {
return EnchantmentTargets();
}
Ah ok thank you I will try
Quick question, is there a way to change item's max durability and how(only the way not the code, I don't need spoon-feeding)??? Cause I used pdc and setDurability() and none worked.
max durability is hard coded
you cannot change it
You'll have to implement your own system for tracking the durability and then scaling the durability damage so the durability bar looks correct
ohh ok
declaration: package: org.bukkit.event.player, class: PlayerItemDamageEvent
I just wanted the players to be able to see it in the client
you can put it in lore or smth
yeah I know
Thank you both
Is there a way atleast to hide item durability(the text not the bar)???
đŚ
I wonder if you could use a resourcepack
a falling block is being shot from a location, 1, 1, 1 for example, and im shooting it to the location 10, 50, 10, for example, the fallingblock just wont go above a certain y level, is there any way to fix this
You could hide the entire tooltip with a shader
Idk if you can just target the durability
I searched for it too, no I haven't found one yet
I ll leave it just as it is and I ll add a lore for the new durability thank you all again.
Do you mean that it slows down ?
no like it wont go above a certain y level
the x and z work fine like it will shoot towards tghe correct x/z but it just wont go above a certain height
Are you launching it with one big setVelocity
im using
FallingBlock fallingBlock = baseLocation.getWorld().spawnFallingBlock(baseLocation.clone().add(0.5, 1, 0.5), blockMaterial.createBlockData());
Vector direction = targetLocation.toVector().subtract(baseLocation.toVector()).normalize();
fallingBlock.setVelocity(direction);
}```
so yeah 1 setVelcocity to get it to the target
you are setting velocity to a unit vector
yeah?
it's got no magnitude. It's always going to fly at teh same speed
so it should have a different speed then itll go above a certain y value?
but i thought the vector/velocity would take that into account?
Would disabling gravity give you the result you're looking for ?
i think i tried that a while ago and it just made it go flying but ill try it again rq
if you want to modify the entity that you spawn do use the spawn method that takes a consumer
will ensure it's spawned with the data instead of being spawned and then modified
@young knoll do u know if biomes are translatable or did choco lie to me I can't find đ
@Override
public void accept(FallingBlock fb) {
fb.setGravity(false);
}
});```
how would i add the blockmaterial to the consumer method?
so choco is a god damn liar!!!! smh smh
okay what about Art I also could find nothing to do with "art translations"
yo facts
probably not
I agree
exactly
biomes do have translation keys
that i dont know
F3
I swear f3 shows the namespace
I just ctrl-F'd for "plains" in en_us.json
not exposed on the server then
because they aren't used anywhere from what i can see
pretty sure thats clientside yes
art does too
art must also be client side
seems like SoundCategory is too
Translatable component hype
Oh yeah I had a wacky idea at work
and F3 also doesnt translate it - it doesnt even show the "biome...." key but only minecraft:plains
yeah it shows the namespace
Advancements?
maybe /locate
nope /locate biome also uses namespace
Mf
ÂŻ_(ă)_/ÂŻ
or not
it does show the translations in Create World -> Single BIome -> ...
they are just there to exist
doesn't look like its exposed on the server anyways
What if I just used translatable components on everything instead of making a lang system at work
its optional though sadge
well it's always just biome.minecraft.<key-name> lol
I mean yeah you can do that
Instead of the player picking the lang on a gui they'd just change their game lang
bump
If you are already using a resource pack I don't see why not
looks like there's no setter for it ;/
Guess you'll need the spawnFallingBlock method
alr
why is fallingblock a serveroperator
all entities are
uh
no?
yeah they are
lmao
since /execute can make entities run commands
"you were banned by armorstand"
"oh no i got banned by a sandblock"
Sadly I don't think /execute can run that type of command
FallingBlock fallingBlock = baseLocation.getWorld().spawnFallingBlock(baseLocation.clone().add(0.5, 1, 0.5), blockMaterial.createBlockData());
fallingBlock.setGravity(false);
Vector direction = targetLocation.toVector().subtract(baseLocation.toVector()).normalize();
fallingBlock.setVelocity(direction);
}```
the blocks just go to space
they dont go back down
maybe because you set gravity to false
this is my original issue
you can set the Y of the velocity to a higher value
so it flys higher
its already doing that though no?
Vector direction = targetLocation.toVector().subtract(baseLocation.toVector()).normalize();
not after normalized
im kinda confused so what should the y of the vector be? the base location y - target location y?
Don't normalize it
i did that but then the fallingblocks went all over the place, they went flying past the target
If you're aiming for a specific block, you're going to have a hell of a time. Velocity's actual metrics are pretty undocumented so a velocity of, say, 3, isn't going to launch it 3 blocks
so theres no "simple" way to launch a falling block to a location?
A very specific one? No, not really
Best way is probably to fake it if I'm being honest. Just teleporting it on a loop in small increments over a predefined path
(and by "predefined", I mean calculating an arch between two points - which you'll need to look up the math for)
welp that sucks
Yeah, but the alternative is velocity which is rather difficult to predict
If your increment is small enough, the teleports are interpolated so it should still look relatively smooth
well ty anywya
Would It be possible to create vĂŠrtices with block displays?
Hello! I was wondering if there would be a way to make RecipeChoice.ExactChoice() ignore some things such as an item's name?
There is a formula you can roughly use to calculate that
remember using it a couple of years ago
should be somewhere on reddit
you mean saving enums?
yes
why wouldnt it be fine? I'd recommend using a try catch tho when deserializing so if you delete an enum that you wont get error and it will just reset to defualt
you arent accessing the file all the time, jsut when loading the player data right?
yes
okay, thats good
yeah but when serializing and deserializing I'd always use a try catch so your stuff doesnt break when something it removed
what is the Effect enum name for minecraft:explosion?
also for minecraft:heart?
ok I just realised EntityEffect etc exists
Damn huh, can I not use EntityEffect at a specific location in playEffect?
how do i disable vanilla critical hits?
damage event, check if damage cause is critical hit, if yes then cancel the event
then event.setDamage(0) I think
if youre using EntityDamageEvent
i want all hits to be non critical
how can i apply the mappings to another dependency? I am using a dependency that uses nms, but i am using it as .jar and it has the obfuscated names. I would like to extend some of its entity classes, but since it has the obsucated stuff, i cant even use the constructor
the class i want to extend
i am using gradle
hey so on org.bukkit.event.player.PlayerFishEvent getCaught() is always a DROPPED_ITEM, if I cast it to (Item)
how can i find out what kind of a DROPPED_ITEM it is??
how i can create a licence and use it for my plugin?
Do you mean ((Item) getCaught()).getItemStack().getType()?
yea i figured it out ty xd
tnx
Hi, is there any cloud system for Spigot that supports auto scaling and containerizing? What I found were CloudNet-v3 and SimpleCloud-v2. However, they do not support docker
yeah don't create an empty shape
wdym?
How?
yeah you're making an empty shape
wdym by empty shape and not-empty shape?
You can't make a recipe without a shape
So don't create an empty shape
let me know if you need a hint :p
yeh I do need it :l
Wait what's wrong though? I don't see anything wrong except for the .shape() on the last line looking weird to me
I'm pretty sure the length is 3
yeah that's the problem
god bless you
Ohhhhhhhhh
I though it was a wrong in the shape
I also wanted to find the issue but I thought that .shape() wasn't an issue but rather some weird new convention
So I blurted that out lol
OHH
I got it
The methods are builder methods
yeah
Why would it not compile
it compiles because it takes var args and returns the instance
May it be that the EntityTrackEvent is called twice when an entity is tracked?
?whereami
PlayerTrackEntityEvent
yep also paper
pepper
paper
okay so
quick problem
i've got a list that stores classes with the parameters (string id, Material material),
if i ONLY give the id, would there be any way to get the material?
a map
quick answer: what
ill try that
is there some way to stop World from being ticked unless I want to?
I keep some extra worlds loaded and dont want them to be ticked unless someone is on them
is gson not able to save enums?
[{"uuid":"3b4b5172-4860-4191-bda8-1be9ae7cace8","flair":"MUSICAL"}]
[20:13:23 WARN]: [HTP] Unexpected error while loading Flairs: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 3 path $[0]
hmm docs say it can
nvm I did a goofy
entered the wrong object
How?
Probably something like inventory.setSomeSlot(item)
Unfortunately, I couldn't do anything with that
its probably just slot ids
Yes but Slot 0 & slot 1 not working (with setItem) & with addItem its also not working
judging the fact the inv is probably from block state, call update onthe block state
that just might be your fix
Also you're referring to "input slot" as the ones players put items into yes?
what's the best class to use for random numbers and chance system?
eg. I have an item with 5% chance to be caught
using Random for this would be ok but if I generate an int between 0 and 100, everything has an equal chance to be generated? for 0, its 1% to be generated, for 1 its also 1%, etc..
would it be ok to develop a system where actually
a number 0 would have 0% to be generated,
a number 1 would have 1% to be generated
....
but this is where I'd run into issues so instead, I though:
how about I develop a system where
numbers between 0-10 have 10% to get caught
numbers between 11-20 have 20%
numbers between 21-30 have 30%
numbers between 31-40 have 40%
numbers between 41-50 have 50%
and numbers above 50 have 50%
... something like that?
for 5% just check if the random number between 0 and 100 is <= 5
What packets can I send to the minecraft server to keep my bot moving?
I tried that but it didn't work
bot.on('position', (packet) => {
bot['position'] = packet
console.log(packet)
})
bot.on('login', (packet) => {
bot['entityId'] = packet.entityId;
setTimeout(() => {
// Send initial packets
bot.write('position_look', {
x: bot['position'].x,
y: bot['position'].y,
z: bot['position'].z,
yaw: 0,
pitch: 0,
onGround: true
});
setInterval(moveForward, 50);
}, 50)
});
function moveForward() {
const position = bot['position'];
const newPosition = new Vec3(position.x, position.y, position.z + 0.01);
bot.write('position', {
x: newPosition.x,
y: newPosition.y,
z: newPosition.z,
onGround: position.onGround
});
}
someone can help me pls
but would that be ok? I guess its 5% likely that the number between 0 and 5 will be generated? or is it an equal chance? It's kinda confusing
it's like.. every number has an equal chance to be generated, between 0-100
so is 5%, numbers in range 0-5 really 5%?
why wouldnt it
It's not like higher numbers will be generated more often? (higher numbers have a higher chance to be generated). numbers will just get picked randomly between 0-100
1 can be generated with the same chance as 100
so 1% is equal to 100%
no
yes
if its 0-5 you get a 5% if its 0-90 you have a 90% chance
hmmm
because theres 5 different numbers that could be generated for it to be that
if it was only 1 number to pass, that would be 1%
because its 1 number out of 100 to get that
I guess yeah... fair point
but then if you wanted it 100 out of 100, theres 100 numbers it could be
Apart from methodhandles on a later platform, those have nothing to do with reflection, those are used for indy bootstrapping, you forgot a few of them though
StringConcatFactory and ObjectMethods might be interesting to take a look at :)
hello i got a problem i created a lifesteal server bungycord and boxpvp so i wona put the lobby on the boxpvp but its says to me a probleam
if someone can help me ill be happy
Image
anyone can help me pls ? https://discord.com/channels/690411863766466590/1209982453955956776
why doesn't the NPC skin work? 1.12.2 ```java
public static EntityNurse nurse;
public static UUID uniqueId;
public EntityNurse(MinecraftServer server, WorldServer world, GameProfile profile, PlayerInteractManager manager) {
super(server, world, profile, manager);
}
public static EntityNurse create(String name, World world, Location location) throws IOException {
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
uniqueId = UUID.randomUUID();
GameProfile playerProfile = new GameProfile(uniqueId, name);
nurse = new EntityNurse(nmsServer, nmsWorld, playerProfile, new PlayerInteractManager(nmsWorld));
nurse.getProfile().getProperties().clear();
nurse.getProfile().getProperties().removeAll("textures");
nurse.getProfile().getProperties().put("textures", new Property("textures", texture, signature));
nurse.getBukkitEntity().setRemoveWhenFarAway(false);
nurse.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());
nurse.playerConnection = new PlayerConnection(nurse.server, new NetworkManager(EnumProtocolDirection.CLIENTBOUND), nurse);
nurse.spawnIn(nmsWorld);
nmsWorld.addEntity(nurse);
return nurse;
}```
First of all i want you to remove those two completely.
After that show us your texture and signature
seems to contain some trash at the end, oh wait
The texture looks fine
{
"timestamp" : 1588347344589,
"profileId" : "04b708a335664f2f85ec5eef27d14dad",
"profileName" : "Violetskyzz",
"signatureRequired" : true,
"textures" : {
"SKIN" : {
"url" : "http://textures.minecraft.net/texture/4c46f7eb284ce4937d8290fd42ecf6b5adc8f0e4cec5c7d44d732bccf2576c1e"
}
}
}
But your signature looks scuffed.
So the NPC spawns but without a skin?
yes
how do I get the skin of any of the players on the server?
In 1.12 you need to use nms. Get the GameProfile and then their skin property.
Btw i think you are missing a crucial part because simply adding the EntityPlayer to a world wont send their profile information to the other online players.
And this profile information contains the skin.
i send packets
1% chance for any given number to be picked, the only way your percentage increases is if your range does first, ie: as epic was saying 0-5 = 5% chance for .Random to pick 0-5.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection;
PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, EntityNurse.nurse);
PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(EntityNurse.nurse);
connection.sendPacket(info);
connection.sendPacket(spawn);
connection.sendPacket(new PacketPlayOutEntityHeadRotation(EntityNurse.nurse, (byte) ((EntityNurse.nurse.getBukkitEntity().getLocation().getYaw() * 256f) / 360f)));
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, EntityNurse.nurse));
}```
i removed static abuse
I find this to be the easiest way to track your .random percentages
You are sending the PacketPlayOutNamedEntitySpawn packet but then also adding the same entity to the world (which will result in the same packet being sent again)
And now i need to change that too
Do you want the NPC to be virtual or actually on the server?
What do you mean
You are sending packets to make the player believe another player is standing there while the server has no idea about that.
But adding the entity to the world makes the server actually aware of that entity (which will result in the server ticking the entity)
I would recommend you to use Citizens or anothe NPC library for now. Im seeing a few red flags in your code (not to mention the dangerous static abuse)
I will do just that; I will use citizens. But I also want to try creating at least one NPC myself. I need to send packets when a player logs into the server, and if the player moves away from the entity and then returns to it, I also need to somehow send them; otherwise, the entity won't be visible.
and if u get 90-100 its a 10% chance
because the difference between the two numbers is 10
it wouldn't be 90% or 100%
yes, 1 has a 1% chance, 2 has a 1% chance..etc
1% (1) + 1% (2) + 1% (3) + 1% (4) 1% + 1% (5) ==> 5% for 1:5 (inclu)
Hello everyone, I'm currently developing a Minecraft Spigot 1.20.4 plugin and I'm having trouble creating custom enchantments. I create them and apply them to an item, and they are indeed on the item, but the item is not highlighted and doesn't have the enchantment in its lore... Is this normal?
This is a text translated into English, sorry in advance...
Show code
ok
whats an easy way to make this take into account damage modifiers
i always assumed e.getDamage has all damage modifiers
but ig now
getFinalDamage
oh okay thxc
From the event
mhm thx
?paste
thx
what issue are you experiencing
when i take the item on me i dont see the echant on it ... its normal ??
yes, the client doesnt have a translation for your custom enchantment
what he said
How am I supposed to do it
add lore
also you shouldn't extend the bukkit Enchantment class
item.setMeta
yeah but the item is dont Shine
u can add shine
how ?
add any entchantment
and set it to false for displaying
meta.addEnchant(Enchantment.LURE, 1, false); // Use any enchantment
yeah but the enchant gonna affect the item .....
there is no "false for displaying" ?
okk i see
okk i gonna try thx guys !!
well u can still add a random entchant and remove it in the lore ig right @tender shard ?
yes
ik someone will say it is not the right server, but shouldnt it work?
that would probably work if it was groovy
and not kotlin
you'll need to get the task in another way ig
but this works on another module
parent
submodule
yeah
?paste
hey its me again xDDDD
i have this error on paste and my code too
if someone know how patch it i ganna be happy for the night ; )
It appears that you're casting something you shouldn't
and that you didn't send the right code
fr.plugin.itemCustom.enchants.enventGrappin.onDamage(enventGrappin.java:21)
is where the issue is
you also seem to be breaking naming conventions
yeah but it was a try with a enchant manager but is the same with this
?conventions
yeah i know i juste a test ....
The entire plugin is just a test?
yeah
oh well ig
you really shouldn't be using that interface for enchantments anyway so đ¤ˇââď¸
witch interface i should use ?
Implementing interfaces from bukkit isn't safe unless explicitly specified so
You can use PDC to add data such as your own enchantments to the item
?pdc
If I understand correctly i must to create a custom class enchant and and on" metadata item" the enchant and read it on evnet ?
Hello, I am using nms to try to hide a player with #Player.hidePlayer() but show him in the tablist to the other players, I have my reasons and I am not going to use the invisibility effect (some answers that I saw checking other forums), I have this code, I don't usually use packets (it's the first time) and I have this code from a friend of his plugin from 1.18.2 that does that, I tried to use it (I'm on 1.20.4) and it doesn't work, at first I I encounter this error when using the code java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_20_R3/entity/CraftPlayer, I don't know why 1.20.3 comes out if I am using the buildtool 1.20.4-R0.1-SNAPSHOT, I have this code and would like help with it
private static void hide(Player tohide, Player hider) {
tohide.hidePlayer(NokHidePlus.getPlugin(), hider);
ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.a(Arrays.asList(new EntityPlayer[] { ((CraftPlayer)tohide).getHandle() }));
(((CraftPlayer)hider).getHandle()).c.a(packet);
}
private static void show(Player toshow, Player shower) {
ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(Arrays.asList(new UUID[] { toshow.getUniqueId() }));
(((CraftPlayer)shower).getHandle()).c.a(packet);
shower.showPlayer(NokHidePlus.getPlugin(), toshow);
}
1_20_R3 is 1.20.4
oh so first error fixed!
thank you
well idk how to make packets works so
probably the packet part is wrong
hideplayer doesnt show the player on tablist
yep
i think i can do it with protocolib but
idk how to use protocolib either so
Hey, is there a plugin for bungeecord/flamecord that could do the POST request on a specific URL with a client IP?
That sounds oddly specific
not enough information
you'll probably have to comission it
also if you're looking for plugins ask in #help-server
this channel is for making them
I guess if I will not find it I will come back here
wat da hell
couldve sworn MethodHandles was reflect
i knew LMF wasnt, but i usually just end up using it with my stuff that uses reflect :V
for the quicker method invocation
what does nms do?
its the internal server code of minecraft
It does everything
even api ?
Everything is api if you cope hard enough
Hey, I can't found solution for my problem, so I need create my own plugin.
In case of IDE i would like to use VSCode, do I need install something else than JDK and Extension on VSC for Java?
Is there a snippet for Bungeecord plugin?
Hello everyone
I need to interact with the basalt generation to change it with another block but I can't find which even I should listen to
Can anyone give me some tips please ? :x
Pretty sure theres a maven plugin for vsc
Java is the only language I would advise not use vsc though, intellij and eclipse are a lot more specialised
You need to override terrain generation
Nooo my bad, I wasn't talking about natural basalt generation, I was talking about player basalt generator
Here is a screenshot from minecraft.wiki
Ooh gotcha
block form event handles those cases usually ^
Oh I didn't think about this event
I haven't used spigot for a long time, feeling lost sometimes đŚ
Thank you for your help guys đ
Java Extension Pack
I am making custom enchantments. I was trying to add that if you put an item in slot 1 of the anvil and a custom enchanted book with lore and a custom enchantment in slot 2 that it would combine in the output slot. Now I cant get something to show up in the output slot. So is it even possible to do this with plugins?
Just experimenting and checking here if it is possible.
Now I have this. A few problems with it.
- If i put in the items I first have to click on the result slot to make something appear
- I cant take anything out of the result slot
ItemStack firstItem = contents[0];
ItemStack secondItem = contents[1];
if (firstItem.getType() == Material.DIRT && secondItem.getType() == Material.STICK) {
ItemStack result = new ItemStack(Material.DIAMOND);
anvilInventory.setItem(2, result);
}
Pretty sure the event has a setResult
hi, i'm trying to send a block update to a target block & its surrounding blocks, i tried BlockState#update but that didn't work
https://www.spigotmc.org/threads/forcing-block-updates.115900/ this thread leads me to look for CraftBlock#setTypeIdAndData and applyPhysics but CraftBlock doesnt exist
Thatâs because itâs not part of the api
why are people talking about CraftBukkit methods on the spigot forums
does anyone know how I can force a block update on a block
Yes it even does api atleast for me but I'm kinda a chad pure NMS developer haven't used the bukkit api since the 90s
I see. I cant see to figure it out with this either tho...
I donât think we have any api to force an update
So youâll have to go with that method or just replace the entire block I guess
how can i replace the block and make sure the data is updated? i dont want to override things like chest inventories but i want to make sure redstone components get updates
How can I turn off the auto completion in 1.20.4 for the aliases that my plugin/commands have??
Copy the state to a variable, set the block to air, then force a state update
this didnt work either https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Block.html#setBlockData(org.bukkit.block.data.BlockData,boolean) with applyphysics = true
ill try this thanks
target.setBlockData(data, true);
BlockState state = target.getState();
target.setType(Material.AIR);
state.update(true, true);
``` this does not update the block either
i'm changing the block rotation with setBlockData(data)
but rotating a repeater that shouldnt be powered anymore doesnt cause it to update
You are changing the type on target then overwriting it with a state update
a BlockState is a snapshot of the Block. It is not live
If you call update on a BlockState it will push teh snapshot data to the live Block.
if you want teh client to see an update you will likely have to delay your state.update a tick
@river oracle yo
I implemented merge sort iterative style
That was way more complicated
Like fully understanding why it works
But it's basically just merge sort but bottom up
wild
target.setBlockData(data, true);
Bukkit.getScheduler().runTask(Bleef.plugin, () -> target.getState().update(true, true));
this still doesn't work, am i doing it wrong
Setting the BlockData doesnt require a state update
then how do i get the block to update đ
*unless target is of type BlockState
target is a block
Simply call Block#setBlockData(BlockData)
Add a debug message to check if your code is even called.
After that, show us your whole code
im trying to send a block update after editing the block rotation data so that if the new blocks rotation has different parameters than its old one (ie a repeater no longer facing a power source) then it will update itself & its surrounding blocks
the blockdata call is being called because the rotation is being applied
its just not updating the power state
Ah, those are calculated on physics updates
okay, so shouldnt BlockState#update(true, true) force physics updates with the 2nd bool
or am i missing something
that doesn't work
and i found a forum thread from 2016 also saying it didn't work
Let me check that out
they ended up using NMS
If we need NMS to update a block this definitely needs to be API I feel like something is missing here
i feel like it should be https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/BlockState.html#update(boolean,boolean) but it doesnt work
I think craftbukkit may just skip doing anything if the current and target state are the same
unless im just a noob
that would make sense
I really expected this to work
The problem might be that the BlockData is an instance of AnaloguePowerable which will be applied as well.
Did we try updating one tick later as well already?
can i update a block around it or something?
doesnt this update 1 tick after
Yeah
doesn't do anything
Well it should
I donât think the repeater itself needs an update
I think the block that would be powering it does
wouldn't updating the repeater make it check if it should be powered or not?
im trying to make this work for more than just repeaters too so i dont want to just case it out and update the back face of it
I think redstone components update their state in onNeighbourChanged
Ah yes. Lets path trace the power to its source and update it /s
lol
Next idea: Lets create a clean new BlockData from the blocks material, apply the rotation and then update the block.
If that doesnt work we enslave coll to write a pr
I have a feeling thatâll make it always unpowered after rotating
Even if the new placement should be powered
Yes there is a high probability of exactly this happening
would updating a block around it work?
maybe the block below it, since that will always be a block
You can try simply updating all 6 ordinal directions
Youll hit the power source then for sure
im trying to think of other cases besides repeaters and comparators where this is going to be an issue
i think thats kind of it actually
I dont think there are any other powered blocks where the rotation is of importance.
wire doesnt have rotation
I thought about that, but the powered state doesnt rely on its connections
it has directions
like booleans for cardinal directions
like walls
im only dealing with Directional, Rotatable, and Orientable blocks
holy fuck i did it
^
target.setBlockData(data, true);
Block below = target.getRelative(BlockFace.DOWN);
BlockState belowState = below.getState();
below.setType(Material.BEDROCK);
Bukkit.getScheduler().runTask(Bleef.plugin, () -> belowState.update(true, true));
``` this seems so wrong but ok
Mojank 
appreciate the help
help I made an impulsive purchase
tomorrow I'm upgrading my pc's ram to 64gb 
I can finally open like 19 intellij windows and like 2 chrome tabs
doing this (updating adjacent blocks) makes the block you update flash
for a tick
and its ugly af
?
Why do you want that?
depends on how you register them in the first place
Because I dont like typing /gamemode and seeing on tab stacked /gamemode and /Gamemode
I want my aliases hidden
Does that make sense?
Please help me
how can I make them not case insensitive?
It gives an error once they type a capital or something in the first argument
I didnt know they werent already
thats why I added aliases with a capital
Okay so just dont
yeah its very odd
Dont type Gamemode?
I know but if someone were to type the command I want the caps to not matter for the command and it to work
it makes the command more unique
Make some kind of command preprocessor then
thanks for this, case insensitive I was looking for these words
lowercase command
by definition of unique a command with multiple aliases is less unique than a command with no aliases
i'm just picking on words
Truth
True
I wish it wasnt case sensitive and didnt give an error
sorry
don't mean to make a commotion, thanks for your help though..
i made the plugin using intellij
i made a plugin but, i cant seem to get it working
can someone please help me
Do you have any errors? Logs? Indication about what is "noy working"?
no
wait i do
idk what it is
Tell us what was your step, what you did, where you're stuck, ...
does any1 happen to know how I would push the plaeyr straight up
if (attacker instanceof Spider) {
if (AttackerName.contains("§5King of Spider's Servant")) {
Vector up = new Vector(0, Playerloc.getDirection().getY(), 0);
up.normalize();
up.multiply(5);
player.setVelocity(up);
player.sendMessage("Debug3");
}
}```
this is what i have
Oh no, uppercase variable, checking mob by name?
yeah
is there a better way to do it?
i assume yes
but i aint that smart
also im very new to this
this is ~3rd day
would any1 be able to explain how vectors work?
i mean i get its direction and magnitude
ive done physics
but like
in code
how does it work
im my head i assume this would work
but
it doesn't
also im not getting any errors
i dont want to be spoonfed as i kinda want to learn
Why are you making a vector with the player.getDirection().getY(), then normalizing (which mean the norm of the vector will be 1)?
What you're trying to do is push the player 5 blocks up?
yeah
Then create a Vector with 5 on the y, and apply it to the player with the #setVelocity as you did
If you only want a jump then x and z should remain 0
if (attacker instanceof Spider) {
if (AttackerName.contains("§5King of Spider's Servant")) {
Vector up = new Vector(0, 5, 0);
player.setVelocity(up);
player.sendMessage("Debug3");
}
}```
this is what i have
Imagine your vector as the arrow showing where the player should jump
Should
i tried it
Have you tried ?
and its not
Please then try to get the player's velocity as based vector. And set the Y to 5.
hm
ok
alr trying it
give me a few seconds to test
if (attacker instanceof Spider) {
if (AttackerName.contains("§5King of Spider's Servant")) {
Vector up = new Vector(0, 100, 0);
player.setVelocity(player.getVelocity().add(up));
player.sendMessage("Debug3");
}
}
``` stilld oesnt work
changed number
to see if it was noticable
but it just doesnt change the velocity
@rough ibex pls check your dms
who ate his butter?
Try
Vector up = player.getVelocity().setY(5);
@agile anvil pls check your dms
I don't get dms, please describe your issue here
how?
if (attacker instanceof Spider) {
if (AttackerName.contains("§5King of Spider's Servant")) {
Vector up = player.getVelocity().setY(100);
player.setVelocity(up);
player.sendMessage("Debug3333");
}
}``` still dont work changed msg to make sure made it 100 cause i thought 5 might not be noticable
soo
at this poitnt i have no clue
this is a EntityDamageEntity event
so there is some velocity due to the kb on getting hit

