#help-development

1 messages · Page 716 of 1

small current
#

the attack works on a normal entity

tough mica
#

can i use a another method?

eternal oxide
#

I already linked it. go read

#

?morepdc

undone axleBOT
tough mica
#

ahh

#

okay

#

thx

small current
#

bump

pseudo hazel
#

probably because this is just for using, i.e. right clicking

small current
#

for example fake player

#

it gets sent

#

but idk why armor stand is doing this

pseudo hazel
#

idk then

#

does it work on boats?

small current
#

normal entities work

#

normal armor stand

#

it gets sent

#

packet armor stand

#

idk

#

should i call a method on the armorstand or something

pseudo hazel
#

i have no clue

#

never worked with packets

thin iris
#

the toxic gossip train

upper hazel
#

the easiest way for npc to understand which region the block being sold belongs to (worldGuard)

#

write to block data?

kind coral
#

you could to the block under them

slender elbow
#

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

agile hollow
#

how can i check a boolean in an if?

worldly ingot
#

what? lol

#

if (boolean)

agile hollow
#

if boolean si true or false

vapid anvil
#

yep

agile hollow
#

i tried with
if(boolean == false) but didn't work

tall dragon
#

??

vapid anvil
#

🤔

tall dragon
#

if (!boolean)

worldly ingot
#
boolean value = true;
if (value) { // Checks if true

}

if (!value) { // Checks if false

}```
#

This is some very basic Java

agile hollow
#

oh shoot i solved by myself

tall dragon
#

no u didnt xD

worldly ingot
#

Just as a note, you'll find basic information like this much quicker online with a quick Google search, "Java how to check boolean"

agile hollow
ancient plank
#

learn java, that's how you fix it

agile hollow
onyx fjord
#

is there a way to prevent adding HEALTH_BOOST potion effect clearing hearts?

#

seems like every time i add it extra hearts just reset

ancient plank
#

h

lost matrix
small current
#

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

lost matrix
#

Pmz with his non-mapped classes again aPES_Eyes

river oracle
#

Ancient versions ancient problems

lost matrix
river oracle
#

If you're on latest with obf maps you just have brain damage

lost matrix
#

He is on a newer version. Just refuses to use obf mappings for whatever reason.

small current
river oracle
#

Just use remapped 😭 it makes versions pretty much copy paste

lost matrix
small current
#

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

smoky oak
#

question. What does requirenonnull do

small current
smoky oak
#

cuz all it seems to do here is to be a wrapper

lost matrix
smoky oak
#

well yea but after that

#

ah

river oracle
#

It's basically preconditions but built in

hushed spindle
#

does anyone happen to know if removing a potion effect off an entity also calls the potion effect change event

#

or is that neglected

lost matrix
smoky oak
#

oh that reminds me

#

can someone explain @contract to me?

small current
lost matrix
# small current yes

I would try setting the metadata of the armorstand. Make sure its damageable and not a marker etc.

small current
#

ok

#

also

#

if i change into mappings

#

should i change the reflections?

river oracle
smoky oak
#

its always jetbrains or google aint it

lost matrix
# smoky oak can someone explain @contract to me?

(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.

small current
lost matrix
#

It can help with the static code analysis in your IDE

lilac dagger
#

can i make it so if i put a specific char, i don't get null?

lost matrix
small current
#

Ok

smoky oak
#

whats a qualifier value? The instance of the current class?
yea it is

small current
#

i guess using mappings might help with my mental problems

lost matrix
quaint mantle
#

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.

lilac dagger
#

that's sad

#

my ide keeps bothering me about 'this might be null'

#

even tho it isn't possible to get null

lost matrix
quaint mantle
#

NMS is so buggy

lilac dagger
#

new villagers ignore the goals

#

it uses a new ai for them

#

i think you need to edit that @quaint mantle

lost matrix
#

Ah yeah, they have that brain thingy

lilac dagger
#

but keep in mind the code quality is much better than before

#

so accessing it is a bit of a problem

#

tho not impossible

lost matrix
# lilac dagger

Those inspections are almost always right.
I think you are just missing a proper annotation.

lilac dagger
#

so not possible

small current
#

thats why i dont use mappings

#

this would prob take 4 years

lilac dagger
#

on maven it doesn't take long

small current
#

no my internet is shit

chrome beacon
#

Mappings will be stored in maven local when running BuildTools

#

so importing a project doesn't do a bunch of web lookups

small current
#

?whereami

small current
#

Ok done

tender shard
#

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

small current
#

at least im using mappings :(

tender shard
tender shard
#

no you'll need the obfuscated names for reflection

small current
#

so i should turn of the inspection?

tender shard
#

but why do you need to get a field's data by reflection?

small current
#

entity id

tender shard
#

why do you need a numeric ID?

#

why not just get the entity directly?

small current
#

i need to get the action

#

of an interact packet

#

which is private

#

i cant do that

tender shard
#

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?

small current
#

but

#

what about action

tender shard
#

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"?

small current
#

i need to check

#

if its right click

#

or left

tender shard
#
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

small current
#

the class is private

#

inner class

tender shard
#

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()"?

small current
tender shard
#

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

ripe moat
#

why doesn't the #setBanned exist anymore?

#

any other alternative as easy as that?

wide coyote
#

OfflinePlayer#ban

ripe moat
quaint mantle
#

Can someone guide me on setting NMS up?

#

Paper 1.18.2

eternal oxide
#

?whereami

quiet ice
#

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.

quaint mantle
#

im not apart of any divides. I just want my villager to work lmao

smoky oak
#

does InventoryAction.MOVE_TO_OTHER_INVENTORY count picking up and then dropping an item in a different inventory?

quaint mantle
#

thanks tho ill look into it

river oracle
#

If your using spigot api set it up as follows

#

?nms

river oracle
#

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

tender shard
#

(still need to run buildtools and use the remapped-mojang dependency from mavenLocal() )

smoky oak
carmine mica
#

gotta initialize it

smoky oak
#

yea but why isnt it null by default? cuz it needs a pointer?

lilac dagger
#

local values are stored in stack and not heap

#

therefore they need to be initialized

smoky oak
#

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?

echo basalt
#

it's just

smoky oak
#

ah it starts counting at the hotbar

#

not top down

echo basalt
#

yes

smoky oak
#

gotcha

lilac dagger
#

while (phase != getPhaseLifecycle().getWaiting() && phase != getPhaseLifecycle().getResetting()) {
phase.stop();
}

this

#

vs

orchid gazelle
#

tf is a PhaseLifecycle

lilac dagger
#

the set of phases a game can be in

opaque scarab
#

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;
}```
lilac dagger
#

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?

