#help-development
1 messages · Page 716 of 1
can i use a another method?
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
bump
probably because this is just for using, i.e. right clicking
works on other fake entities
for example fake player
it gets sent
but idk why armor stand is doing this
normal entities work
normal armor stand
it gets sent
packet armor stand
idk
should i call a method on the armorstand or something
the toxic gossip train
the easiest way for npc to understand which region the block being sold belongs to (worldGuard)
write to block data?
you could to the block under them
well the default will be pitch 1.0 volume 1.0, many of the real game interactions do play at a different pitch than 1
sometimes even at random between two boudnaries
how can i check a boolean in an if?
if boolean si true or false
yep
i tried with
if(boolean == false) but didn't work
??
🤔
if (!boolean)
boolean value = true;
if (value) { // Checks if true
}
if (!value) { // Checks if false
}```
This is some very basic Java
oh shoot i solved by myself
no u didnt xD
thx
Just as a note, you'll find basic information like this much quicker online with a quick Google search, "Java how to check boolean"
thx last think if i can XD, i put a boolean at the top of the class but i want edit it if another action is true how can i do?
learn java, that's how you fix it
right
is there a way to prevent adding HEALTH_BOOST potion effect clearing hearts?
seems like every time i add it extra hearts just reset
h
I guess you can just get the health, add the potion effect and then set the health again.
Im listening to PacketPlayInUseEntity, but for some reason, when i attack (left click) a PACKET armor stand, the packet seems to not be sent (i logged the packets there is no other packet) but when i left click an existing armor stand not made with packets, the PacketPlayInUseEntity seems to be sent
help
Pmz with his non-mapped classes again 
Ancient versions ancient problems
Did you send any metadata for this fake armostand
If you're on latest with obf maps you just have brain damage
He is on a newer version. Just refuses to use obf mappings for whatever reason.
packets.add(new PacketPlayOutEntityMetadata(id, stand.aj().c()));
1.19.4
i might do that
Just use remapped 😭 it makes versions pretty much copy paste
What type of metadata do you send?
nothing
EntityArmorStand stand = new EntityArmorStand(((CraftWorld) Objects.requireNonNull(location.getWorld())).getHandle(), location.getX(), location.getY(), location.getZ());
this.id = stand.af();
packets.add(new PacketPlayOutSpawnEntity(stand));
packets.add(new PacketPlayOutEntityMetadata(id, stand.aj().c()));
List<Pair<EnumItemSlot, ItemStack>> list = Lists.newArrayList();
list.add(new Pair<>(EnumItemSlot.f, getArmor(kit, 39)));
list.add(new Pair<>(EnumItemSlot.e, getArmor(kit, 38)));
list.add(new Pair<>(EnumItemSlot.d, getArmor(kit, 37)));
list.add(new Pair<>(EnumItemSlot.c, getArmor(kit, 36)));
packets.add(new PacketPlayOutEntityEquipment(id, list));
despawnPacket = new PacketPlayOutEntityDestroy(id);
entire code
latest with obf is self harm
question. What does requirenonnull do
it requires non null
cuz all it seems to do here is to be a wrapper
Fail fast
It's basically preconditions but built in
does anyone happen to know if removing a potion effect off an entity also calls the potion effect change event
or is that neglected
Do you get right click interaction packets?
yes
I would try setting the metadata of the armorstand. Make sure its damageable and not a marker etc.
https://www.baeldung.com/jetbrains-contract-annotation hope this helps
its always jetbrains or google aint it
(Jetbrains Annotations) Contract describes the relationship of input and output of a method.
For example null -> null means that if you put null in, then you will get null back.
There are a few rules which can be applied.
?
It can help with the static code analysis in your IDE
can i make it so if i put a specific char, i don't get null?
No
Ok
whats a qualifier value? The instance of the current class?
yea it is
i guess using mappings might help with my mental problems
Thats a runtime specification. The IDE wont know the content of a variable on runtime.
I dont see how this could be inspected.
Im trying to make a plugin that has a villager solve a maze. I am using A* algorithm, however if I have villager AI on, it will mess up the A* algorithm. If I have it off, I can't move it by applying velocity. I know I can teleport the villager, but it looks like crap if I do and itll try to go through blocks. I know I can used NMS but I would prefer not too, wanted to see if there was another way to move a villager beforehand.
that's sad
my ide keeps bothering me about 'this might be null'
even tho it isn't possible to get null
You need to use NMS and add a custom AI Goal to the Villager which prioritizes your Movement over the vanilla ones.
You can also just clear the Goals completely and write your own behavior that way.
NMS is so buggy
new villagers ignore the goals
it uses a new ai for them
i think you need to edit that @quaint mantle
Ah yeah, they have that brain thingy
but keep in mind the code quality is much better than before
so accessing it is a bit of a problem
tho not impossible
Those inspections are almost always right.
I think you are just missing a proper annotation.
on maven it doesn't take long
no my internet is shit
Well internet doesn't matter for that if you're using maven
Mappings will be stored in maven local when running BuildTools
so importing a project doesn't do a bunch of web lookups
im using paperweight for the mappings
?whereami
Ok done
oh so you're also forced to use toolchains and cannot define a custom -source and -target
yeah that's why I use the normal remapping plugin for gradle instead of paperweight
you're also forced to use paper-api with paperweight lol
at least im using mappings :(
me too, without having to use paperweight https://github.com/mfnalex/cesspool/blob/master/nms/versions/v1.20.1/build.gradle.kts
should i change reflections?
no you'll need the obfuscated names for reflection
so i should turn of the inspection?
but why do you need to get a field's data by reflection?
entity id
and beside that
i need to get the action
of an interact packet
which is private
i cant do that
I'd get the action through the field's return type and the entity ID, as said, what do you need that for? why not get the entity directly?
ok i might change my ways
but
what about action
as I said, I'd get the action through the field's return type
what actions are there even besides "ATTACK_ACTION" and "not ATTACK_ACTION"?
Field actionField = ServerboundInteractPacket.class.getDeclaredFields().stream().filter(field.getType() == Action.class).findAny()
sth like that
would get you the correct field no matter how it's called
ofc gotta check if the found field is static
oh well ok that sucks, then yeah you probably have to use the obfuscated name for reflection
what are you going to do with it anyway though? shouldn't it be enuogh normally to know whether it's attack or whether it's "isUsingSecondaryAction()"?
how can i know if its attack
isn't it always attack if it's not a secondary action?
i don't think you can left-click any entity without that being an attack
player.playEffect()??
OfflinePlayer#ban
declaration: package: org.bukkit, class: Bukkit
seems like it doesn't exist
?whereami
Paperweight. Everything beyond this is irrelevant
Few people are going to help you so don't expect much. And even I who generally does help you regardless of the spigot versus paper divide or version divides cannot help you as NMS has been and will continue to be a strict no-no for me.
im not apart of any divides. I just want my villager to work lmao
does InventoryAction.MOVE_TO_OTHER_INVENTORY count picking up and then dropping an item in a different inventory?
thanks tho ill look into it
Nms your on your own if your using paper api go to paper and ask for help there
If your using spigot api set it up as follows
?nms
Just remember you'll probably not get help with nms here or anywhere though it's still possible there are a few who are pretty knowledgeable here idk about paper
this ^ or for gradle, use the remapper plugin from io.github.patrick https://github.com/mfnalex/cesspool/blob/master/nms/versions/v1.20.1/build.gradle.kts
(still need to run buildtools and use the remapped-mojang dependency from mavenLocal() )
er-
gotta initialize it
yea but why isnt it null by default? cuz it needs a pointer?
local values are stored in stack and not heap
therefore they need to be initialized
i need help with InventoryClickEvents. Using the numkeys causes a HOTBAR_SWAP action, but i don't know how to access the itemstack in the slot that's being swapped to
I thought it woudl be currentItem, but that returns null
ah i can use the getHotbarButton
uh
how do i obtain the item using the event.getHotbarButton? It'S not event.getwhoclicked.getinventory.getItem(36+event.getHotbarButton())
do inventories count items differently than inventoryviews?
it's just
yes
gotcha
while (phase != getPhaseLifecycle().getWaiting() && phase != getPhaseLifecycle().getResetting()) {
phase.stop();
}
this
vs
tf is a PhaseLifecycle
the set of phases a game can be in
I'm trying to store a series of itemstacks in a string by converting them to base64. Doing so produces this error:
java.lang.IllegalArgumentException: Illegal base64 character 2d
[16:57:26 WARN]: at java.base/java.util.Base64$Decoder.decode0(Base64.java:848)
[16:57:26 WARN]: at java.base/java.util.Base64$Decoder.decode(Base64.java:566)
[16:57:26 WARN]: at java.base/java.util.Base64$Decoder.decode(Base64.java:589)
[16:57:26 WARN]: at simplethings.jar//cyrei.simplethings.graves.GraveHandler.base64ToItems(GraveHandler.java:170)[16:57:26 WARN]:
What might be going wrong here? I'll provide the code btw
Code for the encoder: ```
private String itemsToBase64(ItemStack[] items) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream data = new BukkitObjectOutputStream(outputStream);
data.writeInt(items.length);
for (ItemStack item : items) {
// if (item != null) {
// data.writeObject(item);
// }
data.writeObject(item);
}
data.close();
return Base64.getEncoder().encodeToString(outputStream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}```
Code for the decoder: ```
private ArrayList<ItemStack> base64ToItems(String base64) {
ArrayList<ItemStack> items = new ArrayList<>();
try {
ByteArrayInputStream stream = new ByteArrayInputStream(Base64.getDecoder().decode(base64));
BukkitObjectInputStream data = new BukkitObjectInputStream(stream);
int size = data.readInt();
if (size % 9 != 0) { return items; }
for (int i = 0; i < size; i++) {
items.add((ItemStack) data.readObject());
}
data.close();
} catch (Exception e) {
e.printStackTrace();
}
return items;
}```
this looks like a problem
if you input the size
you have to put something
even if is null
can you write null?
or wait even better
can you read an array of some type?
I have that part disabled, so it should write the items even when null
in your case make sure the items you write and the ones you read match
a single mistake and you'll get errors
however you seemed to had a problem with base64
ew
no
what the fuck
hardcoded phase enum 
it's not an enum
i have it all figured out don't worry 😄
I see a while loop
It should be matching, shouldn’t it? It adds the size, and then it iterates through all the items
maybe attempt to write an itemstack with the material air
instead of null
otherwise if this isn't the problem it might be a bug while converting to string
i had a similar problem myself
i think i solved it by using utf 8 character set
So this? ```for (ItemStack item : items) {
if (item != null) {
data.writeObject(item);
} else {
data.writeObject(new ItemStack(Material.AIR));
}
//data.writeObject(item);
}
data.close();```
I'll try it
try it
otherwise try to put the entire array
i think bukkitoutputstream has this as an option
objectoutputstreams suck
i agree
it even fails at doing isSimilar after using it
shouldnt do that for a configurationserializable when using the bukkit stream
it did at some point at least, not sure now
Wait there’s a BukkitObjectOutputStream#writeArray() ?
do that
It doesn’t show up
Oh writeObject works with arrays? It makes sense it would
I was following the most horrendous tutorial then because that would save so much
Yeah come to think of it, I was wondering why they didn’t do that
When I looked at it
objectinput stream is actually bad
you can't even get the array back
actually nvm
you get it as an Object
but you don't need the size anymore
Then just cast it to the array?
yes
Alr
not sure
uhh not quite
i think
because load data on certain circumstances is saved after
Basically i'm making temporary worlds
I want to unload and delete them on shutdown to not clutter the world folder
But if I unload and try to delete, the world data (which is often saved in another thread) will just rebuild and persist
With a fancy exception
My current approach is just giving those worlds a tag and deleting them on startup
But there's probably a better way
oh thats annoying
I can't just schedule a task after 5 seconds because the bukkit scheduler can't be used on shutdown
yeah
And if I use futures or something the server will just die before the future is done
i get that
Lemme look at internals and see if I can prevent files from being created in the first place
store world solely in memory?
Pretty much
Yeah there are still file handles
And locks that I just can't delete
boo
I can prob bypass this with reflections
?nms
Compare different mappings with this website: https://mappings.cephx.dev
You could listen for a plugin disable event?
Uhh no
It's my own plugin managing worlds
p sure that I can just nuke them off the face of the earth
I'll either deal with nasty file locks
Or I'll be completely fine
The code still produces the same error: ```private String itemsToBase64(ItemStack[] items) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream data = new BukkitObjectOutputStream(outputStream);
data.writeObject(items);
data.close();
return Base64.getEncoder().encodeToString(outputStream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
private ItemStack[] base64ToItems(String base64) {
ItemStack[] items = null;
try {
ByteArrayInputStream stream = new ByteArrayInputStream(Base64.getDecoder().decode(base64));
BukkitObjectInputStream data = new BukkitObjectInputStream(stream);
items = (ItemStack[]) data.readObject();
data.close();
} catch (Exception e) {
e.printStackTrace();
}
return items;
}```
it must be the string encoding/decoding
maybe your string is just broken
I hate autocorrect
or your item array or whatev
The item array is just player.getInventory().getContents(). For debug, I had it print out the items and it seemed fine
try this
it might work
anyoen know
i'd just try and see I' dassume it does
uhh
good luck
p sure that'll just convert the byte[] into chars
unless I'm an idiot
Try and see
I usually like serializing these separate but I'm pretty sure it does
theoretically speaking, is there a way to present an anvil gui to a player, to get the text input they put in the rename part for like small string grabbing without nms? so the players gets presented with the anvil gui, they have a piece of paper in the first slot, rename it to what the feature needs, then clicks the result and the code gets the string they put in. is there a way to do that without NMS? so far the only ways I seem to have done it in the past is with nms but it doesn't sound like I really need to
I mean you can try just opening an anvil GUI and listening for clicks on the result
Hey do you know how to get a refernce from a config in a diffrent java class?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Unfortunately no, with just how anvils and such work in general the curent inventory API doesn't lend itself nicely to such things. If you want to avoid NMS use a library like AnvilGUI
which does all the NMS for you. If you're intrested in doing something yourself with nms all you really need to do is open an anvil container
// Note NMS 1.20.1
@Nullable
public static InventoryView openWorkstation(@NotNull final CraftHumanEntity entity, @NotNull final Block block, @NotNull Function<BlockPos, MenuProvider> exception) {
final BlockPos position = CraftLocation.toBlockPosition(entity.getLocation()); // arbitrary block location
MenuProvider provider = block.getMenuProvider(null, entity.getHandle().level(), position);
if (provider == null) {
provider = exception.apply(position); // applies certain exceptions this is advanced for a few exceptions you could remove this
}
if (provider == null) {
return null;
}
entity.getHandle().openMenu(provider); // opens menu
entity.getHandle().containerMenu.checkReachable = false; // ignores if the container is even in range of you
return entity.getHandle().containerMenu.getBukkitView(); // gets the bukkit view
}``` I made this method to open any container but anvil specifically would look something similar
Usage in this case would be pretty simple for making an anvil view thats functional
```java
openWorkstation((CraftHumanEntity) entityHuman, Blocks.Anvil, (__) -> null);
you can either apply your items to the menu provider prior to opening it to the player or just appling it after (which is what I do as I don't feel like dealing with nms stacks even with the bukkit translation methods)
if I save an itemstack to config will there be any issues?
idc optimizations but if I do this with an itemstack will it cause any sisues
Idk about "any issues" but it's designed so you can do that
if i send a Player#hidePlayer, disconnects the target player and joins again, it will continue hidden?
Last time I tried reconnecting showed the player
No
Weird
Who are information systems specialists? They need to learn assembly language 💀
?
and are they programmers?
Could be anything, needs more context
nopox u little muncher
need help please: Player is stuck in the end because his bed was destroyed in time. How can I set it so that if the bed is blocked/broken, it spawns normally at the world spawn
lol yeah there must be another plugin interfering
probably the one that set spawns in the end to begin with
or do you mean to spawn a bed in the world?
im kinda confused by your question now lol
Not installed
I'm sending in my plugin list this evening... again to clarify my question: How can I specify that if spawn1(Bed) blocked he should spawn at spawn2(worldspawn) currently there is only one message, bed blocked. So he stucked in the end xD
.
If spawn1 blocked goto: spawn2
This is the name of a programmer's specialty. What specifics do you want to know?
in other words, system programmer
if i have for example .txt file in resources folder of my plugin how can i use that .txt file from there do i just pass it as /resources/file.txt or some other way ?
do you want to read values from a config ?
no no no it is text file and i want to just read it so i can get random line from it
well vanilla should respawn them i the overworld
idk if there is a way to have more than 1 spawnpoint
can you implement multiple respawns?
wdym
why
File file = new File(plugin.getDataFolder(),"yourfile.txt");
i think so
You can't
You can't get file from resources folder
You can only get inputstream
And you can read content from it
why you don't save several locations in a config and let the player spawn randomly at one of these locations for your purpose ?
random spawns is probably not something they want
I mean if they had no plugin interfere, they wouldnt respawn in the end anyways
then I unfortunately do not understand the plan exactly 😄
Because you can't present file inside of jar as actual filesystem path
Doesn't ! Indicate a filesystem change
I believe I saw that when working on a jar extracting thing for gradle
It would be /path/to/jar!/file/in/jar
Going of memory unsure how the ! Was placed
Never heard of it lol
But I'm sure you can't get File object from inside of jar
And I assumed it's because filesystem path can't be presented from it
I believe you can
I'll see if I can check my code when I get hope
Do remind me or I will forget
You can with a ZipFileSystem or however it‘s called
It treats any zip file like a regular FS
But it had a somewhat different name, idr
either that (ZipFile), or JarFile
But thats just the file itself - there‘s another class that provides a FileSystem out of zip file
It was added in java 7 or sth
can you get all the files from within the plugin's jar from a folder?
Yes, just treat it as zip file
it also has the entries which you can just go over
but i know what you mean
i used it for an updater, lemme check
how tho, the class loader doesn't have methods for getting the jar file
it has
SomeClass.class.getProtectionDomain().getCodeSource() gives you a CodeSource
you can then grab an URL using getLocation()
oh, this
then you can throw the InputStream of that into a ZipInputStream
alr, thank you
then you can loop over all ZipEntries
https://stackoverflow.com/questions/1429172/how-to-list-the-files-inside-a-jar-file first answer should do, and it also meantions that in java 7 you can probably just d oFileSystems.getFileSystem(urlToZipFile) and boom you have a virtual file system where you can just do listFIles() and stuff like that
nvm i actually used ZipFile and got my inputstream from that
the first answer here is also great, it shows how you can create a FileSystem out of your zip file or even of a subfolder of your .jar file https://stackoverflow.com/questions/1429172/how-to-list-the-files-inside-a-jar-file @lilac dagger
awesome, i'll check it out
Im listening to PacketPlayInUseEntity, but for some reason, when i attack (left click) a PACKET armor stand, the packet seems to not be sent (i logged the packets there is no other packet) but when i left click an existing armor stand not made with packets, the PacketPlayInUseEntity seems to be sent
Im using mojomaps
Modify the fake armorstand. Make sure its not a marker and can be damaged.
I have done both
And if it was a marker
The right click wouldnt work
This is annoying
Hello everyone, I can't find anything on forums regarding this topic. I have plugin and I have item created from config. How do I ensure that in config "material: diamond_sword" supports every item from 1.8 to 1.20? Any clues are helpful.
XMaterial
Dont understand the problem. Never had that issue.
is there a way to know which number they click inside the InventoryClickEvent after knowing it's a ClickType.NUMBER_KEY?
i just want to cancel the key 9 since the players will have an item in that slot that can't be dragged or dropped, but also want to cancel them from using the number key to move it.
event.gethotbar... i forgot the name
remember its 0 to 8
event.getHotbarButton() is a thing indeed. let me see what does it to do and test things
ty
Nice it worked, thanks again!
yw
do you think the location/code source can ever be null in this case?
@lilac dagger hey
have you ever listened for interact packets for armor stands?
for some reason the packet doesnt come for left click
you mean PlayerInteractEvent ?
Bros got no clue what a packet is
Ok ive done a very simple test
public class FakeArmorstand {
private final ArmorStand nmsBackbone;
public FakeArmorstand(Location loc) {
ServerLevel level = ((CraftWorld) loc.getWorld()).getHandle();
this.nmsBackbone = new ArmorStand(level, loc.getX(), loc.getY(), loc.getZ());
}
public void showTo(Player player) {
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(this.nmsBackbone);
((CraftPlayer) player).getHandle().connection.send(spawnPacket);
}
}
And i get both left and right click packets for this fake armorstand.
No problems.
protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Play.Client.USE_ENTITY) {
@Override
public void onPacketReceiving(PacketEvent event) {
System.out.println("> Received " + event.getPacketType());
}
});
im not using plib
im injecting packet listeners
and 1.19.4
Try to use plib to make sure the issue doesnt lie within your packet listening impl
well i try my best to not
This is one of those times where you need to find out if your impl is dumb
or if mojang wrote some dumb code
so simply it worked for 1.12.2
but
the same impl
protocol changes all the time
with changed codes for 1.19.4
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
ok wait
If I want to create a chest with a custom loot table and I do chest.setLootTable(myLootTable); chest.update(); the chest does not contain any loot yet. What am I missing?
@echo basalt
ArmorStand stand = new ArmorStand(((CraftWorld) Objects.requireNonNull(location.getWorld())).getHandle(), location.getX(), location.getY(), location.getZ());
stand.setMarker(false);
stand.setInvulnerable(false);
this.id = stand.getId();
packets.add(new ClientboundAddEntityPacket(stand));
packets.add(new ClientboundSetEntityDataPacket(id, Objects.requireNonNull(stand.getEntityData().getNonDefaultValues())));
List<Pair<EquipmentSlot, ItemStack>> list = Lists.newArrayList();
list.add(new Pair<>(EquipmentSlot.HEAD, getArmor(kit, 39)));
list.add(new Pair<>(EquipmentSlot.CHEST, getArmor(kit, 38)));
list.add(new Pair<>(EquipmentSlot.LEGS, getArmor(kit, 37)));
list.add(new Pair<>(EquipmentSlot.FEET, getArmor(kit, 36)));
packets.add(new ClientboundSetEquipmentPacket(id, list));
this is how i spawn the armorstand
fine
if (player == null) {
return msg;
}
if (msg instanceof ServerboundInteractPacket usePacket) {
Object field = packet_useEntity_field_action.get(usePacket);
Enum<?> actionEnum = (Enum<?>) packet_useEntity_method_get_type.invoke(field);
ClickType type = getType(actionEnum.ordinal());
if (type == null) {
return msg;
}
handleClick(player, usePacket, type);
}
return msg;
this is how i handle the interact
i had a packet sout before
no other packets came in
and there was no sout
my implementation is correct
https://paperless.jeff-media.com/ does this give you guys a 403 error, show a login screen, or forward to my main website?
403
403
How do I load a custom loottable from a file?
I currently do LootTable customLoot = Bukkit.getLootTable(new NamespacedKey(this, "customloot"));
where customloot is a file in the root of the plugins data folder. Is this incorrect?
when I then check if customLoot is null, it is. Despite the file being present in the folder
403
502
403
@tender shard ^
hi! I need some help sorting out a problem of mine. I made a boss with a minigame phase and I wanted it to not being able to take damage while the minigame phase is active and for some reason it cancels the hit event every time.
@EventHandler
public void onHitMinigamephase(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity().getPersistentDataContainer().has(hellBoss,PersistentDataType.BOOLEAN)){
if(minigamePhase){
Bukkit.broadcastMessage("NOT HIT");
e.setCancelled(true);
}
}
}
}
Then only cancel the hit when the danage only if the minigame phase is active
minigamePhase is a boolean that switches every x seconds
yeah I did that and it applies all the time
If "NOT HIT" is always printed then minigamePhase is always true
but the actual minigame phase works
it switches from normal to minigame and back after 10 seconds
What is the difference between minigamePhase and your "actual" minigame phase?
when im talking about actual minigame phase, Im talking about what its supposed to do when the minigame phase is active
huge troll
Well, your minigamePhase is always true. About all we can say with the provided information.
For me its 418
what the heck is 418
new BukkitRunnable(){
@Override
public void run(){
if(boss.isDead()){
cancel();
return;
}
if(minigamePhase){
Bukkit.broadcastMessage("Minigamephase: false");
minigamePhase = false;
boss.setAI(true);
boss.setInvulnerable(false);
}
else if (!minigamePhase){
Location location = boss.getLocation();
location.setY(location.getY() + 1.75);
Bukkit.broadcastMessage("Minigamephase: true");
minigamePhase = true;
boss.setAI(false);
boss.setInvulnerable(true);
boss.getWorld().spawnParticle(Particle.REVERSE_PORTAL,location,5);
boss.getWorld().playSound(boss.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT,1,1);
boss.teleport(HalalBoxCustomBosses.getInstance().HellBossSpawnLocation);
}
here it switches from true to false
🫖
I can see it in the chat
oh the teapot error
600
Then you are switching a different variable than you use in your event i suppose.
theres only 1 minigamePhase boolean
no other similar variables
Sure, but is it the same instance?
its in the same class
So?
Means there could be a thousand different variables then.
Every instance of a class has its own variables.
I'll try printing out the minigamePhase boolean to actually see
Yep, should do that
But... in the same instance?
wym by that
A class itself does nothing. Its just a blueprint which describes how an object should look like.
Every time you create an object (instance) using this class, it has its own separate variables and states.
Here is an example:
// A simple class with a variable, a setter and a getter
class Bus {
private int speed;
public void setSpeed(int value) {
this.speed = value;
}
public int getSpeed() {
return this.speed;
}
}
// Creating an instance of class 'Bus'
Bus busA = new Bus();
// Creating another instance of class 'Bus'
Bus busB = new Bus();
// Every Bus instance has its own state.
// Setting the speed of busA
busA.setSpeed(50);
// This will still print 0 because they have each their own 'speed' variable.
System.out.println(busB.getSpeed());
This is basic Java to be honest
oh you're talking about this one
well it should be
Do you create only one instance of your Listener?
Otherwise you should overthink your design.
There is no valid reason to ever have more than one instance of a Listener.
well I actually have 2 EntityDamageByEntityEvent
it seems like if I manually switch the boolean in the code, it doesnt apply all the time
well I registered my boolean at the start of the class
switching the state of the boolean doesnt seem to apply to it tho
Sounds to me like you are using two completely different instances
how can I make it one?
Dont create more than one?
learnjava moment
bruh I just code in my freetime, Im still learning
yeah but thats the thing, I dont have any other minigamePhase instance 💀
What class is this in?
How many instances do you create of this class?
I'm positive, I only have one at the start of the class
how 'bout I send you the class so you can take a look at it?
What do you mean?
Whats the name of your class?
I dont need to see the class... I need to know how many instances you create of that class.
The class itself is not the problem
Hellboss.java
How often do you call new Hellboss()?
once
Because every time you do that, you create a completely new Object with its
own methods and variables.
I call it once in a task when the game is starting
And once in your onEnable to register it as a listener i assume?
yes
Well... there you got. Problem solved.
well yeah but I need to register the events, and I have to spawn the boss somehow
You need more classes
You need a structure like this:
HellBoss.class
HellBossManager.class
HellBossListener.class
...
Dont create fat classes that do everything.
A class should have a single responsibility only.
I already got a manager, so I'll just create the listener class
thanks, I'll give it a try
I feel like this is destined to fail until you properly understand what an instance is.
Well at least I'll learn from it
@lost matrix i found out the issue
it is just sad
the armors on the armorstand prevented the interact
and i dont know how to disable the hitbox of the armors
That doesnt sound right+
well
when i go INSIDE the armorstand
and stand on the same block as the entity
and click on it
it works
like this
it is
should i spawn 2 armorstands?
1 marker (the display)
1 interact
thx
fr?
thx
Where is mine?
no ping, no reply
I haven't even found your message specifically after looking for it
did you hide it?
I told a guy that i was getting a 418
a quick question how to check if sender is console
by checking if sender is instanceof ConsoleCommandSender
By using instanceof
good
or if it's instanceof ProxiedCommandSender and the initiator is the console
depends on the needs
ProxiedCommandSenders are annoying as hell to handle
all you'll get from me is "error 0.5: not enough permille to drive a car"
then just check if sender.hasPermission(...)
the console has all OP permissions by default anyway

yea but it doesnt ender because its already a player sender
it check if player that sends has perm
Just call hasPermission or isOp() on the sender before casting
how to get drunk without drinking: 7mg ativan
cops hate this trick
Then I don’t understand the question
2 armorstands and not working...
god i hate 1.19
Use an interaction box
what is it
You can no create empty boxes and detect if a player clicks on it
how
But i can honestly not believe that the armor prevents you from attacking the armorstand
it would make no difference if it's by packets or a real ArmorStand. The client chooses what packets to send
Cant. My GPU is currently getting pounded by training a model.
sadly it does
Thats impossible
look
if i spawn
an armor stand
with packets
give armors
with packets
i cant attack it
unless i get inside it
Does the armor of a real armorstand block the interaction the same way?`
Check that pls.
The only difference between a packet AS and a real AS is whether the server knows about it. That will have no effect on what packets teh client chooses to send
IT DOES
WHA
wait
i was adventure
i changed to survival
it doesnt make any difference on the packet one
and the real one doesnt get blocked
Yeah, as we told you before: Check the permission first and then cast to player later
@lost matrix how to do the interaction box
You are essentially now casting a console to a player.
hmm how to just ask for perm
first of all im trying to see if it works without armor
first check for console
then perm
it shouldnt be in one statement
you will learn
@lost matrix its not the armors
for some reason
without armors its still the same
i came up with a fix
fuck armor stands
lets use skeletons
Use a player which always looks like you, for each person
aint no way
it is not working for skeletons
bruuuh
😭 😭 😭 😭
its the same bug for skeletons
You must be doing something wrong
yeah
but what
why the player npc is ok
Skeleton skeleton = new Skeleton(EntityType.SKELETON, ((CraftWorld) Objects.requireNonNull(location.getWorld())).getHandle());
skeleton.absMoveTo(location.getX(), location.getY(), location.getZ());
id = skeleton.getId();
packets.add(new ClientboundAddEntityPacket(skeleton));
packets.add(new ClientboundSetEntityDataPacket(id, Objects.requireNonNull(skeleton.getEntityData().getNonDefaultValues())));
List<Pair<EquipmentSlot, ItemStack>> list = Lists.newArrayList();
list.add(new Pair<>(EquipmentSlot.HEAD, getArmor(kit, 39)));
list.add(new Pair<>(EquipmentSlot.CHEST, getArmor(kit, 38)));
list.add(new Pair<>(EquipmentSlot.LEGS, getArmor(kit, 37)));
list.add(new Pair<>(EquipmentSlot.FEET, getArmor(kit, 36)));
packets.add(new ClientboundSetEquipmentPacket(id, list));
despawnPacket = new ClientboundRemoveEntitiesPacket(id);
what is wrong here
Send metadata after equipment
not fixed
as i said
if i remove the armors
the bug is still there
Hi, can you help me finding why no data is saved on the player's profile?
PlayerProfile profile = e.getPlayer().getPlayerProfile();
profile.setProperty(new ProfileProperty("custom-prop", "1"));
e.getPlayer().setPlayerProfile(profile);
e.getPlayer().saveData();
Why do you want custom properties in a player profile?
I want to save some data in the player's dat file, so I can use it in multiple places
pdc?
^
isn't it a paper thing?
No, pdc was introduced in spigot back for version 1.14
but why doesn't this code work?
First of all: Thats all paper specific code
After that: Im not sure if custom properties get saved at all by the server
I'm on 1.12.2, so I can't use pdc unfortunately. Is there any other way to add custom stuff in player's dat?
NBT
nbt through nms or just use a normal File for your data
I just need to know if a player is moved from other server or the current server is the first one. I wanted to add custom property to the player's profile before sending the plugin message, but it seems to be too complicated
Neither profile data nor pdc/nbt is persistent between servers.
You need a custom system for that either way.
I have a modified server which has persistent player dat between the servers
"node that the player is facing" What does that mean exactly.
is it due to this
if (!setupEconomy()) {
getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this);
return;
}```
probably
check startup logs
alr
[21:25:16] [Server thread/ERROR]: [Bosses2] [Bosses2] - Disabled due to no Vault dependency found!``` dam it disables whole plugin wow
i am officialy insane
daym
itemdisplay teleport afterimage problem
1.19.4 packet entities interact problem
Sorry for late response. The node is essentially a step towards the goal. Each node contains a cost (distance from current node, and distance from end node) I want to add another heuristic for the way the player is facing somehow. Higher cost means the node is less likely to be explored, so the PVP NPC should try to go to the sides and behind the player to attack instead of approaching head on. This introduces a new issue of yaw and pitch tho.
If a player is facing in the direction of a node with a low cost, it should increase the cost of that node by ALOT, but this also causes issue with concurrency since it requires changings while the path is being computed.
The algorithm is a modified version of A* pathfinding optimized to reduce computational load.
Essentially what im trying to accomplish is, if the player is directly facing the computed path, the node cost need to change in real time.
Im listening to the interact packet, when i right click a packet armor stand or skeleton or any entity (other that an npc), it works fine and the packet seems to come in, but i cant listen to left click because its kinda strange, i have to go to the same block as the entity and look down and left click so the packet comes in
i tried the paper unknown entity whatever event, same results
you can’t change weights whilst its running tho reliably. You are better off just running it and if their rotation changes running again. changing weights halfway through is gonna have weird affects on the route
You think I should just stop the thread its running on and restart it on a new position when the player moves? Wouldn't that be extremely computationally expensive?
I would have to most likely change from A* to a depth search algorithm.
idk the full sorta usecase here - but i would have thought that if you do that you would never get outputs if you are turning a lot
The problem is, if I could access the player information from inside the runnable without using a final instance. It would be 100x easier, im still new to mc development so wanted to see if I was just missing something.
I need the distances to be mutable
If you just want to reduce the computational load of A* you can try using JPS Algorithm
I was working on that myself but I never got around to completing it
What's the pro's of that compared to alpha beta pruning in a depth search?
It's just a modifed version of A* that fits the MC environment well
Ill take a look into it.
Thanks 🙂
This looks like it'll fit better.
Thus far
guys, i have 2 branches and i'm trying to push updates from one to another without making them 1, is there a way to do this? (in intellij)
Why do it directly in Intellij
if i already commit and push, why not do this too?
cd projectpath
git checkout target-branch
git cherry-pick commit-hash
To find commit-hash run git log while on the source branch
@lilac dagger
If your talking about intellij's built in version control?
yeah
Open Version Control Log:
Navigate to View -> Tool Windows -> Version Control (or simply press Alt + 9), then click on the Log tab.
Select the Source Branch:
In the branch filter at the top, select the source branch from which you want to pick commits.
Pick the Commit:
Right-click on the commit you want to transfer, then select Cherry-Pick.
Resolve Conflicts (if any):
If conflicts occur, IntelliJ will show a pop-up window guiding you through resolving these conflicts.
Commit the Change:
After resolving conflicts, you'll need to commit the cherry-picked changes. IntelliJ might automatically open a commit dialog for you.
oh there is
Its better practice to use terminal.
how do you solve conflicts from terminal?
Considering this can differ on IDE. It's better to learn how to do it with a terminal.
Finding Namespacedkey of datapack loot-table
Does anyone know if the NPC object in citizens API is serializable?
Not sure
You can take a look at the source on their Github page
yeah, better look
Thanks guys
even citizens has messy code
Feel free to PR
nah, it was mostly to myself
every decently sized codebase has messy code
i have messy code too, it makes me feel better about this
Clean code does not exist
^
Organization is normally not a trait of an engineer.
Unless you dont have tism
i've been using chat gpt recently to help me find names or even better find errors in my logic
like stuff that can be simplified
Oh yea, gpt is responsible for my naming conventions. Don't use it for anything besides that tho, everytime I use it for code it just significantly fucks it up more than it already was.
yeah, ik
tho it did a good job once changing a piece of code from recursive to a while loop
I was training a CNN a few months ago and it was going for days. I had an issue in my reward mechanism and it recommended a single change (add weights to rewards), GPT-4 mentioned multiple times it should be fine to continue training on its pre-existing data because the changes weren't significant. Like the idiot I am I didn't make a backup of my training data and it overwrote my training data with absolute nonsense. 2 days wasted.
I use it to write simple stuff because im too lazy to get copilot
i should try copilot but i don't wanna give my whole project to it yet
if its on github , copilot already has it
it's private
doesnt matter to copilot xD
i'm sorry what?
@lilac dagger It finally converged tho
I mean do you really trust github
i know
i'm just saying
but not like a pathfinding algorithm in that sense
does it know how to optimize path yet?
like once it grows to a certain size it tries to stay close to the tail
Yes, it's a overly large network for the task at hand. It's pretty much mastered snake.
I didnt record the whole game for the sake of the file size
But it does this cool shape after a certain length, it repeats these cool rotations to the apple and back to its tail
Yea but I learned a harsh lesson about ML in java
dont do it
use python
DL4J is so buggy I had to make it from scratch
i'd love to make something myself too
If you add me as a friend im down to help you with your stuff. I don't respond much on here.
Its a really fascinating field, you get a new feeling of accomplishment when you watch your code 'learn'.
I'm currently working on a small language model as well.
that's super cool
You gotta go to settings and turn off copilot sharing
i don't have this option
not spigot related but mongodb question
Hello, im creating a db using use ffa_db
my plugin creates the collections, inserts and updates
it also gets from the db and the data seems to be fine
but when i try to do show dbs in mongosh, nothing seems to be appearing
and when i use ffa_db and then show collections, no collection is here
How can i resend the Server Resourcepack when an Player leaves and joins again?
Currently its just using the old file thats already in the users server-resource-packs folder
public void onJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
String resourcePackUrl = "http://example.com/RP.zip";
player.setResourcePack(resourcePackUrl);
}
It’s in your account settings
for loop faster than lambda, correct?
for loop and lambda are uncomparable. Different things
for loop is fractionally faster than a Collection forEach
well my stopwatch cant time it so 🤷♂️
and its not recommended to use forEach at places which get called a lot
but profilers can
I mean they added forEach for a reason
that tells me neither where nor why
there are very few places I had to resort to using more optimized ways to access data
There is not much of a difference. Most times they compile to the same byte code
.forEach(collections::remove);
i used it to remove 0 - 2 elements from a set
arent lambdas encapsulated functions?
at times for each is fractionally faster, but often they are the same
wouldnt that mean that it cannot compile to the same as a for each?
yes
why cant it
cuz a function and a for loop are inherently different?
is this one of the 'you dumb compiler smarter' things?
not if all the lambda does is iterate
well I would say this is one of the "just assume the compiler fixes it for you" kinda things
unless you really wanna be sure
I have had no issues using either raw for loops or foreach so to me it doesnt matter
my arrays dont get that big and all the code is so horibly abstracted that another nested function call wont hurt
It really makes no difference in teh end. Its micro optimizations
wellllll some of the things im working with have micro-second tolerances
soooo i kinda need em
well then you shouldnt use lambdas in the first place ever
also what are you even making that has micro second tolerances in minecraft
welllll if you have lots of plugins and a large world and a lot of players... 50 ms minus processing time divided by 40 plugins leaves you with maybe 600 µs to do your processing
also sql is involved
thats always fun
lol
it is not micro optimizations
you shouldn't call that micro
Do you understand what a micro optimization is?
forEach is not made to slap at every part of the code
when the place is right, use it
a micro optimization is when you change your code to achieve the tiniest of performace increase. The difference between a for loop and a forEach is so minuscule that making those changes is a micro optimization (except in very specific cases).
Well you are wrong
Please point out where I'm wrong
its is not SO minuscule
first of all, it is visibly slower
second, using it too much makes your code unclean
when in the majority of cases it compiles to the exact same byte code it is minuscule.
but using it right, it makes it clean
no it does not
uh yes it does.
nuh uh
if you run it in a potato and in interpreter mode, sure
otherwise, not really, no
it is
benchmark?
i do, every day
high amount of players
using in wrong places
like on player join
or death
it sure has a visible problem
forEach shouldn't be used everywhere
this is all im saying
forEach is not going to make that run any slower than a regular for loop
some slap it all over their code
I mean, if you replace a Set#remove with that
obviously
but compared to a normal for-each, i have no idea how large that set would have to be
to be able to measure a difference
The difference is negligible (as I already said) unless it's a very specific circumstances. https://medium.com/@KosteRico/for-each-loop-vs-foreach-method-in-java-11-which-one-is-faster-8a5120c0c8c3
i mean, forEach is literally an enhanced for-loop
for is faster guys 🤓 I also use short and byte for most of my numbers to save memory
but but
it calls a lambda
checkmate
everyone knows those are black magic that is very slow

