#help-development

1 messages Β· Page 1076 of 1

sterile breach
#

is there a packet to allow player trough block? I tried to simulate spectacting gamemode I am trying to reproducte gamemode spectacting (for some reasons) I've more or less rebuilt but I can't go through walls and there doesn't seem to be this kind of parameter in the https://wiki.vg/protocol

runic pine
#

no

#

i need a enderchest plugin without this method

#

because i want edit the sizeenderchest

#

but

#

have a dup with freecam

#

idk how fix

tardy delta
#

just find a yt video that exploits it

grim hound
#

Does bukkit still create a new Thread for each join? The one used in AsyncPlayerPreLoginEvent

quaint mantle
#

How can u have a block display entity with a chest where the chest has the open state

inner mulch
acoustic pendant
#

Hey, could someone help me trying to solve this method?
I'm trying to calculate the maximum possible upgrades depending on the balance of the player.
The level price is calculated like this: initialPrice (100) + ((level) * increasePrice (150)) (Summing all levels)

    public Result calculateMaxUpgrades(Player player, CustomEnchant enchant, ItemStack item) {
        double initialPrice = getNextLevelPrice(item, enchant);
        double firstBalance = plugin.getEssenceManager().getEssence(player);
        int itemLevel = getEnchantmentLevel(item, enchant);


        int upgrades = 0;
        double currentPrice = initialPrice;
        double balance = firstBalance;
        int level = itemLevel;

        while (balance >= currentPrice) {
            if (itemLevel + upgrades >= enchant.getMaxLevel())
                break;
            upgrades++;
            balance = balance - getLevelPrice(enchant, level);
            currentPrice = currentPrice + getLevelPrice(enchant, level);
            level++;
        }
        return new Result(upgrades, currentPrice);
    }```
#

I've tried many different ways but cannot solve this mf

#

As you can see in chat I have balance for more levels but it gets stuck

grim hound
lost matrix
lost matrix
# acoustic pendant Hey, could someone help me trying to solve this method? I'm trying to calculate...

Eyeballed this one. lmk if it works:

  public Result calculateMaxUpgrades(Player player, CustomEnchant enchant, ItemStack item) {
    double balance = plugin.getEssenceManager().getEssence(player);
    double initialPrice = getNextLevelPrice(item, enchant);

    if(balance < initialPrice) {
      return Result.EMPTY;
    }

    int itemLevel = getEnchantmentLevel(item, enchant);
    int maxLevel = enchant.getMaxLevel();

    if(itemLevel >= enchant.getMaxLevel()) {
      return Result.EMPTY;
    }

    int upgrades = 0;
    double currentPrice = initialPrice;

    while(balance >= currentPrice && itemLevel + upgrades < maxLevel) {
      upgrades++;
      currentPrice += getLevelPrice(item, enchant, itemLevel + upgrades);
    }
    
    return new Result(upgrades, currentPrice);
  }
#

Not sure if itemLevel + upgrades < maxLevel or itemLevel + upgrades <= maxLevel
Brain is baked from exams

acoustic pendant
#

let me check

lost matrix
#
public static final Result EMTPY = new Result(0, 0);
acoustic pendant
#

yeah yeah

lost matrix
#

^^

acoustic pendant
#

thx

acoustic pendant
#

I'll try it now

#

But it should work

acoustic pendant
#

I have this method too

#

This is just when enchanting the item to get the price

#

Look at the chat

#

Like it is almost the same

#

but NOT the same when it should be

lost matrix
#

Hm

acoustic pendant
acoustic pendant
lost matrix
#
  public double getPrice(int currentLevel, int levels, CustomEnchant enchant) {
    double price = 0D;
    for(int i = 0; i < levels; i++) {
      price += getLevelPrice(enchant, currentLevel + i);
    }
    return price;
  }
quaint mantle
#

Is it possible to have a block display entity, with a chest that has an open state?

acoustic pendant
#

smart way lol

lost matrix
lost matrix
acoustic pendant
lost matrix
#

Is it too low or too high?

acoustic pendant
#

I think high

#

<= levlels?

lost matrix
#

🀨

quaint mantle
lost matrix
acoustic pendant
#

oh true

quaint mantle
#

or those dont even have an open state I think nvm

acoustic pendant
#

+6 for 2850.0!

#

why 😭

lost matrix
#

I dont know, i have nothing i can base this price on

acoustic pendant
lost matrix
#

Uhm

#

Sleep

acoustic pendant
#

xD

lost matrix
#

Thats why im gonna head out now ^^

#

Sry, and bye

acoustic pendant
#

Well, gl

acoustic pendant
#

This was the solve

#

nvm

#

This was the solve

hazy parrot
#

wasn't there some button on intellij to download all docs/sources ?

chrome beacon
#

yes

#

Open the maven/gradle tab

hazy parrot
#

yeah im looking there can't seem to find it

chrome beacon
hazy parrot
#

fml

#

thanks

tardy delta
#

double shift and download sources

inner mulch
#

Can the tablist or scoreboard be changed async ?

gray geyser
#

Any idea as to why I can't access import org.bukkit.Material;?

I'm using Maven and Java16.
Here's my dependencies:<dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.20.6-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies>

echo basalt
#

good ol' 1.20.6

#

try ItemType

gray geyser
# echo basalt try ItemType

🀦Thank you very much, I'm following a mini-course on youtube to learn it and this is the only hitch so far.

chrome beacon
#

The Material class still exists

#

For 1.20.6 you should be using Java 21

#

The material class won't load properly with Java 16

#

@gray geyser ^^

young knoll
#

Don’t use ItemType

#

It’s still internal

gray geyser
#

Ok, I've changed to Java21: <properties> <java.version>21</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>

and my dependencies remain the same: <dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.20.6-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies>

yet i'm still unable to import org.bukkit.Material. any ideas?

chrome beacon
#

Did you set jdk 21 in project settings as well?

gray geyser
dry hazel
#

is your IJ up to date?

gray geyser
chrome beacon
#

also language level should be set to 21

gray geyser
#

19 is the highest

chrome beacon
#

?

gray geyser
#

do you mean SDK?

chrome beacon
gray geyser
chrome beacon
#

Are you sure Intellij is up to date

gray geyser
quiet ice
#

that must be really out of date then

gray geyser
chrome beacon
#

._.

#

The first thing I told you was to update it

gray geyser
#

I did update it

#

It must be going one version at a time

#

Because I checked for another update and it's updated again

quiet ice
#

Well J19 is "only" 2 years out of date

gray geyser
#

Good as new

quiet ice
#

A bit strange, I could swear it was older than that though

gray geyser
#

Gotta love IntelliJ taking 10 minutes to update

#

Guess I should've updated 2 years ago

chrome beacon
#

Could just grab the installer again

#

and reinstall

gray geyser
#

Eh it's finished now

#

Oh wow language level 22

#

this should work then?

#

And it works, my bad all 😭

young knoll
#

What is it about enums and java 21 that makes IntelliJ upset

young knoll
#

Idk that’s why I’m asking

chrome beacon
#

maybe smth in the bytecode changed

#

πŸ€·β€β™‚οΈ

tardy delta
#

just an intellij bug

eternal night
cyan silo
#

Hello, Ive been watching tutorials on how to make a currency diamonds instead of dolars on my mc server. But I am lost and have no idea how to do it, so I will try a shot here, if anyone has any suggestions. Thank you

young knoll
eternal night
#

java ehhh, 17? idk. Something shat in a $values method into the bytecode

young knoll
#

I see

rough ibex
eternal night
#

ye

#

hmm

#

that would actually imply they fail somewhere else if it is only on java 21

#

java 15 changed the bytecode layout for the values method

#

but w/e

#

update your IDEs people BONK

rough ibex
#

seems like whatever it is, it's fixed

mortal hare
#

are there any workarounds for shading java 21 classes with gradle?

#

shadow plugin seems to be stuck on java 17

eternal night
#

change the shadow plugin ^

pearl turret
#

someone explain why don't work windcharge explosion range?

eternal night
#

there is a somewhat popular fork

mortal hare
#

why is it even a fork still

#

why maintainers havent merged it

dawn flower
#

best way to make someone glow with color?

remote swallow
#

because then they still have to keep up with stuff

#

iirc its becoming a gradleℒ️ managed thing

eternal night
#

the shadow maintainer no longer has time for hte project

#

it has not yet ℒ️

remote swallow
#

ref

eternal night
#

there is an option issue to finally fucking move it

mortal hare
#

oh

#

so project is kinda dead

#

in this repo?

eternal night
#

yea

mortal hare
#

sad

remote swallow
eternal night
#

Tbf, johnrengelman absolute legend doing something as important as shading for so long

worldly ingot
#

I will take care of the trademark grant when I am black from vacation
Must really want a good tan

remote swallow
#

i saw that and it made me laugh

eternal night
#

FYI, I will be off for the next month

#

good old month long vaca

#

couldn't be USA

remote swallow
#

its not august yet

young knoll
#

Month long vacation?

#

What is he, rich

remote swallow
#

nah just european

eternal night
chrome beacon
pearl turret
#

like this?

brisk estuary
#

hey guys, are you able to compile any plugin that uses spigot? i think there's a problem with the repositories, it's taking too long to compile

#

after 6 min mvn clean package finally finished

#

but with this warning: Could not transfer metadata org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT/maven-metadata.xml from/to sonatype (https://oss.sonatype.org/content/groups/public/): status code: 502, reason phrase: Bad Gateway (502) org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT/maven-metadata.xml failed to transfer from https://oss.sonatype.org/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of sonatype has elapsed or updates are forced. Original error: Could not transfer metadata org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT/maven-metadata.xml from/to sonatype (https://oss.sonatype.org/content/groups/public/): status code: 502, reason phrase: Bad Gateway (502)

bleak reef
#

I think its down to some extent

eternal oxide
#
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>```
brisk estuary
bleak reef
#