opaque scarab
# lilac dagger

I have that part disabled, so it should write the items even when null

lilac dagger
#

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

echo basalt
#

no

#

what the fuck

#

hardcoded phase enum puke

lilac dagger
#

it's not an enum

echo basalt
#

Just setup the arena before creating the game

#

and reset it after the game is done

lilac dagger
#

i have it all figured out don't worry 😄

echo basalt
#

I see a while loop

opaque scarab
echo basalt
#

pro tip

#

you can yeet the entire array

lilac dagger
#

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

opaque scarab
#

I'll try it

lilac dagger
#

try it

#

otherwise try to put the entire array

#

i think bukkitoutputstream has this as an option

sullen marlin
#

objectoutputstreams suck

lilac dagger
#

oh yeah

#

you can write the whole array

lilac dagger
#

it even fails at doing isSimilar after using it

sullen marlin
#

shouldnt do that for a configurationserializable when using the bukkit stream

lilac dagger
#

it did at some point at least, not sure now

opaque scarab
#

Wait there’s a BukkitObjectOutputStream#writeArray() ?

lilac dagger
#

do that

opaque scarab
#

It doesn’t show up

lilac dagger
#

writeObject then

#

it'll do the saving internally

opaque scarab
#

Oh writeObject works with arrays? It makes sense it would

lilac dagger
#

tho not sure how you get it properly

#

yes

#

writeArray is private

opaque scarab
#

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

lilac dagger
#

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

opaque scarab
lilac dagger
#

yes

opaque scarab
#

Alr

lilac dagger
#

i don't know if it'll work tho

#

it'll work

echo basalt
#

Is there a way to delete world data onDisable

#

plugins disable first

lilac dagger
#

not sure

opal carbon
#

i mean i think so

#

you can unload worlds

#

asterisk being default world

echo basalt
#

uhh not quite

opal carbon
#

i think

echo basalt
#

because load data on certain circumstances is saved after

opal carbon
#

at least in my experience

#

wdym

#

like what are you saying in that sentence

echo basalt
#

Basically i'm making temporary worlds

#

I want to unload and delete them on shutdown to not clutter the world folder

