#help-development
1 messages · Page 801 of 1
I thought I remembered sending a sound to a player through packets for some reason (IDK why LOL) then stopping it using stopSound. Maybe the server sends a packet that contains an ID of the sound. For example “minecraft:entity.pig.snort”
I mean yeah you can play sounds to a player
And stop them
Doesn’t mean all sounds are played that way
i dont get why such system even exists, i guess its due to jukeboxes and noteblocks
but they could've got around that with more primitive system
My original goal here is to change the breaking/mining/walking sounds of a specific noteblock. Any ideas on how to do this?
download worldedit on your test server (not FAWE one) set ridiculous amount of blocks
try to block break
walk, dig noteblock
if you stil lhear the sounds, you cant do it
mfw resource packs
am i trippin
Plugins can send resource packs
In fact in 1.20.3 plugins can send multiple resource packs
.3 looking lit
Indeed
why would you want that
finally able to tell which resource pack was applied/denied from the server
my bug is amazing, i love when there's no bug, but there's not any action of the code
Because you might have more than one plugin with a resource pack?
my favourite part of coding
ok this makes sense
nah
but from vanilla side
im done
it doesnt
i guess data packs
not a json object
Well sure but Mojang knows 90% of the game isn’t vanilla these days
are you using proper encoding
:p
ill use utf 8
Doesn’t this technically mean there is no size limit anymore
Since you can just send multiple packs
tanks
same error
:)
gson is buggin
jdk provides an http server module already lol
Well, is a REST-Api, i'll use HikariCP and stuff
Granted that’s a very simple server
mind it's very bare bones but yeah
yeah
but thats 0 abstraction
and i need it fast
someone knows any libary?
any library will be fast
I’ve heard of okhttp before
javalin is pretty nice imo
I think
Shoutout to Mojang, I don’t need to make a fancy runtime pack merger anymore
im a slowed paced learner
i developed plugins in main class for 6 months
until i found OOP
oop is the love of my life, after Java
i'll check
Alright time to make http skript
like, people doesnt start hundred times a plugin per second
Actually I bet that exists
HELL NAH
bet
Alright, so when NOT using stopSound, is there any way to change the break sound of a custom block?
what's your opinion abt Kotlin @young knoll?
okhttp is for clients
:(
seemed so abstract
Never used Kotlin
javalin
Don’t really have an opinion
thanks
seems i was scrolled, emily mentioned it already
there is also spark, see which you like more
but i think javalin is superior
okay
i'll check both
why examples on kotlin
kotlin isnt beautiful enough like java
:(
yo, if i got a domain can i setup a email by myself?
lol
you need mail server
saw that
but
its too simple
idk
and i dont wanna use ai's anymore
yes screw simple
why would u use ai for learning
i used it when chatgpt was released like on september last year
i learnt good stuff
but only how to use it
not why neither how it works
is this the spark im looking for right?
i would assume it is because of static import
its just static method
or its just a stupid implementation in c#
import me.Bar;
public class Foo {
public void a() {
Bar.doSomething();
}
}
import static me.Bar.doSomething;
public class Foo {
public void a() {
doSomething();
}
}
hmm
thats curious
didnt how you could import methods
time to import org.bukkit.Bukkit.createInventory;
only time i really used it is for JUnit
whats JUnit?
unit testing framework
Sometimes I do it for math
Is there any spigot method for this? EnchantmentHelper.getDamageBonus(
You pass in an item stack and a mob, and it returns a float
i get this error
Could not find artifact org.spigotmc:spigot:pom:1.19.4-R0.1-SNAPSHOT in spigotmc-repo
i followed the ?nms tutorial but still get this error when i try changing spigot api to spigot
Yes
Enum for example is one that is static without needing to implicitly declare it as such
So on top of classes being able to be static. You have methods and variables that can be static. Constants are static too
The downside of statics for a class or anything static is the jvm initializes them the moment they are loaded onto the classpath and they can never be gc'ed so they are always loaded. This is one of the few major reasons to not abuse statics
Well i suppose they could be gc'ed if you nuke the class loader. Never really tested this lol
public static void selectRandomPlayer() {
Player[] onlinePlayers = Bukkit.getOnlinePlayers().toArray(new Player[0]);
Arrays.sort(onlinePlayers, Comparator.comparing(Player::getName));
Random random = new Random();
int randomIndex = random.nextInt(onlinePlayers.length);
Player randomPlayer = onlinePlayers[randomIndex];
target.put(randomPlayer, randomPlayer.getName());
if(target.containsKey(randomPlayer)) {
Bukkit.broadcastMessage(Main.Color(Main.prefix + "&7Kill " + target.get(randomPlayer) + "&7and earn &2$500"));
} else {
}
}```
OnEnable (Main Class)
@Override
public void run() {
if(Bukkit.getOnlinePlayers().size() >= 2) {
Target.selectRandomPlayer();
} else {
Bukkit.broadcastMessage(Main.Color(Main.prefix + "&7The Target event has been cancelled"));
}
}
}.runTaskTimer(this, 500, 700);```
guys i have problem here
now if someone kills the target will get a reward
But I also want if the target survives to get a reward
my question is how to check if the player is survives or not after time finished?
Should remove static from that hashmap
As well as possibly that method too
so, can u give me another way?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
yup i know the deathevent
and i make a conditon to check if the target player died by someone or not
As for the surviving bit, you will have a scheduler that checks after your set time and see if they are alive. From the death event ideally you would cancel your task instead
So if the task runs that means they didnt die otherwise it would have been cancelled if they did 
Nothing too difficult other then restructuring your code to be more appropriate
?nms
where can i find documentation of nms mojang mappings
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
if you're really looking for documentation what each nms method does, well you're out luck because that doesnt exist, since minecraft is technically not open-source and commercial product
hm , it has wierd things like there was spawnaatLocation() method i though it would spawn the entity at a specific location instead it asked for a itemstack in parameter thats why i was looking for some clear instructions
that probably spawns item entity at specific location
probs you chose wrong nms method
yah but it should take location as parameter but it takes a itemStaclk
maybe it takes not bukkit's itemstack but mojang one
Player#getFirstPlayed is seconds right? not ms?
lol
if i use it without mojan mappings will it be any different cuz most tutorials that i find uses it without mojang mappings
NMS doesn't have docs
you're on your own
Mojang mappings mostly are used for reference
doubtful most people here can even help you
if you need help translation from spigot to mojang mappings this site can be helpful
https://mappings.cephx.dev
there's tools like to paperweight for paper that converts mojang mappings to spigot ones
but if you use lets say reflections
there could be some issues still
if you have any Inventory/Container questions related I can answer that
Mojang mappings didnt exist in public until 1.16 I believe, Mojang went generous at that time and shared the deobfuscation mappings for modders to use
yep and then oyu have projects like parchment too <3 which are using those mappings to doccument NMS, but such tooling is really only avaliable for Fabirc/Forge
Minecraft coders pack also existed long time ago, i believe but that was incomplete and not enough for modders to use
i believe it was maintained by dinnerbone
but im not quite sure
Mache, by paper, is pretty good
i am able to compile the mapings but i cant compile it in my plugin folder directly i get this error
java: cannot access java.util.stream.Stream
class file for java.util.stream.Stream not found
how does one even get that error
im as surprised as Y2K
Did u build with maven or gradle?
Java 7 maybe??
How can i check if a scheduler is running or not?
Bruh did not just reply for that unrelated tangent
Javadocs
You want to know how to start a scheduler, right? Well, there are many ways to do that, but I have a challenge for you. I want you to show me the code that you use to launch your scheduler. Don’t be shy, I won’t judge you. I’m just curious to see how you do it. Whatever it is, I want to see it. Show me the code, and I’ll show you mine. Deal? 😜
ok np
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
@Override
public void run() {
Player[] onlinePlayers = Bukkit.getOnlinePlayers().toArray(new Player[0]);
Arrays.sort(onlinePlayers, Comparator.comparing(Player::getName));
Random random = new Random();
int randomIndex = random.nextInt(onlinePlayers.length);
Player randomPlayer = onlinePlayers[randomIndex];
target.put(randomPlayer, randomPlayer.getName());
if(target.containsKey(randomPlayer)) {
Bukkit.broadcastMessage(Main.Color(Main.prefix + "&7Kill " + target.get(randomPlayer) + "&7and earn &2$500"));
}
}
}, 20L, 500L);
}```
isCurrentlyRunning(int taskId)
Javadocs
hello,
i want to use the anvilGUI and it won't work.
link: https://github.com/WesJD/AnvilGUI
i got this error:
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:160) ~[bukkit-1.20.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[bukkit-1.20.2-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 18 more
i think it's my pom.xml so if anyone can look at it, it would be great.
(to big i'll put it in thread)
how to use this.goalSelector.removeAllGoals(Predicate<goal> var1); i want to remove all the target goals from zombie so i can modify it from its base
Paper?
So nms?
yah
I guess the predicate checks whether the goal should be removed, so check whether the goal's a target one and return that
Does anyone know how to hide the holograms from DecentHolograms from the view when behind a wall?
they were backported a little bit
what's the best event to use to constantly check if a player is in a chunk owned by a faction, which then applies negative potion effects?
i was thinking some sort of tick event but would that be bad performance wise?
or would you use a scheduler for this?
How can I make decentholograms update itself x amount of time. I'm looking online but cant find anything
Player move event
Bros should use timer task instead imo
yeah i think timer is better after reading up a bit
can iget help please
PlayerMoveEvent but early exit with a check to see if they have move a whole block
Depends i suppose
MoveEvent is expensive, he’ll probably misuse it.
Its not expensive o.O
But they could misuse it as you said. But that is up to them lol
What does .runTask do on a Bukkitrunnable, isnt it then just running it like normal code without the runnable?
It adds it to the underlying task queue if I recall correctly
What does this mean?
It is executed the next time the queue is iterated upon, which is the current/next server tick depending on when you call it
It schedules next tick, it also synchronizes code to main thread
Okay
yeah I think so, have a look in the docs tho maybe you find even more there
it runs the task once in the next tick.
lets say u use sth like CompletableFuture.runAsync(() -> { blah() }), then blah() is executed on the fork join pool, or well more generally its executed off the server thread. If u wanna do something back on the server thread you'd then have to use a BukkitRunnable or the BukkitScheduler and for example call runTask() inside the runAsync(...) lambda.
okay thanks :)
is there a vector method to calculate the right hand angle of a vector pair in a plane?
left and right are really arbitrary, even in 2d space
given a normal vector for the plane lol
i need to know this to calculate the amount of iterations for the rotation
?
'angle' just spits out the minimal angle, but i might want to generate > 180° of a segment
If you have a fixed projection, then its always gonna be 90°
i have three vectors, plane normal vector and the two vectors that created it over cross product. I need a way to figure out a relative angle between those span vectors
if i generate 270° i dont want the 90° angle im trying explicitly NOT to generate
Then... just use the Vector#angle(Vector) method
Do you want the angle between a vector and a plane?
no that one'll be 0° cuz the vectors are in a plane
qq if you swap the vectors in the cross product the resulting planar identifying vector will be inverted, correct?
That is the normal on your plane then
i meant is a x b = -1 * b x a
Lets start from the beginning. Define your coordinate system, and each of your vectors with their role in this system.
im using deltas so my vectors are from 0 to some point. I have 2 vectors, one for the start and one for the end of the circle segment.
What i want to do is generate a circle segment with 0 as the circle's center between the two span vectors, but I'm having trouble figuring out how to iterate over a span larger than 180°
are 2 vectors not enough information to infer rotational direction?
So you want to lerp the rotation between two vectors? This can be quite tricky
Wait a moment ill write an example
i have the interpolation math, its just the circle stuff
the problem is calculating the cutoff point
@lost matrix
Its literally just the angle between the two vectors you want to interpolate between...
the angle method, again, returns the small angle, because it has no argument for the direction i want to measure the angle in
the angle 90° is measured in the other direction 270°
I dont quite get the problem with that...
You could just brute this
boolean isClockwise = startNorm.crossProduct(endNorm).getY() > 0;
if(!isClockwise) {
angle %= 180;
}
i mean i could by asking for the values directly but the idea here is to make it simple to use, aka leave all the weird math to the generation method
huh
yea that'd probably do it
ill try it out
though it'd probs be angle += 180
Really depends if you use the isClockwise variable to change rotational direction
i mean ideally i want to swap the rotation direction by switching the order of the input vectors
which probably just amounts to inverting the norm vector if it's y is < 0
Hm, still working on an actuially usable slerp method... Thats really not easy
Hello.
I have a problem with grass. As shown in the photo, if I place tallgrass on top of the leaves, they will disappear after a few seconds. Does anyone know what kind of event causes this?
I'm sorry for my bad English.... Thank you.
Just disable random ticks. Those are usually only usefull in survival.
Thank you for your reply.
I've already tried that, of course, but I can't use it because it affects crop growth and snow accumulation... :^(
Might be the block physics event
It worked! Thank you so much🙏
I want to make TextDisplay with line changes but I don't know what to write in text.
display.setText(Component.Serializer.fromJson("{text:{\"text\":\"Test1\\\\nTest2\"}}"));
Shouldn't I make it like this?
Hi , does anyone know how to convert org.bukkit,entity.Player to ServerPlayer?
Just cast it
*Without getHandle()
getVelocity() ?
no, with. otherwise it's just a CraftPlayer
well that returns always 0, -0.08, 0
their initial message asked for CraftHumanEntity
they changed it
*Which extends CraftHumanEntity
Wait they changed their message
well I only saw this
I saw this 🙂
Doesnt the line break work?
I feel like it should
player.getHandle().do() it does the same 😭
only jerks edit their messages :angry noises:
what? o0
(0.0, -0.0784000015258789, 0.0)
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 3 path $.
...
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 3 path $.
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1657) ~[gson-2.10.jar:?]
at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1463) ~[gson-2.10.jar:?]
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:517) ~[gson-2.10.jar:?]
at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:422) ~[gson-2.10.jar:?]
at com.google.gson.internal.bind.TypeAdapters$28.read(TypeAdapters.java:779) ~[gson-2.10.jar:?]
at com.google.gson.internal.bind.TypeAdapters$28.read(TypeAdapters.java:725) ~[gson-2.10.jar:?]
at com.google.gson.internal.Streams.parse(Streams.java:49) ~[gson-2.10.jar:?]
... 29 more```
An exception occurs, but I don't know why.
How about not using json? 
Component.Serializer only has the json method, is there any other way?
Is that an nms class?
yes
usnt text just a string?
I intend to mount the TextDisplay and print several lines of text over the player's head
I looked it up and I think I can use CraftChatMessage.fromStringOrNull(string)
You need to give more context next time. So its a virtual nms entity which is only
sent to the client and not spawned on the server. In this case you can use the CraftChatMessage class.
I'm sorry, I was thinking about it for a few hours and I was taking it for granted that it was nms.
Why doesn't it line up even if I type "Test1\nTest2"?
Is escape character supported only on json?
I am using nms way to open AnvilInventory, but there is a error occurred.
ServerPlayer serverPlayer = ((CraftPlayer)player).getHandle();
System.out.println("test");
serverPlayer.openMenu(new SimpleMenuProvider((syncId, playerInventory, playerEntity) -> new AnvilMenu(syncId, playerInventory), Component.literal("Anvil")));```
how detect interact with inventory - shift + mouse click
InventoryClickEvent #isShiftClick and #isLeftClick ?
Something is "not supported yet"
@river oracle its ur expertise
You're doing this wrong
Don't use the menu provider
Just use AnvilMenu and open it with Bukkit api
One sec I'll give code
I am trying to open AnvilInventory , and item in slot 1 and 2 , and take result.
It doesn't output any result.
so i am trying to use nms way.
CraftPlayer player;
ServerPlayer splayer = player.getHandle();
AnvilMenu menu = new AnivlMenu(splayer.nextContainerCounter(), splayer.getInventory(), ContainerAccess.create(splayer.level(), splayer.blockPosition()));
menu.setTitle(Component.literal("thing");
player.openInventory(menu.getBukkitView());
This is much easier than what you're doing
ok , trying.
AnvilMenu needs to be given a ContainerAccess
generally its okay to just use the players location for this since we're spoofing it
Can't ya just set checkAccessible false
openInventory(InventoryView view) already does this
I see
but we have the player there's not really a much easier way to make a ContainerAccess
I corrected it correctly, the second line is not visible, but only "Test1".
: CraftChatMessage.fromStringOrNull("Test1\nTest2")
How do I type that into json in the plugin?
display.setText(CraftChatMessage.fromJSON("{text:'{\"text\":\"first line\nsecond\"}'}"));
It works well with the summon command, but I don't know why it doesn't work
ContainerLevelAccess.create(player.level(), new BlockPos(0, 0, 0))
as said, you need to escape the \n to \\n - or in a java string, \\\\n
why not use BaseComponent? and than turn it into a mojang Component
you're bound to have issues doing it like this
craftbukkit's deserializers do all the hard work for you if you already have the BaseComponent
I didn't know because it just came up as a higher version! i'll try that
/**
* Translates the given base component into a json string
*
* @param component the component to translate
* @return the string
*/
public static String toJsonString(@NotNull final BaseComponent... component) {
return ComponentSerializer.toString(component);
}
/**
* Translates the base component into a minecraft component
*
* @param components the component to translate
* @return the minecraft component
*/
public static Component toMinecraftChat(@NotNull final BaseComponent... components) {
return CraftChatMessage.fromJSON(ComponentSerializer.toString(components));
}
Does the job juust and and you don't need to worry about weird JSON errors
you could also just use BlockPos.ZERO 🧠
I always forget you need to set the title.
Updated my code accordingly if need be
its the same thing you just don't need to create an object every time
Yes but which is more version safe
Aka which will be less likley to change obfuscated names
oh no clue I don't bother with that problem 💪 moojang maps ftw
This guy knows
Currently I have to remake my custom anvil class for each version anyway
Dang you craftbukkit relocation
I'm making a tool for this
lame
Need to remake a lot of spigots tooling tbh
Mostly since it's not public and I want to start doing some weird stuff
Oh yeah Mojang also changed setItemName from void to boolean in 1.20
E.g. snapshot support
Clearly just to annoy me
And keeping my PRs up to date in snapshots
What are we fabric
Ig I am md isn't tho
Are you modmuss
?? Tf is that
Oh no I'm not
We still need to switch to mojmaps but idk where I'd start if I made that pr
ServerPlayer splayer = ((CraftPlayer)player).getHandle();
int nCC = splayer.nextContainerCounter();
Inventory inv = splayer.getInventory(); <-----
ContainerLevelAccess containerAccess = ContainerLevelAccess.create(splayer.level(), splayer.blockPosition());
java.lang.NoSuchMethodError: 'net.minecraft.world.entity.player.PlayerInventory net.minecraft.server.level.EntityPlayer.fN()'
at org.MEGeyserSupport.MEGeyserSupport.onEnable(MEGeyserSupport.java:76) ~[?:?]```
seems remapping gets something wrong?
I mean but remapping .java files
xD yeah nah
Probably a missmatch between development and server version
^ nms is only 1 version supported
*Kinda
it's 1.20.2-R0.1-SNAPSHOT
and server is 1.20.2
how does your remapping config look like?
oh , nvm , i see that i forget to update the <plugin> section, i just update the dependency scope.
nothing will happen if I do this? private static final BarrelMarketX instance;
static {
instance = new BarrelMarketX();
}
InventoryView view = new AnvilMenu(nCC, inv, containerAccess).getBukkitView(); <-- Line 78
view.setTitle("Anvil");
java.lang.IllegalStateException: Title not set
at com.google.common.base.Preconditions.checkState(Preconditions.java:512) ~[guava-32.1.2-jre.jar:?]
at net.minecraft.world.inventory.Container.getTitle(Container.java:92) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3940-Spigot-7de1049-eeb7dfc]
at org.bukkit.craftbukkit.v1_20_R2.inventory.CraftInventoryView.<init>(CraftInventoryView.java:30) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3940-Spigot-7de1049-eeb7dfc]
at net.minecraft.world.inventory.ContainerAnvil.getBukkitView(ContainerAnvil.java:357) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3940-Spigot-7de1049-eeb7dfc]
at org.MEGeyserSupport.MEGeyserSupport.onEnable(MEGeyserSupport.java:78) ~[?:?]
How can i set title before AnvilMenu.getBukkitView?
Relook at my code earlier
I edited it and pinged you about it
As long as this isn't your main class yep. If it is your main class things will explode horribly
dem why
Because If you initialize it before bukkit you can't use it properly
Set the instance in your onEnable
this is why onEnable need hah
The static final doesn't need to be final for those
i was want use constructor
Just make it private static
ok
you can use final if variable is assigned in static block
YES it open the anvil ui sucessfully , thank you~
Nothing it will work
That's the main plugin class right there o think you mean everything will explode
Oh, no i just didn’t pay any more attention to it
if BarrelMarketX is class that extends javaplugin, it will break
@river oracle but the anvil inventory closed quickly , how can i keep it open?
i see
It shouldn't unless you're closing it that's the same code I use inside Cratbukkit
ok , i'll run at 1.20.2 and try again
I remember I had skinsrestorer on my server because of a cracked friend and it somehow fucked up potion effects, like, it was the last plugin I suspected to be the bad one
when i update my client to 1.20.2
the UI stays longer , but still closed after about 0.5s😂
Do you have code that closes it? It should stay open
no,
this is whole enable function
@Override
public void onEnable() {
for (Player player : Bukkit.getOnlinePlayers()) {
ServerPlayer splayer = ((CraftPlayer)player).getHandle();
int nCC = splayer.nextContainerCounter();
Inventory inv = splayer.getInventory();
ContainerLevelAccess containerAccess = ContainerLevelAccess.create(splayer.level(), splayer.blockPosition());
AnvilMenu menu = new AnvilMenu(nCC, inv, containerAccess);
menu.setTitle(Component.literal("Anvil"));
InventoryView view = menu.getBukkitView();
player.openInventory(view);
}
Bukkit.getServer().getPluginManager().registerEvents(new Events(), this);
}```
Give me 15 minutes I'm eating ima see if I can replicate 1
inb4 you do need this.checkReachable = false;
Lol that might be true
@odd adder trye menu.checkReachable = false
ok~
Before you open
Genius energy right here clearly I sont deserve inventory pr you can have it 😢
oh yeah , succeed ~
Im so smart
Yes you are
Miles thought that was in inventory view:<
But alas
Miles forgot his pr does that
No clue
is there a way to put alot of text into a text display without server crashing
Why
If it does I have some code to redo so lmk
Is it possible to change @s to the player's name while writing a command in chat or in the command block?
I notice my anvil menu takes a brief second to open the first time
Trying to figure out why
why not 😭
specifically at the time of writing and not after
Try using the players location
Define a lot
Becuase then it'd already be loaded
yeah probably smarter
Why
i want 100x lorem ipsum
Why
Yo he got the gif to work
anyway
use multiple entities
yes beside that
you don't
because it'd crash the server
Too many entities will too
why would it crash the server
I mean display 100k lines of text is completely unreasonable and out of scope for text displays
so it doesn't matter what you do
its gonna lag
Time for science
Yo guys, when I was making a plugin for b1.7.3 I needed to make an inventory, but in that version bukkit had no inventory stuff yet so I used nms and made my own class extending a nms class. Rn I'm wondering, would it be possible to do the exact same thing in the latest version?
Sure, but why?
Also wtf
Just wondering if stuff changed
"Wtf"?
do they have contianers back then?
if not things have changed a decent bit
how i can get all Word Loaded in SlimeWordManager?
Iirc yes
AnvilMenu.java
public void setItem(int i, int j, ItemStack itemstack) {
this.getSlot(i).set(itemstack);
this.stateId = j;
}```
What is argument j for?
well you'd probably beable to though it wouldn't really be too useful
set an item 😅
You mean since 12 years ago?
Yes, things have changed dramatically. You will barely find any line of code which was not completely
replaced from back then.
Yeah, modern bukkit/spigot is amazing
you should just use spigots methods within InventoryView though you can edit the InventoryView before you open
you don't need to even touch those NMS methods
I hope mojang replaced their shitty Block and Item classes
Which ones
I tried spigot api , when i set item , then the result is not updating.
The ones with all the static constants?
Yes
try using the Inventory
Nope they still there
view#getTopInventory()*
you could also try using player#updateInventory()
This is why I disabled the vanilla anvil output code :p
trying
Well, do they still work in the same shitty way? Where blocks had an array of 256 elememts and only like 90 of that were used and all of the blocks were also added to the 32000 long array in the items class and items were added only after the 256 index
I think even before that
And luckily b1.7.3 doesn't have the thing were you had one block and like 20 others under the same id but different idk what's it called
it's called joseph
Joseph?
(you are meant to laugh)
Am I a boomer, a zoomer or just shchewpid?
not working , same.
i think i need call AnvilMenu#createResult()
no you don't it should work as intended try just putting the items in by hand
maybe the setItem is bugged
but the feauture i am coding , need directly set item into.
also you have these items the wrong way around no?
doesn't it have to be chestplate than enchantment book
Yes
yes
.w.
then*
You really confused the shit outta me
Looks good to me
More no workey?
is that one?
😂
Lmao
yes
how many chars?
26k
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
wrong channel my bad
Lets see how 100k goes
i tries coping zombie registergoals and addBehavious function , ovverrided a pig class and pasted it there(nms) and it ended up breaking its ai , now the pig does not move , it just startes at players
public class badPig extends Pig {
badPig(Location location){
super(EntityType.PIG,((CraftWorld) location.getWorld()).getHandle());
this.setPosRaw(location.getX(),location.getY(),location.getZ());
this.persist = true;
this.registerGoals();
((CraftWorld) location.getWorld()).getHandle().addFreshEntity(this);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers(new Class[]{ZombifiedPiglin.class}));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, true));
if (this.level.spigotConfig.zombieAggressiveTowardsVillager) {
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, AbstractVillager.class, false));
}
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(3, new BreedGoal(this, 1.0));
this.goalSelector.addGoal(4, new TemptGoal(this, 1.2, Ingredient.of(new ItemLike[]{Items.CARROT_ON_A_STICK}), false));
this.goalSelector.addGoal(6, new WaterAvoidingRandomStrollGoal(this, 1.0));
this.goalSelector.addGoal(7, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
}
}
i tried to use it directly aand also by ovverridding the registerGoals but the pig just does not move
If i use full of spigot api, then it still not updating even added player.updateInventory()
for (Player player : Bukkit.getOnlinePlayers()) {
Inventory inv = Bukkit.createInventory(player, InventoryType.ANVIL);
ItemStack is = new ItemStack(Material.ENCHANTED_BOOK, 1);
ItemMeta itemMeta = is.getItemMeta();
EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) itemMeta;
enchantmentStorageMeta.addStoredEnchant(Enchantment.MENDING, 1, true);
is.setItemMeta(enchantmentStorageMeta);
player.openInventory(inv);
inv.setItem(0, new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
inv.setItem(1, is);
player.updateInventory();
}```
but after using AnvilEvent , it solved.
i've check the slot this time , chestplate is first , enchanted book is second
Why does the second "e.getInventory.getTitle" if statement doesn't work ? i just don't understand.
https://paste.md-5.net/babojalazi.cs
Nothing prints
@young knoll
Inventory has no getTitle method
in 1.8.8 it does
oh can't help with legacy then
Anyone got any idea's
Rip NBT is too long
Btw , when i developing non-nms plugin , i can set artifact->build->directly to plugin folder.
When i developing nms plugin , it will not remap the code.
Do you guys know how to setup artifact with remapping?
this thing:
?nms
you need to use maven
or rather you should* use maven
I'm sure theirs some jank ass you can do to remap with artifacts
I forget people use debuggers 🤷♂️ idk how you'd even use a debugger with minecraft so sorry not sure
or can maven set the jar output directory?
It can
where should i add it ?
in build section?
ty
Do you want teaching later
Bc PvP
Wouldnt it be easier to revert those pvp changes with plugins
It does not feel authentic then
And does not have several gameplay-deciding bugs like kb reducing
Make it a mechanic then
Then cope with new system
Life is everchanging
Or something
Old pvp was boring either way, who spams more wins
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class GodCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (sender instanceof Player){
Player p = (Player) sender;
}
return true;
}
}
Hi. Im following a toturial, and he does this. But my "sender"s is red? It says, that i have to create a local variable, but what? Cody Simpsons does not do that :(
watch the tutorial better
??? Im writing here to get help, not to look on smart-ass comments like yours.
It should be commandSender, not sender
Both places?
You can either rename sender to commandSender
Oh, i understand now.
@NotNull CommandSender commandSender you named it commandSender. If you don't want smart-ass comments learn some basics so these questions can be avoided. can't blame the guy
Doesnt excuse answerers from any kind of decency
Im trying to learn basics ffs..
My answer was completely accurate. You tried to blame cody for the mistake when it was you not watching attentively.
literally watch the video closer and you'd have learnt from your mistake.
Yea. I know its my bad. But instead of being a smart-ass, then just tell me that? Tell me what i did wrong - Didnt even know what that line did?
It would also be nice if you didnt word yourself as if you were being smart-ass even though you werent
I guess I could have been more patient.
You can thank DuskTaler for the smart-ass comments as he's been in here winding people up for weeks on java basics. Kinda got annoyed at him and ended up giving basic responses to basic questions.
Why does the second "e.getInventory.getTitle" if statement doesn't work ? When i tried to debug it it printed nothing.
https://paste.md-5.net/babojalazi.cs
You essentially said that you cant control your emotions over a guy on the internet
convert control codes if you want to match
best to compare inventory instances not titles
wdym
Your String title must exactly match if you want to compare Strings.
It's not a good way to compare inventories as a player could rename an inventory and fake yours
Instead use if (e.getInventory() == yourRolesInventory)
is it possible to make custom bar(like the hp bar, hunger bar, armor bar) ?
Doesn't work.
it will work if your code is correct. show code
== is comparing instances (memory location) so you have to check against the same inventory you created when you opened it.
?paste
you are creating a new inventory every time
it has to be the same instance you created when you opened the inventory for the player
you are also still checking by name
Yeah but its only the second that doesn't work
you are comparing String names
https://paste.md-5.net/agiyecorom.java, still doesn't work
you can;t create a NEW inventory and compare against it
it has to be the same inventory you opened for the player
I use a button on a GUI to open the GUI
where do you create the inventory?
oh ok
you don;t need a holder, but you should make it a field so it's created when the class is instanced
I make a class where i make all inventory's ?
?
Yeah, still doesn't work
that will work
you want a screen share ?
it will be an empty inventory as it's only been created
Yeah, but it just doesn't work
you shoudl also not close nor open inventories in the click event
read teh java doc notation https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryClickEvent.html
Man it just doesn't work i copyed your code
Yeah my bad for this, but it still doesn't work
This code will not work in the click event
so i do runTaskLater for these linges ?
just runTask will do
that will run on the next tick
no need to close at all, just open the soloInventory
Hello, what is the event for when an entity place a block?
okay thanks
ye
did you reload gradle
just wait for that to finish
do all the imports work now?
the gray ones arent used
?paste the class
also
my friend helped me
with code with me
he told me what things do lol
i have no idea what to do
i just had a idea
permissions doesnt exist so its not adding anything and the other errors are just saying those methods dont exist
k
the ranks are probably under perms
update the code to use correct methods to make it work
k
i fixed
all the errors
but
i have 1 left
@remote swallow
you probably have an extra curly brace
yep
BRO
@remote swallow u know how to add
ranks?
no idea
i would advise against just copying chatgpt code
ranks are in TownyPerms not the permission provider
yeah im reviewing
i know permissionnodes are
but the plugin lets players create their own ranks
ranks are in the TownyPerms instance of a town
yeah
How to remove field from FileConfigurationSection?
set to null
a field can be null
set the section without the field
you set a Section to null to remove it
but a field you have to set teh section excluding the field
basically delete it from teh map before setting the section
the value being set to null will remove it from the config
it won't
it will
hey I am working on a custom model data texture for a custom item in hand that utilizes the poppy, but I noticed when I do this even though the new texture works for the custom item, the poppy default texture breaks. are flowers handled differently in texture packs by chance?
EDIT: Nevermind it was block/poppy not item/poppy
and setting the value in the section will remove it from the section
no, a value can be null
no there is no remove
hey protocolLib only allows me to do a whitelist of which packets i want to receive but how can i receive every packets?
@Override
public ListeningWhitelist getReceivingWhitelist() {
return ListeningWhitelist.newBuilder().types(PacketType.Play.Client.GROUND).build();
}
a value can be null
Why
because
you have to remove the key/value from teh Map/MemorySection
Without a reason you won’t get an answer
Gotta agree with emily on this
thats a section not a field
Elgar is on shrooms
lists can contain null not values

yep I was thinking of Lists in sections not fields
yeah lists probably, they're just lists, no special mapping
thanks!
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
for myself
Im quite new to making plugins, and one thing i was trying to do is make a block placed above a block that the user placed, the block above the placed block cannot be broken unless the place block is broken
I forgot to give the code:
public void onBlockBreak(BlockBreakEvent event) {
for (Location i : Locations) {
Location blockLocation = i.subtract(0, 1, 0);
Block DestroyedBlock = event.getBlock();
World world = DestroyedBlock.getWorld();
if (DestroyedBlock.getLocation().equals(i)) {
event.setCancelled(true);
return;
} else if (DestroyedBlock.getLocation().equals(blockLocation)) {
world.getBlockAt(blockLocation).setType(Material.AIR);
world.getBlockAt(i).setType(Material.AIR);
Locations.remove(i);
}
}
}
(Locations is a list full of locations on where the user placed the block + 0,1,0)
whats the problem? since theres no errors
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block broken = event.getBlock();
if (isCustomBlock(broken)) {
event.setCancelled(true);
return;
}
Block above = broken.getRelative(BlockFace.UP);
if (isCustomBlock(above)) {
ItemStack mainHandItem = event.getPlayer().getInventory().getItemInMainHand();
above.breakNaturally(mainHandItem);
}
}
The locations of custom blocks can be saved in a HashSet of Locations, which would result in the following isCustomBlock method.
private final Set<Location> customBlockLocations = new HashSet<>();
private boolean isCustomBlock(Block block) {
return customBlockLocations.contains(block.getLocation());
}
public void tagAsCustom(Block block) {
customBlockLocations.add(block.getLocation());
}
HashSet is much faster for contains as it doesnt need to iterate through all elements like ArrayList would.
wtf?
how i can resolve?
absdygdyyasgdyasudgygasdgyasgd igay gdasydgyasg idgas dig asygdy gasdgyasgdias
spigotmc, ok?
doesnt seem like a spigotmc question
Catch the exception yourself and check it
is SlimeWordManager
Then ask the dev to fix it
public SlimeWorld loadDefSkyBlock(String name) throws IOException, CorruptedWorldException, NewerFormatException, WorldInUseException, UnknownWorldException {
try {
return slimePlugin.createEmptyWorld(slimeLoader, name, false, slimePropertiesSkyBlock);
} catch (WorldAlreadyExistsException e) {
//e.printStackTrace();
}
return slimePlugin.loadWorld(slimeLoader, name, false, slimePropertiesSkyBlock);
}
?
Peak programming right here
What code makes it so that if it doesn't exist it creates it and then if it exists it executes it.
How about you handle those?
They probably already are
At least move your loadWorld inside your catch block
no need, they apply to both of you.
No idea what that means
The above exceptions apply to both "create.." and "loadWord.."
okay?
So where do you handle those?
how do you handle them when calling loadDefSkyblock
Come I sent you.
hahaha
swm version?
last
1.8 ?
yes
you should be printing the exceptions not just passing them up the stack
this can be changed to CREATE TABLE IF NOT EXISTS
I need it for this
How does "behaving bad" manifest? Ah there is an exception attached.
and does it print any errors?
removing the fact you dont print an exception in the loadDefSkyBlock method
nope
is this line still commented out
I need it so that if it already exists it just executes it
Exceptions are a wonderful thing. They can let your code recover from unexpected situations in a nice and clean way, if you use them properly. That does not mean that you should always rely on them though. For example, imagine this: Most highways have guardrails in the middle to avoid cars going into oncoming traffic....
somewhere in your code you are most likely throwing an error and not handling it anywhere so you arent seeing the actual issue
k
Hi! I have my /eat command, and i wanna make a cooldown on like 20 minutes. Is it possible? If yes, how?
elgarl probably
who is that
@eternal oxide
Kody has tutorial on it with time elapsed
But I forgor which video was it
D:
Me, I wrote it, but it's be years since.
Oh - I'll find it, thanks :D
nice
You type in value in miliseconds
Which would be 1200000 for 20 mins
?scheduling
how on earth do i create a rank from the plugin
like im making a plugin
addon for towny
that lets people
create their own town specific
ranks
ideally you would use the scheduler so it woul dbe in ticks
like mayors
When I wrote teh API you could not create a rank yourself
To me this looks like a connection leak of some sort...
you cant even now
It may have changed, but ranks are server wide not town specific
yes thats what im trying to do
Is there any real advantage to server time elapsed?
i am making a plugin
heres a better example of cooldowns, https://www.spigotmc.org/wiki/feature-command-cooldowns/ id recommened the 2nd or 3rd options
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
that lets town mayors
make ranks
for their specific town
i actually made it kinda work
but i need to know
how do i create a rank?
using
the
thing
not really, for cooldowns their bad as its tied to the server thread so would slow down if the server wasnt on 20 tps
like mayors will specify rank name
and permission nodes
but i dont know how to create it
you can't
welp
as any rank created by any mayor would become available to all mayors of all towns
is there a workaround or nah
no workaround as it's a global system
have fun
and then make it a local system
probably not that high just a hell of a lot of work to make it work properly
on big servers
not really a performance issue, but it would be a pain to save data
especially so you can have per town perms plus global config specified ones
you would need to add save functionality as TownyPerms has no save currentrly
I would start by dramatically reducing your connection timeout and leak detection threshold. 120s and 300s is way too much.
dont tell me i need add a part to the api too
to make it work.
damn.
imagine if i pull it off
how big is towny anyway
ive never cheked
checked
If a query takes more than 30s then you are way beyond anything reasonable already.
huge
id say at your current skill level trying to pull it off would take forever
yeah i had it open for the api documentation
im sure of it
i like how in css this is actually doable unless the library is in a ancient version
Player#chat
ok
thanks
towny is insanely good
And do some testing. There are tools which can create minecraft clients and connect/disconnect constantly.
Then check for frozen and timed out connections-
what its right hto
Yeah it knew just fine
rip cant upload images but it said sendMessage and broadcastMessage to me
do !verify
with ur
!verify
Usage: !verify <forums username>
uh i frogor
just go to https://spigotmc.org
!verify
nedlolmanwoo
A private message has been sent to your SpigotMC.org account for verification!
me listing my failed projects
the works this link is a hyper link
pretty sure swm in 1.8 has a bug where it just doesnt add the world to its list
like it creates the world just fine
but doesnt create its settings in config
I would find that amusing
its probably something with ur browser
either an extension or just outdated browser
I use Brave
try a different browser eg chrome/firefox