It won't compile with that in there at the minute

opal gazelle
#

I am so confused. org.bukkit.Material is not recognized, but it is these when i check in my dependencies. Here's a picture showing the Material class and the error

eternal oxide
#

update IJ

pearl turret
#

help me how i increase explosion range of wind charge?

#

or explosion force

#

something like

runic pine
#

player#getuuid#hashcode remains even if the server restarts?

echo basalt
#

proper hash collision chance

opal gazelle
pseudo hazel
#

cuz you had an onld version of intellij that probably wasn't compatible with all the latest minecraft dev stuff

young knoll
#

I mean, the uuid itself will remain after the server restarts

#

And has a much lower collision chance

pseudo hazel
#

yeah a player uuid doesnt care about your server, its always gonna be unique for every player, thats what mojang kinda needs

opal gazelle
#

Is there any way to disable the animation of chests opening when in vanish?

undone axleBOT
quiet hearth
#

how do I get a sword's damage?

hard radish
#

it would be easier if you do packets but packets are a pain for dev

drowsy helm
#

will be GENERIC_ATTACK_DAMAGE i think

young knoll
#

Unless it only has default attributes

#

Plus you gotta account for sharpness

hard radish
#

?paste

undone axleBOT
hard radish
#

this error pops up when i join my localhost and ends up timed out

cold pawn
#

Does anyone have any idea what causes this?

pseudo hazel
#

wtf am I even looking at

#

whats a

cold pawn
#

its the PacketPlayOutScorebaordTeam packet, but its obfuscated thus why I'm asking what causes the error message

pseudo hazel
#

why is it obfuscated, does it not have mojang mappings

cold pawn
#

no it doesn't, was using protocollib for most of my packet work, so I never needed it πŸ˜…

#

but i keep getting that error in protocollib

#

so im wondering what the issue is

pseudo hazel
#

how are you sending the packet

#

there is probably some mistake in there

cold pawn
#

It worked in 1.20.2 but not 1.20.6

pseudo hazel
#

hmm

#

idk

#

never used protocollib

rough ibex
#

half the world has

#

bring up a diff

#

decompile .2 and .6, side by side

pseudo hazel
#

yeah im on the other half I guess

flat lark
#
    public void SetSkin(Player player) {
        CraftPlayer craftPlayer = (CraftPlayer)player;
        GameProfile profile = craftPlayer.getProfile();
        ServerGamePacketListenerImpl connection = craftPlayer.getHandle().connection;

        connection.sendPacket(new ClientboundPlayerInfoRemovePacket(Collections.singletonList(player.getUniqueId())));

        int randomSkin = new Random().nextInt(skins.size());
        Property property = new Property("textures", skins.get(randomSkin));

        plugin.getLogger().log(Level.WARNING, skins.get(randomSkin).toString());

        profile.getProperties().removeAll("textures");
        profile.getProperties().put("textures", property);

        connection.sendPacket(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ((CraftPlayer)player).getHandle()));
    }

After using this method I disappear from the tab but my skin dosent change nor do I get any errors. If anybody could help me I'd apprentice it.
MC Ver: 1.21

cold pawn
humble tulip
#

?paste

undone axleBOT
rough ibex
#

and youre getting the illegalstateexc

hard radish
hollow sage
#

Any plugin developers in here ????

eternal oxide
#

nope

rough ibex
#

we're all tumbleweeds

cold pawn
drowsy helm
#

yeah, i skript

rough ibex
#

ie. does it work if someone else sees you

#

check how other plugins do it

#

I just depend on skinsrestorer because I am lazy.

hollow sage
drowsy helm
#

whats your question just ask it

humble tulip
#

https://paste.md-5.net/ofajihuwin.php I'm getting this error when i try to enable respawn anchors in the end. The error shows when i try to tp into the world and it kicks me from the server.

Here is my code: https://paste.md-5.net/paduwaboxe.java

What i'm trying to do is enable respawn anchors in the end. This is just to see if i am able to get it to work. Anyone knows why I get the error?

rough ibex
#

I don't think you can do this, sorry

#

ensure it does work with the nether

#

in your own code

#

if not, maybe there's some sort of registry desync issue

humble tulip
#

I will see

rough ibex
#

yes with your own code

#

to see if its your code specifically

humble tulip
#

same error when i try to disable in nether

hollow sage
#

@setrooper

#

@alpine urchin

#

See dms

pearl turret
#

WHYY wind charge explosion force not increase ................

rough ibex
#

see if theres a packet for that

humble tulip
rough ibex
#

send more registry data?

humble tulip
#

seems like if the client knows the entry which will be the_nether

#

it doesnt send the data

#

or something

#

i'll see if i can change the name

rough ibex
#

well the problem is the client gets the packet and doesnt understand what dimension it means

hollow sage
rough ibex
#

yes

#

what do you want

hollow sage
#

Can you compile a code for me

rough ibex
#

why?

#

what code

hollow sage
#

It's a plugin

#

Economy plugin

rough ibex
#

okay

pseudo hazel
#

do it yourself?

rough ibex
#

yeah

hollow sage
#

Idk how

pseudo hazel
#

or ask gpt to do it for you

rough ibex
#

i am not executing arbitrary code

rough ibex
rough ibex
pseudo hazel
#

thats probably how they got the code in the first place

young knoll
#

Can chat gpt compile now

hollow sage
rough ibex
#

no

pseudo hazel
#

I mean probably wont take long before it can

rough ibex
#

in right hand menu click the V

#

it says Maven

#

go to package

hollow sage
#

Bro you have to make many files

young knoll
#

I know it can run python code now

hollow sage
#

Idk hownto use intellJ idea

young knoll
#

Slap javac in there and call it gpt 5

pseudo hazel
#