opal carbon
#

and why cant you just do that

#

im confused

echo basalt
#

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

opal carbon
echo basalt
#

I can't just schedule a task after 5 seconds because the bukkit scheduler can't be used on shutdown

opal carbon
#

yeah

echo basalt
#

And if I use futures or something the server will just die before the future is done

opal carbon
#

i get that

echo basalt
#

Lemme look at internals and see if I can prevent files from being created in the first place

opal carbon
#

store world solely in memory?

echo basalt
#

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

echo basalt
#

uhh

#

?mappings

undone axleBOT
opaque scarab
echo basalt
#

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

opaque scarab
# lilac dagger it'll work

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;
}```
lilac dagger
#

it must be the string encoding/decoding

opaque scarab
#

Yeah, honestly a byte array might be better for my needs anyone

#

*anyway

echo basalt
#

maybe your string is just broken

opaque scarab
#

I hate autocorrect

echo basalt
#

or your item array or whatev

opaque scarab
#

The item array is just player.getInventory().getContents(). For debug, I had it print out the items and it seemed fine

lilac dagger
#

maybe read the string before closing

#

but that can't be it if i think about it

quaint mantle
#

anyoen know

river oracle
echo basalt
#

good luck

#

p sure that'll just convert the byte[] into chars

#

unless I'm an idiot

echo basalt
#

I usually like serializing these separate but I'm pretty sure it does

opaque scarab
#

It contains everything in your local inventory

dense geyser
#

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

young knoll
#

I mean you can try just opening an anvil GUI and listening for clicks on the result

quaint mantle
young knoll
#

?di

undone axleBOT
river oracle
#

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)

quaint mantle
#

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

sullen marlin
#

Idk about "any issues" but it's designed so you can do that

final monolith
#

if i send a Player#hidePlayer, disconnects the target player and joins again, it will continue hidden?

shadow night
#

Last time I tried reconnecting showed the player

sullen marlin
#

No

shadow night
#

Weird

upper hazel
#

Who are information systems specialists? They need to learn assembly language 💀

#

?

#

and are they programmers?

sullen marlin
#

Could be anything, needs more context

jagged lantern
#

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

sullen marlin
#

Find what is setting bed spawn

#

Essentials maybe?

pseudo hazel
#

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

jagged lantern
#

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

jagged lantern
#

If spawn1 blocked goto: spawn2

upper hazel
#

in other words, system programmer

mellow pebble
#

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 ?

grizzled sable
#

do you want to read values from a config ?

mellow pebble
#

no no no it is text file and i want to just read it so i can get random line from it

pseudo hazel
#

well vanilla should respawn them i the overworld

#

idk if there is a way to have more than 1 spawnpoint

quaint mantle
#

can you implement multiple respawns?

upper hazel
#

i think so

hazy parrot
#

You can't

#

You can't get file from resources folder

#

You can only get inputstream

#

And you can read content from it

pseudo hazel
#

why not

#

oh cuz you cant write probably

grizzled sable
pseudo hazel
#

random spawns is probably not something they want

#

I mean if they had no plugin interfere, they wouldnt respawn in the end anyways

grizzled sable
#

then I unfortunately do not understand the plan exactly 😄

hazy parrot
chrome beacon
#

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

hazy parrot
#

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

chrome beacon
#

I believe you can

#

I'll see if I can check my code when I get hope

#

Do remind me or I will forget

tender shard
#

It treats any zip file like a regular FS

#

But it had a somewhat different name, idr

hybrid spoke
tender shard
#

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

lilac dagger
#

can you get all the files from within the plugin's jar from a folder?

tender shard
hybrid spoke
#

but i know what you mean

#

i used it for an updater, lemme check

lilac dagger
#

how tho, the class loader doesn't have methods for getting the jar file

tender shard
#

it has

#

SomeClass.class.getProtectionDomain().getCodeSource() gives you a CodeSource

#

you can then grab an URL using getLocation()

lilac dagger
#

oh, this

tender shard
#

then you can throw the InputStream of that into a ZipInputStream

lilac dagger
#

alr, thank you

tender shard
#

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

hybrid spoke
tender shard
lilac dagger
#

awesome, i'll check it out

small current
#

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

lost matrix
small current
#

And if it was a marker

#

The right click wouldnt work

#

This is annoying

golden garden
#

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.

lost matrix
frank kettle
#

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.

small current
#

remember its 0 to 8

frank kettle
#

event.getHotbarButton() is a thing indeed. let me see what does it to do and test things

#

ty

#

Nice it worked, thanks again!

small current
#

yw

lilac dagger
small current
#

@lilac dagger hey

#

have you ever listened for interact packets for armor stands?

#

for some reason the packet doesnt come for left click

lilac dagger
#

i do

#

they work

#

@small current

grizzled sable
echo basalt
#

Bros got no clue what a packet is

lost matrix
# small current have you ever listened for interact packets for armor stands?

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());
      }
    });
echo basalt
#

you don't even need an nms backbone

#

ig it makes it easier to spawn fast

small current
#

im injecting packet listeners

#

and 1.19.4

lost matrix
echo basalt
#

This is one of those times where you need to find out if your impl is dumb

#

or if mojang wrote some dumb code

small current
#

but

#

the same impl

echo basalt
#

protocol changes all the time

small current
#

with changed codes for 1.19.4

echo basalt
#

at this pace I'll just

#

?nocode

undone axleBOT
#

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.

small current
#

ok wait

granite olive
#

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?

small current
#

@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

echo basalt
#

fine

small current
#
        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

tender shard
hasty prawn
#

403

shadow night
#

403

hasty prawn
granite olive
#

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

eternal oxide
#

@tender shard ^

upbeat fog
#

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);
                 }
             }
         }
     }
lost matrix
#

Then only cancel the hit when the danage only if the minigame phase is active

upbeat fog
#

minigamePhase is a boolean that switches every x seconds

upbeat fog
lost matrix
#

If "NOT HIT" is always printed then minigamePhase is always true

upbeat fog
#

but the actual minigame phase works

#

it switches from normal to minigame and back after 10 seconds

lost matrix
#

What is the difference between minigamePhase and your "actual" minigame phase?

upbeat fog
#

when im talking about actual minigame phase, Im talking about what its supposed to do when the minigame phase is active

topaz cape
lost matrix
topaz cape
lost matrix
topaz cape
#

what the heck is 418

upbeat fog
# lost matrix Well, your ``minigamePhase`` is always true. About all we can say with the provi...

         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

eternal night
upbeat fog
#

I can see it in the chat

topaz cape
lost matrix
upbeat fog
#

no other similar variables

lost matrix
#

Sure, but is it the same instance?

upbeat fog
#

its in the same class

lost matrix
#

So?

#

Means there could be a thousand different variables then.

#

Every instance of a class has its own variables.

upbeat fog
#

I'll try printing out the minigamePhase boolean to actually see

lost matrix
#

Yep, should do that

upbeat fog
#

yeah its constantly true for some reason

#

even tho I set it true/false every swtich

lost matrix
#

But... in the same instance?

upbeat fog
#

wym by that

lost matrix
# upbeat fog 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

upbeat fog
#

oh you're talking about this one

upbeat fog
lost matrix
#

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.

upbeat fog
#

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

lost matrix
#

Sounds to me like you are using two completely different instances

upbeat fog
#

how can I make it one?

lost matrix
#

Dont create more than one?

echo basalt
#

learnjava moment

upbeat fog
#

bruh I just code in my freetime, Im still learning

#

yeah but thats the thing, I dont have any other minigamePhase instance 💀

lost matrix
#

What class is this in?

upbeat fog
#

In the same class

#

all of it

lost matrix
#

How many instances do you create of this class?

upbeat fog
#

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?

lost matrix
#

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

upbeat fog
lost matrix
#

How often do you call new Hellboss()?

lost matrix
#

Because every time you do that, you create a completely new Object with its
own methods and variables.

upbeat fog
#

I call it once in a task when the game is starting

lost matrix
#

And once in your onEnable to register it as a listener i assume?

upbeat fog
#

yes

lost matrix
#

Well... there you got. Problem solved.

upbeat fog
#

well yeah but I need to register the events, and I have to spawn the boss somehow

lost matrix
#

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.

upbeat fog
#

I already got a manager, so I'll just create the listener class

#

thanks, I'll give it a try

lost matrix
#

I feel like this is destined to fail until you properly understand what an instance is.

upbeat fog
#

Well at least I'll learn from it

small current
#

@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

lost matrix
#

That doesnt sound right+

small current
#

well

#

when i go INSIDE the armorstand

#

and stand on the same block as the entity

#

and click on it

#

it works

#

like this

small current
#

should i spawn 2 armorstands?

#

1 marker (the display)
1 interact

tender shard
tender shard
tender shard
lost matrix
tender shard
#

I haven't even found your message specifically after looking for it

#

did you hide it?

lost matrix
dire bluff
#

a quick question how to check if sender is console

tender shard
lost matrix
dire bluff
#

good

tender shard
#

or if it's instanceof ProxiedCommandSender and the initiator is the console

#

depends on the needs

#

ProxiedCommandSenders are annoying as hell to handle

dire bluff
#

i mean

#

i want to do if the player has permission or if tis console

tender shard
tender shard
#

the console has all OP permissions by default anyway

tender shard
#

and properly declared permissions are always given to all OPs

#

and console is OP

dire bluff
#

yea but it doesnt ender because its already a player sender

#

it check if player that sends has perm

lost matrix
#

Just call hasPermission or isOp() on the sender before casting

tender shard
#

cops hate this trick

tender shard
small current
#

god i hate 1.19

lost matrix
#

Use an interaction box

small current
#

what is it

lost matrix
#

You can no create empty boxes and detect if a player clicks on it

small current
#

how

lost matrix
#

But i can honestly not believe that the armor prevents you from attacking the armorstand

small current
#

try it

#

give armors with packets

eternal oxide
#

it would make no difference if it's by packets or a real ArmorStand. The client chooses what packets to send

lost matrix
#

Cant. My GPU is currently getting pounded by training a model.

eternal oxide
#

Thats impossible

small current
#

look

#

if i spawn

#

an armor stand

#

with packets

#

give armors

#

with packets

#

i cant attack it

#

unless i get inside it

lost matrix
#

Does the armor of a real armorstand block the interaction the same way?`
Check that pls.