anything with a hash is pretty much identical

Yes it's not clean but we were discussing performance and you claiming changing between is not a micro optimization
anyway, on a different topic...
I'm about to do some location nonsense. What is the best way to check if an object is within a certain distance to another? Bounding box, then call location.squaredDistance?
read best = fast
distanceSquared
AABB checks can certainly help you a bit if you expect to most of the time not hit anything
tho, if you are gonna be constructing those instances a shit load of times
stick to distanceSquared
I mean, that would be terribly stupid
wait wdym with AABB then
Well you'd obviously use the getNearbyEntity stuff
given that that call can optimize based on chunks
so instead of all entity you'd only get back the entities in the nearby n chunks, depending on the radius
it is not so little
when it comes to big amounts
I s2g
you cannot reach the amounts where that would remotely matter
you get a single added lambda call which
might as well be as fast as the native method call
well actually ☝️ 🤓 I just ran a jmh benchmark over 10 trillion elements and forEach is slower

🥴
it might have mattered a bit more in java 8 but in 14+ it really doesn't
i doubt that considering our CPUs have at most 9GHZ
mine has much more GHZ
I made it at home
in my state of the art CPU lab
real
I need a quick tip, whats the best set implementation for small sets (<100 elements)
HashSet :kekw:
dunno actually
I have been using HashSet since that has been the obvious choice for me, but I wanna know f anyone uses something else
funnily enugh at small numbers ArrayList is actually really fast
but does it set
you could also make your own Array backed Set implementation (but really just use hashset lol)
HashSet
okay
and now something to keep the convo going while I am away
whats the best implemention of Collection?
i really dont like the pose of the guy in the gif
stickers are under-used
?paste
i has game logic task help what chance do you have to break everything?)) - https://paste.md-5.net/ucucisemov.js
bruh??
whats the problem
that aint it either man
you think of nocode
I give up too
anyways, whats the issue with the code you sent?