#help-development
1 messages · Page 1272 of 1
do you do minecraft:reload at any point in time
because that would reset recipes
no
are you sure any of the plugins you have installed don't do it either
well, that's the only way recipes would stop working, unless something is cancelling the craft event for your recipes in your code or whatever
to begin with, are you registering recipes via the Bukkit Recipe API or are you using the PrepareItemCraftEvent to manually detect your recipes?
bukkit recipe api
I can't really tell with the given information then, you'd have to try and debug the issue somehow
I'd start by creating a MRE to have a more clear idea of where the issue is
look at that beautiful hitbox
don't know how to avoid it from hitting beyond tbh
hm
does arm swing happen before or after breaking a block
after, great
Anyone familiar with a way of creating boss bar for 1.8?
I tried using packets but it's causing alot of fps drops
fps drops?
how many times are you sending the packet
pretty sure 1.8 doesn't have a bossbar packet
you gotta rely on upside down invisible withers or ender dragons
Ender dragons, yes
ender dragons cause lag but are more accurate
withers spawn particles which are often visible
Withers dont work for some reason
Too old! (Click the link to get the exact time)
1.8 hater 😔
twice as old as my nephews, whose classmates could be playing minecraft
isn't there any way to tackle this?
you mean aside from updating to 1.21.5?
yes
maybe, last time I worried about 1.8 code was about 10 years ago
🤔
hm
can armor stands have health
as in survive more than a tap
sounds like they should right
I'll give it a try with armor stands
Wait, how would I do it with armor stands?
cause no boss bar
He's not talking about boss bars
oh, mb
if there is 1 1.8 hater left in the world, it is me
if there are 0 1.8 haters left in the world, I am dead
Do you genuinely need 1.8
I need it for 1.8 support sadly
I'm being held gun point
how can I remove creative menu tabs from the creative menu, e.g. the SpawnEggs tab and the SavedHotbars tab or at least prevent players from accessing them?
Is it better to use Runnable rather than raw thread?
Y-yes ?
Spawning a new thread means you can't use most of the spigot API functionality.
Thread safety?
Idk, but some methods will throw exception if you try to use them off main thread.
I think setting block or spawning entity does that.
anything that interacts with the spigot api is not thread safe unless explicitly mentioned
Yea, some methods catch off threaded invocations, others will allow it but u may render inconsistency at that price, for example get methods
What is Particle.BLOCK_CRACK and Particle.ITEM_CRACK and Particle.SMOKE_NORMALin 1.21.4?
BLOCK, ITEM, and SMOKE
Can i turn on tnt duplication on spigot?
spigot does not disable tnt duplication
Im playing on spigot and I can't duplicate TNT
What is the output of /version
plain spigot server?
spigot server with craftserve host, there are some plugins
well it will probably be the plugins
what plugins are they
any anti-dupe / anticheats?
Gsit, Tab, EssentialsX
.
@EventHandler
public void onBlockGrow(BlockGrowEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.VINE) return;
UnnaturalBlocks.setUnnatural(block, plugin);
System.out.println(event.getBlock());
}
why doesnt it work when i use bonemeal but works if something grows naturally?
setUnnatural just ads pdc key to blocks
Try checking the StructureGrowEvent?
its not called when you do crops
you didn;t specify what you were growing
yeah its only for naturally grown
but its CALLED but not working
I doubt there is an event for bonemeal other than the interact event
the javadoc says its only for naturally grown
then yippee?
if the event fires using bonemeal, what is yrou issue?
then i wanna do the same thin as i do with natural growth
its also called when i use bonemeal but wheen i add the pdc to block it doesnt work
the block changes when it grows
😭 but it works when naturally
your pdc is probably being overwritten
or it doesnt
ohhh wait
its probably done by CustomBlockData, and not by my event
yeah
that explains everything
so how do i change the actual block
do i havr to do a delay
apply it 1 tick after or change teh block and cancel the event
thankss
what about when block is forming by lava and water? i dont need to do 1 tick delay, why?
I did /viewinv hi_rad to get rad's inventory, but if you steal something and try to stack it with the "normal version" from the creative menu it won't stack. Why
?
I need rad to help me on this 
@blazing ocean help him then smh
i mean you could too if he's not around
im not here what you on about
come on bruh
if i wasnt busy rn i would
ok i'll just wait for someone who is not busy 🥺
They probably have some sort of data on them
Hold em and type /data get entity @s SelectedItem
how to translate it over to code :o
ItemStack offhandStack = inv.getItemInOffHand();
if (offhandStack.getType() == Material.AIR) {
offhandStack = new ItemStack(Material.BARRIER);
}
GuiItem offhand;
if (offhandStack.getType() == Material.BARRIER) {
offhand = ItemBuilder.from(offhandStack)
.name(Component.text("Offhand Slot")
.color(NamedTextColor.GRAY)
.decoration(TextDecoration.ITALIC, false))
.asGuiItem(e -> e.setCancelled(true));
} else offhand = ItemBuilder.from(offhandStack).asGuiItem();```
Triumph GUI Library in use
What
then,
private final Gui gui;
private final Player target;
public InventoryGUI(Player target) {
this.target = target;
gui = Gui.gui()
.title(Component.text(target.getName() + "'s inventory"))
.rows(6)
.create();
setupInventory();
}
private void setupInventory() {
ItemStack offhandStack = inv.getItemInOffHand();
if (offhandStack.getType() == Material.AIR) {
offhandStack = new ItemStack(Material.BARRIER);
}
GuiItem offhand;
if (offhandStack.getType() == Material.BARRIER) {
offhand = ItemBuilder.from(offhandStack)
.name(Component.text("Offhand Slot")
.color(NamedTextColor.GRAY)
.decoration(TextDecoration.ITALIC, false))
.asGuiItem(e -> e.setCancelled(true));
} else offhand = ItemBuilder.from(offhandStack).asGuiItem();
// set the stuff now
gui.setItem(5, offhand);
}
All I said was to hold the item and run a command to see what data it had
Thereby telling you why it wouldn’t stack
wtf did I do now
ayyy
look
but how do I not make the cobblestone have all these data
i just wanna be able to open someone else's inventory and steal stuff
wild question, when you make your inv are you adding pdc to its items?
whats a pdc
I assume the gui library is adding that
if you dont know ur gui lib is adding pdc to items to id them most likely
my gui lib is adding pdc without telling me?!!!
also whats a pdc
?pdc
no mention of adding pdc to items in docs
why
because i don't want it to be different
inclusivity
imagine i steal your diamonds using the /viewinv command, and see that those diamonds are being racist in simple terms
go to triumph support is gonna be the best answer
What
Meanwhile diamonds used to be called emeralds internally
you could've just said that they don't stack
as for that case, what one would usually do is off-load the metadata somewhere else, like the player's pdc instead and have some other way to identify the item
but the issue with player pdc is that people often forget to remove it so it gets big really fast
That’s up to the gui maintainer
who needs cleaning up anyway smh
eh im not gonna use that stupid library for this then
every GUI library either uses slots or PDC to identify items, it all depends on the functionality you're looking for
personally i don't see why you'd use pdc for guis, it seems rather silly to me
it isn't much of an issue for non-moveable items but when you deal with items that can in fact move around and they got a specific behavior, PDC is pretty much the only sensible choice
if duping isn't an issue, you could go for lore-name matching like people used to do but it is usually a problem
anyone knows why ?
i suppose, though i can't really contrive a case where you'd want players to be able to pick up and place down the gui elements within the gui to move them
yes if it was an admin GUI or something where you don't have to take the items then adding pdc is fine I don't care
maybe a chess or minigame board or something
but its a /viewinventory command
trade GUIs, or minigames yeah
is there a need to use a GUI library for something like that
where you can steal their stuff
you can just open the player's inventory for the command sender
true that's why i'm just planning to use plain old spigot api's ItemStack and ItemMetas and what not
is there a need to write this yourself in the first place
yea but that just opens main inventory
there are a bazillion invsee plugins
ah, you also want armor slots and what not ig
it'll be like this
but yeah, as vcs mentioned, there's quite a lot of invsee plugins lol
yea i know
you could just take an open source one and do your own thing with it, even
its not bout that, its bout the grind and the power
i'm not sure what the cleanest way of doing this actually is
🤣
using inventory click/drag events to determine when slots change is annoying and error prone
tried stealing code but super confusing
so if i had to do this i'd probably copy over the contents from the inv to the gui every tick
i can't understand their code
wouldn't that be really laggy?
as for stealing items, i'd probably only allow simple left/right clicks to pick/place all/one and reflect the changes manually
it wouldn't necessarily be laggy, you could diff the inventories in order to avoid copying it over every time
it's not efficient, but it would be fairly cheap
do wvat?
you underestimate how much nonsense of this sort the server does every tick
e.g. a hopper basically does the same, except it also does item comparisons which is like 10x more expensive
take both inventories and compare whether the items in the given slot are still the same material, fairly cheap check
if they aren't, then copy the inventory over
yae
/viewinv:
- compare both inventories every tick (gui & target's actual inv)
- update gui inventory
- reflect changes only place or drop
good?
Can somebody please tell me why this is not moving the entity?
Entity vehicle = p.getVehicle();
assert vehicle != null;
vehicle.teleport(vehicle.getLocation().add(p.getLocation().getDirection().clone().normalize()));
sounds good enough for me
the entity doesn't move a milimetre
should we be using assert vehicle != null; cuz I always see my IDE screaming at me to use it
you can improve upon that if it isn't enough at some point as it is a fairly flexible way to go about it
You can’t teleport entities with passengers
assertions are useless if you don't have assertions enabled in your jvm
you can't teleport something that has riders i don't think
assert is ignored at runtime. It just silences your IDE on a null check
why
mojang can't into tick loop
too heavy 🙂
it silences it however you don't want to do that, you should properly check if the thing is null
how are all these vehicle plugins working then?
same with Object.requiresNonNull?
if you think about it, velocity is just teleporting with collision checks 🤡
no, that is checked at runtime
And gravity! Unless disabled for that entity
but, it just makes your code explode earlier
Objects.requiresNonNull is just telling the IDE "I know this can be null, but I don't care", if you use it irresponsibly then it will throw a NPE at runtime, just like using assertions
so kids, always use ternary operator or if-else null checks
try catch ignore nullpointerexception
asserts, require non null, and null checks are all distinct and have their different use cases
a good case for it is JavaPlugin#getCommand, it is nullable because it can in fact be null if you forget to add the command in question to your plugin.yml, but when you know it is there then you may wrap the getCommand call with Objects#requireNonNull to assert that it is in fact not null
though using asserts at all is disfavored by some
Does kotlin’s precondition.nonNull (or wtv the call is) work the same way under the hood as objects.requireNonNull
alledgedly, they're not performant, I haven't tried using them ever though
they're about the same as require non null except that the check is actually disabled by default
kotlin has an operator for Objects#requireNonNull, which is !!
you have to launch the process with assertions enabled, or call things on your classloader to enable them
🧠
this makes them very useful for internal "micro testing" where you don't want the performance impact of validating all constraints to happen on production, but want to catch exactly where something goes wrong during testing
I don't know why you would use precodition.nonNull over the operator
imagine having to manually do all the identations
just imagine trying to code a big project entirely in notepad
Well for those cases where you want to throw a message with the error
well, it should never be null in the first place if you're using that operator 😛
but makes sense
Preconditions.x( , “something something”)if I remember kotlin syntax but eh
a rule of thumb i use is that if the validated thing comes from outside the scope, use exceptions (require non null); if it comes from within the same scope, use assert
obviously only works if you actually test your code though
Yeah that’s fair
How about in cases of fields being passed around in some tightly coupled classes
?: is what i think you mean
getNullable() ?: "WOAH ITS NULL"
if its a method you dont want null in dont accept a Type? only accept a Type
as with all edge cases, make a judgement and try sticking to it; whether something is on one side of the fence or the other is usually less important than it is to keep it consistently on the same side
without knowing the context or seeing the code, assertions would probably suffice as long as all of the call sites and api points that might be used by "other code" are covered by exceptions, and all the tightly coupled classes are tested with assertions enabled
typically in Kotlin if you're using !! it's because you've verified it won't be null through some other means, like calling #isPresent() on the Optional then #get()
if it is null it'll throw an NPE
if you want to throw an error with a message then you'd chain ?. so
someObj?.aField ?: throw IllegalArgumentException("someObj is not nullable for thisMethod(Object)")
Kotlin has an optional impl? Jeez rad needs to redo his cheat sheet for me kek
Or is that just how it’s handled under the hood…
Registry.EFFECT.iterator
could probably include that in the deprecation note to be honest
okay.. so lets say I need a random potion effect..
how do I get the number of potion effects in the game?
so I can pick from them
You could do Registry.EFFECT.stream().toList()
Hey I wrote about nullable types
I think?
Yeah you probably did, I just thought he meant kotlin has an optional impl
Nope
that's quite a bit more than minimal
minimal or not minimal that's my code
yes, but I mentioned a MRE because it's necessary to pin down what exactly it is that is removing the recipes, you'll have to strip it down of anything that isn't required to reproduce the issue
other option is to take a debugger and track where the Recipe object is being cleaned, among other things
you could start by doing something simpler like adding a breakpoint to Server#reloadData or the respective internal minecraft method, as well as checking if there's anything cancelling the craft events for your custom recipes for whatever reason
By adding some debug logs, it turns out that no event is being cancelled. I noticed that when I create the shapedRecipe, nothing appears as the result, but if I click on it (I added a debug log), the console returns the correct result — however, it's not shown as the result in-game.
wait till you hear about SELF
yeah i saw it
but i was like ok
maybe its no face
just the block
but whats that
and there are no descriptions
these are mostly used as offset vectors
How would you guys approach wind physics in terms of frisbees? My thought was a rather randomized approach within a scale, ie: wind mph 5-15 where 5 will affect the physics a little bit and 15 a lot... that being said, I want to emulate a more realistic system that will take into account say a frisbee's thrown speed as well it's weight and apply changes to the base physics this way. I'm just a bit concerned on what the algo impl will look like such as that it returns weird physics manipulations... the system should always be dynamic in that the wind speed / direction is always changing. I run the physics manipulations currently in a task every tick so I think the wind impact must be as small as possible
how accurate do u need winds to be?
could u have a set vector field per chunk?
for example
Well like, I can't be having the frisbees thrown left and right wildly
Yeah I could, but then I feel like the wind is more of a constant rather than dynamically manipulating the base frisbee physics
i mean wind is a vector field no?
but u could make that vector field per chunk, so one chunk has the same wind vector
mostly because chunks are soooo easy to calculate
since u just get xz position and then bitshift
yeah hmm
Just implement a fully functional air current system
Don't even ask kek
Here's another thing though, wind tends to be a bit crazier at higher altitudes so considering this and the way a frisbee can be thrown, there will have to be Y levels attached to the wind vector as well
Yeah but to do this smoothly is also an issue
I think whats most performance impacting on ur stuff is how many times u run sqrt w length + normalize
It's hard to explain... a frisbee may be thrown low and flat which usually results in minimal wind impact right? On the other hand, you may throw a frisbee high and angled in which the wind can really do anything mid flight... I'm basing this off irl experience... so with that I feel like the smoothness of the manipulations are going to be detrimentally affected by the initial throw mechanic and it's returned vectors for the throw itself without a genuine wind system impl or air current system like coll said
Well that also depends, on a forehand throw, your frisbee is usually spinning faster than say a backhand, this in regards to the wind would also make an impact
i mean yea
Isn't that just the dot product between the wind vector and the frisbee rotation vector
Well neither of these are implemented yet so I guess it could be...
I'd start with the Wii sports approach like Jish said
Yeah I think that's what I'll try to get a result out of
And then just update it to different vectors per location
Well I also wanted to try and design the wind system around the terrain of an arena or course as well...
Maybe there are a lot of "wooded" holes on this course so even if the wind speed is high you wouldn't be affected by it as much since you're surrounded by a lot of trees as an example
just simulate the universe since the big bang
Man I just integrated my course gen with native objects... I don't need to be crashing the server more with universe sims kek
a little particle physics never hurt anybody
Man I'm so over physics but still need to write so much more out
Been doing this shit for like 6 months
And I've only accounted for two throw types out of like 13 total
Maybe one day I'll write a physics engine for frisbees so I don't have to rely on rather hardcoded systems
you really like frisbees to put this much effort into this
I mean I love disc golfing which is what I'm implementing right now
kek
That's basically the point I'm at right now
Only with slight random deviations involving the throw mechanic and initial vectors
why does meta.addItemFlags(ItemFlag.values()) not hide attributes?
Are u using paper
yeah but that shouldn't make a difference i assume
:Clueless:
Also are u setting the meta back properly
yep
Except it does
?whereami
ok fair enough
hello how i can install soul link plugins pls
Download jar, put in plugins folder
hello ga-ga-ga-ga-ga-gamers
I doubt it's the case but is there a field in materials or blocks to see if they're supposed to be opaque or not
oh cool
then we have isSolid
glass is solid tho
just wanted an easy out to see my beautiful custom models through a nice glass display case
I'm not too stressed about accuracy here
isOccluding returns false
I'm usually the kind of guy to just look up by keywords
so words like "GLASS", "FENCE", "GRASS", "POTTED", "BARRIER"
no
alright I optimized it and now it's using 15% of the tick
an interesting magic trick
how did I even do that
i am currently coding a snail into mc using armadillos. can anyone tell me how to force armadillos to stop curling up?
why not just use the snails in mc?
im sorry what!!??!!
you don't have to apologize, but I forgive you
thanks
u will have to use NMS
i was gonna use that for pathfinding but i didnt realise i would have to do that for curling as well
The Armadillo curling up is a result of a "threat", this is apart of BehaviorController
but, would "EntityPoseChangeEvent" work ? have u tried
no i havnt. im considering switching from not piggy backing off armadillos and doing something else.
im trying to make the immortal snail meme but i cant really retexture armdillos to look snaily enough
would love a recommendation on a better mob to do this with
see this pr @random compass
u can freeze with this method in nms
less ironically why not just use a custom model for this
ive made a texture pack
just make a model
i wouldnt even know where to start
the one I posted there took maybe 10 minutes
here, it already served its function
knock yourself out
Ur a snail bb

thanks. bbbut would you mind explaining how custom model works?
i am extremely new to this
you use a nondescript custom model plugin and find a nondescript way of hosting the resulting resource pack
there might be some dev gigachads out there that have made free tools that handle both of these things
i see
then before you know it your snails broke out of containment
those look crazy good
I should use a real timings solution, I'm getting some really weird data out of this
would this work? https://github.com/Ticxo/Model-Engine-Wiki/wiki
not free and not updated for 1.21.5 and not open source but yes absolutely it should
ok, ill try find a free one
freeminecraftmodels
magma it's ad time
i mean you could sell it
then it wouldn't be free dumdum
it can still be free as in freedom
GPL allows you to sell your product
tbf didn't say it was gpl holding me back
Magma you have my permission to advertise your model plugin in this channel for the next 2 minutes
You do have one, right
aaaaaaaand screenshotted
what's a plugin
alright cool
@random compass freeminecraftmodels + resourcepackmanager
if you want to test the new freeminecrafmodels plugin lmk, I was about to release it with what is basically a full remake
sure. is it easy to use?
Hmm, u should make it so the timestamp is 1 minute ago whenever u post it
foolish md_5 didn't realize it just says 6:20 am
I shall advertise my plugin every day from 6:20 to 6:22 am henceforth
smart
Fair
ghost if you want the early access just go join my plugin discord and I'll send it there
I'll also tell you how to use the api there
what are the steps to implementing a custom model? i download a model plugin and pack manager, then upload the bb model, and then my plugin should control the behaviour?
yeah basically you just tell fmm to disguise an entity and then it's up to you what hte entity does
wheres a link to your server?
bros actually famous
so famous I paid to have my name not be my name
He's legit the coolest guy in this server
not the hottest
😢
i joined but i cant even ping you in general
nvm i found what to do
incorrect, balu is cooler
?mappings
Compare different mappings with this website: https://mappings.dev/
do you guys think this plugin can handle a large player base (like 2000 avg players), the problem im having is that its using MySQL instead of PostgreSQL:
https://battlepass.advancedplugins.net/
whats your opinion on that?
im not, its a server system
but 2000 avg players
^ not using pg doesn't mean it'll be slower
yeah ik, but from what ive learned postgre is way better on large player bases
I mean you don't really need postgres
so do you think i'll run fine with that large player base?
yes
thanks!
For most workloads, the performance between Postgres and MySQL is comparable with at most 30% variations
mongo is so cool they don't even compare it to other dbs
ew mongo
pov nosql
hey guys anyone know a plugin that would allow me to make a redeemable item that would randomly give you another item from a list. so for an example youd get like a "lucky egg" that would pick a random spawn egg from a list (of all the spawn eggs)
It depends on the design
i mean really any design. i was just thinking something like really simple where it just removes the redeem and gives you a random egg (or ofc other item) from a list of items
but anything rly
If you want all the magic to happen in the inventory you need a PlayerInteractEvent. If you want a custom item use a resource pack along with the plugin. On click simply change the slot to the wanted ItemStack
ah alright ty
hi guys I need help I tried making a system where it would give me the custom items
but it didn't gave me the custom item
Information 100
ok ok I'll try
how do I detect if the player is not afk?
(in detail)
I am making a stupid effect that will put you in creative mode every 20 seconds
And I want to put the player back in survival as soon as they try to do anything
so that they don't actually abuse it
Check player move event, player interact, inventory change
but InventoyOpenEvent is not really working?
Inventory change is an event?
Inventory events are kinda cursed in creative
Afaik
damn
declaration: package: org.bukkit.event.inventory, class: InventoryInteractEvent
ahhh
Check the item's PDC for a specific namespace key that identifies it as a lucky egg
Read the configuration file where you've defined the list of possible spawn eggs
Select a random item from that list
Give the selected item to the player
Remove one lucky egg from their hand
Ur IDE is telling u why
Hover over the args.length == 2 and see what it says
Dude…
Look carefully.
you’re not exiting that initial “if args length is 1”
you’re checking args.length == 2, in a block where it’s already established to be 1
does that make sense?
basically what I’m saying is. That if statement that checks if args has a length of 2, is being performed in the if statement checking if its 1. Something cannot be 1 and 2 at the same time. If it is 1 then it cannot be 2. Meaning that portion of code will always be false if it’s there, not only false but redundant.

I've tried to "force" result with PrepareItemCraftEvent but nothing to do, the item doesn't appear. But If I click on empty Result Slot I obtain the item here the code: https://paste.md-5.net/ewitelebiy.cs
Anyone that can help me?
Hey, ive been using DevNatan's Inventory Api but i keep getting errors that the viewframe doesnt have a owner.
When i use viewFrame.create(plugin) the returned viewFrame really doesnt have a plugin (owner) attached to it. It has a private constructor, but i cannot initialise a viewFram instance cause its private. So how to fix this?
He has a quantum computer
Whenever i have issues i cheat with updateInventory
Why is the InventoryCloseEvent triggered if i right click a block? Its only if i right click a block
Are you sure you're listening to the right event?
also are you trying to detect the player inventory closing?
how to make an npc
Use Citizens
if i wanted to do it myself id need to use nms?
yes
either that or protocollib or libsdisguises
i recommend libsdisguises if you for whatever reason don't want to depend on citizens for it
rawdogging it with protocollib is going to be marginally more stable than nms but far more annoying and troublesome to make work
citizens is free?
yes
yes
and yes
can you send the class?
package eltown.api.invgui.listener;
import eltown.api.invgui.InventoryGuiHandler;
import eltown.api.invgui.components.InventoryGui;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
public class InventoryGuiListener implements Listener {
@EventHandler
public void on(InventoryCloseEvent event) {
if(event.getPlayer() instanceof Player player && InventoryGuiHandler.guiPending.get(player.getName()) != null) {
InventoryGui inventoryGui = InventoryGuiHandler.guiPending.get(player.getName());
inventoryGui.setClosed(player);
InventoryGuiHandler.guiPending.remove(player.getName());
}
}
}
can you send the rightclickevent class too
@EventHandler
public void on(PlayerInteractEvent event) {
Player player = event.getPlayer();
InventoryGui.Builder builder = new InventoryGui.Builder("Test", InventorySize.x5);
for (int i = 0; i <= 8; i++) builder.addElement(new GuiElement(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE)));
builder.addElement(new GuiElement(11, new ItemAPI(Material.PAPER)
.setItemModel("eltown:lobby_compass")
.setCustomName("§aNavigator").build()), p -> {
p.sendMessage("Custom Item wurde angeklickt.");
}).onClose(p -> {
p.sendMessage("GUI wurde geschlossen");
});
builder.build().send(player);
}```
what is this aimed to do?
This is simply to open a custom GUI for testing when I make any interaction. And when I click left, a UI opens and I can't move items because I forbid it. But if I right click on a block, the GUI also opens, but because the InventoryCloseEvent is strangely triggered, I can move the items, which should not be the case. I have not closed the inventory, but it is still triggered.
open the inventory a tick later
or try cancelling the interact event
minecraft tries to trigger a blocks default interaction from right clicking
I interact, the playerinteractevent is triggered and only as soon as I right click on a block, it triggers the InventoryCloseEvent. When I left click it does not. I just canceled the PlayerInteractEvent, but that didn't help.
Same behavior if I execute it 1 second later. it still triggers the event
uhh
and what is the inventory involved in the close event?
what are you right clicking?
}).onClose(p -> {
p.sendMessage("GUI wurde geschlossen");
});```
Any block
emily asked what the inventory was, not what the close event does
its a custom thing i think
he has a class called InventoryGui
would be nice to see how exactly onClose works under the hood
iirc when you open an inventory the player's own inventory "closes"
which is why i ask what i ask
I want to try something for a moment
Ok i fix it
I have now queried the Reason in the InventoryCloseEvent. Normally “PLAYER” is used as the reason when I close an inventory. But strangely enough, the right click uses the reason “OPEN_NEW”. So I have now made an if query and said that if the value is not “OPEN_NEW”, it should no longer execute the event. Only with the value “PLAYER”. This way it works, for whatever reason.
The client doesn't tell the server about it opening or closing it's own inventory
Only about other inventories like chests
or so I remember it... if it works for you, good ig 🤷♂️
I bet 5 bucks the impl is just a Consumer<Player> / a list of it
closing yes, opening no
how can I prevent the player nametag from changing color while changing the color of team the player's in?
hi does someone have good guilds plugins? and can help me upload it to craftserve? - I need it for +/- 25 people
Hi what's a guild plugin? Also what is craftserve?
?support
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
hm that's interesting
the server needs to know when you close the inventory to drop whatever you have on your cursor, or place back in the inventory what you have in the 2x2 crafting grid and such
I just assumed the client would send drop item packets for that
since there are hacked clients that allow you to use those slots as extra inventory
yeah all they do is not send the menu close packet
which makes for an easy way to check for them too, if you placed items there and you're moving around, then you're cheating :p
Almost guaranteed always stupid edge cases with people shitty computers and internet
eh, the close inventory behavior is reliable enough for that not to be an issue
i mean, packets are sent serially
it's a bit more sensible now with the input packet
but previously, you had to account for things like pistons, gravity, water, etc
since "player moving" doesn't always mean "player moving"
oh yeah that reminds me
is the input packet still sent in spectator mode?
or do we still have to rely on the vehicle mount + spectate entity trick and listen for the vehicle movement packet?
seems to be the case
client sends it as soon as its tick method gets called, along with the vehicle move packet
nice
I assumed the vehicle move packet was sent from the vehicle's tick method and not the client, the more you know
i always hated depending on the vehicle move thing because it seemed like a hack that might get changed up any time some intern at mojang feels like refactoring the client tick loop
yeah, not a very reliable workaround and kind of annoying to work with honestly
well, not unreliable since that's how everyone does it since god knows how long, but definitely can see mojang doing what you said at some point
how do you change a player's attributes?
I want to reduce the player's max health
I found the Player#registerAttribute() method but I can only set Attribute enums inside? how do I change the player's MAX_HEALTH value
AttributeInstance#addModifier
wth..
what's the difference between the attribute and the attribute instance?
and I need to modify them using an attribute modifier now?
RIP
player.setMaxHealth()
Attribute is just the type / ID for the actual attribute, AttributeInstance is the instance of the attribute on an attributable which can be modified
maxHealth.addModifier();
assignedPlayer.registerAttribute();```
this is what I got so far
I need to connect both ends
You don’t need registerAttribute
ah okay.. so it register changes right away
but I still need that attributeModifer
use the constructors
AttributeInstance maxHealth = assignedPlayer.getAttribute(Attribute.MAX_HEALTH);
assert maxHealth != null;
maxHealth.addModifier(new AttributeModifier(NamespacedKey.fromString("potionMayham:hearts"), -6, AttributeModifier.Operation.ADD_NUMBER));```
I have a feeling this isnt right
from the fact that I'm unsure why I need a namespaced key tbf
(which Idk what it is yet)
I understand what namespacekeys are but I don't think I have any registered under my plugin
isnt that an issue?
okay I see
oh how do I check if an attribute already has the modifier applied?
ah get modifier
how spawn particle for player? this harder then i was think
i always getting error
what the "T data" is arguments in method?
T data depends on the particle being sent
bruh
The javadoc tells you what data is for the particle (if it even has one)
if you don't need data, don't pass in data
im trying to write a mc bot and im getting this error message
Reason: {"translate":"disconnect.genericReason","with":["Internal Exception: io.netty.handler.codec.DecoderException: Failed to decode packet 'serverbound/minecraft:hello'"]}
are you sending the hello packet properly?
do you mean the login start packet?
btw for testing purposes i disabled online mode
(no, they are not)
People very, very often have questions regarding the Java Edition protocol, so we'll try to address some of the most common ones on this document. If you're still having trouble, join us on the Minecraft Wiki's Discord server, the Minecraft Protocol Discord server or our IRC channel #mcdevs on irc.libera.chat.
I was thinking of writing my own server impl in kotlin with coroutines
I'm bored rn so time to do that
make it work in compose 
i dont see a hello packet there
im getting 0x00 (disconnection) after login start
thats 0x01 isnt it
it would probably be helpful if you shared your code
its in rust but okay 😭
is this AI-generated
all of that looks AI-generated to me
i gave it base structure from rust-mc-proto examples
hi retro
how did you identify the ai
comments probably
compared my english level to it
comments + thread::sleep(2s)
lol
what are you writing
mc bot
you could have used a specific library
i am
it starts with P
can we stick to sending raw packets
PE does not support rust
whats PE
packetevents
there's another library you should've used
SOON™️
rewriting PE in rust
any issues in my code?
retrooper if he didn't have PE
I'd probably would have been a great philosopher
because i'd repeatedly question the meaning of life
@blazing ocean r u reading my code
im trying to keep things low level
at what stage are you getting that error, i.e. add debug statements
is that nvchad
(optional field, setting to 0 for offline mode)
top ten biggest lies
nevermind
I cannot read
that you're writing something wrongly
😭 which part tho
have you tried just writing an int instead of a boolean
turn on debug mode on the server
is that in server properties
it is
ok restarting
wow now it isnt even printing what it was printing before
the hello error
magic
no idea what that means I usually just run the server with a debugger attached
wdym
I run the server and attach a debugger
ok ill try to
If I just have
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
as a Maven dependency, is this using Spigot NMS mappings?
Or is that a separate thing
Is it OK to use mojang mappings in a commercialized server as long as I don't distribute my private plugin?
In terms of the eula?
specialsource remaps your plugins back to spigot
Oh poyfect
what does this clicktype do
i mean in creative its not called, in normal inventory it doesnt work
Sorry to overshadow your question Kmys; on the post you sent rad, does the specialsource maven plugin in the pom.xml automatically remap it back to spigot on jar compile?
Elaborate on doesn’t work
hi kat
if i dont have an item on cursor and middle click nothin happens and its not called, if i have an item and middle click anywhere, nothing happens but its called
like whats the purpose of that click, i get it you can do multiple functions by checking if player clicked right, left or middle
but why is it there
did you try in survival too
yeah, in creative its juts "CREATIVE"
is there a way I can make the hp bar look as if it's withered without actually withering the player?
ooo I also needed that!
why?
I'm making a plugin that rotates custom made "potions" on you.
I'm making an effect that puts you in creative every 30 seconds, but if you do anything, it will set you back to survival.
oh okay
okay
wait but I still don't get it
I have checks for Inventory Interact Event
but they don't call in creative mode sadly
it was inventory click
Most of these don't call when the player already had their inventory opened.
and inventory open event in creative doesnt work
idk why
i dont know
its very screwed in creative
that's why I disabled it for now ... you can easily find bugs or cheat your way
Creative is pretty much all client side
like middle mouse doesnt call PlayerInteract
nvm
there's a seperate
event
for creative mode
because creative is all client side. The client decides everything and just tells the server the result
if i need to let other plugins use commands available in my plugin, do i have to do something? or do they just Bukkit.dispatchCommand("plugin:command") ?
idk why I never thought of that
expose an API to access yoru plugin features
not all inventories are the same 🏳️🌈
oh
but what if its by yml
you put the command in other plugins yml
what?
there is plugin 1 which has a command implemented, and there is plugin 2 which has yml with list of commands, user only writes the commands
and plugin 2 executes them, so it can also execute a command from another plugin
what do i do
create an API for the implementation
but plugin 2 has to add that api ,what if its an already written pluginm
so your second plugin can do java Bukkit.getPlugin("PluginWithImplementation").executeCommand(args...);
couldnt it do Bukkit.dispatchCommand("plugin:command") ? and paste there ocmmand from config
dispatch is lazy
you have to create the method you want to make available in your first plugin
If you use it, ur lazy
yup but if there is already a plugin with a command i cannot implement it myself
so then i only have dispathc
but does it work worse?
yes, dispatch is heavier than accessing teh API directly
it goes through all the Bukkit command processing when it doesn't need to.
oh okay
will Entity#isOnGround() always return true when the entity has gravity, y = 0 and block below the entity is solid?
I believe its undefined as teh client can lie about being on ground
InventoryCreativeEvent
I swear i just saw u ask on paper
Be careful tho
Creative is very clientside though so they can prolly do smth
Just cancel the event in any case it’s called obviously 🙄
Doesn’t even ensure nothing funny happens
how can i install itemsadder 3.6.6 i cant install on spigotmc
In germany we say "Doppelt hält besser"
Is there any API to append to the Classpath similar to Paper's loader? The library loader doesn't support external repositories, and I have a dependency bundled with a lot of native binaries which is around 700 MB in total for everything. I have my own repository, but I can't use the library loader and I'd prefer not to upload to central.
not when the two of them are completely different
Not in every point
Just hijack luckperms
doesn't gremlin do that too
I ended up using this
But its only paper supported
doesnt support spigot because it uses the loader api so i need to figure something out
bros' dependencies are 10x the size of the server itself
just use Libby
I've tried it and it just sometimes breaks, not sure why
It doesn't support redownloading either
well, you can either debug it or try make a gremlin loader for Spigot
you could also just try with a more general-purpose runtime library appender, but I doubt it'd work out of the box with Spigot/Paper
Yeah i tried Spring slim launcher and that doesnt really work
Yeah I could fork it and try adding a Spigot loader
Maybe I could add a module that injects into classloader using Unsafe
it shouldn't be too hard given you can just copy whatever Libby does
but idk its a bit sketchy to do that
Yeah i made my own loader in the past but im surprised there arent really like
many options out there
another option is to bootstrap
well, it is ultimately discouraged as well
That's true, it's an anti design
just opens many doors for exploits
not if you do it properly
What on earth are you librarying
the entire northern hemisphere
can probably send a packet to make the player think they are withered
is that using protocolib?
I never dabbled with packets before
protocollib or packetevents or NMS idk
whatever u choose to use to send a packet tbh
well atleast I know its possible now. but I guess i'll keep t for the next project
thankss
sendPotionEffect or whatever?
you mean setPotionEffect or smth different?
sendPotionEffectChange I think
oh theres an api method for it?
hmmm..
Yes
declaration: package: org.bukkit.entity, interface: Player
sendPotionEffectChangeRemove
sendPotionEffectRemove?
could've just named it removePotionEffectChange
or sendFakePotionEffect/removeFakePotionEffect
I personally don't see the point in keeping the nomenclature to the point it becomes an absurd name, but it is what it is
Hey, I have some test code that is supposed to spawn a Guardian, but it keeps despawning and I don't understand why. I’m not using any other plugins, only my lobby system is running on the server.
player.getWorld().setGameRule(GameRule.DO_MOB_SPAWNING, true);
Location startLoc = player.getLocation().add(0, 5, 0);
Guardian guardian = (Guardian) player.getWorld().spawnEntity(startLoc, EntityType.GUARDIAN);
guardian.setAI(false);
guardian.setSilent(true);
guardian.setInvulnerable(true);
guardian.setGlowing(true);
guardian.setCustomNameVisible(false);
guardian.setRemoveWhenFarAway(false);
guardian.setPersistent(true);
new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
if (ticks >= 100 || guardian.isDead()) {
if (!guardian.isDead()) guardian.remove();
cancel();
return;
}
Location currentLoc = guardian.getLocation();
Location targetLoc = player.getLocation().add(0, 1, 0);
double progress = ticks / 100.0;
double newY = startLoc.getY() - (4 * progress);
Location newLoc = new Location(currentLoc.getWorld(), player.getLocation().getX(), newY, player.getLocation().getZ(), currentLoc.getYaw(), currentLoc.getPitch());
guardian.teleport(newLoc);
guardian.getWorld().spawnParticle(Particle.END_ROD, newLoc, 5, 0.3, 0.3, 0.3, 0.01);
ticks++;
}
}.runTaskTimer(Lobbysystem.getInstance(), 0L, 1L);```
Does anyone know why this might be happening?
you're despawning it after 5 seconds, is that intended
Yes, I want to make a teleport animation, but it just despawns — it doesn't even stay for a second.
I always forget the difficulty level lol
ye lmao
my bad
thanks
He unfortunately still despawns immediately.
difficulty is normal now
are you sure you set the difficulty on the right world
also, try listening to the EntityRemoveEvent and check for the cause
yeah
Changing it in server.properties will only effect new worlds iirc
So use the /difficulty command
im making a minigames server, nothin crazy rn but would like some help
whats the question
just need basic help like building some minigames and coding. im getting several plugins for money rn
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
I'm using NMS for pathfinding, I know you use
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, true));
to find the nearest player, how do you make the entity stay a certain distance away + move back and forth between X and Y distance away? Is there a better pathfinding goal for this?
Can always make your own
I don't know how to start with that, I thought of using the block move to goal and controlling, not sure how to implement something like that - could you point me in the direction ?
For staying away you can look at the creeper ai
Creeper always goes as close as possible
They are afraid of cats
I mean staying away in terms of it's X distance away, but still targets the player
Tried looking at the tamed wolf ai
Thx I'll look into that
is there something native in Spigot like that of "sockets"? Being able to send messages to other plugins, wihout nexessarily needing either to depend on eachother
kind of like events of your own?
You can create your own events
oh, without needing to depend on eachother. Not really
you can have a common lib tho
There is no way to like send a signal to another plugin?
What im saying is like, have something optional happen in Plugin B, when A sends a signal.
thought Bukkit had something like "Channels"
you can use the service loader, if anything, but that still depends on there being a common interface as "protocol"
ah okay, so no way to globally beam a signal across the server, and something picks it up?
I mean, there's nothing specifically in Spigot for it, but you can just use standard communication protocols like unix sockets, a file with a specific format, pretty much anything really
will unix sockets work in jvm?
yes
noice
https://inside.java/2021/02/03/jep380-unix-domain-sockets-channels/ here's a blogpost on it, if you're interested
no syntax highlighting in those codeblocks is painful
ahh thank youso much
plugin messages?
huh
I was going to suggest that too, but figured if they want to do plugin-to-plugin communication then the requirement of a player being online might be a limitation they don't want to deal with
should've mentioned them still, my bad
ohh a player has to be online?
Nah I dont want that
so props for not bringing it up
it's usually not much of an issue since most data is transferred when players are online anyway but it is kind of annoying
You really want a message queue
Thanks Legends
could someone help with the addon for crafting and additions? I'm just bad at java and don't understand how to connect electricity to my mod
forge
Go to their discord then
To craft and additions dis?
Maybe, might be useful since u’d need to hook into their api
I just don't care at all in all places where it can help me in theories to write
I'm using path finding
to make an entity walk to a location, I want them to face backwards while doing it but setting the rotation slows them down drastically and they try to rotate back to their original position walking there - could anyone point me in the right direction for this ?
you'd probably have to override the mob's LookControl in order to make it look backwards while doing anything
if it is a custom mob, you'd just have to do it in your custom mob class, but if it is a vanilla mob, then you'll have to use some reflection to replace it on the spawned instance
I'm using a custom mob class; how would I override it? I did this:
I don't know what the numbers mean but it doesn't do anything
Also tried this
if you have a custom mob, you just have to override getLookControl method and create a custom LookBackwardsControl class or whatever
then in the getLookControl if some variable like walkBackwards is set, return LookBackwardsControl, otherwise return the default LookControl instance
ideally walkBackwards would actually be something handled at the MoveControl, but overriding one control is already a hassle, so do it in the way you find the most convenient
if you want them to look backwards regardless of what goal they might be running, then you can just return your own look control instance here and forget about the original instance