eternal oxide
#

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

small current
#

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

dire bluff
#

can someone help me and tell me why when i send it from console doesnt work

lost matrix
# dire bluff

Yeah, as we told you before: Check the permission first and then cast to player later

small current
#

@lost matrix how to do the interaction box

lost matrix
dire bluff
#

hmm how to just ask for perm

small current
#

first of all im trying to see if it works without armor

small current
#

then perm

#

it shouldnt be in one statement

dire bluff
#

fk

#

i feel idiot now xD

#

it was so simple

#

if else

#

omg bro

small current
#

you will learn

dire bluff
#

i just burned out im coding for like 8 hours

#

:PPPPP

#

am bouta sleep

small current
#

@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

lost matrix
#

Use a player which always looks like you, for each person

small current
#

aint no way

#

it is not working for skeletons

#

bruuuh

#

😭 😭 😭 😭

#

its the same bug for skeletons

lost matrix
#

You must be doing something wrong

small current
#

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

lost matrix
#

Send metadata after equipment

small current
#

as i said

#

if i remove the armors

#

the bug is still there

grave kite
#

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();
lost matrix
small current
#

i might just jump of a window

#

why this thing not work :(

grave kite
small current
#

pdc?

lost matrix
#

^

grave kite
small current
#

?pdc

lost matrix
#

No, pdc was introduced in spigot back for version 1.14

grave kite
lost matrix
#

First of all: Thats all paper specific code

#

After that: Im not sure if custom properties get saved at all by the server

grave kite
#

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?

river oracle
#

NBT

lost matrix
small current
#

i cant find why it wont work

#

its just strange

quaint mantle
grave kite
#

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

small current
#

why a player npc got no problems with that

#

but any other npc i tried does

lost matrix
grave kite
lost matrix
chilly hearth
#

guys

#

iam getting a error

#

while running a command

#

?paste

undone axleBOT
chilly hearth
#

getting this error

remote swallow
#

you have a startup error

chilly hearth
#

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;
        }```
remote swallow
#

probably

chilly hearth
#

but i have vault in my plugin folder why sould it disable it

#

would*

remote swallow
#

check startup logs

chilly hearth
#

alr

#
[21:25:16] [Server thread/ERROR]: [Bosses2] [Bosses2] - Disabled due to no Vault dependency found!``` dam it disables whole plugin wow
small current
#