exactly

#

running python code means it must some kind of compiling

#

unless its just guessing and not running anything

drowsy helm
#

press the big m

#

then type package

flat lark
hollow sage
#

EclipseEconomy/
β”œβ”€β”€ pom.xml
β”œβ”€β”€ src/
β”‚ └── main/
β”‚ β”œβ”€β”€ java/
β”‚ β”‚ └── com/
β”‚ β”‚ └── eclipsemc/
β”‚ β”‚ └── economyplugin/
β”‚ β”‚ β”œβ”€β”€ Main.java
β”‚ β”‚ β”œβ”€β”€ BalanceCommand.java
β”‚ β”‚ β”œβ”€β”€ PayCommand.java
β”‚ β”‚ β”œβ”€β”€ TopBalanceCommand.java
β”‚ β”‚ β”œβ”€β”€ BankCommand.java
β”‚ β”‚ β”œβ”€β”€ InventoryListener.java
β”‚ β”‚ └── BalancePlaceholder.java
β”‚ └── resources/
β”‚ └── plugin.yml
└── config.yml

#

I want it in this format

pseudo hazel
#

its more effort to try and get someone to compile your mysterious plugin then it is to learn intellij enough to do it yourself

young knoll
rough ibex
flat lark
#

I'd rather not

rough ibex
#

or are you just testing yourself

#

then see other plugins

flat lark
#

I just need something really simple.

flat lark
rough ibex
#

what do they do

flat lark
#

I check multiple and they have some libary they used.

rough ibex
#

which

flat lark
#

CustomSkinManager, Gysier Skin Manager or something

hollow sage
rough ibex
pseudo hazel
#

then learn it

hollow sage
rough ibex
#

show?

hollow sage
#

Show what

young knoll
#

Presumably the screenshot

humble tulip
#

There was a website where i could view what methods are what when converting from mojang mappings to obfuscated names

#

i forgot what it was

worldly ice
eternal oxide
#

?mappings

undone axleBOT
humble tulip
#

tyyy

hard socket
#

how can I hide the player completly

#

armor and held item and the plaer it self

eager turtle
hard socket
#

will this make the armor work??

eager turtle
#

yeah armor will still block the same amount

eternal oxide
#

just use teh hidePlayer in the API

eager turtle
#

oh mine must be old

#

or im just silly

hard socket
#

or does it?

eternal oxide
#

it always works

eager turtle
#

does anyone have a good method for giving user input during onEnable?

eternal oxide
#

just loop over all players and hide the player from them

kind hatch
#

wut

eager turtle
#

I am trying to use a scanner or registering a command but its extremely laggy

#

and not getting input right

kind hatch
#

Why

#

Why are you doing that?

eager turtle
#

when its connecting to my database I want to ensure that the database schema matches the schema i have defined in my code. and if it doesnt it prompts me to create a new table, rename a table, create new columns, etc

#

just dont wana manually keep the schemas the same

keen charm
#

Not sure if your issue has been resolved

#

But you need to send a respawn packet for the player itself

#

And do hidePlayer & showPlayer for the rest of the players

#

And it's not only respawn packet

#

You have to add them to player list since you removed the player etc.

torn shuttle
#

and we're not even close to done

#

send help

flat lark
flat lark
humble tulip
#

Ok follow up to this.
Now I have registered the custom dimension type in which respawn anchors are enabled in the overworld. I no longer get the error. However, the new issue I'm facing is a weird one.

If i reload the plugin with the player online and read the value of the world's dimension type, it's respawnAnchorWorks boolean is true.
If i then leave and rejoin or die, this changes to false. Any suggestions?

My code:
https://paste.md-5.net/onikakivey.java

quaint mantle
#

which UTF does mc use?

#

16?

humble tulip
#

as u can see respawnAnchorWorks is true before i leave and then false when i rejoin

hard radish
#

is there a way to make holograms not turn dark color when player is behind a wall?

drowsy helm
hard radish
#

is text hologram via armor stand ok?

drowsy helm
hard radish
#

or is it true?

humble tulip
#

i think so

#

what is even setting it back to default?

wet breach
#

Then invoke a world save if you want it saved.

humble tulip
#

would that actually?

wet breach
#

There is some things that dont stay loaded if there is 0 players on

#

Hence it being loaded during a reload but not if you disconnect. Fairly certain if you had 2 players on and one disconnected and rejoined it would still persist

humble tulip
#

Where is my custom dimension saved

wet breach
humble tulip
#

I think it's very hacky what i did

#

and i dont think this is gonna work

#

but i'll test it anyyway

wet breach
#

But you need to account for when no players and you should never assume your data is always present

#

So you should implement some checks to ensure its still there and if not fix it

humble tulip
wet breach
#

Yes i looked at it

humble tulip
#

ah ok

#

gonna build and test with 2 players

wet breach
#

I cant look at it with an ide currently at work

humble tulip
#

no probs

#

ran into some issues with testing

#

will try later and let you know

flat lark
#
    public void SetSkin(Player player) {
        protocolManager = ProtocolLibrary.getProtocolManager();

        PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);

        WrappedGameProfile profile = new WrappedGameProfile(player.getUniqueId(), player.getName());

        int randomSkin = new Random().nextInt(skins.size());

        WrappedSignedProperty texture = new WrappedSignedProperty();

        profile.getProperties().put("textures", texture);


        protocolManager.sendServerPacket(player, packet);
    }

I am now using ProtocolLib. I just need help applying the skin. I have a list of strings which are a mineskin url.

blazing robin
#

hey guys is ConfigurationSerializable can saved float type? 'cause when I tried it

@AllArgsConstructor
@Getter
@Setter
public class RegionSoundImpl implements RegionSound {

    private String name;
    private float volume;
    private float pitch;
    private int length;
    private boolean isRepeat;

    @NotNull
    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> result = new HashMap<>();
        result.put("name", name);
        result.put("volume", volume);
        result.put("pitch", pitch);
        result.put("length", length);
        result.put("isRepeat", isRepeat);
        return result;
    }

    public static RegionSoundImpl deserialize(Map<String, Object> data) {
        String soundName = (String) data.get("name");
        float volume = (float) data.get("volume");
        float pitch = (float) data.get("pitch");
        int length = (int) data.get("length");
        boolean isRepeat = (boolean) data.get("isRepeat");
        return new RegionSoundImpl(soundName, volume, pitch, length, isRepeat);
    }
}

error said :

java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Float (java.lang.Double and java.lang.Float are in module java.base of loader 'bootstrap')```
echo basalt
#

I'd suggest using doubles for that

#

It's a bit wonky because collections can't hold primitives

#

So it gets saved as a Double

blazing robin
#

oh, got it thank you

echo basalt
#

And when you deserialize, it autocasts to the primitive double

#

You're casting it before this autocast is done, which means it's trying to convert Double to Float

sterile breach
#

its possible to execute something in main thread from another thread?

shadow night
#

using the scheduler

sly seal
#

Hi!, im looking for developer if anyone is interested just mention me !

shadow night
#

?services

undone axleBOT
brisk estuary
alpine urchin
#

guys

#

we dont need ai for everything

#

@young knoll use a compiler lmao

#

β€œcan AI download minecraft now?”

modern ridge
#

hi, how can i getHolder as EnderChest when getClickedInventory?

#

it returned as null

remote swallow
#

a platapus

drowsy helm
chrome beacon
#

^^

#

Was about to say

drowsy helm
#

oh wait no im wrong

chrome beacon
#

?

drowsy helm
chrome beacon
#

what about it?

drowsy helm
#

oh nvm enderchest isn't listed lol

#

ignore me i just woke up

paper viper
#

Does anyone have a Gson adapter that I could use to serialize and deserialize ItemStacks ☠️ currently using Base64 with BukkitObjectOutputStream but it’s super outdated.

modern ridge
drowsy helm
#

just sounds like your system isn't designed correctly

modern ridge
#

well im just make sword handler and it affected to other one

drowsy helm
#

yeah how are you keeping track of your custom inventories though

modern ridge
#

the listener is not based on any GUI as well

chrome beacon
#

Don't use the holder for your GUI

modern ridge
#

im just want make it listener on Chest and EnderChest only

chrome beacon
#

?gui

paper viper
chrome beacon
#

it's safe to use for local storage

modern ridge
drowsy helm
#

public class InventoryManager{
    private final Map<UUID, CustomInventory> inventoryMap = new HashMap<>();
    
    public void openInventory(Player player, CustomInventory customInventory){
        inventoryMap.put(player.getUniqueId(), customInventory);
    }
    
    @EventHandler
    public void onClose(InventoryCloseEvent event){
        inventoryMap.remove(event.getPlayer().getUniqueId());
    }
}

public abstract class CustomInventory{
    public abstract Inventory getInventory();
}```

