#help-development
1 messages · Page 2020 of 1
Not gonna discuss on this
because the Convention isn't part of the JVM
you are free to make your own rules around what style you want to use
as long as the compiler is happy, you can do whatever
Okay
does anyone know what version of spigot I need to run
array.get(0).sendTitle("Hello!", "This is a test.", 1, 20, 1);
most everyone will generally recommend you run latest
it still seems to not be working though
define not working
their code for sending the title most likely
so, cause the java plugin.getTokenMiner().getInt("Player."+p.getName()) = 1000 and it isn't equal with 0, and it isn't less or equal with 250
i expect to happen the
plugin.tokens.put(p, plugin.tokens.get(p)+TokenMare(level));
p.sendMessage("3");```, but it happens
```java
Random r = new Random();
Integer rr = r.nextInt(5);
if (rr == 1){
plugin.tokens.put(p, plugin.tokens.get(p)+1);
}
p.sendMessage("1");```
still gives me same error
what error
The method sendTitle(String, String) in the type Player is not applicable for the arguments (String, String, int, int, int)
I am going to let others help you both, I am not awake enough for this XD
Did you actually update to latest
1.18.2
that's 1.8
update
?bt
Correct
yes...
The method you want is 1.12+
is there a place with all the javadoc versions
cause you're not on 1.18
but I am?
Inb4 what’s a build system
what is that
xd
build system?
how are you depending on spigot then
IDE
yes, show the spigot dependency you have
well check it
it is 1.18.2
I can't really help much anyway, I haven't used eclipse and IDE dependencies in years
BUT
I also have downloaded 1.8.8
with it
2
could that be why
_>
I have 2 paths
Be aware that your plugin won’t run on 1.8 now
is that an issue
Should be a remove button on the side
there is
but it wont let me click it
it does not want to die
new question
how do you get y pos of player
._.
player.getLocation().getY()
thx
i highly recommend you check the javadocs by the way whenever you want to know how to use anything in the spigot api
?jd-s
I am looking through them but whenver I try it it does not work
for example
for location
all I saw was getY()
yeah, don't you want the Y?
Whenever I dont know how to do something I just look for appropriately named methods for whatever I can find and try using those
but I did not understand the player and get location thing needed before that
the getY() method returns a float from memory.
you're asking how to get a player's Y coordinate
well the coordinates are part of the location if you think about it
so thats how people figure that out
okok
getLocation is a method in Player which returns the Location object of a player
in Location you can do things like getWorld, getY, etc :)
i see i see
by the way, I highly recommend getting all the basics of Java nailed down before doing anything with the Spigot-API, it will make your life so much easier
you don't need to learn the entire language, just the bare basics
how bad are streams for performance in comparison to for example a for each loop?
i kinda got java, but just never used plugins before
i think the performance drawback of streams are only noticed in large loads
depends on what you use them for really
so streaming a players inventory contents and filtering a couple of times into a collect wouldnt be bad at all?
how frequently is this ran?
in response to a command the player issued that is, sorry
oh, if it's from command and not an event, I can't vision any performance issue at all with using streams especially on inventories
gotcha
I started a plugin for replacing villages with cities, and I really want to use my algorithm for generating smooth steps from arbitrary position a to b, (because vanilla village roads are garbage) but doing so requires knowing the blocks along the y axis at those coordinates, which basically means all chunks contained within the city need to have finished generating before it can start populating roads and structures.
Obviously far from ideal to delay chunk population like that.
Any brilliant ideas?
can I play tic tac toe on that map?
Datapack structures are limited to 64x64 blocks iirc, and I'd really like to generate very large buildings, so not going to be using that.
The chunks only need to be past basegen, not finished
Datapack structures are limited to 48x48
But you can use jigsaws
😬
Although worldgen plugins are nice to see, not many people like to tackle worldgen
The chunks only need to be past basegen, not finished
I can't queue up all of those chunks to only load in partially, especially not without breaking the no recursive chunk loading rules.
So kinda have to deal with letting the chunks load in whatever order they happen to.
My plan was to let the plugin's users add in schematics of buildings they want to be included in generation, because there's basically no server admin friendly customizability for villages at the moment.
That sounds fun
Really should expand the spigot worldgen API
I’d love to add an API to add new biomes and structures
is there a reason why plugins cant add new items?
Because you can’t add new items to the game server side
You need a client mod
Of course you can basically add new items with custom model data
yeah, if only you could make a server force the client to have an ItemPack or something like it already does with resource packs
I hope that spigot will be able to aswell 😄
Someone should make a client mod that allows servers to inject custom content
I really like the spigot api
My thoughts at the moment are, whenever a chunk generates, check a radius for a valid source chunk for spawning a city, and if it finds a valid one, plot a y-blind road map for the city, and any chunks where those roads are contained, queue for generation, and once they've all generated, populate it with a city.
As long as the radius is larger than the max city size and the view radius, the city would theoretically have generated in before a player gets a chance to see it.
I’ve thought about it
I think someone has for fabric
Maybe
That'd be awesome lol
Yeah... Maybe we should just annoy Mojang so much that they add it
Will never come because of "security concerns"
like we did with the cave update?
anyone know why i am in a void when I do this
try {
Thread.sleep(10);
}
catch(Exception e) {}
if(array.get(1).getLocation().getY() < 30) {
array.get(0).sendTitle("You Won", "Winner: " + array.get(0));
array.get(1).sendTitle("You Lost", "Winner: " + array.get(0));
Bukkit.broadcastMessage(array.get(0).getName() + " has beat " + array.get(1).getName() + " in sumo!");
gameIsRunning = false;
array.remove(0);
}
if(array.get(0).getLocation().getY() < 30) {
array.get(1).sendTitle("You Won", "Winner: " + array.get(1));
array.get(0).sendTitle("You Lost", "Winner: " + array.get(1));
Bukkit.broadcastMessage(array.get(1).getName() + " has beat " + array.get(0).getName() + " in sumo!");
gameIsRunning = false;
array.remove(0);
}
}```
threads are messing me up
Dont use while loops on the main thread. You just block it forever this way.
?
So minecraft naturally just crashes
The game sends the entire biome registry to clients as json
So there’s no reason they can’t do the same with the block or item registry
how can I always check if the player is above a certain y level then
?scheduling
Check every tick or in the PlayerMoveEvent
how do i do that ._.
We send you a wiki entry
Look above my msg. Scheduling
?event-api for events
wait really
So custom biomes are possible
Sure
Interesting
Have been since 1.16.2
custom biomes are indeed possible
Look at the terralith datapack
Structures/World Gen/Biomes is something I've yet to work with so I don't know much about it
https://www.spigotmc.org/resources/terraformgenerator-alpha.75132/ look at this for example
its very cool
That's sick, ty for the resources
I do plan to mess with those things fairly soon, but gotta finish other stuff first lol
I really want to learn to make cool worldgen
But noise is hard to wrap my head around
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Skyblock.main, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
@Override
public void onPacketReceiving(PacketEvent event){
WrapperPlayClientUseEntity packet = new WrapperPlayClientUseEntity(event.getPacket());
Entity clickable = packet.getTarget(event);
}
});
[17:42:29] [Netty Server IO #1/ERROR]: [ShulkonSkyblock] Unhandled exception occured in onPacketReceiving(PacketEvent) for ShulkonSkyblock
java.lang.RuntimeException: Cannot retrieve entity from ID.
at com.comphenix.protocol.wrappers.BukkitConverters$11.getSpecific(BukkitConverters.java:727) ~[?:?]
at com.comphenix.protocol.wrappers.BukkitConverters$11.getSpecific(BukkitConverters.java:706) ~[?:?]
at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:229) ~[?:?]
at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:197) ~[?:?]
at TheLudoBile.Utils.WrapperPlayClientUseEntity.getTarget(WrapperPlayClientUseEntity.java:37) ~[?:?]
at TheLudoBile.Utils.WrapperPlayClientUseEntity.getTarget(WrapperPlayClientUseEntity.java:46) ~[?:?]
at TheLudoBile.Listeners.EventPlayerJoin$1.onPacketReceiving(EventPlayerJoin.java:74) ~[?:?]
Caused by: com.comphenix.protocol.reflect.FieldAccessException: Cannot find entity from ID 27.
at com.comphenix.protocol.injector.EntityUtilities.getEntityFromID(EntityUtilities.java:271) ~[?:?]
at com.comphenix.protocol.injector.PacketFilterManager.getEntityFromID(PacketFilterManager.java:851) ~[?:?]
at com.comphenix.protocol.wrappers.BukkitConverters$11.getSpecific(BukkitConverters.java:721) ~[?:?]
... 55 more
``` whats the problem
There are generation techniques that don't deal with noise, which might be a good way to dip your toes into it if you want to avoid noise specifically.
You’d think I’d know some stuff about it being on the dev team of a large worldgen project :p
But I don’t
Ask your colleagues to give you some pointers?
WrapperPlayClientUseEntity.java:37
Whats this line?
Yeah yeah go ask them and then when I tackle it you can help me 
how would I stop my code from consistnelty doing something by checking each tick, instead of using a while loop
since while loops aint working
use a repeating runnable
BukkitRunnable#cancel() exists
Why are the packets different? Did you relocate after shading?
would I just wrtie BukkitRunnable#cancel() ;
no
No
oh
You need an instance of the runnable
I prefer using a runnable that is sheduled once and where i can just add/remove tickables.
But you can also cancel runnables by their id or use BukkitRunnable#cancel()
you would call cancel on your instance
packets are different?
The stack trace is pointing towards
TheLudoBile.Utils.WrapperPlayClientUseEntity
so how would the line look like
BukkitRunnable#cancel()
those wrapper classes are the same
copy paste
What spigot version are you using?
<runnable instance>.cancel()
very simple example
public class ExampleRunnable extends BukkitRunnable
{
int ticks = 0;
@Override
public void run() {
if (ticks >= 10)
{
//stop after 10 ticks
cancel();
return;
}
ticks++;
}
}
1.18
Yes you can also cancel from within the runnable
The wrapper is from 2014. The packet content has probably changed since then.
Look at the protocol and try to get the content by using raw modifiers.
off by 1 since you dont return
20
okok
if the server is on 20 tps
How can I check if there is an entity in a chunk before unloading it?
Chunk.getEntities
2017 version has the same error
where can I find info about raws anyway
https://wiki.vg/Protocol
Also: the nms packet class
I'm actually able to reproduce it now. Code inside if(!count) only runs once
Print the block that it runs on, and then check what block it is
i think the errors more about
Preconditions.checkNotNull(world, "world cannot be NULL.");
return this.structureModifier.withType(Integer.TYPE, BukkitConverters.getEntityConverter(world));
}
some class named abstractstrecture
public Entity getTarget(World world) {
return handle.getEntityModifier(world).read(0);
}
handle is packetcontainer which comes from protocollib
What data do you want to get from what type of packet?
org.bukkit.Entity from which packet?
the client entity sent to server with parameters i suppose
What do you mean you suppose? What packet are you listening for?
play client use entity??
PacketType.Play.Client.USE_ENTITY this one? @dull whale
guys does this make sense (tring to make a loop with ticks)
Plugin plugin = null;
task.runTaskTimer(plugin, 0, 1);```
import org.bukkit.scheduler.BukkitRunnable;
public class Loop extends BukkitRunnable
{
int ticks = 0;
@Override
public void run() {
HelloCommand.array.get(0).sendTitle("woosh", "Game Starting!");
if (ticks >= 100)
{
cancel();
return;
}
ticks++;
}
}```
Plugin plugin = null;
task.runTaskTimer(plugin, 0, 1);
...
That ain't gonna run chief
oh dam
is you want a title to get send 100 times in 5 seconds
why null lol
If you fix the first 3 lines then this will run something every tick for 100 ticks
anyway, im trying to do max length and min leght for home with custom msg
how fix
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
your main class which "extends JavaPlugin"
read this
i see i see
Something.getClass(Something.class);
its the right?
hihihihih
hihi
many ppl use it
dependency injection ftw
Well then many people shouldn't
JavaPlugin plugin = JavaPlugin: ??!?!?!?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
i am so confused about what the object Plugin really is
It's an instance of (very likely) your plugin.
Unless you've retrieved it from elsewhere.
Your plugin's main class extends JavaPlugin, no?
it does
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Therefore your 'Main' is also a JavaPlugin and therefore you have an instance of JavaPlugin.
ok
so with this information
what would I put in
task.runTaskTimer(plugin, 0, 1);
that
instead of plugin
Your Main instance.
Absolutely not.
is that not creating an instance?
You should be using the instance that was already created by the server.
how do I use that
If you're creating that task in your Main class, then pass "this"
It does create an instance, you should just never instantiate Plugins.
no task is in a diffrent class
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
???
Most plugin developers store their plugin instance as a singleton in their main class and use a static getter to fetch it from other classes.
I'm not going to argue about the validity of that design choice, but it is an option.
You shouldn't, though.
is there a work around to this, like could I just use while loops instead of ticks
I dont understand why a while loop aint working
No because while and the Scheduler are completely different
So im trying to make it so ythat when a chunk is unloaded, it teleports the entity to you. I get the message "Unloading", but the entity wont teleport. Any idea why?
It's to do with concurrency
public Entity getClickedEntity(Player sender, PacketContainer packet, ProtocolManager manager) {
Preconditions.checkArgument(packet.getType() == PacketType.Play.Client.USE_ENTITY);
int entityID = packet.getIntegers().read(0);
return manager.getEntityFromID(sender.getWorld(), entityID);
}
but like while(true){do stuff} u know
Now this doesn't work due to the + in between the ChatColors, how can I make the text bold?
why cant I just do stuff
Add "" + at the beginning
Yeah that would block the main thread and cause the server to permanently freeze.
Yep, thanks!
but dont threads run sepreatly
The server runs on the main thread, the plugin runs on the main thread
Also I think the bold needs to go after you say its yellow
Running based off ticks w/ the scheduler is basically the only accurate, reliable way to do things.
does someone know how to dumbdown how to implement a "dependency injection"
Making some assumptions about your project design, you should pass 'this' as a parameter in the constructor to whatever class you're creating the task in, store it in an instance field, and use it when you go to make your task.
Eh? Cancelling the EntityToggleSwimEvent doesn't work?
@EventHandler
public void onToggle(EntityToggleSwimEvent e) {
if(e.isSwimming()) e.setCancelled(true);
getLogger().info(String.valueOf(e.isCancelled()));
}
It will send "true" in the console, but the player will still swim.
take main class instance, when make other object, give main class instance
ta-da
public class Dependent {
private final Plugin plugin;
public Dependent(Plugin plugin) {
this.plugin = plugin;
}
}
There
That's all dependency injection is
yeah that lol
^ As Maow has demonstrated.
The concept of dependency injection is that plugin is a "dependency," as our dependent class requires it to function.
much wow
Instead of creating a new plugin, which (for Bukkit) can cause issues or (for everywhere) lead to sloppy code, we inject the dependency via the dependent class's constructor.
Instead of creating a new plugin, which (for Bukkit) can cause issues
It will cause issues
As in, the plugin won't work
you know there is a post somewhere on this already
No because that is not dependency injection.
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
That's what you would call a singleton.
That is a singleton.
would a singleton not work?
It would, but OOP fanatics hate it.
it's also unconventional
wouldn't say messier, unnecessary more like it
See, in your plugin class you can just like
new Dependent(this)
If you're going to use a singleton, best practice is to at least hide it behind a static getter.
also when you refer to plugin class, you mean Main right?
But prefer dependency injection where at all possible.
well you just remove the public method for it 😛
Yeah
alrigh altight
do I need to have like Dependent something = new Dependent(this)
or just
new Dependent(this)
so like
Dependent something = new Dependent(this)
Ay, there ya go.
less gooo
If you want to keep the instance of something, then yeah
Store the JavaPlugin instance you've passed it, and access it when creating your task.
what would I add for inicitaing the ticks
"Store"
as in
is it not already stored?
in Main
Assuming you're not creating the task within your constructor, you'll need to store it in an instance field in order for it to not fall out of scope.
instance field*
Maow already gave an example.
Or actually "member field" might work better
public class Dependent {
private final Plugin plugin;public Dependent(Plugin plugin) { this.plugin = plugin; }}
"field" is probably one of the most common terms aside from "method," "function," or "variable"
oh ok
'private final Plugin plugin' is the instance field in this case.
the most common word in java: S y s t e m
ok so that has now been made
now what ._.
Now within your method for creating the task, you can use the plugin you've stored in that field.
NO OR
Don't use Ike's lib when it's not even finished lmao
alot of it is finished
i only have two parts that aint
lmao
Also don't recommend libs to people who don't understand the basics
You're going to give him an aneurysm.
fair
Okay so I'm going to assume you actually made a class called Dependent, in which case: no.
i started like 6 months ago, I consider myself pro in java (🤣)
i started like, in 2017
tears roll down left eye
I started in 2019
I started in 2014 and I'm far from calling myself a Pro.
I personally am actually a pro
tear roles down right eye
But that's because I don't have a life
i racommended someone my lib
That's what a non-pro would say.
I literally do nothing besides watch YouTube and code
Real pros realize they're not pros.
WAIT GUYS
what do I do with this
Be more specific.
lmao, imagine thinking you're good
- this post was made by me, who think's i am trash
Timer lag
hm
I remove Plugin plugin = null
big brain time
That's a good first step.
and instead of plugin
in
task.runTaskTimer(plugin, 0, 1);
I add something else
something much more powerful
which iss ....
You're adding the JavaPlugin you stored.
Because you actually need to give it your plugin, not null.
dont I need an acessor to get the plugin thoigh
unless you're using my lib
it is private
You've already created a reference to your plugin?
Okay so @lime jolt, that wasn't a suggestion to actually create a Dependent class, like I assume you did.
It'd be helpful if you maybe showed us your dependent class.
I used that as an example to show you the general idea of dependency injection.
wait slow down 2 steps back
We don't know what class you're creating a task in, so the name "Dependent" was used as an example.
is
private final Plugin plugin;
public Dependent(Plugin plugin) {
this.plugin = plugin;
}
}````
that the dependincy class
That was supposed to be inside the class you're creating the task in.
or is my code the dependicy class where I do the tick
ok one sec let me get it
Yes
i forgot the cmd
I just want u all to know
I already know how bad it is.
that I have not deleted a lot of the bugs
Its ?learnjava
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Also he's already seen like 2 learnjavas- okay
guys
yet they forgot like
I cant paste my code
it to long
?paste
ok
yeah that
Eh, i'm confused:
https://www.toptal.com/developers/hastebin/kowawabiri.sql
@EventHandler
public void onToggle(EntityToggleSwimEvent e) {
if(!(e.getEntity() instanceof Player)) return;
if(((Player) e.getEntity()).isSwimming()) ((Player) e.getEntity()).setSwimming(false);
}
Looks like Player#setSwimming doesn't work, is this the right way to do it (I'm trying to block the player from sprint-swimming)?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I thought you were being pessimistic.
That code has to be divided into at least 3 methods
private final Main plugin;
public HelloCommand(Main plugin) {
this.plugin = plugin;
}
brain explodes
Ur also storing an arraylist of plauers
what that all it is
💥
Which is bad
I DONT KNOW ANYOTHER WAY
don't name it Main
name it like
;_;
YourPlugin
I started minecraft coding less then 24 hours ago
?main
Lots to learn then
_<
Player Toggles Swiming > You set Swiming > ToggleEvent is fired again > Repeat
Imagine storing a player count alongside a list of players when collections allow you to retrieve their size
True
itemStack = new ItemStack(Material.PLAYER_HEAD, 1);
itemMeta = itemStack.getItemMeta();
if (itemMeta != null) {
itemMeta.setDisplayName(displayname);
itemMeta.skullOwner(skullOwner);
}
}```
hi, the "skullOwner" method doesnt work anymore how can i do this in 1.18.1 ?
Unchecked call to 'add(E)' as a member of raw type 'java.util.List'
Can somebody explain this error to me?
this
Very confused on what that means.
Look into the PlayerProfile class
But setSwimming is only called when the player is swimming, so Player#setSwimming doesn't seem to work...
hello?
The ItemMeta needs to be of type SkullMeta
and what should i do with it ?
The event is fired before it changes in the player object. Get what it's toggled to from the event
nvm
In 1.18 it can be used to do this much better
Testing rn
how can i implement your idea in my code ?
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
It removed the errors but it still doesn't work
Is it possible to find the the nearest solid block to a player to spawn an entity? If the horse gets teleported to you while you're flying it dies :/
Yes
ofc its possible. but there are probably tons upon tons of different ways
mkay
Several depending on your needs.
EMERGENcy
import org.bukkit.scheduler.BukkitRunnable;
public class Loop extends BukkitRunnable
{
int ticks = 0;
@Override
public void run() {
if (ticks >= 100)
{
HelloCommand.array.get(0).sendTitle("woosh", "Game Starting!");
HelloCommand.array.get(1).sendTitle("woosh", "Game Starting!");
}
if (ticks >= 10000)
{
cancel();
return;
}
ticks++;
}
}```
no working
it does not display nothing
gonna need a bit more info
does your runnable even begin
Hey folks, I'm a little stuck in reflection wonderland again. I'm trying to instantiate a PacketPlayOutRespawn, which changed in 1.18.2. to require a Holder<DimensionManager>, I'm retrieving the holder like so:
Class<?> holderClass = ReflectionUtil.getMinecraftClass("core.Holder");
Object dimensionManagerHolder = ReflectionUtil.invokeMethod(holderClass, null, "a", new Class<?>[] { Object.class }, new Object[] { dimensionManager });
When calling the constructor I'm getting a argument type mismatch error, printing the holderclass and dimensionManagerHolder gives:
[16:56:15] [Server thread/INFO]: interface net.minecraft.core.Holder
[16:56:15] [Server thread/INFO]: class net.minecraft.core.Holder$a
While yes they are different, Holder$a implents Holder, so that should work should it not?
...
What speaks against using ProtocolLib?
I don't want to switch 🙂
man, we have all explained that 25 times by now
;-;
and u were messing with it before
?scheduling
Thread thread = new Thread();
?
Btw, I'm using this method from Holder to get my instance of it:
static <T> Holder<T> a(T var0) {
return new a<>(var0);
}
``` and that returns a Holder<T>, which PacketPlayOutRespawn accepts, so it should work I'd say
scheduling is a nice thing
where do you start your runnable
umm
new a?
Make an assignableFrom check with the class
'thinking'
its probably somethn like runTaskTimer()
This is from the MC source, a is a class 🙂
you should have that somewhere.
lel
dimensionManagerHolder is indeed assignable from holderClass
I've also tried holderClass.cast(dimensionManagerHolder);
yea, but are you sure that code is being executed?
Loop task = new Loop();
task.runTaskTimer(plugin, 0, 1);
try {
Thread.sleep(1000000);
}
catch(Exception e) {}
boolean gameIsRunning = true;
Loop task = new Loop();
task.runTaskTimer(plugin, 0, 1);
dont mind the long thread.sleep
you should print a text message to console just before you start the runnable
yea, there are alot of issues. one at a time :D
in spigot context
it will stop the game from running
Thread#sleep on the main thread will stop the whole server from proccessing anything
what are you tryin to do?
that has nothing to do with threads
?!?!?!?
what are you tryin to do?
just a loop?
do scheduling
There is no real async loop. Best you can do is a repeated task.
As explained here:
In real life, X and Y is size to side, and Z is up. In minecraft Y is up. How does spigot work?
?scheduling
you can make a runnable run every couple of ticks or however frequent you want
Y is up
thats not just a loop
thanks
I thought I was tripping when you sent that XD
Code: Location loc = new Location(block.getWorld(), block.getX() + 0.5, block.getY() + 3.5, block.getZ() + 0.5); final Hologram hologram = HologramsAPI.createHologram(plugin, loc); hologram.appendItemLine(new ItemStack(Material.DIRT));
If anyone has experience with the holographicdisplays API, why are my holograms deleted after a restart. Everything works as intended, no errors.
Because Notch felt like defining its coordinate system like that
anonymous holograms get deleted on shutdown im pretty sure
u will need to recreate them on start
How can I make them non-anonymous?
Im always astound with how much plugins like Holographic Displays get away. They literally send all changes
to every player all the time and never unload a hologram for a player. Not even when the chunk unloads.
block.getLocation().clone().add(0.5, 3.5, 0.5) 😏
That does seem easier haha
You can even skip the cloning here
i never understood when you have to clone it
im not sure they provide api to do so
In older versions that messed up quite a bit. But nowadays you receive a cloned Location everywhere.
when you dont want to edit the location you do the changes to maybe?
You expect so much!
nowadays does that also mean 1.17?
Hey, can anyone help me "turning off" sprint swimming?
I've tried these things but neither of them works
@EventHandler
public void onToggle(EntityToggleSwimEvent e) {
e.setCancelled(true);
}
@EventHandler
public void onToggle(EntityToggleSwimEvent e) {
if(!(e.getEntity() instanceof Player)) return;
final Player p = (Player) e.getEntity();
p.setSwimming(false);
}
at least 1.13+
Storing every location in a db and then creating them would work?
thats what i would do yea
Alr, thx
Did you remember to register your listener?
Yes i did
try setting the swimming to false and cancelling the event?
So just both?
i would give it a try
as in the second one, you set the swimming to false but still allow the toggle which sets it to true i guess
doesnt make sense lol
It’s interesting that the event is cancellable but the cancel supposedly isn’t respected.
Didn't work
how do i make an entity look at a block (NMS) ?
I have done that already
hmm weird
Set its head direction in the direction of the Block.
wondering if you just change the yaw or pitch of the players location that will immediately affect the players view
hey folks, what did isFlatWorld get renamed to in net.minecraft.level.WorldServer? In 1.18.1 and prior it was D(), but that seems to be a long now. Mini's mapping viewer doesn't have WorldServer either
How would I get the items Position that I clicked it on in a inventoryUI?
(EXAMPLE: If an item were in the third slot, and I clicked it, it return 3)
event.getSlot / event.getRawSlot
nee man
🇳🇱
That’s how it is in many 3D environments, Y is even vertical on 2D graphs in algebra. Z is the third dimension introduced which is depth
Ah, seems it is C now
how do I get an inventories name?
EX: If a chest was named "Epic", it return epic
(sorry lol)
(im making a shop ui)
are Executors.newFixedThreadPool(1) and Executors.newSingleThreadExecutor() the same?
is there an event for when an armorstand touches any block? like if it was launched towards a celling, a wall or the floor
hi does somebody know how to fix this kind of error? I tried to reset Intelji, reload project, reset PC and none of those thinks had helped
ty
meh does'nt help
ok my bad, i was running spigot project instead of build it
strange package name
That would be quite the specific event.
strange ide lol
blockchangeevent
Doubt a block gets changed when an armor stand collides with a ceiling.
EntityColideEvent or is that only entities with each other?
mmm isnt that only on ones affected by knockback?
dunno lol
did you not read what i gave you?
i didnt give you the collide one
?
If you have a reference to the armor stand stored, you could run a repeating task that uses its velocity to determine the next block in its path and checks if it’s solid or not.
btw this is what i'm tryna do, it's for bounce physics
just sharing in case anyone has a better method for doing so
Why don't you want to use projectiles?
idk
feels like it'd be better with just the armorstand
(i wanna have an armorstand to have a head on it for the bouncy ball)
how would I make a straight line of air to bedrock from the player?
or even break the bedrock
Could use a custom model for the projectile.
If you want to break all blocks down to bedrock at a location, iterate down to void using the y value of the starting coordinate and set every block at those coordinates to air?
But how would I set every block to air?
block.setType(Material.AIR)?
Yep
thanks
I'm sorry, Im really new to spigot. How would I iterate down to void?
you know how to count?
1 2 4 3 5 obviously
then you would go from your location to the bottom
for loop?
depending if you are using worldedit api, yes
well im not
How do you add command argument suggestion??
For example, /rank [set/remove/add..] and it gives you a suggestion list of what you can use?
Example of a usage:
then yes, you would have to handle each block
?tabcompleter
aw
its not a command
using arguments
tab completers bruh
override TabCompleter#onTabComplete (let your command class extend it is the easiest way)
Hello ! Is it normal that the Block::breakNaturally doesn't drop XP of the block ?
no make another tab completer class
I'll take a look at it right now, thanks everyone for the help!
GRR
yes
the only unknown variable would depend on your version of server
1.18.2
well not cool, is there a way to implement xp drop properly or did i need to calculate all potential xp of the block ?
then you know and would use the new max depth from your location
?
when i have an executor service with a few threads and i add a few tasks in the order: task 1 first, then task 2, etc. Is it possible that the outcome doesnt execute task 1 first and then 2 etc because of the number of threads?
so get the lowest block?
you know the lowest block, you need your y coordinate and remove everything inbetween
I have the y cords with player.getLoc().getBlockY, but how would I remove everythin in between?
count and set every block to air
alright
if you utilized teh worldedit api, you would only need the start and end coordinates
for (int y = startingY; y >= world.getMinHeight(); y--) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
Something along those lines.
thank you guys for your help!
decriment after ... should stop at bedrock?
Yeah my bad.
he said either - just verifying in my head that java decriments after the test this way
If you don't want to break bedrock, check if the block at the coord is bedrock, and if so, break out of the loop rather than changing it to air.
anyone have a good tutorial on the basics of vectors in spigot? i google searched but didn't find anything helpful
i wanna make a circle with particles
My next question now is, are you able to use it on the 1/2/3rd argument or just the first one ?
check argument length
Did you just agree to your own message, Ike?
(int)home.location().getX(),
There is #getBlockX(), which returns an int.
Location#getBlockX?
i most of the times react to reactions on my msgs
Yeah.
oeh i should use that
I can appreciate the consistency.
😊
Oh, I was talking to Ike, not you.
🙁
lmao
There there. I'm sure you're very consistent in your own way too.
Theather in 4 messages
im sad now
eat a taco
i've probably never eaten that lol
extra hot salsa - remember if you don't cry you didnt try
how to loop through a bounding box blocks
a what?
i just ate ice cream
a bounding box
the blocks which a bounding box covers?
yeah
isnt there some cool .getBlocks() methods
bro i am drowning myself in water bottle
yea
why?
In BoundingBox?
ye
which you can use a populator for
what part of it would you be looping through or looking for?
:P
probably manually looping based on the #getX and #getZ stuff
its much easier using a lib
thats what i dont wanna do
maths kek
I got this utility method if you want to use it:
public static void forEachBlock(final BoundingBox box, final World world, final Consumer<Block> blockConsumer) {
for (int x = (int) box.getMinX(); x <= (int) box.getMaxX() - 1; x++) {
for (int y = (int) box.getMinY(); y <= (int) box.getMaxY() - 1; y++) {
for (int z = (int) box.getMinZ(); z <= (int) box.getMaxZ() - 1; z++) {
blockConsumer.accept(world.getBlockAt(x, y, z));
}
}
}
}
kekw my head
o dayum
but the why
the consumer is pacman!
i think -1
Im currently really getting into kotlin and i which java had extension methods...
yes
but, did you try scala's operator overloading?
@ExtensionMethod
uwu
lombok my beloved
what are extension methods?
lombok can go do something i can't say here
cast is executed first.
Now that i look at it i could actually make this a bit better.
how can I convert an itemframe's itemstack to ItemFrame (entity)
I wanna change its properties: item that it is holding, fixed, and visible
oh right
e.g: "diamond".substring(0, 1);
you can make like
fun Player.test() {
}
myPlayerObject.test()
and using this inside the method refers to the object you called the method on
which makes sense
so writing a method outside of a class but throw it to a certain class?
ye
weird
its mad pog
why would you even-
Its more of a wrapper than actual injection. You cant use any private fields/methods in there. So in reality its just a static method
that receives the object as a parameter.
hm
thats cool
So you want to change an ItemStack of type ITEM_FRAME so it will have different properties when
placed later on?
exactly
how can i make entity look at player?
LivingEntity#setTarget iirc?
hmm, i want to use only yaw and pitch, because i want to rotate only armorstands head
can someone answer this?
Hm thats a bit tricky because the ItemFrame is not a Block. So it wont have a BlockDataMeta.
Yes you have no guarantee about the order.
yeah and there ain't any ItemFrameMeta class
but it's definitly possible cuz it's doable with commands
I think you might have to use PDCs and some trickery including player clicks
I see. Then lets search for an api approach first.
Might be there but ive never seen this
give @s minecraft:item_frame{EntityTag: {Fixed: 1b, Invisible: 1b}}
this gives you an invisible & fixed item frame
wdym fixed?
when you place it, it will in fact be invisible and fixed
would need to use a state check
it can float in the air without support block, it's not sticked to any block
So thats at least the structure if we would have to use something like nbtapi or nms for this
i use nms for other stuff anyway
i'd prefer to avoid using nbtapi tho cuz i don't use it
But we want to set the Fixed tag to 1 and the Invisible tag to 1. And preferably by using spigot
^^
because the tasks are assigned to threads so the speed of the threads determines the outcome order?
might be wrong im still learning it
I mean you can probably make this happen by using spigot#unsafe
there is nothing to say that the thread is not interrupted or deferred
should i add
nms lib
to omnilib
i hate having to deal with fixing serialization rn
its a pain in the ass
ah so interrupted threads will get tasks too?
xD
It could also be that some of the threads are currently occupied or the internal performance of providing new threads differs.
what does this do exactly and how do u use it? i can't find that method in docs
declaration: package: org.bukkit, interface: UnsafeValues
you have to remember that threads get priorities as well
Bukkit.getUnsafe().modifyItemStack(ItemStack, String)
i see
I think the String would be
{EntityTag: {Fixed: 1b, Invisible: 1b}}
But im not sure. Never used this before.
is that for modifying nbt directly?
if thats the case
imma just
make an entire lib for that
o_O
I know Mythicmobs can do it, but I'm tryna do it within my plugin
nbtapi exists
i'll try, but i'll also need to be able to access information of what item the itemframe holds, and what are current configs for fixed and invisible, before setting stuff
Get their equipment and place an ItemStack on the head slot...
Are you on the latest version?
yep
Then just use moj mappings and use nms. If you already use nms then this is probably the most convenient route.
But this smells PR-y
PR-y?
pull request-ish
aha, i still don't get what he meant by that tho
Does anyone know how to exclude a dependency from the output jar in maven? I'm importing another plugin and spigot doesn't like it when you're importing a jar that's already installed as a plugin.
The thing, is I'm not even sure how to get the item, the model is generated using ModelEngine
Change its scope to provided
thanks
why would you not set it as a dependency ?
Spigot doesn't like it
show your pom
I fixed it
Can someone explain this to us, so we have a plug-in that checks for when someone left clicks, and it summons a fireball. However the fireball also appears whenever you drop an item, and occasionally whenever you open a door. Does anyone know why this happens?
did you check which hand?
After reading his issue several times i came to the conclusion that his problem isnt dependency related.
He just shaded the dependency in because of mavens default scope. He just had to make it provided.
The problem was there being 2 of the same classes and I was getting cast exceptions
yeah that makes sense, one of the reasons i stopped using maven
you can left click in both hands, you need to know which one you are checking
You can have the same problem with gradle... idk why this is a valid reason
But why would that trigger when you drop an item?
you can, but the setup is clearer
playerInteractEvent.getAction().isLeftClick()
What version are you on? I remember this being a problem in an older version.
1.18.2
Is there a way to change the metadata of an itemstack after it's been added to an inventory without just setting the slot again?
"This is because the LEFT_CLICK_AIR in PlayerInteract event is essentially a hack and listens to your arm swinging. Now that dropping items swings your arm, it fires LEFT_CLICK_AIR if you're not looking at a block."
Ah okay
Sure. Get the ItemStack from the inventory and apply a different ItemMeta to it.
So anyway to stop it from triggering?
Is there a way with the original itemstack of getting the new one?
Or a way to get where the same itemstack is in the inv
You should not hold references to ItemStacks in hopes of modifying it in other places.
No kidding I already understood they clone it when adding to inventory
ItemStack is a really werid API layer that might lose its nms reference at any time in quite unpredicting events
The reference just can't be used from what I've understood
I might just do it in packets, which is anyways better for what I'm doing
What are you trying to do anyways?
Buy God damn are packets a pain sometimes
I made a dynamic item system
It's pretty nice and basically done other then this issue
Oh i also made one. All the data is stored in PDCs and how this raw data is displayed is
defined by a neat little adapter that changes all outgoin ItemStack packets.
PDC?
PersistentDataContainer.
Ah ye, I just am storing in nbt since I wanted it to work 1.8-1.18 so I just used nbt api
This way the same ItemStack could look different to several people.
Or if we want to change the design of how an ItemStack is displayed we dont
have to touch the ItemStack at all. We just change the adapter a bit.
Whats "os"?
open source
https://paste.helpch.at/bohevikeze.json doesn't need to do that exactly, it's more just super handy for custom items. You just make a json like this and write a tiny bit of code to intreract
it would allow something like this to be created super duper easily with no code