i am officialy insane

chilly hearth
#

daym

quaint mantle
#

itemdisplay teleport afterimage problem

small current
#

1.19.4 packet entities interact problem

quaint mantle
# lost matrix "node that the player is facing" What does that mean exactly.

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.

small current
#

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

opal juniper
quaint mantle
#

I would have to most likely change from A* to a depth search algorithm.

opal juniper
#

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

quaint mantle
#

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

chrome beacon
#

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

quaint mantle
#

What's the pro's of that compared to alpha beta pruning in a depth search?

chrome beacon
#

It's just a modifed version of A* that fits the MC environment well

quaint mantle
#

Ill take a look into it.

quaint mantle
#

This looks like it'll fit better.

#

Thus far

lilac dagger
#

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)

chrome beacon
#

Why do it directly in Intellij

lilac dagger
#

if i already commit and push, why not do this too?

quaint mantle
#
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

lilac dagger
#

hmm

#

so there is no intellij way of doing it

quaint mantle
#

You can do this in intellij

#

Open terminal

lilac dagger
#

i see

#

thank you

quaint mantle
#

If your talking about intellij's built in version control?

lilac dagger
#

yeah

quaint mantle
# lilac dagger 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.
lilac dagger
#

oh there is

quaint mantle
#

Its better practice to use terminal.