this should ideally be the way you do it
#

but yeah check out that turtorial olivo sent, virtually the same thing

modern ridge
chrome beacon
#

?

modern ridge
#
@EventHandler
    public void onSwordEnchantInChest(InventoryOpenEvent event) {
        Player player = (Player) event.getView().getPlayer();
        IArena arena = Arena.getArenaByPlayer(player);
        if (arena == null || BedWars.getAPI().getTeamUpgradesUtil().isWatchingGUI(player)) {
            return;
        }
        // Check if player is watching a shop GUI
        if (ShopCategory.categoryViewers.contains(player.getUniqueId())) {
            return;
        }
        // Check if player is watching quick buy menu
        if (ShopIndex.indexViewers.contains(player.getUniqueId())) {
            return;
        }
        org.bukkit.inventory.Inventory inventory = event.getInventory();
        if (inventory == null) return;
        InventoryHolder holder = event.getInventory().getHolder();
        Bukkit.getLogger().info("Clicked Inventory Type: " + event.getInventory().getType());
        Bukkit.getLogger().info("Inventory Holder: " + (holder != null ? holder.getClass().getName() : "null"));
        if (!(holder instanceof CraftChest)){
            return;
        }
        InventoryType inventoryType = inventory.getType();
        if (inventoryType == InventoryType.ENDER_CHEST || inventoryType == InventoryType.CHEST) {
            for (ItemStack item : inventory.getContents()) {
                if (item != null && VersionCommon.api.getVersionSupport().isSword(item)) {
                    ItemMeta im = item.getItemMeta();
                    ITeam team = arena.getTeam(player);
                    if (team != null) {
                        for (TeamEnchant e : team.getSwordsEnchantments()) {
                            im.addEnchant(e.getEnchantment(), e.getAmplifier(), true);
                        }
                    }
                    nms.setUnbreakable(im);
                    item.setItemMeta(im);
                }
            }
        }
    }```
modern ridge
drowsy helm
#

change your event priority

#

to highest

#

but you really should use a more robust inventory system

modern ridge
#

okay i will try

acoustic pendant
#

Hey, does someone know why when i'm trying to compile my plugin, it gets stuck in "Downloaded from spigotmc-repo..."?

#

It just keeps there and never compile

flat lark
#
    public void SetSkin(Player player) {

        CraftPlayer craftPlayer = (CraftPlayer)player;
        ServerPlayer serverPlayer = craftPlayer.getHandle();
        GameProfile profile = serverPlayer.getGameProfile();
        ServerGamePacketListenerImpl connection = serverPlayer.connection;


        ClientboundPlayerInfoRemovePacket removePacket = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(player.getUniqueId()));

        connection.sendPacket(removePacket);

        int randomSkin = new Random().nextInt(skins.size());
        Property property = new Property("textures", skins.get(randomSkin).value, skins.get(randomSkin).signature);

        profile.getProperties().removeAll("textures");
        profile.getProperties().put("textures", property);

        ClientboundPlayerInfoUpdatePacket addPacket = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, serverPlayer);
        connection.sendPacket(addPacket);

        Level level = serverPlayer.level();

        CommonPlayerSpawnInfo playerSpawnInfo = new CommonPlayerSpawnInfo(
                level.dimensionTypeRegistration(),
                level.dimension(),
                0,
                serverPlayer.gameMode.getGameModeForPlayer(),
                serverPlayer.gameMode.getPreviousGameModeForPlayer(),
                level.isDebug(),
                true,
                Optional.of(GlobalPos.of(level.dimension(), serverPlayer.getOnPos())),
                serverPlayer.getPortalCooldown()
        );

        ClientboundRespawnPacket respawnPacket = new ClientboundRespawnPacket(playerSpawnInfo, (byte) 0x01);
        connection.sendPacket(respawnPacket);

        skinStorage.put(player.getUniqueId(), randomSkin);
    }

I got my skin changer to work. The only issue is the respawnPacket that reloads the whole world or something and the skin layers get messed up assuming its the respawnPacket.

drowsy helm
#

or two separate issues

#

if its a separate issue, you need to set the DATA_PLAYER_MODE_CUSTOMISATION for the layers

flat lark
drowsy helm
#

yeah for the layer you have to set their customisation mode before you send the update packet

#

if you're settings the skin beforehand, which you are

#

not sure on the others

flat lark
#

Dam

drowsy helm
#

i think 2 is just a matter of sending add plaeyr again possibly?

flat lark
#

What is the packet called?

drowsy helm
#

oh you are doing add player

#

its part of player info update packet

#

you can try send it with udpate_Display_name maybe that will update the tablist

#
        EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.noneOf(ClientboundPlayerInfoUpdatePacket.Action.class);
        actions.add(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
        actions.add(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME);
flat lark
#

Can I put in the same packet or.

drowsy helm
#

yeah

#
ClientboundPlayerInfoUpdatePacket playerInfoPacket = new ClientboundPlayerInfoUpdatePacket(actions, list of players);
        ```
#

like that

flat lark
#

whats list of players do you mean just player

drowsy helm
#

yeah the packet takes a list tho

#

just do a singleton list

flat lark
#

Okay, what was the update skin layers packet?

keen wind
#

yo

drowsy helm
#

its part of teh info update packet, you have to set the player's entityData

#

hold up i got code

keen wind
#

any1 know how to put the setup server?

flat lark
#

I may be blind

drowsy helm
#

nah you have to use reflection for it

#

sec

eternal oxide
#

skin layers can be done just via data, so long as your NPC extends ServerPlayer

drowsy helm
#

it's not an npc

drowsy helm
#

its an actual player

eternal oxide
#

easier then

drowsy helm
#

oh is there another way?

eternal oxide
#

sec have to open IDE as code is old

flat lark
#

If you can see the line at the top thats my tablist lol

drowsy helm
#

is that with the update player name aswell

flat lark
#

Before and After of skin.

keen wind
#

any1 know how to setup the server?

drowsy helm
#

lol

flat lark
#

I know its Cringe.

eternal oxide
#

ServerPlayer#getEntityData().set(Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);

#

however, thats only useable in your own object I believe. you are probably right abour having to reflect

drowsy helm
#

0xFF is no layers i think

eternal oxide
#

FF shoudl be layers

drowsy helm
#

this.getEntityData().set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0x7F);

#

i use that

#

i think thatm ight exclude capes tho

flat lark
marsh imp
#

Hello, does anyone know where I can find CraftScheduler.java? I have a problem with it.

flat lark
#

DATA_PLAYER_MODE_CUSTOMISATION

Where does this come from?

drowsy helm
#

whats wrong with it

#

net. minecraft. world. entity. player. Player

flat lark
young knoll
#

It’s protected

drowsy helm
#

oh it is too

#

yeah you need reflect

eternal oxide
#

only accessible from inside the Object

