#help-development
1 messages · Page 1009 of 1
So my apologises @quiet ice
Yep, as I told him, Spigot says not to
I didn't know that actually
?xy
Bro you have a highly bad attitude, tf
Any way to get ID without throwing "java.lang.IllegalArgumentException: Cannot get ID of Modern Material"
.
paper has their own way of doing things
try/catch?
simply dont use ids tf
thats just dumb
Everything above 1.12 dont have ids
Tell me please how do i get Item instance then?
material?…
you triggered?
kinda yh
a little
And how do i get Item from that?
Material.fromString
net.minecraft.item.Item
thats how enums work
what do you wanna do with the Item class
so NMS and not Spigot
you dont understand what items are
that is nms, so nms probably has its own way to get the id
they never said that
.
stop being triggered by nothing
When i said Material?
.
except they did?
thats not what im triggered by even lol im trigged cause the dude was toxic from the start for no reason
No ITEM variable
When i walk to the people to whom i tell i want Item instance
And you tell me to use .toString() on enum
XD?
i literally asked you if you mean material and you said yes
cause guess whaz
Material is an enum
Bro wants help without telling you exactly what he wants and hoping you can read his mind
ig
?xy can only say that lol
I told you everything in first three sentences
I want to get and id to get Item.getId(int id);
Yeah I began to ask him questions to narrow down what he actually hanted and he just got rude.
Where's the id coming from that can't be replaced with a string material?
The only time i was rude was to geol
okay
Item item = BuiltInRegistries.ITEM.get(new ResourceLocation("NAME_OF_ITEM"));
Item.getId(item);
Next question
so teh first thing you should be telling us is that its a Minecraft Item not anything to do with Spigot
Apigot???
He said itemStack so its obv Spigot xd
obviously 🙂
When i said ItemStack?
Actually here's an idea, make your own list of ids for each item stack
There is no ITEM variable in BuiltInRegistries
a
Will take you hours and might keep you off discord for a bit
I have one
Are you using 1.18.2?
Do you use mapped?
Yes
If you have it and i don't, i will go blame my friend for removing it
i found it inside Registry class. Thanks for help
@fair rock
Np
Oh i have another qustion
Not related to coding
But i was always wondering
Why ItemMeta is marked as @Nullable
where?
ItemStack
in what context?
Wdym valid?
as Conclube said
AIR has no meta
so a call to getItemMeta() would return null if used on AIR
just dont check for it and hope you never get air 😅
Hey guys! Has someone already figured out how to get the new mapping for the following NMS?
this.toChatBaseComponent = iChatBaseComponentClass.getDeclaredClasses()[0].getMethod("a", String.class);
https://mappings.cephx.dev/1.20.6/net/minecraft/network/chat/Component$Serializer.html
I am trying to update my plugin's nms, but havent figured out what the new method is nor how to run it.
version: 1.20.6, hash: 10a28f86e8
ArrayList<String> lore = new ArrayList<String>();
Set<String> stats = NBT.get(item, nbt -> (Set<String>) nbt.getCompound("stats").getKeys());
for(String stringStat : stats){
Stat stat = Stat.valueOf(stringStat);
lore.add(colored("&7"+stat.getDisplayName()+": "+stat.getColor()+NBTHandler.getStat(item, stringStat)));
}
for(String s : lore) {
Bukkit.broadcastMessage(s);
}
item.getItemMeta().setLore(lore);
}```
why does the item not update lore? the broadcast part works
so how do i directly
meta is ALWAYS a clone, you have to put it back on teh item after changing it
ItemMeta meta = item.getItemMeta();
do Stuff
item.setItemMeta(meta);
that was paper
can i do it in one line
no
damn that sucks
I mean, just make a helper method
why is meta even a clone?
public static ItemStack editMeta(ItemStack stack, Consumer<ItemMeta> consumer) {
final ItemMeta meta = stack.getItemMeta();
if (meta != null) consumer.accept(meta);
stack.setItemMeta(meta);
}
like a method to do it all in one line?
and off ya go
i dont evne know what is a consumer 💀
then you can just call editMeta(stack, i -> i.setLore(list));
design decision long long long time ago
you can enter a lambda function
oh alright
that you cannot really revert now without breaking everything
in what way was it a good one tho?
i dont really get why cloning it is better
Who mentioned good?
i mean some1 decided it was better
¯_(ツ)_/¯
Someone also decided Windows ME was a good idea too
is it related to the packets that need to be sent to update the item?
a live reference is a bit annoying in how it interacts with e.g. minecraft
if you have a life reference and edit it, but the player merge the item into another, what happens?
this way, you have to have an item stack reference to set it back to
so it kinda forces you to not run into ugly issues
Hey guys! How can I completely unload a plugin from the server? I am trying to make an autoupdate feature
Auto update shouldn’t do it live, it’s risky to fully unload and then start it again
Just replace the jar and prompt the user to reboot
just put your new jar in an update folder and the server will update it when it restarts
sure
is there an app that turns an animation into spigot code using ticks instead of frames? and if there isn't, how possible would it be to make one
Is this a GIf?
Or a blender model
What kind of animation
actually nvm i don't think it's possible
can u change the position of an entity's hand?
damn
if you want to animate an npc or something just make an armor stand look like it?
i think thats the approach
There is also display entities
does anyone know why my goto command isn't teleporting me? all of the others work but not goto
switch (command.getName().toLowerCase()) {
case "die":
p.sendMessage("DIE loser");
for (int i = 0; i < 100; i++)
p.getWorld().strikeLightning(p.getLocation());
p.setHealth(0.0);
case "gmc":
p.setGameMode(GameMode.CREATIVE);
case "goto":
Location world = Objects.requireNonNull(getServer().getWorld("world")).getSpawnLocation();
p.teleport(world);
}
your switch statement needs a break; in each section
currently they all fall through
oh yeah whoops
goto looks fine, so long as you are not getting a console eror
i think i am?
ima reset the server to get a clean slate rq
oh wait i'm getting an error when i'm first joining the world
@EventHandler
public void onPlayerFirstJoin(PlayerSpawnLocationEvent event) {
event.setSpawnLocation(Objects.requireNonNull(getServer().getWorld("world")).getSpawnLocation());
}
wait i can just get rid of this rn
yeah that was that issue
okay i just realized i need to make a forum account so i can post images here
cuz i am getting a crash log
and i haven't quite learned how to read these yet
?paste
line 44 specifically is Location world = Objects.requireNonNull(getServer().getWorld("world")).getSpawnLocation();
also fsr it freaked and told me to switch to enhanced switch statements?
idk why intellij wanted me to do that but whatever
your world doesn;t exist
did you name it differently?
ph no I see
oh
remove the )) to be one )
after getWorld("world")
close at the end
your world is not called world
is there another thing to paste images
enhanced switch statements is just a syntax update
bc i have a world indeed called world
Is that world loaded?
you could do getServer().getWorlds()[0].getSpawnLocation()
oh it's a list, so get(0) not [0]
mhm
okay so that works sweet
that i'm confused about is my order of worlds
ima try something
main world will always be 0
print all the worlds and see if the names arent weird
Is there a protocollib discord server?
how do i parse a string as an int in java
I cant find one
casting does not work in this situation
Integer.parseInt(String)
Integer.parseInt(String)
cool
what I wanted to ask it. How would I read a varint? Normally I can just do PacketContainer.readString() etc, but readVarInt doesnt seem to exist
whats a varint
It's
cant you just read it as int
I
alright so somehow i made my main world "worlds/parkour"
man ima go verify i wanna post images brb
/nick wizard
aw shucks
eh whatevs doesn't matter that much
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
anywho i think i messed up by making a worlds folder because now the autogenerated paths are getting kinda icky
ah you have
Did you change the worlds container path and in server.properties the world name to parkour?
That would explain why the name is parkour
i named it parkour bc i had a map to use as a test and i made it in a folder worlds/parkour
the plan was u would be at the main world and could type /goto parkour and it would take u there
but eventually i deleted the world
but when i loaded the server back it considered that a reset
but your server.properties says world is the main world?
it couldnt get world cuz it wasnt loaded
is there a way i could make it not generate a nether and end equivalent of each world?
spigot.yml/bukkit.yml
server.properties
allow-nether: false
allow-end: false
Something like that
to get the default world use Bukkit.getWorlds().get(0) btw
overworld is 0, nether 1 and end is 2
doesnt it only generate nether and end for the main world?
oh i think maybe
since the parkour world became the new main
that would make sense
idk how other worlds work
yea
well rn im trying to create additional worlds with their own nethers and ends but the portals are giving me issues, since I have to basically generate all the worlds from scratch, so that means also linking portals
if there is a better i wanna know xD
but yeah thats what I understand
it creates ow, nether, end for main world, and then any extra world you create is just a single world
with nether portals bringing you to world 1 (main world nether)
so this main world is the one set to be the one you originally load in, but how would i load and then send people to a different world called lobby
load the world
and then you can teleport players to it
getWorld doesnt work until its loaded
Or keep it loaded, to reduce that heavy load
But it is a lobby so that’s not really necessary in this case
Yeah that’d be fine
It’s the difference between like a nanosecond and a full second for transfer times so it’s really not that big of a deal, however when it comes to other multi world mechanics, you’ll want all your worlds loaded before interacting with them
okay so now how do i actually load worlds lol
you use createWorld
Does create world have worlds loaded til plugin disables / server?
yeah or until you unload() it
though I think you can remove the world's folder when it doesnt have players
and I think that would cause getworld to fail afterwards
since the world is gone
but im not sure
still in the process of debugging that
Why would you need / want to remove the world’s folder?
oh i'm now realizing i need to make a system where it like
if you dont want the world anymore 🤷♂️
resets the lobby world and doesn't save what people do
like for minigames or whatever
yea
But that brings up: why would you let people do something to the lobby world?
Just prevent people from making changes then?
You guys are trying to do extra work kek
spawn protection everywhere 🙂
so people can have fun lol
Just save the changes made, and revert them when it's over/done
Yea
If it’s parkour, then it’s fine you don’t need to remove and add a new world every time a player needs to get to the lobby
what about like spleef
You can handle that with plugins
my brother in christ I am Making The Plugins
Auto generation of an area with your spleef blocks or something
Obviously?
I’m just telling you that you’re doing extra work for no real benefit
i just wanna learn
i wanna be able to do it myself, i wanna understand why and how it all works
Well sure, but just be vigilant in the advice you get, a lot of it is yes, correct, but sometimes it can be extra work for no reason
It’s hard to say what to do and what not to do on a project when you’re not the one writing it
I made eveyrthing for my plugin by myself, except for spigot api and the anvil gui backbone since that requires nms
so it depends on what you wanna do
i just code for fun
That’s a good look man
Keep at it!
proguard. And even then you need to be careful with what options you enable
The rules around obfuscation are honestly so strict that it isn't worth it
Geol you got md’s obfuscating link
i looked at the rules, you can't really go wrong with proguard
the rules apply for string encryptors/long obfuscations
ELGARL
and flow obfuscations/ crashing
Thx guys, I'll check
You just slow if a grandpa beat you
well you still need to keep package structure intact iirc
i flattened mine to ro.fr33styler.project
Tbf I didn’t start looking til 45 seconds after it was mentioned lol
i think that's within the rules
same 😛
Ok shut up I know I’m faster than you I just know it! How about we run a race
famous last words
🏁 start your engines!!!
can i make it so that you basically have infinite miners fatigue without showing that you have miner fatigue
, false, false, false
it's the closest to it
these are flags either in addpotion or potion effect
i always forget
I think -1? im not sure
it's the wrong usage
yea i see
or there was a constant for it
im just asting about the duration param
i forgot
i use Integer.MAX_VALUE
yeah but I believe they added a specific infinite duration method
I thought -1 worked for infinite?
because there is a difference between the **.** and inifite
i dunno
I think
oh they did, that's nice
use that
but use the constant
update
miner fatigue makes your hand slower
and i set my amplifer to just like 100 or something
are you just trying to disable breaking?
it stops on attempt?
if you are punching a block it doesn't show the damage done
use gamemode adventure instead
but it still does the animation
what exactly should I select in proguard?
I don't want my resource to be terminated Xd
i like that
i want the normal speed punching to be happening but no block damage to be done
must use short obfuscation, the main plugin class name must remain integral, your.main.path package must remain
that's it
still looks like i can break blocks
set it to 0?
did you register the listener?
i think it has a damage step
I see. This is good?
https://i.imgur.com/EG7iSBQ.png
also the damage state may be client side. see if you can actually break
you might wanna keep EventHandler methods
everything else works
set what to 0 exactly?
also you didn't add an obfuscation file
i think you can set the level of damage to a block
I'm betting it's just a visual on the client
so if you reset it to 0 that's gonna clear up any weird bugs
mayeb getBlock().progress? or something
Wait did you register the listener?
Because BlockBreakEvent should cancel that
block break cancels when the block is broken
i also wanna cancel like the progress of blocks being broken
like if u mined bedrock or something
i wanna get rid of this cracking without getting rid of the punching yk
I thought there was a break speed / block durability something or other now?
Maybe? I haven’t explored enough, but I swore there was something about block break speed
why the command dont stands in the console when i execute it with performCommand?
More context please and perhaps some logs + code
when the player executes an command with perfromCommand(" ") it dont counts as an command for the PlayerCommandPreprocessEvent
p.performCommand("betterrtp world world_the_end");
is there a way to do it?
this doesn't seem to work
why do you want to preprocess teh command you issued?
add a sysout and see if the event is even firing
okay so new info
it's fired once when you start to damage the block
but doesn't continue
if you delay sending the BlockDamage by 1 tick does it rest it?
I wanna do an rtp system and i use BetterRTP and becasue the betterrtp cooldown is ugly i do my own cooldown and only use the teleport from betterrtp. so i wanna do that only my command works
String command = e.getMessage();
Player p = e.getPlayer();
if (command.contains("betterrtp")){
if (PublicVariablen.getRtp() == true){
PublicVariablen.rtp = false;
} else if (PublicVariablen.getRtp() == false){
e.setCancelled(true);
p.performCommand("rtp");
}
}
}```
p.performCommand("betterrtp world world");```
how do i delay by a tick
you could use a bukkit runnable
theres also this
@eternal oxide
access BetterRTP and just call their onCommand
wdym
((BetterRTP) Bukkit.getPlugin("BetterRTP")).onCommand(...
i dont know what this does can u prob explain?
it gets the instance of BetterRTP thats on the server and calls the onCommand method that is in their main class
and how can i add my code to it?
look how betterrtp rtps you, copy it, put it into ur **custom **rtp command
saved afew milliseconds on server load time and no ugly cooldown message
you do yoru code, then call the BetterRTP command you want to run
but if i run the betterrtp command it executes with no cooldown
yes
or check if BetterRTP has a rtp method and run that
DO YOUR code, THEN call BetterRTP
which prob wont have a cooldown so u can make ur own cooldown
okay
actually that was all a waste of time. Just do your delay handling before you call performCommand
You were going ot do it in preProcess
Kek
why is my server getting crashed if i use openInventory in guiclose event?
read the javadoc, but also because you are still in teh event so it's not yet closed. calling open forces it to close again, over and over
so just run task 1 ticks later?
yes
k
Now somehow when i open the inventory its calling the inventory im opening's close event
but i have an inventoryholder check
how did that happen
dont have the holder check first of all
I guess thats also second of all
you should ideally use the reference of the inventory itself for comparison
?gui
then do what?
.
like have a list of your inventories
and then check if the inventory is the one from your list
its still the same inventory
the reference doesnt change
and if you keep the reference you can reopen it if you wanted
oh i see it now
which event do i need to use to prevent the player from eating
got it
PlayerItemConsumeEvent
and why doesnt the inventoryholder check work?
im not sure but I have heard its very not optimized, but it should technically function I guess
unless you gave them all the same handler
i only have 2 holders
anyways there is no real reason to use the holder if the reference to the actual inventory works too
if the inventory is linked to the holder if i do it like you say it will keep its old handler right?
i have an inventoryholder something i create inventories with.all inventories have separate InventoryHolder object of my inventoryholder class. i asked if i stored the inventories like you said if it would keep their inventoryholders
i have some data storing in the inventoryholder class in each inventory
thats why i am asking
I mean yes probably, but I remember strongly there is a good reason against using holders
here it is
the story of how jimmy commits warcrimes without him knowing
poor innocent jimmy
actually this reminded me to check my itemstacks in my plugin 😅
its just you
regarding that, here's the important code for first time putting PD on the item and for modifying it:
https://paste.md-5.net/lubaquyoqo.cpp
if teh arrays have teh same information, the data is gonna be the same
If I'm making an API is it better to make a jar file that is downloaded, or it better to make it in maven and the user has to call a registerEvents(this) in their OnEnable so they don't need to have users download dependencies to use their plugin
you can download dependencies in your plugin I think
for libraries you probably shade them into the jar
so I guess the second
I need the formula of changing block breaking time because of instrument
though usually the only thing a library needs is a reference to the plugin instance
MyLib lib = new MyLib(Myplugin);
and then the library can register stuff themselves
on behalf of your plugin
right, I just always thought it was a bit annoying to have to have people download a separate jar file for my plugin when it could just be internal
the user of the api I mean
Like by hand break block time is 15 ticks, but using wooden shovel it's 8 ticks
So how to get the formula?
Only the initial ones are the same
The problem i have, is that when on one item I modify the PD
then for a new instance of that item (which uses the default values) i have the modified values somehow
@EventHandler public void onItemCraft(CraftItemEvent event) { ItemStack result = event.getCurrentItem(); Player player = (Player) event.getWhoClicked(); if (result != null && result.hasItemMeta()) { ItemMeta meta = result.getItemMeta(); player.sendMessage(String.valueOf(result)); player.sendMessage(String.valueOf(meta)); if (meta.hasCustomModelData() && meta.getCustomModelData() == 637334) { if (event.getWhoClicked() instanceof Player) { player.getInventory().remove(result); Random(1, player); } } } }
How do i make it remove the deepslate?
Can you cancel the event?
nope, as theres no connection between modifed and the default values, they're handled differebtly. thx for trying to help tho :)
Possible is a BukkitRunnable with a delay of ~2-5 ticks
I wouldn't recommend doing that
That gives the player 2-5 ticks to drop the item
You should register your own recipe instead of handling it through events
Oh, it's random
Yeah its a random, idk if everytime you craft you get a random item xd
just for my sanity, if you have an offline player, getting a (possible) online player in the best way is just doing Bukkit.getPlayer(offlinePlayer.getUniqueId()) right?
Sounds right?
offlinePlayer.getPlayer
oof
Do check if they're online with isOnline first
Why tf has the OfflinePlayer a player instance, im confused but i feel the same Steaf
Hello, what is the packet to start and end the animation of eating / using bow / drinking potion.. etc ? (1.20.4)
I've searched on wiki.vg, but I couldn't find anything
it doesnt have a player instance
it probably just uses Bukkit.getPlayer itself if I had to guess xD
Entity metadata; https://wiki.vg/Entity_metadata#Living_Entity
Yeah i looked that up, its:
public Player getPlayer() {
return this.server.getPlayer(this.getUniqueId());
}
Yeah doesnt matter xd
but offlineplayer::getPlayer is more convenient
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerLoginEvent(PlayerLoginEvent event) {
// blah blah
var result = event.getResult();
if (result == PlayerLoginEvent.Result.KICK_BANNED) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Porttikielto: " + banReason);
event.setKickMessage("Porttikielto: " + banReason);
}
What am I doing wrong?
I'm not seeing the message I set.
Can you try EventPriority.MONITOR?
What does that one do?
Its a higher priority then highest
declaration: package: org.bukkit.event, enum: EventPriority
Do not use monitor if you do changes to the events result
Yeah make sense but for testing its possible to check if his stuff gets called or another plugin interferes
There should not nothing interfering as far as I know.
Setting to monitor made no difference.
Is the user banned using the default banlist? Idk how the default ban message looks like
same 💀
Because I've seen it happen that a vanilla ban will put the vanilla message there no matter what you do. Idk tho
I am using ProfileBanList banList = server.getBanList(BanList.Type.PROFILE);
Can you debug and check with what Result the event gets called?
Would be interesting if its get called or just dont because of vanilla disallowing you to join
I also tried the deprecated PlayerPreLoginEvent, but that seemed to make no difference.
I just run tostring on the result?
Yeah would be interesting
Something seems to be interfering and quitting early. Let me debug that too...
It appears the event is not firing at all 🤔
But I'll make sure one more time.
Yes, it's definitely not outputting anything.
BukkitRunnable runnable = new TaskManager(manager, e.getNewPhase());
runnable.runTaskLater(plugin, (long) plugin.getConfig().getInt("world" + ".Phase1.timer") * 20 * 60); // in minutes```
Why is this crashing my server? 💀
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerLoginEvent(PlayerLoginEvent event) {
System.out.println("PlayerLoginEvent triggered!!!");
}
I do think this should do something.
But it doesn't.
Gimme sec, i check that myself
OMG. I'm such a noob today. I didn't register the listener.
I thought you had, next time i ask the stupid question first 💀
I had originally only command executors.
we all have those days sometimes
And the listener was the last thing I added.
So I just forgot to register it and nothing was red.
Now I'm seeing everything as it should show up.
Thanks for helping out.
I didnt help really but its nice you figured that out <3
declaration: package: org.bukkit.event.player, class: PlayerLoginEvent, enum: Result
why does my click event call twice on one click?
because of two hands or something?
Why doesn't this show up in my IDE 🤔
The player is not allowed to log in, for reasons undefined
Argh. So helpful.
Banned, Kicked, Whitelist, Full and if you kick someone because of stupid stuff its KICK_OTHER idk xd
Because mouse click and mouse release maybe? Is that a thing?
Which click event?
Like, mouse button press and mouse button release.
InventoryClickEvent
Double registration? xd
whats that
Cancel the event?
You dont cancel event
what's the method for the teleport interpolation for display entities
i keep forgetting it
i recently moved back to spigot so
I don't think you can use the beacon laser. You might be able to use guardian rays though
spawn millions of redstone dust particles
Isnt the beam client-side or im stupid?
The guardian one? It has packets
Nah the beacon
The beacon beam is client sided
You can probably use a resource pack to recreate the effect though
But tbh would be cool if that effect would be possible vertical and horizontal lmao
assuming you're on a modern version a resource pack can do that
yeah ik but i mean without xd
what do i do if i have class that i need to use everywhere in my project (package-private isn't an option), but when some1 is using the api it shouldn't be accessible as it would break stuff?
Just have a public class that's not part of the api?
but how does the api work if the classes arent there?
I updated to the latest version of 1.20.6 and it works perfectly. They probably fixed the bug in one of the recent builds
Keep the api separate from the implementation
oh
i have managed to fix it without updating
It wasn't working for me because of the version. I was using a jar that was 15 builds old 💀
^
15 builds old is not that bad
Yep, it's always been like this 🐱
but after running this it creates a new one right here?
i wanted it to load the one i put, not make a new world
well i guess i did do .createWorld
but there is no .loadWorld i don't think
I try to understand:
You placed the world in worlds/minigames/tumble/default
You created a world with path: worlds/minigames/tumble/default
Right?
Did you set your world-container to "worlds"?
If you did, the createWorld method would use that path and put them in front like
world-container-path/your-path
that would be ./worlds/worlds/minigames/tumble/default
^ sounds like not the default world container setting
also what is that
If you dont know the setting, i dont think you changed that (its in bukkit.yml or a start parameter like --world-container)
So you didnt changed that, okay thats weird then
so how do i actually like load the world instead of it making a new one
Can you try createWorld without worlds/ (Just in case you have anywhere set the world-container to /worlds)
getServer().createWorld(new WorldCreator("minigames/tumble/default"));
sick
Just asking, did you downloaded a prepared server or something?
Im just confused why your world-container is set to /worlds as default, did that changed?
Can you look in bukkit.yml for world-container or in your start script for --world-container, --W, --universe?
Weird, okay
this is my start.bat
none of these either
Okay, im just confused, im just accepting that your world container is worlds without any reason lmao
maybe it's bc my main world is in worlds so it makes that the root?
Yep its because of that.
I changed level-name to "worlds/world", logged the WorldContainer absolute path and its was fr ./worlds
Changed in back to "world" and the path was ./ so thats why your createWorld was like
worlds/worlds/... because of the WorldContainerPath + your extra path
Now i know you can change the world container path with server.properties xd
wow i am so good at guessing
Make sense but now we know why that happend!🫡
so uh, i have custom bosses with "minions", these "minions" are just husks with custom stuff but i recently ran into an issue where some husks spawn with a chicken. This messes up the coded BADLY since the minion animation STRONGLY depends on teleportable entities and creates exotics since you shouldn't be able to get vanilla raw chicken or feather. Is there a way to stop jockeys from spawning but not stop the mob itself from spawning?
There is a SpawnReason. You could try to cancel on that.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html#JOCKEY
declaration: package: org.bukkit.event.entity, class: CreatureSpawnEvent, enum: SpawnReason
I would expect this to only prevent the actual jockey entities to spawn
does JOCKEY fire for the chicken or the husk
I'd assume so. Just spawn a few and check the entity type via println. Then you'll see if it works
It's the chicken
Technically a zombie can hijack an existing chicken as well if it spawns on top of it, but if you have no chickens nearby then yeah it will spawn a new one with the JOCKEY reason
it can? How precise is "on top"?
so i just have to kill all entities with JOCKEY spanw reason
5x3x5
not kill, just cancel the event for them
You said minions, so if you're extending an internal zombie entity type, you can override finalizeSpawn() and copy the majority of the logic while excluding the chicken jockey code
they're temporary minions so im just spawning a vanilla husk with custom attributes
Okay then yeah, opt for the API then
alr
If a zombie "obducts" a chicken, can it still despawn?
imagine losing your chicken because a zombie took it and despawned lol
It's still a 5% chance to actually become a jockey, even if it spawns on top of a chicken, but yeah. Regular despawn rules would apply to both entities I would imagine
I see, thanks
if ((double) randomsource.nextFloat() < 0.05D) {
List<EntityChicken> list = worldaccess.getEntitiesOfClass(EntityChicken.class, this.getBoundingBox().inflate(5.0D, 3.0D, 5.0D), IEntitySelector.ENTITY_NOT_BEING_RIDDEN);
if (!list.isEmpty()) {
EntityChicken entitychicken = (EntityChicken) list.get(0);
entitychicken.setChickenJockey(true);
this.startRiding(entitychicken);
}
} else if ((double) randomsource.nextFloat() < 0.05D) {
EntityChicken entitychicken1 = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
if (entitychicken1 != null) {
entitychicken1.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null);
entitychicken1.setChickenJockey(true);
this.startRiding(entitychicken1);
worldaccess.addFreshEntity(entitychicken1);
}
}
Relevant code in the zombie spawning logic
Top block is hijiacking an existing chicken within a 5x3x5, bottom block is spawning a chicken if one isn't nearby
is it possible to make a slime with a double size?
A double size. Not sure what you mean?
You can change the slime's size with Slime#setSize()
Size as a double instead of int
Oh, I see. No. Sizes of slimes aren't their scale. Think of it more as a "level". If you have a size 3 slime, kill it once and you'll get a handful of size 2 slimes. Kill those and you'll get a bunch of size 1 slimes, until finally you kill the size 1 slimes and they die without splitting
You can use the scale attribute that was added in 1.20.5 now though, which I believe is a double and should work for slimes? I can't remember if maybe slimes were an exception
It's still going to respect the "size" value of the slime though in that size 1 slimes will die, > size 1 slimes will split
super small slimes sure would look funny
doesn't look like it
what's the difference between setPower and setVelocity in Fireball.class
what version are oyu using
setPower isnt a method of Fireball
declaration: package: org.bukkit.entity, interface: Fireball
1.20.1
you're using paper
it isn't in paper docs as well?
but if I had to guess, power is explosive power
it takes a vector so im confused
it's in the paper docs, not spigot
Note: For fireball entities, their movement is also controlled by their power.
Specified by:
setVelocity in interface Entity
Parameters:
velocity - New velocity to travel with```
declaration: package: org.bukkit.entity, interface: Fireball
alr thanks
I'm using protocol lib to spawn a packet entity from the server to the client and im wondering if i can teleport the entity by calling the packetcontainer for the entityspawn under the entity teleport packet
or if thats not right, how would i do it
Does anyone know how I can put armor on wolves in code? In version 1.20.6
should be able to set the body equipment slot
I can't find a method in the Wolf class for this
should just be on the EntityEquipment you can get from any LivingEntity
thanks :)
Is this for your own plugin?
It doesn't seem possible
is there no setting to disable it?
i don't want it to save on exit, not sure about how to do that
my idea was to like
instead of load the world
make a copy of the world and load that?
so nothing tampers with the original world
?
i don't know what any of that is sorry
Oh, you're on windows
properties
no idea how windows wants to do it
on linux (the one true way) you just do chmod 440 file
Wouldn't that cause stack traces in console when io threads go to save
Personally especially if you're doing mini games I'd reccomend just unzipping a zip file from a Mongo bucket or something
Or spin up servers dedicated to a map if you have enough instances
correct
the server puts a lock on the world aswell, if it can't do that it'll throw aswell
what does this mean it looks pretty useful
as I said, hacky workarounds
although i feel this is an XY problem
you likely just want copies of your world
I'm making a fishing plugin and im trying to have the fish spawn in much like how they do in vanilla minecraft coming out of the water and landing at the player. I can't seem to get it working how i'd like it to. any ideas appreciated! https://paste.md-5.net/ekeyuriboy.cs
I have a question. Let’s say I have a special item called Zeus’s trident. I add a persistent data container to the trident, storing the name “zues trident” so I can get it later. On projectile launch event, how can I get that the trident is Zeus‘s trident or not? Obviously, I can filter by entity type trident, but there is no event.getitem() for this event, only event.getentity(). Would the same persistent container, still be on item even tho its an entity? Or would I have to use event.getplayer().getiteminmainhand()? The main hand method works, but I am concerned that it might result in null sometimes if the trident has already left the inventory.
Or is there a way to covert the trident entity back to an item to get access to the PDC?
Have you tried calling getItem on the trident entity
I swear i tried but let me look again
yeah theres no getItem for it, unless you can cast the entity to a diff type that lets you
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
cast to trident
(check that it's actually a trident first...)
yep that works great thanks. cant believe i overlooked that
(not related to above) I also keep getting warning issue everytime I compile my 1.20.6 plugin
hm? It does tell you what's wrong
You didn't specify which version of the maven compiler plugin to use
yeah ive tried adding it to the properties tag of my pom.xml but it still complains after
its not in this photo
yeah
also you can compile against Java 21 if you want
You don't have to set the java version to 8 and miss out on the new features
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
i keep putting this but maybe i have to use 21
im using SDK 21 anyways
I was refering to the java.version property
where do you specify this?
ah okay
1.21?
21
kk
- prefix was dropped
I believe that was in Java 9
it kept telling me i was using 8 and im like bruh it says 1.8
what about this?
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
21s for both or target a lower?
21 for both
yeah i did and reloaded my pom but still getting the same warning
or <maven.compiler.release>21</maven.compiler.release> as a property and remove the compiler plugin entierly from the pom
You probably didn't specify the version yet
The error isn't complaining about Java version it's complaining about plugin version
no idea wtf
tyty
so either set the source and target to 21 for that or add <maven.compiler.release>21</maven.compiler.release> to my properties aswell?
yes
well i think it also wants a version tag for the plugin
yeah that's the warning you've been getting
oh very nice thanks for that ill bookmark it
why do i even need this plugin tag though what is it doing?
It's configuring the compiler
like you said i could put that snippet in properties instead
Telling what to compile for
but this isnt specifying a version number: <maven.compiler.release>21</maven.compiler.release>
so why does this one haha
?
sorry im not trying to be annoying just want to know so i know have to keep asking in the future
ah I read your message wrong
i think you said earlier i could put that in the properties tag and remove the plugin one entirely
yes
im just wondering how that could replace the plugin tag if it isnt specifying a version
like why does the plugin tag version of it need the version but this doesnt
if you dont know its fine im being a little ocd
Putting it in properties will just use the bundled version I believe
welp i think ill go with that so i dont have to keep updating the version number!
specifying it in the plugins section allows you to tell it exactly what to use
that makes sense
which can be useful if your maven install is outdated
You can skip source and target
release is the modern replacement
also you can use a variable so you don't have to update java version in 2 places;
<maven.compiler.release>${java.version}</maven.compiler.release>
its compiling alot faster now too
but thanks I appreciate the help
heres my full pom.xml if you wana take a peek maybe im doing something else silly
You can define a property for spigot.version and then replace all cases of 1.20.6-R0.1-SNAPSHOT with a variable
makes it easier to change in the future
thats a good idea
do you have any links for keeping this version number correct also? i had the wrong number for it someone else had to help me
also you can use variable from your pom in the plugin.yml or any other file in your resources folder
oh that would make it easier
That site helps with searching for maven dependencies
You can for example also find the compiler plugin
Note this only works with maven dependencies in the central maven repository (the default one)
and not self hosted repositories like the spigot repo
thats awesome i appreciate you sharing that i had so much trouble updating from 1.20.4 to 1.20.6
and getting nms to work
but now we in full swing
oh it does appear to index certain 3rd party repositories
though I wouldn't rely on it for that
yeah ill mainly just need the special source one
or might just switch back to the api version cause its reducing the need for nms
at least in my case
finally adding a way to do holograms efficiently without nms
Display entities are quite useful
havent tried them yet!
more specifically the text display
yeah i read you can make them larger and stuff, set them to hidden from everyone by default
no more triple armor stands
nifty forsure
yeah
anyone have a better method of getting all blocks within the radius of a player?
Collection<Block> blocksInRadius = new HashSet<>();
int locX = location.getBlockX();
int locY = location.getBlockY();
int locZ = location.getBlockZ();
for(int x = locX - radius; x <= locX + radius; x++) {
for(int y = locY - radius; y <= locY + radius; y++) {
for(int z = locZ - radius; z <= locZ + radius; z++) {
blocksInRadius.add(location.getWorld().getBlockAt(x,y,z));
}
}
}
also curious about this as ive been trying to create my own explosion without using the createExplosion method
cause for some reason you cant set the damage to be 0 for it
he said without using the createExplosion method
well you can set power to be 0, but then it wont destroy any blocks
you either want damage or you don;t
or clear teh blockList in the event
depends which you want
broken blocks or players hurt
theres no event specific to this type of explosion i dont think
EntityExplodeEvent
no but you can get the source of the damage
yes i think on entitydamageevent
should work but then it would cancel all explosion damage
What exactly are you trying to do? Blow up blocks but not damage players?
yep
setting the damage manually
i just need something to explode blocks, and also set off other TNT and stuff in the area
you can;t have it both ways (automatically). Cancel damage on EntityDamageByEntityEvent
if the damaged is a Player, cancel
well i dont think it would call that event since its not by entity
does createExplosion have a way to attach an entity to it ill have to check
yes
it does
okay now were cooking here
ill just throw in my causing entity there and in the listener check if its the causing entity and cancel
yep
canceling it in EntityDamageByEntityEvent would cancel the EntityDamageEvent right?
i think they are inherited
anyone know the packet name for picking up an item?
there is an event in the API for it
haven't been able to find it anywhere, i thought it would be ClientboundTakeItemEntityPacket but it's asking for an item id as an integer
im cancelling the block break so no item is actually being dropped... im trying to fake it
why not spawnNaturally teh item you want to drop?
i dont understand, i cancel EntityExplodeEvent when its my entity i pass in but it still sends the EntityDamageByEntity event
dropItemNaturally
it cancels the explosion part, but not damage
is there a way to manipulate the distance of grabbing said item? I'm basically adding an item to the players inventory when they break a block, cancelling the block break event and setting it to stone. only the player that breaks the block should be able to grab the item and it should be given no matter the distance from the block
some of the enchants that i have break blocks from a distance
If you use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#dropItemNaturally(org.bukkit.Location,org.bukkit.inventory.ItemStack,java.util.function.Consumer) you can set the owner in teh Consumer
Only the owner can pick up that Item
yeah im using that for some stuff to deal with spawn but for this the player shouldnt be required to go back to the block broken to get the item
then just add it to their inventory
im still trying to simulate picking it up though. im already adding it to their inventory
anythign which doesn;t fit will be returned in a Map, you can then drop on the floor
For what reason do you want to fake a pickup?
What are you hoping to achieve?
im trying to get the itempickup animation from the block coordinate to the players location
I don;t see that happening unless you also fake an entity drop at the location
the client animation would just be a setPos on the dropped entity
the client will extrapolate the movement
ill try it, ive been on a few servers that do it so i know its possible
So spawn a fake Item for that player, setPos so it moves to the Player, then destroy it
however
you can do all that with the API, no packets needed
Interesting I thought I'd need to manipulate the packets
DropItemNaturally... set its owner so it can;t be picked up by anyone else. Then teleport it to the player
The pickup animation is a single packet
the player will then automatically pick it up
No need for fancy vectors and shit
alright ill give it a go
The teleport will cause teh client to extrapolate teh movment. Unless you are miles away
yea it only needs to be possible for ~10-15 blocks
8 blocks is ok, over that I'm not sure, try it and see