lilac dagger
#

how do you solve conflicts from terminal?

quaint mantle
#

Considering this can differ on IDE. It's better to learn how to do it with a terminal.

granite olive
#

Finding Namespacedkey of datapack loot-table

quaint mantle
#

Does anyone know if the NPC object in citizens API is serializable?

chrome beacon
#

Not sure

#

You can take a look at the source on their Github page

lilac dagger
#

yeah, better look

quaint mantle
#

Thanks guys

lilac dagger
#

even citizens has messy code

chrome beacon
#

Feel free to PR

lilac dagger
#

nah, it was mostly to myself

pseudo hazel
#

every decently sized codebase has messy code

lilac dagger
#

i have messy code too, it makes me feel better about this

quaint mantle
#

Clean code does not exist

#

^

#

Organization is normally not a trait of an engineer.

#

Unless you dont have tism

lilac dagger
#

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

quaint mantle
#

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.

lilac dagger
#

yeah, ik

#

tho it did a good job once changing a piece of code from recursive to a while loop

quaint mantle
#

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.

lilac dagger
#

oof

#

yeah, don't trust gpt noted

pseudo hazel
#

I use it to write simple stuff because im too lazy to get copilot

lilac dagger
#

i should try copilot but i don't wanna give my whole project to it yet

pseudo hazel
#

if its on github , copilot already has it

lilac dagger
#

it's private

pseudo hazel
#

doesnt matter to copilot xD

lilac dagger
#

i'm sorry what?

quaint mantle
#

@lilac dagger It finally converged tho

lilac dagger
#

nicee

#

making a snake algorithm is so hard

pseudo hazel
#

I mean do you really trust github

quaint mantle
#

It's a NN

#

Not a algorithm

lilac dagger
#

i know

quaint mantle
#

Well

#

NN is algorithm

lilac dagger
#

i'm just saying

quaint mantle
#

but not like a pathfinding algorithm in that sense

lilac dagger
#

does it know how to optimize path yet?

#

like once it grows to a certain size it tries to stay close to the tail

quaint mantle
#

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

lilac dagger
#

that's really cool

#

yeah

#

so that answers it

quaint mantle
#

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

lilac dagger
#

i'd love to make something myself too

quaint mantle
lilac dagger
#

in ml

#

sure

quaint mantle
#

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.

lilac dagger
#

that's super cool

quaint mantle
lilac dagger
#

i don't have this option

small current
#

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

dark harness
#

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);
    }
quaint mantle
smoky oak
#

for loop faster than lambda, correct?

eternal oxide
#

for loop and lambda are uncomparable. Different things

smoky oak
#

i meant in collection iteration

#

shouldve mentioned that lol

eternal oxide
#

for loop is fractionally faster than a Collection forEach

small current
#

not fractionally

#

it is a lot faster

pseudo hazel
#

well my stopwatch cant time it so 🤷‍♂️

small current
#

and its not recommended to use forEach at places which get called a lot

small current
smoky oak
#

wym

#

why wouldnt you if its faster

pseudo hazel
#

I mean they added forEach for a reason

small current
#

forEach is a really clean code

#

and at places

#

you can use it

smoky oak
#

that tells me neither where nor why

pseudo hazel
#

there are very few places I had to resort to using more optimized ways to access data

eternal oxide
#

There is not much of a difference. Most times they compile to the same byte code

small current
#

.forEach(collections::remove);

i used it to remove 0 - 2 elements from a set

smoky oak
#

arent lambdas encapsulated functions?