marsh imp
drowsy helm
marsh imp
#

Oh i dont have The permissions to send a Screenshot

drowsy helm
# flat lark
private List<SynchedEntityData. DataValue<?>> getSynchedEntityData(){
        SynchedEntityData synchedData = asEntity().getEntityData();
        SynchedEntityData.DataItem<?>[] dataItems = DataItemReflectionUtil.getDataItems(synchedData);

        //add to list
        List<SynchedEntityData.DataValue<?>> sendList = new ArrayList<>();
        for (SynchedEntityData.DataItem<?> dataItem : dataItems) {
            sendList.add(dataItem.value());
        }
        return sendList;
    }

    private <T> EntityDataAccessor<T> getAccessor(int id){
        SynchedEntityData synchedData = asEntity().getEntityData();
        SynchedEntityData.DataItem<?>[] dataItems = DataItemReflectionUtil.getDataItems(synchedData);

        //add to list
        for (SynchedEntityData.DataItem<?> dataItem : dataItems) {
            if(dataItem.getAccessor().id() == id)
                return (EntityDataAccessor<T>) dataItem.getAccessor();
        }

        return null;
    }


    //WARN REFLECTION
    public static SynchedEntityData.DataItem<?>[] getDataItems(SynchedEntityData entityData){
        try {
            Field field = entityData.getClass().getDeclaredField("itemsById");
            field.setAccessible(true);

            SynchedEntityData.DataItem<?>[] dataItems = (SynchedEntityData.DataItem<?>[])field.get(entityData);
            return dataItems;
        } catch (NoSuchFieldException | IllegalAccessException e) {
            return null;
        }
    }
#

i use this for my npc, you cna modify it to suit yourself

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

tardy delta
#

warn reflection hehe

drowsy helm
#

lmao

drowsy helm
#

it's just getting synched data fields from the entity class

#

if you go to wiki.vg you can figure out what id the player customisation accessor is

#

then whack that in to getAccessor

#

I'm not 100% sure if it's the best way to do it, but worked fine for me

flat lark
#

I have no clue what todo now lmao.

#

This dosen't even solve no issues but the skin itself.

drowsy helm
#

it might be easier just to use reflection to get the value of DATA_PLAYER_MODE_CUSTOMISATION

#

if you're not gonna reuse synched entity data stuff

drowsy helm
#

on playtime plugin

flat lark
drowsy helm
#

it's worth learning

#

it's not hard at all

flat lark
#

Yeah, but NMS in itself is a pain lmao

wet breach
flat lark
#

I've tried making this at least 15+ times.

drowsy helm
#

you're really close, i'm happy how to show you how to do the reflection

wet breach
#

means you need to take a break

flat lark
#

I have

#

Been working on this for the past 4 days off and on lol.

young knoll
#

I need to make a system for modifying entity data values for my packet entities

#

Do the ids change every version? That would be annoying

wet breach
#

which ids?

marsh imp
young knoll
#

The accessor ids

drowsy helm
#

i might be wrong

#

but they are prone to change

drowsy helm
young knoll
#

Blah, that’s annoying

acoustic pendant
#

Hey, I have a problem with files, I have a config that has a value set to it, will say number: 8 But in game, I have changed it. However when i load this value (onEnable method) it doesn't change. Why does this happen?

drowsy helm
acoustic pendant
drowsy helm
#

like while the server is off?

acoustic pendant
#

No, when it is on

drowsy helm
#

you'll have to flush the cache

#

FileConfiguration caches to memory so any updates won't be seen

eternal oxide
#

how did you change the value?

acoustic pendant
#

manually

#

wdym with flush?

marsh imp
eternal oxide
#

edited teh file by hand?

acoustic pendant
#

yea

drowsy helm
eternal oxide
#

just call Plugin#reloadConfig() after ytou manually edit it

marsh imp
acoustic pendant
#

However what does buoobuoo mean with flush?

#

English is not my native language sorry

drowsy helm
#

reload flushes the cahce

acoustic pendant
#

aja

drowsy helm
#

so the server keeps a copy of the config in memory, if you change it while it's running, it won't know

eternal oxide
#

He means, when you start your plugin, the first time you access teh config its loaded into memory

#

from that point it is accessed from memory

acoustic pendant
#

I thought the server just saved the changes when it closes

eternal oxide
#

no

acoustic pendant
#

Okay thanks

#

Should I also reload configs onDisable?

eternal oxide
#

no

acoustic pendant
#

Or is it better to just have a command for it

eternal oxide
#

if you are makign changes via code you should save

acoustic pendant
#

Yeah

#

I mean manually

drowsy helm
#

you should really only ever reload by command

acoustic pendant
#

Why's that?

#

I'm not really into files

drowsy helm
#

if you're at a point where you are relying on reloading your config automatically for functionality, you're generally doing it wrong

acoustic pendant
#

I wasn't even reloading

drowsy helm
#

yeah I'm not saying you are

#

i'm just saying in a hypothetical situation

acoustic pendant
#

oooh

young knoll
#

In a perfect world everyone would override reloadConfig to handle all their custom config reloading

acoustic pendant
#

But are changes not saved when the server shuts down?

#

I really thought it happened

drowsy helm
#

yes they are

#

but while the server is running, it's in memory

acoustic pendant
#

The thing is that, I changed the value then restarted the server

young knoll
#

Nothing is saved by default

acoustic pendant
young knoll
#

You need to call saveConfig if you make changes in code

acoustic pendant
#

Yeah, that's what I came xd

acoustic pendant
young knoll
#

Then they should be fine

drowsy helm
#

that just sounds like the file isn't saving properly

young knoll
#

Unless a saveConfig call somewhere overrides them

drowsy helm
#

like manually

acoustic pendant
#

I'm not using any saveConfig

acoustic pendant
acoustic pendant
#

This is by default 8

#

But changed manually and it is supposedly saved

#

But when i ask for it

#

(I restarted the server after change)

eternal oxide
#

the plugin will not detect manual changes until the server restarts

acoustic pendant
#

That's what is weird for me

acoustic pendant
young knoll
#

Does it work if you change it when the server is off

acoustic pendant
#

I mean, the value is already changed

eternal oxide
#

then the file you are editing is not the actual config.yml the server is reading

acoustic pendant
#

it is a custom file

#

I'll remove all config files and try again

#

maybe it is a bug

flat lark
eternal oxide
#

you can;t edit teh layers

#

you can enable/disable is all

flat lark
#

oh

eternal oxide
#

all skins come from Mojang to the client

#

the server is just telling the client which skin to use

acoustic pendant
#

I promise i'm restarting the server xd

eternal oxide
#

show your config load/reading code

acoustic pendant
#

Sure

#
public class HoeEnchantsFile {

    private final HarvesterTools plugin;
    private FileConfiguration dataConfig = null;
    private File configFile = null;


    public HoeEnchantsFile(HarvesterTools plugin) {
        this.plugin = plugin;
        saveDefaultConfig();
    }

    public void reloadConfig() {
        if (this.configFile == null)
            this.configFile = new File(plugin.getDataFolder() + "/enchants", "hoeEnchants.yml");

        dataConfig = YamlConfiguration.loadConfiguration(configFile);

        InputStream defaultStream = plugin.getResource("enchants/hoeEnchants.yml");
        if (defaultStream != null) {
            YamlConfiguration defaultConfig = YamlConfiguration.
                    loadConfiguration(new InputStreamReader(defaultStream));
            this.dataConfig.setDefaults(defaultConfig);
        }
    }

    public FileConfiguration getConfig() {
        if (this.dataConfig == null)
            reloadConfig();
        return dataConfig;
    }

    public void saveConfig() {
        if (dataConfig == null || configFile == null)
            return;

        try {
            this.getConfig().save(this.configFile);
        } catch (IOException e) {
            plugin.getLogger().log(Level.SEVERE, "Couldn't save " +
                    this.configFile, e);
        }
    }

