#help-development
1 messages ¡ Page 2186 of 1
hm?
wait
https://blog.jeff-media.com/persistent-data-container-the-better-alternative-to-nbt-tags/ this explains the basics about PDC: You can use PDC to store information in your item, like a boolean "this is my custom item"
so you whipped a guy
if create a shapedrecipe which uses a bucket of powdered snow in it, will the empty bucket be left behind? or will i have to manually put an empty bucket in the crafting grid?
the code I sent knocks the player back more each time I hit him
can u elaborate?
hm
once I reach a knockback of 18, it stops increasing
u know how when u craft a block of honey it leaves the bottles behind quackiee
What are you trying to do with it now?
where's the problem? you're applying a vector 10|2|-10
that's pretty much
just use a shorter vector
knockback further than 18 blocks
mfnalex do u know if this happens
you want it to go further and it won't?
sorry, I don't understand
yup, it doesn't increase on it's own
does your multiplier still increase?
the vector is increasing as you see in the console, but the actual kb doesn't
omg I have been waiting to use this command for a long time
oh you want to do more than 18 blocks? well then use a bigger vector
?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.
(its a joke dw)
isn't it supposed to get bigger on it's own?
as I programmed it to do
you increase your multiplier
mhm
if you find it is hitting the floor increase your Y
if its only reaching 18 blocks and hitting the floor, you don;t have enough elevation
we tried .add(new Vector(0,5,0)) and .setY(2) and still 18 blocks
set Y to 100 and see what happens
^
aight
if you get further than 18 blocks now, it's simply because you hit the ground too soon
private static final double MILLION = 1_000_000;
private static final double THOUSAND = 1_000;```
can I use this isntead of the thing I sent?
_ delimiter?
one holds a million and one holds a thousand
and this
if (health >= MILLION) {
// The `/=` is short for `health = health / MILLION`.
health /= MILLION;
else if (health >= THOUSAND) {
health /= THOUSAND;
}
return format.format(health);```
the _ doesn't do ANYTHING
I was finding the code tho D:
ah k
it's as if nothing happened
as if it's still .setY(2)
no vertical velocity
and still 18 blocks
makes no sense
yeah very weird
show your code again
package me.r3dx.mcbrawl;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class Knockback implements Listener {
int heatValue = 0;
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event){
if(event.getDamager() instanceof Player && event.getEntity() instanceof Player){
heatValue++;
Vector v = event.getEntity().getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(100);
System.out.println(v);
event.getEntity().setVelocity(v);
// event.getEntity().setVelocity(event.getEntity().getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(2));
}
}
}```
math is fine
console output: https://prnt.sc/XGS8C-376yab
hard code your heatValue and don;t increase it. set it to 100
see if that gets you beyond 18 blocks
or just do multiply(100)
yep
a
public static Map<Integer, String> prefixes = ImmutableMap.of(
7, "k",
10, "M",
13, "B");
public static String formatNumber(double num){
int length = Double.toString(num).length();
String numAfter = String.format("%,d", num);
for (int i : prefixes.keySet()){
if (length > i) continue;
if (length < i && length > 3){
String prefix = numAfter.split(",")[0];
if (prefix.length() == 1){
prefix += "."+numAfter.split(",")[1].charAt(0);
}
numAfter = prefix + prefixes.get(i);
break;
}
}
return numAfter;
}```
changing the d to a f
will change the number display format?
@eternal oxide can u help please?
yk what
nvm I asked
test it on a mob as I know they can get thrown miles
see if there is somethign odd going on with the player velocity
so I should comment out the if
just the entity part
still keep damager so other things are not confusing the console
public void onPlayerHitPlayer(EntityDamageByEntityEvent event){
//if(event.getDamager() instanceof Player && event.getEntity() instanceof Player){
heatValue++;
Vector v = event.getEntity().getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(100).setY(100);
System.out.println(v);
event.getEntity().setVelocity(v);```
oh
right
nah don't worry about it I disabled mobs and animals
I will try it on the wandering villiger
if I've spawned a custom NMS entity
and the server restarts
would it be possible to convert that entity back into my custom entity so that it has custom pathfinding?
for example, kind of like "Hijack" all living zombies in the world to make their pathfinding not attack players
i think i just found an insane side hustle that no one is talking about
Writing apps for cryptocurrencies?
yes đ
You can just use the api to prevent zombies from attacking players. Use the EntityTargetEvent
If not load and unload your entity with the ChunkLoad and ChunkUnload events
sent the villiger so far I can't even find it anymore
so it has to do with the player
How can I equip player with Elytra in spigot 1.18.2 ?
well that was just a hypothetical scenaro
you can
i'm not actually using pathfinding on zombies
surprisingly easy
i have a very complex horse entity
that i need to convert a living horse to that entity
I even have a 50 line PathfinderInjector class for that
you'd have to respawn entities but that's fine
can i see this actually
if thats fine
it might work
ah yeah entities are loaded after now
Forgot about that
https://pastebin.com/5BevYpN6
Guys, I have a problem, there are two values inside the hash and at exactly row 49, they both become equal... I did some tests and (You can see also from the code) this comes out in the console, (where there are the two 'rara' is the problem!) Can you help me?
[18:36:51 INFO]: BAWGAE - scoteca
[18:36:51 INFO]: rrrrrrr rara
[18:36:51 INFO]: BAWGAE - rara
[18:36:51 INFO]: CUSTOMCHAT VALUES: scoteca
[18:36:51 INFO]: rara
[18:36:51 INFO]: CUSTOMCHAT VALUES: rara
[18:36:51 INFO]: rara```
Olivo i bliv in u
@eternal oxide
forgot to mention but I believe it also does a little exception throwing whenever a player joins lmao
but that can be easily fixed
im tryna create flappy bird with chest inventory but sadly i am failing
thanks
I guess a player has a limit
@eternal oxide â¤ď¸
michè doesn't believe in me đ
tbh it might just be a mutability problem
try cloning at line 71
I don't belive in you, I LOVE YOU â¤ď¸
hmhm
also you have some weird debugging names let me tell you
wdym with cloning?
ItemStack#clone
i was angry
you're modifying the walkie itemstack
I, too, print "why is this working #6" when I'm angry
haha
intellij crashed
it's tired of suffering with suspicious quality code
how can i add persistent data container info to an nms entity
you can't
PDC is bukkit only
you can only use NBT
don't tell him!"!!"q34235
not really
if your NMS entity is also a CraftEntity you can
whats a craftentity
yeah sure, I assumed they only have an NMS entity
looks like
the bukkit version of the entity
can i still do pathfinding operations on it?
on what?
craftentity
CraftEntity is basically a wrapper for the NMS entity
how did you spawn your nms entity?
I only need to know how you spawned it
can't we alter this limit with some kind of setter?
craftentity is the implementation of the interface
api or packets?
sry what
nm
so like
how would i use persistent data container
or do you think i should just use NBT tags
nbt
you could look into the source code of CraftPersistentDataContainer or so
PDC also uses NBT internally
im creating a custom entity
can i use that with my current setup?
ur mom is a bukkit entity
And you get the craftentity
how do i get the CraftServer parameter
kinda stupid that it requires the server tho given that there is only one server
@humble tulip hey dude
yeha
we figured it has to do with the player
because it worked fine on all other entities
oh wow
still trying to figure out how to bypass that
i'm assuming like this though right
CraftEntity craftEntity = CraftEntity.getEntity((CraftServer) Bukkit.getServer(), entity)
yep
alright
only thing I hate is how Spigot internally casts to CraftServer
If you get an ItemStack from Inventory#getContents, and then use ItemStack#setAmount (or ItemStack#setType etc...), is the ItemStack in the Inventory updated, or do you need to overwrite the ItemStack somehow?
breaks the concept of abstraction but whatever
I found an event called PlayerVelocityEvent
do you think I can for loop the thing?
i'm actually not sure
u can try
nah that would make it happen every time the player walks
velocity is not only kb right?
Yeah, although the api in this case is an api where we aren't supposed to know about the impl anyway
tbh they can do whatever they want internally
But sure, most stuff will end up having leaky abstractions somehow
causes unexpected crashing tho
I once tried injecting something that wasn't CraftServer
wait why
yeah
funky command map that didn't fire events on certain conditions
I mean the api doesn't really support custom implementations unless mentioned otherwise
there's supposed to be one server
believe its even documented that way
I wrapped CraftServer
but gotta love having everything final
can't even extend it
CraftServer is a final class, with a final command map with final implementations
sounds like fun
but I mean apis like these are not very friendly towards the open closed principle for instance, they only care about providing the api as is and thats it, no custom implementations or low level detail exposure
Is there a way to disable nether and end portals
Or end and nether navigation through the portals
on top of that, java12+ locked down the final modifier
we can only bypass it with bytecode manipulation iirc
yes or sth like unsafe
but if we're going this far, it's easier to just fork the server
declaration: package: org.bukkit.event.player, class: PlayerPortalEvent
Ty
bump
items are internally nms items so probably immutable
there's conversion when calling setItem
hmm okay, so you need to overwrite them?
nah for loop didn't do shit @humble tulip
yes
okay, thanks!
is there a method to hit the player? maybe we can do that @humble tulip
do you need the knockback vector or something?
you might want to craete a thread for whatever you're working on
@carmine valley can you explain what youâre attempting to do and what your current solution is to that problem
I made a knockback plugin, on entitites it keeps increasing like I want it to, on players once it reaches 18 blocks it doesn't knock them any further
can I edit it?
Are you running an anticheat
but it usually throws a console warning if you go above it
nope none, flight is on too
just run it on a scheduler and call it a day
You could theoretically lerp between two points and perform a sequence of small delayed teleports
Lol
the player also didn't experience any vertical velocity even though I tried to do .add(new Vector(0,5,0)) and setY(100) and neither worked
no vertical velocity at all
I tried 2 and 100, same results
He set it at 2 and still notbing
2 is decently high
what's frustrating is that it works fine on all entities but not players
Oh yeah that's why antikb works
You can tell the player their new velocity is whatever you want, if the client doesnât like it it isnât gonna happen
then how did I even get to 18 blocks in the first place if it's solely depends on the client
oh ok
The client decided that was ok
so are you saying I need a custom client?
Or a mod maybe
No Iâm saying you need to stop trying to do massive vectors at once
You need to calculate the locations in small steps
^
what about if we hit the player again? is there a method to do that?
Lerp between two points
you just add the vector or something
but yeah
smaller steps
that's why my custom shield works :)
wouldn't that look crude with the tp?
the client will smooth between near locations
Minecraft treats small teleports as movement
oh you mean very small teleports
Yes
every tick
^
I've never done anything like that, what would that look like?
uhh
I meant in code
You need a bukkitrunnable
here's a video of what this ends up looking like
5 seconds ¡ Clipped by Illusion ¡ Original video "Minecraft but there are CUSTOM SHIELDS" by Socksfor1
does the video explain implementation?
no but my code is pretty simple to understnad
its just a custom recipe and a resourcepack x)
but just to make sure, there is no method to hit the player right?
and a scheduler
LivingEntity#damage(double, LivingEntity)
perhaps
hmmm
so are all servers
you can do a lot with custom recipes and resourcepacks
ye
how about I just damage the player again so he goes further distance?
knockback doesn't occur with that method
in the game I'm trying to make the player's will be always healed to 100%
you can just set a manual knockback
with setVelocity?
yes
wrong link
ther
i hate my teacher.. exposing collections...
when you can just write methods that interact with it
what's the problem with public static List<Object> ACollection = new Hashmap<>();
nothing is wrong with this
me do not like that
what could possibly be wrong
I can't find that in the docs
feel free to leave this conversation :)
if the db is too big, a cache might end up killing stuff
you can clearly see the applications slowing down cuz of the unneccesary db stuff
@echo basalt I can't find LivingEntity#damage(double, LivingEntity)
but can you set velocity to that?
u can do it after
I literally gave you a util that calculates accurate kb vectors
what else do you need
I'm trying to do it the multiple damages way
they might not be loaded by that stage
should work if you set "load" to "STARTUP" in plugin.yml
is there a built in method to get the target entity a player is looking at
LivingEntity#rayTraceBlocks
returns a RayTraceResult
and that has a method getHitEntity
I imported org.bukkit.entity.Damageable, why can't I use the method damage()?
you can
gives me an error
then fix this error
no the error suggests to create a method damage() in my class
why isn't the compiler recognizing the import?
obviously you can only use instance methods on an instance of the class that declared that method
my guess is because you don't know basic java and simply tried to do "damage(...)" somewhere instead of using it on an instance of a Damageable
shouldn't it work on a player entity?
Ěóğ
or show a screenshot or whatever
what's the double argument for
i cant find the method in the docs
distance
declaration: package: org.bukkit.entity, interface: LivingEntity
EntityDamageByEntityEvent returns an Entity, not a LivingEntity
cast the entity to Damageable or LivingEntity
oooh ok
getHitEntity keeps returning null
is distance the measurement in blocks?
or is it something else
Managed to get scores working but does anyone know why the tablist is not sorting itself?
by score, I mean
I made that ```cpp
package me.r3dx.mcbrawl;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class Knockback implements Listener {
int heatValue = 0;
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
heatValue++;
Vector v = event.getEntity().getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(2);
event.getEntity().setVelocity(v);
LivingEntity en = (LivingEntity) event.getEntity();
if(heatValue >= 8){
int extraKnock = ((heatValue - 8)/3);
for (;extraKnock >= 1;){
en.damage(1, event.getDamager()) ;
}
}
}
}
}
@tender shard
Nice
oh wait I forgot to add the setVelocity to the artificial damage
RayTraceResult raytraceResult = player.rayTraceBlocks(50);
if (raytraceResult == null) {
player.sendMessage(Utils.colorize("&cYou are not looking at a horse!"));
return true;
}
Entity entity = raytraceResult.getHitEntity();
entity is always null
because you're raytracing blocks not entities
how do i ray trace entities
oh mb
wait, LivingEntities don't have a .getLocation?
Hi! Do you know how I can add color to the name of my item on my plugin? Thank for your help
I'd say read the docs but that's exactly your problem
you are reading the docs for LivingEntity and completely ignoring all hierarchy
i mean why saying thank for your help if noone has answered yet
Check out the ChatColor clas
take a look at ChatColor.translateAlternateColors and the ChatColor enum
i cant believe people arent checking the forum for simple questions đĽş
People are dum
not even trying to google
Very dum dum
?bing
Bing your question before asking it:
https://www.bing.com/
come to us if you have serious questions and you've done previous research of attempts
Gross bing
.
?tryandsee
ayy
?tas
is there any way to store data in non-tile-entity blocks? (without an external file)
I've got a tool for that in my library
It's backed by either pdc or sqlite
whats pdc?
?pdc
Pdc is 1.14+
can i not use lambdas?
What are you trying to do
why don't use language level 17
trying to pass in a predicate to World.rayTraceEntities
You can't specify the type of a lambda parameter in the lambda
set your project version to java 8 smh
well im still getting the same issue
ah mb
Use 8 or above
java 17 đ
Yeah newer is better of course
ye ill do that
I'm using this code and server crashes after the heat value exceeds 7 ```cpp
package me.r3dx.mcbrawl;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class Knockback implements Listener {
int heatValue = 0;
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
heatValue++;
Vector v = event.getEntity().getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(2);
event.getEntity().setVelocity(v);
LivingEntity en = (LivingEntity) event.getEntity();
if(heatValue >= 8){
en.damage(1, event.getDamager());
en.getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(2);
}
}
}
}
you are firing a damage event in the damage event i guess?
en.damage(1, event.getDamager());
how do I determine which block was the cause of a BlockExplodeEvent? event.getBlock() is AIR
can I see the library?
BlockExplodeEvent#getBlock i guess
declaration: package: org.bukkit.event.block, class: BlockExplodeEvent
no, it's AIR
thx
if you prefer getting a PDC for blocks: https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Man I should really advertise my libraries via the spigot forums more
and write better javadocs đ
idk I only looked at the overview and there's nothing
my overview always looks like this lol
package_info.java
i was writing javadocs and i stopped it when i wrote what a getter did đ
yeah thats annoying
yeah not everything needs javadocs
ctrl + alt +shift + g
it doesnt do anything for me
oh it's another plugin
Everything?
whats in fact the use of a package_info.java?
i mean its not that great but all you have to do is modify a few words in the description
lol
Why isn't the player getting knocked back more when the heatValue exceeds 8?```cpp
package me.r3dx.mcbrawl;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class Knockback implements Listener {
int heatValue = 0;
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
heatValue++;
Vector v = event.getEntity().getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(2);
event.getEntity().setVelocity(v);
LivingEntity en = (LivingEntity) event.getEntity();
if(heatValue >= 8){
en.damage(1);
en.getLocation().toVector().subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue).setY(2);
}
}
}
}
i mean clean up that code lol
and this
kinda sucks to make a separate file for it
why?
it's just a tiny file
/**
* <b>Main Library methods.</b> Some methods require initialization first, see {@link de.jeff_media.jefflib.JeffLib#init(org.bukkit.plugin.Plugin)}
*/
package de.jeff_media.jefflib;
theres a shortcut in intellij to generate them
conclure is very sus today
@waxen plinth
werent you doin it in rust?
what
thats the guy with the book right
Hi, anyone know how to publish Kotlin lib to maven repository using Gradle Kotlin DSL?
uhh
im java.lang.ClassFormatError: Class file version does not support constant tag 16 in class file ... when i try to load my plugin now
Hi
Given a config like below how can iterate through all groups and all the stuff inside them?
groups:
admin:
- "somestuff"
- "someotherstuff"
mod:
- "something"
- "someotherthing"
player:
- "idk"
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>17.0.3.1</maven.compiler.target>
Why are you compiling source to java 8?
for (string key : config.getSection("groups"))
because 17.0.3.1 wasnt working
then iterate over the stringlist
compiler source and target should be the same i think
if i set the source to 17.0.3.1 then i get this underline
thanks :D
it throws an error too when running
Are you using maven?
Can't u set it to 17
yes
Just set target and source to 17
intellij?
oh wait thats not what i want, sorry im not clear enough
I want to iterate thru each group knowing what group it is.
VSCode
smh
vscode
wdym knowing what each group is
you have the string
I recommend using a proper java IDE
i have an object called Group and i want to iterate thru the config, create for all groups an object and assign strings that are under it
red borders everywhere and it kinda broke plugman on spigot lmao
Don't use Plugman
I've got a config library that could make that trivial
Use PlugWoman đ
well besides plugman theres still these red underlines everywhere
for (String groupname : config.getSection("groups")) {
new Group(groupname);
}```
Don't catch ClassCastException wtf
i guess
is it just a Snippet or a whole lib?
i try to add as small amount of libs to my project.
That code appears to be written outside a method
i saw people catching npe and out of bounds đĽş
It's a full library
thanks, but i will pass :P
I want my plugins to be as independent as possible.
Ok
its temporary lmao
im just writing some debug code
sender instanceof Player
i was testing something earlier dw
wouldn't that just create object for everything? including the substuff of each group
actually i believe its config.getConfigurationSection("groups").getKeys(false)
Compass pointer not updating on join event?
oh okay thanks :D
Don't do it
Seriously
Now you catch the exception but if it happens you're just gonna get an NPE anyways lol
that will iterate over all keys under groups
it seems like everything built into java is just gone
says that Object is missing, no String, no @Override, etc
?paste The entire file
my pom.xml?
target and source should both be 17
yeah when i do that i get this issue
mb i posted my temporary fix-ish kinda
One issue at a time
What does it say
still just a bunch of red underlines
and when you hover over it
now would be a good time to switch to intellij
also wtf mvn now says its not recognized as a command
i have the location saved in path..
ima restart my pc
Do you actually have Java 17 installed
yes
What IDE?
VScode
eww
sorry
not even an ide
And is that one in path
but i like the color scheme 
Path
Not JAVA_HOME
yeah its there
vscode gives useless error messages
Hey guys, I'm trying to make a spigot plugin that increases the player's KB the more they are hit, I've so far constructed the following code. One issue with it is that it stops knocking the player further once the knockback sends you 18 blocks away due to some Player class restriction(All other entities can be hit further than 18 blocks and don't have such a threshold) I've tried fixing it by damaging the player artificially and sending him further away once after 3 hits of reaching the threshold, but it didn't quite work, any ideas why it didn't? and any alternative solutions? code:```cpp
package me.r3dx.mcbrawl;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class Knockback implements Listener {
int heatValue = 0;
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
heatValue++;
Vector v = event.getEntity().getLocation().toVector();
event.getEntity().setVelocity(v.subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue));
LivingEntity en = (LivingEntity) event.getEntity();
Vector v2 = en.getLocation().toVector();
if(heatValue >= 8){
en.damage(1);
en.setVelocity(v2.subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue));
}
}
}
}```
Run maven and see what it says
well just like 2 minutes ago my pc apparently forgot what maven is
im gonna restart my pc
lmao just use intellij
Iâll check the error in just a sec
Yes
which would easily be fixed in intellij
1.18 requires Java 17?
think so
Are you actually running 1.18
1.18.1 yes
Then Java file versions shouldn't be an issue
yeah it shouldnât
Unless you used Java 18 for some reason
okay, but now that i got names of the group how can i get stuff thats under it?
List<String> list = config.getStringList("groups." + groupname)
^^
why am i just getting random errors now
thanks :D
such as?
well use intellij for plugins?
maven is failing
i mean it seems likely enough
vscode + java has always sounded pretty unstable
just use intellij đ
java.lang.NullPointerException: Cannot invoke "net.minecraft.core.BlockPosition.v()" because "pos" is null
at net.minecraft.world.level.LevelHeightAccessor.isOutsideBuildHeight(LevelHeightAccessor.java:41) ~[paper-1.18.2.jar:git-Paper-268]
at net.minecraft.world.level.Level.getBlockState(Level.java:824) ~[?:?]
at net.minecraft.world.entity.Entity.lambda$findDimensionEntryPoint$4(Entity.java:3359) ~[paper-1.18.2.jar:git-Paper-268]
at java.util.Optional.map(Optional.java:260) ~[?:?]
at net.minecraft.world.entity.Entity.findDimensionEntryPoint(Entity.java:3357) ~[paper-1.18.2.jar:git-Paper-268]
at net.minecraft.server.level.ServerPlayer.findDimensionEntryPoint(ServerPlayer.java:1050) ~[?:?]
at net.minecraft.server.level.ServerPlayer.changeDimension(ServerPlayer.java:1103) ~[?:?]
at net.minecraft.server.level.ServerPlayer.changeDimension(ServerPlayer.java:1066) ~[?:?]
how do i fix this
not sure since you havent sent any code
doing what?
The full error would also be good to have
try {
Field field2 = net.minecraft.world.entity.Entity.class.getDeclaredField("ah");
field2.setAccessible(true);
field2.set(player, player.getPortalWaitTime());
player.setPortalCooldown();
player.changeDimension(getMinecraftServer().getLevel(level));
Field field1 = net.minecraft.world.entity.Entity.class.getDeclaredField("ag");
field1.setAccessible(true);
field1.set(player, false);
Method method1 = net.minecraft.world.entity.Entity.class.getDeclaredMethod("H");
method1.setAccessible(true);
method1.invoke(player);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
it worked with the end and the overworld
but for the nether it doesnt work
that just looks like a disaster waiting to happen
^^
what are you even trying to do here?
you are calling a dimension change without a portal location
this seems like an xy problem
which will explode
getDeclaredField? how do you know what string to put in there
I mean yea obviously this fails
you are calling a method that should not be called
the name of the field?
without prior preporation
wdym how
oh
i put in the name of the field and method
?xy
Asking about your attempted solution rather than your actual problem
why is it named like that
obfuscation
but yea, please xy
alright so i want to warp the player into the nether
oh right, i thought minecraft wasnt obfuscated
using NMS
why NMS
why do you need nms to do that?
there is proper API for cross world teleportation
because nms knows exactly where to teleport the player to
if the nether chunks are loaded then NMS teleports me straight to the portal
you should be caching the methods and fields instead of getting them everytime
but with bukkit api i need the location
true
this was a test tho
just wanted to mention it đ
protected void handleNetherPortal() {
if (this.level instanceof ServerLevel) {
int i = this.getPortalWaitTime();
ServerLevel serverlevel = (ServerLevel) this.level;
if (this.isInsidePortal) {
MinecraftServer minecraftserver = serverlevel.getServer();
ResourceKey<Level> resourcekey = this.level.dimension() == Level.NETHER ? Level.OVERWORLD : Level.NETHER;
ServerLevel serverlevel1 = minecraftserver.getLevel(resourcekey);
if (serverlevel1 != null && minecraftserver.isNetherEnabled() && !this.isPassenger() && this.portalTime++ >= i) {
this.level.getProfiler().push("portal");
this.portalTime = i;
this.setPortalCooldown();
this.changeDimension(serverlevel1);
this.level.getProfiler().pop();
}
this.isInsidePortal = false;
} else {
if (this.portalTime > 0) {
this.portalTime -= 4;
}
if (this.portalTime < 0) {
this.portalTime = 0;
}
}
this.processPortalCooldown();
}
}
this is nms code for the portal
i dont know what im missing though
ehh you might want to look at the actual method contents in a craftbukkit/spigot/paper server
ok i managed to fix everything else, im just running into an issue where maven isn't compiling the plugin.yml
as that has a special case for players
well it's only supposed to compile .java files lol
put it in src/main/resources
and make sure your pom doesnt specify a different location
also it doesnt compile a yml file
it copies it as a resource
thanks that worked
this is in my pom.xml btw, is it necessary
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
<sourceDirectory>src/main/java</sourceDirectory>
the ${basedir} part is useless
why do people put that in their pom
yeah
the source directory part too
i found it online i was desperate for answers
thats the default
the <includes> part is useless too
remove it
All of that
to keep
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
just keep this
the rest is useless
yeah
alright thanks
for (Player onlinePlayers : Bukkit.getOnlinePlayers()) {
setNametag(onlinePlayers, player);
}
}
public void setNametag(Player player1, Player player2) {
Scoreboard scoreboard = player1.getScoreboard();
if (scoreboard.getTeam(player2.getUniqueId().toString()) != null) {
scoreboard.getTeam(player2.getUniqueId().toString()).unregister();
}
Team team = scoreboard.registerNewTeam(player2.getUniqueId().toString());
team.setPrefix(ChatColor.translateAlternateColorCodes('&', "eee"));
scoreboard.getTeam(player2.getUniqueId().toString()).addPlayer(player2);
}``` Hello friends, i have this code for setting a player's prefix to their overhead name with scoreboards, whenever the join. But it only works for the latest player who joined and removes it from all the other players. Any Ideas?
Wrong sized inventory
oh
Why do u have to set the nametag for every online player on join?
so do i need to change it to 45?
how come end portals in the end keep teleporting me to the end again
well
i set the nametag of the new player
for every player
on join
right?
So why do you use a for loop?
to get all the online players?
If there are 20 players
You're setting the players scoreboard 20 times
Ohhh
Wait
Now i understand
đ
Each player has their own scoreboard right?
How many account did u test this with?
So player 1 and player 2 joins they both have nametags
no,
player 1 joins gets the name tag
when player 2 joins
player 1 looses the tag
and player 2 gets it instead
Are you adding all online players to the scoreboard of the newly joined play btw?
Bukkit.getServer().reload();
What's this for?
I love memory leaks
I'm going to make a plugin for this
I call it Reload unlimited
while(1) {
malloc(1);
}
I try my best for my plugins to not leak memory
cat
Its not a memory leak its a feature
im gonna run that code and see what happens
I wonder if it does the same thing as /reload
Probably
I hate having no idea wtf to name my packages
I just sit in this stasis until I figure it out
name it a.b.c
no I need something that is discriptive yet also not long
What are you putting in there?
no
Yea I'm overlaying images in minecraft inventories
Shouldn't you be doing this?
each player should have their own scoreboard..
their scoreboard display's their stats
Right.. So you need to add all online players to that players scoreboard so that the newly joined player can see their nametag prefix?
should i make a seperate scoreboard to do this?
my computer froze when i ran that code
Don't you have to give the new ppayer a scoreboard?
I have code that gives them a new scoreboard with their data yes?
The same way u need to add the newly joined player to currently online player scoreboard
U also need to add currently online players to the newly joined plauers scoreboard
so 2 scoreboards it is
I'm not too well versed on scoreboards
Well doesn't each player have tjeir own scoreboard?
Yep
but wouldn't that display the wrong stats on the online player's scoreboard then?
okay,
@subtle folio is this consistent with what you see ingame?
Cuz this is wjat i think your code does
I believe so
Yeah so when p2 joins u need to add p1 to p2 scoreboard
Basically add new player to everyones scoreboard
And eveeryone to new players scoreboard
got it
thought its a gif
Huh?????
nice handwriting
Is this a clever way of listening for potion effects being added?
by the server?
Im basically setting a new map with custom implementation on add and remove
that's one way
smort
i dont have that on this version
no i mean, create a custom event
oh yeah
not sure if you'd be able to cancel it though
server might still send the packet
so things may get weird
you'll have to test to find out
yeah i guess i might just have to listen for both packet level and using this map
ty
I want to do conversations between a user and an npc user using basecomponents, if I want to make a yes/no choice in the dialogue, should I just create a temporary command using the reprocess event like /doFJ3DFGGTJRE2FFDDJVJFD92KDVFD3F9K or is there a better way
ItemStack a = new ItemStack(Material.LEATHER_BOOTS, 1);
LeatherArmorMeta b = (LeatherArmorMeta)a.getItemMeta();
ItemMeta c = a.getItemMeta();
b.setColor(Color.RED);
c.setDisplayName("§cStivali §cVDF");
a.setItemMeta(c);
a.addEnchantment(Enchantment.DURABILITY, 1);
player.getInventory().addItem(a);
player.sendMessage("§7[§cVDF CORE§7] §7Stivali givvati con successo!");
Not working LeatherArmorMeta, why?
ok
@subtle folio did you solve the scoreboard issue?
test_tags_profile:
type: tags_profile
debug: false
block:
climbable:
ladder: false
vine: false
iron_bars: true
chain: true
oak_wall_sign: true
oak_sign: true
oak_door: true
mineable/shovel:
stone: true
obsidian: true
gravel: false
mineable/axe:
oak_sign: false
item:
non_flammable_wood:
CRIMSON_DOOR: true
CRIMSON_HYPHAE: false
CRIMSON_PLANKS: true
worldgen/biome:
is_beach:
SNOWY_BEACH: false
jungle: true
config.getBoolean("block.climbable.iron_bars") will always return false, but Boolean.valueOf(config.getString("block.climbable.iron_bars")) will return true
Is this happening for anyone else?
edit: config is of test_tags_profile
Am I forgetting to do something?
thanks
?paste your code pls
It should work but you say it doesn't so maybe it's something wrong above
Last thing, how do I do that when the player wears a it gives it a certain effect?
You have to use multiple events to listen to when it's equipped
Or u can google armor equip event
And copy the class
I have a lib for that
ok
something like npcdialogueinteract <sessionid> <option> would be better
well actually a sessionid isn't even required
it doesn't really add anything useful imho
just something like /npcreply yes|no
and if you currently don't have any conversation, then this command simply does nothing
Is there any way I could compact this or make it more efficient?
@EventHandler
public void getSoulboundItems(PlayerRespawnEvent event) {
if (soulboundItemMap.containsKey(event.getPlayer().getUniqueId())) {
for (UUID uuid : soulboundItemMap.keySet()) {
if (uuid.equals(event.getPlayer().getUniqueId())) {
PlayerInventory inventory = event.getPlayer().getInventory();
SoulboundItemData soulboundItemData = soulboundItemMap.get(uuid);
int slot = soulboundItemMap.get(uuid).getSlot();
if (inventory.getItem(slot).getType() == Material.AIR) {
inventory.setItem(slot, soulboundItemData.getItemStack());
} else {
inventory.setItem(inventory.firstEmpty(), soulboundItemData.getItemStack());
}
soulboundItemMap.remove(uuid, soulboundItemData);
}
}
}
}
It's for adding any items back into someone's inventory when they respawn. The item comes from the player's inventory when they died, assuming it had the enchantment that is actually supposed to do that.
Yes
You can use if + return, instead of nested if-else
well itâs useful for keeping track of which npc someone is talking and the actual task itâs about to and for preventing some exploits
Still need to remove it from the map
looks okay to me
whut
What do you use for java catching
catching?
Like catching custom objects
have you smoked too much devil's lettuce again lol
catching = cache
no idea what you mean with caching custom objects
couldnât you just do .get(player.getUniqueId()) instead of this?
Map<UUID, Bla> map => Catching
But i have seen there are libs that make that easier and with a timer to expire the object every x time
Something like:
Cache<UUD, BlaBla> cache = new CacheBuilder().expireAt(10, TimeUnit.Minutes).build();
I would have to make a new field for player
He?
what
just use event.getPlayer then?
no idea why someone would want to make that "expire"
Not really much of a point of making another field
If the player isn't in the map then it just "exists" and making it for one usage is just a waste
I wondering to keep track of a custom player object, and keep it cached for some minutes. So if player get disconnected for some reason his cache is still loaded. Until it happen x time
iâm not sure what youâre saying
Do i explain? - mfAlex
iâm asking why you iterate through all keys of the map and check if itâs the players instead of using .get on it
Map#get(path) will return the value if exists, if not will return null
You can always null check it.
yeah
it already checks that here though
Shadown any idea?
It's getting every item in the map that is stored under that player
No, that's checking if there's an entry with that player at all
I should just add the UUID to that class and use an ArrayList
But why? There is no need to check tha
im really confused what you mean
You check if they have an entry then loop over all the entries to find the players?
Me too lmfao
No point in looping through everything if the player isn't in there at all
.get(event.getPlayer().getUniqueId()) does the same thing as iterating through all of them and checking if its the players
But why loop through everything when you can just .get?
Yeah, he can just do Map#get(path) instead of iterating
use a cleanup pattern
I was trying to use duplicate keys for whatever reasonđ¤Śââď¸
Allright thanks. Something like Guave or Caffeine one?
Caffeine is definitively favored to Guava
it might look like the same deal superficially, but the implementation is much more sophisticated and optimized
Idk man Guava tastes pretty good
myes, but anyway when I say cleanup pattern I mean that you can have some runnable that clears invalid map entries every minute or so
iirc thats how they do it in luckperms
does PersistentDataContainer work for CraftEntitys?
CraftEntity craftEntity = CraftEntity.getEntity((CraftServer) Bukkit.getServer(), entity);
PersistentDataContainer persistentDataContainer = craftEntity.getPersistentDataContainer();
persistentDataContainer.set(new NamespacedKey(plugin, "hunger"), PersistentDataType.DOUBLE, 0.5);
I'm using this code but it doesn't save any data
i've worked with persistent data containers before and they work fine, but I suspect this may have sometihng to do with CraftEntity..
what are you using craft bukkit entities rather than normal bukkit
custom NMS entities
i imagine that might have something to do with it
but you can cast that to a normal bukkit entity anyways
wait rlly
but the fact that it is a âcustom nms entityâ is probably the reason your pdc doesnât work
iâm not sure how much registering normally happens that you havenât done
I dont think it matters if you cast it to entity or not
uhhh you sure Caused by: java.lang.ClassCastException: class me.screescree.SuperiorSteed.SuperiorHorse.SuperiorHorseEntity cannot be cast to class org.bukkit.entity.Entity
Okay, fixed whatever the hell that was đ¤Śââď¸
@EventHandler
public void getSoulboundItems(PlayerRespawnEvent event) {
Player player = event.getPlayer();
for (SoulboundItemData itemData : soulboundItems) {
if (itemData.getPlayerUUID().equals(player.getUniqueId())) {
PlayerInventory inventory = player.getInventory();
final int slot = itemData.getSlot();
if (inventory.getItem(slot).getType() == Material.AIR) {
inventory.setItem(slot, itemData.getItemStack());
} else {
inventory.setItem(inventory.firstEmpty(), itemData.getItemStack());
}
soulboundItems.remove(itemData);
}
}
}
Wrong cast
Anything here that could be improved?
wdym
U casting ur nms horse to bukkit entity
what should i use then
oh well, yours doesnât extend entity clearly
package me.screescree.SuperiorSteed.SuperiorHorse;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.animal.horse.Horse;
public class SuperiorHorseEntity extends Horse {
public SuperiorHorseEntity(World world) {
super(EntityType.HORSE, ((CraftWorld) world).getHandle());
}
}
thats my custom entity for now
this is what I'm casting it to:
import org.bukkit.entity.Entity;
...
// in some function:
Entity newEntity = (Entity) entity;
oh no thatâs not gonna work
Can't cast nms stuff to bukkit stuff
i might have misunderstood u then
It doesn't matter if u cast it to entity because craftentity is the implementation
I'm gonna test it
You say it doesn't save
yeah
Check if it exists right after u set it
Does it?
how are you spawning it
Probably have to go the route of nms nbt then
Nbt is easier tbh
If mc handles the data
@ornate patio I'm gonna look at some stuff to see if i can help
In a command:
new SuperiorHorse(player.getLocation());
SuperiorHorse class acts as a wrapper:
public class SuperiorHorse {
private static SuperiorSteed plugin;
...
private SuperiorHorseEntity entity;
public static void setPlugin(SuperiorSteed javaPlugin) {
plugin = javaPlugin;
}
public SuperiorHorse(Location spawnLocation) {
entity = new SuperiorHorseEntity(spawnLocation.getWorld());
ServerLevel serverLevel = ((CraftWorld) spawnLocation.getWorld()).getHandle();
serverLevel.addFreshEntity(entity);
entity.setPos(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ());
...
System.out.println("TEST YES");
CraftEntity craftEntity = CraftEntity.getEntity((CraftServer) Bukkit.getServer(), entity);
PersistentDataContainer persistentDataContainer = craftEntity.getPersistentDataContainer();
persistentDataContainer.set(new NamespacedKey(plugin, "hunger"), PersistentDataType.DOUBLE, 0.5);
}
SuperiorHorseEntity is the entity itself:
public class SuperiorHorseEntity extends Horse {
public SuperiorHorseEntity(World world) {
super(EntityType.HORSE, ((CraftWorld) world).getHandle());
}
}
oh yeah you definitely need some sort of registering for the pdc
wdym registering
@opal juniper sorry for ping