eternal oxide
#

at times for each is fractionally faster, but often they are the same

smoky oak
#

wouldnt that mean that it cannot compile to the same as a for each?

pseudo hazel
#

why cant it

smoky oak
#

cuz a function and a for loop are inherently different?

#

is this one of the 'you dumb compiler smarter' things?

pseudo hazel
#

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

eternal oxide
#

It really makes no difference in teh end. Its micro optimizations

smoky oak
#

wellllll some of the things im working with have micro-second tolerances

#

soooo i kinda need em

pseudo hazel
#

well then you shouldnt use lambdas in the first place ever

#

also what are you even making that has micro second tolerances in minecraft

smoky oak
#

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

pseudo hazel
#

oh

#

well than that will be your slowest operation anyways

#

probably

smoky oak
#

true lol

#

at least the server im forced to use is in the same network :/

pseudo hazel
#

lol

small current
#

you shouldn't call that micro

eternal oxide
#

Do you understand what a micro optimization is?

small current
#

forEach is not made to slap at every part of the code

#

when the place is right, use it

eternal oxide
#

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).

eternal oxide
#

Please point out where I'm wrong

small current
#

its is not SO minuscule

#

first of all, it is visibly slower

#

second, using it too much makes your code unclean

eternal oxide
#

when in the majority of cases it compiles to the exact same byte code it is minuscule.

small current
#

but using it right, it makes it clean

eternal oxide
#

uh yes it does.

small current
#

nuh uh

slender elbow
#

otherwise, not really, no

small current
slender elbow
#

benchmark?

small current
#

it matters where you use it

#

try yourself

slender elbow
#

i do, every day

small current
#

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

slender elbow
#

forEach is not going to make that run any slower than a regular for loop

small current
#

some slap it all over their code

eternal night
#

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

eternal oxide
slender elbow
#

i mean, forEach is literally an enhanced for-loop

river oracle
#

for is faster guys 🤓 I also use short and byte for most of my numbers to save memory

eternal night
#

but but

#

it calls a lambda

#

checkmate

#

everyone knows those are black magic that is very slow NODDERS Kappa

eternal oxide
#

anything with a hash is pretty much identical

small current
#

im saying dont use forEach everywhere

#

its wrong

#

its not clean

eternal night
small current
#

and for does the job

#

i saw codes with no for loop

eternal oxide
#

Yes it's not clean but we were discussing performance and you claiming changing between is not a micro optimization

smoky oak
#

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

eternal oxide
#

distanceSquared

eternal night
#

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

smoky oak
#

i mean

#

I'd rather NOT calculate distance to every entity currently loaded

eternal night
#

I mean, that would be terribly stupid

smoky oak
#

wait wdym with AABB then

eternal night
#

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

small current
#

when it comes to big amounts

eternal night
#

I s2g

slender elbow
#

mate

#

forEach is literally a for loop

eternal night
#

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

river oracle
eternal night
dry hazel
#

🥴

slender elbow
#

it might have mattered a bit more in java 8 but in 14+ it really doesn't

smoky oak
river oracle
#

I made it at home

#

in my state of the art CPU lab

opal carbon
#

real

pseudo hazel
#

I need a quick tip, whats the best set implementation for small sets (<100 elements)

pseudo hazel
#

I have been using HashSet since that has been the obvious choice for me, but I wanna know f anyone uses something else

river oracle
smoky oak
#

eh

#

i use the simplest collection for the job unless its a truly massive list

pseudo hazel
#

but does it set

river oracle
#

you could also make your own Array backed Set implementation (but really just use hashset lol)

pseudo hazel
#

okay

#

and now something to keep the convo going while I am away

#

whats the best implemention of Collection?

smoky oak
#

i really dont like the pose of the guy in the gif

river oracle
pseudo hazel
#

stickers are under-used

upper hazel
#

?paste

undone axleBOT
valid burrow
upper hazel
smoky oak
#

?issue

#

?explain

#

?error

#

lright i give up

upper hazel
#

bruh??

smoky oak
#

whats the problem

pseudo hazel
#

?problem

#

hmm

smoky oak
#

that aint it either man

pseudo hazel
#

?code

#

nope

smoky oak
#

you think of nocode

pseudo hazel
#

I give up too

smoky oak
#

but code was provided

#

just not the problem

pseudo hazel
upper hazel
#

the problem is that threads are my weakness)

#

are there any contradictions in the code