    public void saveDefaultConfig() {
        if (this.configFile == null)
            this.configFile = new File(plugin.getDataFolder() + "/enchants", "hoeEnchants.yml");

        if (!configFile.exists()) {
            plugin.saveResource("enchants/hoeEnchants.yml", false);
        }
    }
}```
eternal oxide
#

?pase as its hard to read in a narow discord

#

?paste

undone axleBOT
acoustic pendant
#

Okay sorry

eternal oxide
#

saveDefaultConfig will ONLY save config.yml

acoustic pendant
eternal oxide
#

ah I see

acoustic pendant
#

It's the last one

eternal oxide
#

um

acoustic pendant
#

Even changing the value when the server is off didn't work

eternal oxide
#

comment out line 23 and check again if yoru value changes

#

this.dataConfig.setDefaults(defaultConfig);

acoustic pendant
#

Could be

#

let me try

acoustic pendant
#

The file is not null so that doesn't even run

eternal oxide
#

then I see nothing wrong

acoustic pendant
#

uuh

#

Let me show how I load the value then

#

I do it in the onEnable method

#

I load this into a Object

#

and the get the values from that object

eternal oxide
#

what is the definition of config?

acoustic pendant
#

This

#

Forget about "name" I was trying to use config.getName But returned "" xd

eternal oxide
#

show where you define and assign config

acoustic pendant
#

onEnable method

eternal oxide
#

you are reading from teh plugins config,.yml not hoeConfig

acoustic pendant
#

I don't really see anything wrong

acoustic pendant
#

No

eternal oxide
acoustic pendant
#

do you mean config?

eternal oxide
#

reading from config

acoustic pendant
#

That's another class

#

config is the param of the method

#

I can't access config without putting plugin.config before

#

And if that is the case

#

the value that is returning should be 0 not 8

eternal oxide
#

I asked you tyo show where you defien and assign config

acoustic pendant
#

loadEnchantment(FileConfiguration config)

eternal oxide
#

none of those assign to config

acoustic pendant
#

The problem I'm having is not with config.yml

eternal oxide
#

then why did you post code reading from config. Thats my point

acoustic pendant
#

I mean, file

#

a custom file

eternal oxide
#

show me where you read from the problem config

acoustic pendant
#

It is a bit messy

#

hoeConfig = plugin.hoeEnchantsFile.getConfig();

eternal oxide
#

all your loaded configs are assigning to the same variables

#

so only swordConfig is going to be used

acoustic pendant
#

Oh wait

#

I'm dumb

#

I'm creating the same object twice or more

#

so that's why it doesn't change :-;

#

I didn't realize because for testing purposes it was the same

#

uuh

#

how do I solve this know xdd

#

I have an idea ig

#

just making an enum for Tools and that

#

Lol, it wasn't the file it was me just being dumb

#

Thanks Elgar :3

hushed spindle
#

is it possible with resource packs to enable/disable item texture layers conditionally? like if i wanted to make a tinkers construct-esque item building system to have items look different depending on what you put into em

drowsy helm
#

only custom model data

#

which means you have to have a variation for every combination

#

actually i don't evne think layers can be toggled, so no

hushed spindle
#

darn

#

would be cool if that was a thing

drowsy helm
#

still definitely possible to do tinkers like stuff, just visuals will either look the same between variations or you have to make a different png for every single combination

hushed spindle
#

yeah and thats not very maintainable

#

required textures would go up exponentially the more parts or upgrades i add

drowsy helm
#

you could maybe do it with shaders?

#

i've never really messed around with them enough but i believe its possible

faint tide
#

Hola, stupid question. but in vanilla Mc commands, when you spawn a particle, you have the Delta property. Does this exist in Java code?

For example: this is the mc command I am trying to recreate in java (I want the player to be able to make custom particle images (for example. a mcfunctions file with their particle commands that in the end form a picture) , so they have a file with the commands and I turn them into java code.

an example command:

particle    minecraft:dust  1 0.65 0      0.3       ~-0.0529651 ~0.6532368 ~0 0 0 0     0         1         force @a
<Command>   <Particle>      <color>     <Scale>                <delta>                <speed>   <count>   <force visible>

In code documentation, I don't see anywhere for the Delta info (it's the offset, but static. cuz offset in java makes it go all places I believe)

hard radish
#

your probably ganna need to find a particle api for that kinda stuff. simple minecraft particles are doable but making custom particle images, if it was me, i would go find a dependency and depend on it.

grim hound
#

why does this

#

throw a NotSerializeableException?

faint tide
runic pine
#

if i change the block type of a stairs block, the stairs direction will change?

grim hound
faint tide
#

dang

hard radish
faint tide
#

that's pretty neat

grim hound
grim hound
drowsy helm
runic pine
#

if i change the block type of a stairs block, the stairs direction will change?

grim hound
grim hound
grim hound
faint tide
grim hound
drowsy helm
#
    public static String serialize(ItemStack[] obj) {
        try {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);

            dataOutput.writeInt(obj.length);

            for (int i = 0; i < obj.length; i++) {
                dataOutput.writeObject(obj[i]);
            }

            dataOutput.close();
            return Base64Coder.encodeLines(outputStream.toByteArray());
        } catch (Exception e) {
            throw new IllegalStateException("Unable to save item stacks.", e);
        }
    }```
faint tide
#

did you use an api or made this yourself?

runic pine
#

if i change the block type of a stairs block, the stairs direction will change?

drowsy helm
#

but obvs with byte

#

not b64

grim hound
grim hound
faint tide
drowsy helm
#

not a b64 string

grim hound
drowsy helm
#

im just going off what your method is returning

faint tide
runic pine
grim hound
drowsy helm
#

man, github desktop sucks with multiple git accounts

faint tide
#

you can set a fixed state if you want

drowsy helm
#

they allow multiple accounts on teh site, but not on desktop client

sullen canyon
grim hound
#

after my byte buffer magic it needs 0.01ms to be sent and written

#

but it weighs 17 KB on each refresh

faint tide
#

i'm more interested in 2d, since it's just a pretty display when a player wins a game :3

grim hound
tardy delta
grim hound
sullen canyon
grim hound
grim hound
sullen canyon
#

which city if it's not a secret

grim hound
sullen canyon
grim hound
#

I'm a village guy

#

nearly perfect middle of poland

grim hound
# drowsy helm ```java public static String serialize(ItemStack[] obj) { try { ...
    public static ItemStack[] deserialize(String encoded) {
        try {
            ByteArrayInputStream outputStream = new ByteArrayInputStream(Base64Coder.decodeLines(encoded));
            BukkitObjectInputStream dataOutput = new BukkitObjectInputStream(outputStream);

            ItemStack[] items = new ItemStack[dataOutput.readInt()];

            for (int i = 0; i < items.length; i++) {
                items[i] = (ItemStack) dataOutput.readObject();
            }

            dataOutput.close();
            return items;
        } catch (Exception e) {
            throw new IllegalStateException("Unable to save item stacks.", e);
        }
    }
#

based on that I made this

#

would this be correct?

tardy delta
#

whats the output stream for

grim hound
tardy delta
#

and yes it would

grim hound
hybrid turret
#

When using sqlite, would it make sense to have multiple sqlite files to not make them too big? For performance reasons

grim hound
tardy delta
#

sqlite is one file

hybrid turret
#

Um, what stops you from just having multiple?

faint tide
tardy delta
#

would mean multiple dbs

#

if you prefer performance, go look at something else than sqlite

grim hound
#

gl

#

I mean I tested it with 228 000 entries and ConcurrentInt62Set scored ~0.0035ms on average while LongOpenHashSet scored ~0.005ms on average

drowsy helm
grim hound
grim hound
quiet ice
#

yeah okay it's the #add that is an issue in this algo - I'm not sure how much I stress #contains here

faint tide
# faint tide Hola, stupid question. but in vanilla Mc commands, when you spawn a particle, yo...

so, I actually managed to get this to work. what I did, is I took the first three Delta numbers (removed the Wave dash ~) and added these to the spawn location. which made the image render.

But right now I have the issue that the image only spawns in one direction. Do I need to rotate the Yaw for the spawn location to make the image face the player?

    public void payout() {
        this.loc = player.getEyeLocation().add(player.getEyeLocation().getDirection().setY(0).normalize());
        spawnAnimation(this.loc);
    }
---
    public void spawnAnimation(Location loc) {
        for (var CMD : Commands) { // Commands being all the particle command lines for the image)
            Location loc = location.clone().add(CMD.Delta1, CMD.Delta2, CMD.Delta3);
            location.getWorld().spawnParticle(this.particle, loc, CMD.Count, CMD.offSetX, CMD.offSetY, CMD.offSetZ, CMD.Speed, new Particle.DustOptions(Color.fromRGB(Math.round(CMD.colorRed * 255.0F), Math.round(CMD.colorGreen * 255.0F), Math.round(CMD.colorBlue * 255.0F)), CMD.Scale));
        }
    }

Then again, I thought getDirection() already rotated the location towards the player?

eternal oxide
faint tide
#

so i added that, but that didn't change the rotation

#

the particle image still spawned in one direction

inner mulch
#

guys do you have some advice or how you usually keep consistent chat messages? (example: the chat response stating that the player doesnt have the permission to do something always has the same color / formatting) I dont really like the idea of having this as a static string somewhere, has anyone any dynamic solutions?

tardy delta
#

just have a config file where your messages are located, and make the messages consistent with eachother

jolly solstice
# faint tide so, I actually managed to get this to work. what I did, is I took the first thre...

Currently you are just "moving" the location to where the animation should spawn to exactly one block away (normalize) into the direction the player is looking (getDirection), while ignoring / removing the height component (setY) of the direction and therefor moving it on the same "level" as the players eye location.
From that you are just calculating the offset location of each particle, purely based on the base location, without taking rotation into consideration anywhere.
Logicially the particles will therefor always only be adjusted on the world axis, with no relation to where the player is looking.

To fix this, you will need to rotate the offset locations around the Y-axis of the animation origin.
This could either be the Y-axis of the original location or the Y-axis of the center of the whole animation "image" (which would need to be defined or calculated beforehand).

faint tide
jolly solstice
winged anvil
#

i feel like this is a dumb question but how do you guys determine what should be run on the main game thread. ik like db stuff should be run on another thread but when im writing code i dont think about if it should be run outside the main thread or not and i feel like i should be thinking those things sort of as a background process in my head when i code.

inner mulch
hazy parrot
#

If it's io/some other expensive operation -> async, in any other scenario there is no reason to do async

jolly solstice
# winged anvil i feel like this is a dumb question but how do you guys determine what should be...

80%-90% of things (in games mostly) actually need to run on the main thread for synchronization and other reasons.
The 10%-20% that can be run outside of that asynchronously are all things, that don't interact directly with anything that is in a context to the things (like the world in a game) you interact with - that means, everything that is not directly relying on underlying changes of synchronized data.
This is why database interactions usually can be run on another thread, as you basically just shoot a bunch of (collected) data in the general direction of the database and "forget" about it - and when you want to retrieve data, you make a call (and forget about it), until you get a reply (or not).

#

For what it matters, you really don't have to worry about asynchronous programming all too much - especially when you are quite new to programming in general.
As long as you don't run "blocking" code on the main thread (e.g. those database calls you would need to wait for) or anything that really would benefit from being run asynchronously, you are good for anything else.

jolly solstice
slender elbow
#

technically, async doesn't mean not on the main thread πŸ€“

opal gazelle
jolly solstice
#

Also, something a lot of people don't realize is, that creating and switching thread-contexts is one of the more expensive operations for CPUs - therefor the benefits of putting some "simple" calculations into another thread can easily be outweighted by simply just switching to that thread to run it.

winged anvil
#

yeah i’ve just not done any multithreaded programming or much async at all so was just wondering

#

seems powerful and interesting but seems difficult but i don’t know if i have any good use cases for it

chrome beacon
#

It's quite powerful and useful to know

#

though for basic plugins you probably won't need it

grim hound
#

And that the most sig bits are zeroes

#

Since I use your structure to save ipv4 values

opal gazelle
fiery wren
#

hello

#
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        if (event.getItem() != null && event.getItem().getType() == Material.NETHERITE_AXE) {
            Location location = event.getPlayer().getLocation();
            ItemDisplay display = (ItemDisplay) location.getWorld().spawnEntity(location, EntityType.ITEM_DISPLAY);
            display.setItemStack(event.getItem());
            rotateDisplay(display, 0.5f);
        }
    }

    private void rotateDisplay(ItemDisplay display, float speed) {
        new BukkitRunnable() {
            @Override
            public void run() {
                if (display.isDead()) {
                    this.cancel();
                    return;
                }
                Transformation transformation = display.getTransformation();
                transformation.getLeftRotation().rotateZ(-speed);
                display.setTransformation(transformation);
            }
        }.runTaskTimer(RandomThings.getPlugin(RandomThings.class), 0L, 1L);
    }```
how do i make the itemdisplay face the player's direction?
mortal hare
#

am i the only weird one who appends this to every inner member field access from a class?

fiery wren
#

some people do that

mortal hare
#

it makes me clear where field belongs, + eliminates naming issues with field assignment in constructors

tardy delta
#

should start counting how many times ive said this

inland owl
#

Any ideas why doing import org.bukkit.Material isn't working check both screenshots for hierarchy of where Material.class is
https://imgur.com/a/CboGZWd

eternal oxide
#

Update IJ

chrome beacon
#

also that's Paper

inland owl
chrome beacon
#

in the Paper discord ofc

inland owl
#

oh i thought it was for people editing papers source code on git

#

but thats all good

#

cheers

torn shuttle
#

did you join the server 15 seconds ago

#

sounds like you have

slender elbow
#

nothing wrong with using BukkitRunnable

eternal oxide
#

I use it if I have a local field I need to alter as it loops.

mortal hare
#

does minecraft use kotlin?

#

CompletableFuture<Unit> initialStage, boolean profiled) {

#

Unit object is kinda sus since its like Kotlin's Unit

slender elbow
#

no

#

it's mc's own Unit type

river oracle
#

Imagine if mc used kotlin we would be cooked bro

slender elbow
#

:pepela:

river oracle
#

Decompiling that mess

blazing ocean
glacial moth
#

Anything change in the PrepareAnvilEvent for 1.21? I have a set up to apply item skins (changing custom model data) and it seems to have stopped working, I setResult, it flashes then disappears

blazing ocean
#

yea true

mortal hare
#

enchantments are now fully server sided

glacial moth
#

oh I don't touch enchantments

#

just setting and getting custom model data. any changes with itemMeta?

sterile breach
glacial moth
#
public class PrepareAnvilEventListener implements Listener {
    @EventHandler
    public void onPrepareAnvilEvent(PrepareAnvilEvent event) {
        AnvilInventory inventory = event.getInventory();
        ItemStack item = inventory.getItem(0);
        ItemStack skinItem = inventory.getItem(1);

        if(item == null || skinItem == null) return;
        EasyItemSkins.debug("Item 1 = " + item.getType() + " Item 2 = " + skinItem.getType());

        if(!SkinUtils.isItemSkin(skinItem)) return;
        EasyItemSkins.debug("Item 2 is a skin item");

        ItemSkin skin = SkinUtils.getItemSkinFromSkinItem(skinItem);

        if(!SkinUtils.isCorrectSkin(item, skin)) return;
        EasyItemSkins.debug("Item 2 is the correct skin for Item 1");

        ItemStack skinnedItem = SkinUtils.applySkin(item, skin);
        event.setResult(skinnedItem);
    }
}```

this is running, and it attepts to set result
tardy delta
#

am i the only one who read that as "flashing contest"?

blazing ocean
#

nope

spice burrow
#

ive only ever worked in one core plugin, but im starting to make independent plugins that are made available for more than just one network. im currently working on something that needs to interact with the servers economy, from what ive noticed all i really need to do is hook into the vault api and economy plugins handle the rest? seem accurate?

tardy delta
#

if those economy plugins support vault, yes

spice burrow
#

ye ^ that's what i figured

torn shuttle
#

toasty

#

30c in my office again

#

at 8 pm

eternal oxide
#

I'm sat next to an AC πŸ˜‰

torn shuttle
#

yeah I just turned it on

#

tbf I was at the gym where it was more like 38

#

because not working out when it's hot outside is just making excuses

#

though I do wish I had a way to put ice in my water

eternal oxide
#

Theres the new invention called a refrigerator.

torn shuttle
#

yeah, wish mine was bigger

#

or had one of those ice dispensers

#

the freezer is simply filled to the brim

#

really that thing is pressurized right now

tardy delta
#

just put a bottle of water in the freezer

#

and dont forget to take it out

torn shuttle
#

yes in the space I don't have

tardy delta
#

i remember i forgot to take it out and it took a day to fully defrost

torn shuttle
#

I could probably defrost 2 liters in 2 hours here

#

it's nearly 40c in the shade

tardy delta
#

the heat at night is the worst

torn shuttle
#

I like it

#

I really like the heat

#

just wish I had ice is all

zenith bobcat
#

Hey could someone tell me how to create a npc in version 1.20.4?

tardy delta
#

have you even tried something?

torn shuttle
#

help, I've tried nothing and I'm out of ideas

#

my poor ac is fighting its little heart out

#

it's a good unit it's just competing with the massive heat from outside plus my battlestation

tardy delta
#

poor thing

torn shuttle
#

ac-chan can do it

#

that's kind of a lie, it does tend to overheat on days like these

#

but it eventually gets there

#

are you trying to hide the player from themselves?

#

if they're alone who would they be hidden from

eternal oxide
#

hideEntity works fine. show code.

mortal hare
#

so im looking into minecraft default datapack for new data-driven enchantments

#

and i stumbled upon this

#

does this mean that in some rare case when you're enchanting using enchanting table, it could cost you 51 levels to enchant efficiency?

#

wtf

#

or is this xp amount not levels

#

i get that:
max_level maximum level of the enchantment (Efficiency I/II/III/IV/V)

#

max_cost/min_cost:
base -> cost of xp for the first level
per_level_above_first -> cost of xp per level (base + n * per_level_above_first)

#

not sure if that's right tho

dawn flower
#

can you listen for tebex purchases with an event?

#

nvm

rough agate
#

Hi everyone!
I'm working on a plugin that places *SWEET_BERRY_BUSH * blocks where a thrown potion lands. I want these bushes to immediately reach their maximum age, but I'm unable to get them to grow. Here's my code:

public void placeBlock(Location location, Material material) {
    Block placeBlock = location.getBlock();
    placeBlock.setType(material);
    BlockData blockData = placeBlock.getBlockData();

    if (blockData instanceof Ageable) {
        Ageable ageable = (Ageable) blockData;
        ageable.setAge(ageable.getMaximumAge());
        placeBlock.setBlockData(ageable);
        getLogger().info("Set age to maximum for " + placeBlock.getType());
    }

    new BukkitRunnable() {
        @Override
        public void run() {
            if (placeBlock.getType() == material) {
                placeBlock.setType(Material.AIR);
            }
        }
    }.runTaskLater(this, 200L);
}

Problem: The *SWEET_BERRY_BUSH * blocks never reach their maximum age and remain in their default state.
What I've tried: I logged the age setting, but I don't see any errors in the logs. The place-material and lifetime values are correctly set in the config.yml file.

Can anyone help me understand what might be going wrong or suggest anything else to try? Thank you!

tardy delta
#

another one using a bukkitrunnables instead of the scheduler

tardy delta
rough agate
#

org.bukkit.entity.Ageable;

chrome beacon
#

wrong Ageable

#

That's for entities

tardy delta
#

will you not ninja me

chrome beacon
#

no

rough agate
#

bruh i just noticed lmao

#

thanks for bringing this to my attention πŸ˜‚

mortal hare
#

any better way to get enchantment registry without joining the server in minecraft

    @SuppressWarnings("unchecked")
    private Registry<Enchantment> getMinecraftEnchantmentRegistry() {
        return (Registry<Enchantment>) Registries.REGISTRIES.get(RegistryKeys.ENCHANTMENT.getValue());
    }
#

i dont like this nasty unchecked cast

#

but i cant seem to find a hook where i can access this type safe way from main menu screen (fabric)

#

ik this isnt right place to talk about clientside mods, but knowing well that this is more a question regarding minecraft internal code, maybe you guys know?

chrome beacon
#

You should be doing it on world join

mortal hare
#

i cant

chrome beacon
#

Doing it from the main menu isn't safe/reliable as the data may vary

mortal hare
#

i need to fetch it in main menu

mortal hare
#

so its safe

chrome beacon
#

So not the main menu?

mortal hare
#

datapack reloads at splash screen too

chrome beacon
#

so can you not access it in that reload then?

#

after*

mortal hare
#

i can, but i cant get the reference to registry

chrome beacon
#

also for what purpose do you need it in the main menu?

mortal hare
#

and they're only loaded at startup of the game

#

from what i see

chrome beacon
#

yeah but why do you need them

mortal hare
mint nova
#

How i can check when player uses ANY pickaxe not only for example diamond or ston

chrome beacon
#

I still don't see why you need them in the main menu

mortal hare
#

because i need to resync my data structure when datapack reloads, and since 1.21 enchantments are data driven, they're defined in datapacks

#

so i need to get default minecraft enchantments asap

#

since singleplayer worlds do not reload default datapack

#

when you join

chrome beacon
#

that would explain it

#

what version are you on?

#

1.21?

mortal hare
#

1.21

chrome beacon
#

will check in a bit

mortal hare
#

i have another idea

#

that might work even better

#

instead of checking for datapack reload

#

i can use fabric-api's RegistryEntryAddedCallback event

#

which allows you to listen for registry changes

#

oh wow

#

i though where's remove method in registries

#

apprently it doesnt have one

#

strange

#
public interface MutableRegistry<T> extends Registry<T> {
    RegistryEntry.Reference<T> add(RegistryKey<T> key, T value, RegistryEntryInfo info);

    boolean isEmpty();

    RegistryEntryLookup<T> createMutableEntryLookup();
}
chrome beacon
#

Registries get frozen

mortal hare
#

yea but why add add() but not remove() its name is kinda not fitting

chrome beacon
#

might get entirely wiped on reload ig

mortal hare
#

Registry should allow to remove entries

#

in minecraft sense it wouldnt make sense

#

since those are mostly loaded by datapacks anyways

mortal hare
#

lol i've gotten around this problem in a kinda hacky way but it works

#

so i hook into fabric-api's two events, one for datapack reloading and one, for player join

SimpleSynchronousResourceReloadListener listener = new RegistrySyncResourceReloadListener(mod.getEnchantments(), mod.getItemTypes(), MinecraftClient.getInstance());

ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(listener);
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> listener.reload(client.getResourceManager()));

basically when player joins any kind of world it invokes the listener which would resync data structure with default minecraft datapack values (since there's no safe way to access enchantment registry at splash screen, and datapack reload event is too early to retrieve it from there) and if there is any datapacks, we take care of it by datapack reload event