#help-development

1 messages · Page 795 of 1

ivory sleet
#

And I havent read the source for it soooo

river oracle
#

really that's weird I thought they only supported latest

ivory sleet
#

No like different uuid versions have different purposes sort of

pseudo hazel
#

cant you read the version of the uuid in the actual id itself?

ivory sleet
#

Yes

ivory sleet
#

That’s what I asked if y2k could do

river oracle
#

one sec I juts have to run UUID#Version or sth right

ivory sleet
#

Like there is one version that tells u the uuid is randomly generated, one that is time based, etc etc

#

Yea

clever lantern
#

how can i disable hoppers in spigot

#

i mean just disable tranfering items by them

pseudo hazel
#

power them

valid burrow
#

theres a setting for how often hopper items get transfered

clever lantern
#

so its not possible through code?

valid burrow
#

u can edit the server settings through code.

clever lantern
#

but you have to restart server, no?

valid burrow
#

guess so yh

river oracle
#

@ivory sleet its version 4

#

Version-4 UUIDs are randomly generated

#

seems like this type is almost exclusively used by microsoft*

ivory sleet
#

Ah rip

#

Gg go next

#

alr use a UUID as key type for the outer map

#

And then inner map either array or record

river oracle
#

does it matter whether an array or record is used really

ivory sleet
#

No, I mean using an array is more data oriented design of an approach while using record is more of a data oriented programming approach

river oracle
#

lol I'ma stick with the array as its an internal temporary object anyways

#

its just going to get GC'd

ivory sleet
#

Yeah alr

rotund ravine
#

Functional programming approach when

river oracle
#

java could never

rotund ravine
#

Skill issue

ivory sleet
#

And then y2k u prob just want to use the map as a read through, right through one right?

pseudo hazel
#

if you can make a function, you can make a functional approach

ivory sleet
#

How do you define a function steaf?

#

There is the mathematical definition which is based of sets

pseudo hazel
#

idk just like a method or something

ivory sleet
#

And there is imperative programming one

pseudo hazel
#

idk im just trying to get distracted from work

river oracle
ivory sleet
#

and if it happens to be the case that a chunk is unloaded for a specific coordinate, how do you serve the cache end user then?

ivory sleet
#

Let’s say the chunk (-10,4) is not loaded by the api

#

But somehow a call is invoked to the cache for a coordinate (x,y) in that chunk

eternal night
#

explode

river oracle
#

^

#

+1

ivory sleet
#

🔥🔥

river oracle
#

one might assume I'd read PDC there, but like

#

exploding

eternal night
#

I mean, it is somewhat valid to say "this cache is only usable for loaded chunks"

#

depends on the premise of the cache

ivory sleet
#

Indeed, absolutely

eternal night
#

Worst case, read PDC from region file manually NODDERS

river oracle
#

since the objects are only really defined with the world calling it in an unloaded chunk is the same as trying to do things with a block entity or entity in a unloaded chunk

river oracle
#

I'm on my mission to make a plugin that for some reason most authors tick and do it completely lazily

#

😎

#

I'm lazy so my code is lazy too

#

ticking is for plebs

tough mica
#

this is all right, it worked before i dont used a async database

devout vault
#

Hello, if I did it right: I set the size of the world map using worldborder to 15000x and 15000z world. It works.
And I want the world to be 15000x15000. Then I set the chunky radius to 15000? And I want the world to be 15000x15000 Is that right?

slender elbow
#

no it doesn't

#

15k radius is 30k x 30k

#

15k x 15k is 7.5k radius :d

frail crystal
#

is there a list of slots to slot numbers somewhere?

#

what slot number is a player helmet?

slender elbow
#

thanks bb

chrome beacon
#

If you just want to set amor you can use entity equipment

frail crystal
#

im using player.getInventory().setHelmet(item) but i want to make sure your clicking on the helmet slot

rotund ravine
remote swallow
#

its fake

slender elbow
#

crafting has been discontinued

#

only mine, no craft

rotund ravine
#

I see

#

Mine

frail crystal
#

also when i use player.getInventory().setHelmet(item) the item just disapears

rotund ravine
#

Like my forefathets

#

@frail crystal

#

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

storm crystal
rotund ravine
#

@storm crystal Didn’t feel like paying this month

slender elbow
rotund ravine
#

I see

#

The girl runs with some weird pants

frail crystal
#
@EventHandler(priority = EventPriority.HIGH)
    public static void PlayerInteractEvent(PlayerInteractEvent event) {

        ItemStack item = event.getItem();
        Player player = event.getPlayer();

        if (item != null && item.hasItemMeta()) {
            if (item.getType().equals(Material.KNOWLEDGE_BOOK)) {

                if (player.getInventory().getHelmet().getType() != Material.AIR) {
                    player.getInventory().setHelmet(item);
                }
                event.setUseItemInHand(Event.Result.DENY);
                event.setCancelled(true);
            }
        }
    }```
trying to equipt an item as a helmet, anyone know why this isnt working?
#

im getting java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.inventory.PlayerInventory.getHelmet()" is null

#

and [10:02:49 ERROR]: Tag not valid: {AttributeModifiers:[{Amount:3.0d,AttributeName:"minecraft:generic.armor",Name:"armor",Operation:0,Slot:"head",UUID:[I;-738681445,809191117,-1596173948,-1024297573]}],CustomModelData:1,HideFlags:2,display:{Name:'{"extra":[{"text":"this is a hat name "}],"text":""}'}}

river oracle
#

🥲 should probably check for both, spigot uses a mixutre of null and air or atleast item != null && item.hasItemMeta as he did above

frail crystal
#

nvm

storm crystal
#

its sometimes me with rent

frail crystal
#
if (item.getType() == Material.KNOWLEDGE_BOOK && item.getItemMeta().hasCustomModelData()) {
                    if (event.getSlot() == 39 && player.getInventory().getHelmet() == null) {
                        player.getInventory().setHelmet(item);
                        item.setAmount(0);
                    }
                }```
trying to make it so you can manually put this item on your head but it doesnt seem to work
#

also using ItemStack item = event.getCurrentItem();

smoky oak
minor junco
#

you set the amount to zero? Couldn't that be the issue

smoky oak
#

hes trying to swap the head and item in hand

#

iirc you shouldnt set the item to 0 but set the item in main hand to air btw

frail crystal
#

well it doesnt dissapear

#

also yeah i didnt mean to put that there

frail crystal
smoky oak
#

ye

minor junco
# smoky oak hes trying to swap the head and item in hand

He's passing the same instance as the helmet of which he set the amount to zero right afterwards, but that alone wouldn't explain why there's no helmet (there should still be an item stack with amount of zero at least it was in legacy versions)

smoky oak
#

setting amount to 0 is supposed to remove an item

#

what version r u in

rotund ravine
#

In newer versions

minor junco
#

In legacy versions you were able to have items with zero amount of them (it's weird yh)

#

So I assume the underlying implementation was changed so a zero amount equals out a removal of that item

frail crystal
#
 @EventHandler
    public static void inventoryInteract(InventoryClickEvent event) {
        ItemStack item = event.getCurrentItem();
        HumanEntity player = event.getWhoClicked();


        if (item != null) {
            if(item.hasItemMeta()) {
                if (item.getType() == Material.DIAMOND_HELMET && item.getItemMeta().hasCustomModelData()) {
                    item.setType(Material.KNOWLEDGE_BOOK);
                }
                if (item.getType() == Material.KNOWLEDGE_BOOK && item.getItemMeta().hasCustomModelData()) {
                    if (event.getSlot() == 39 && player.getInventory().getHelmet() == null) {
                        player.getInventory().setHelmet(item);
                        event.setCancelled(true);
                    }
                }
            }
        }
    }```
ok i have this but it still dosnt work
rotund ravine
#

This looks awful on phone

minor junco
#

It does indeed

frail crystal
#

it looks awful normally lol

minor junco
#

Yeah we all love 5 nested control blocks

smoky oak
#

hm this is weird i dont see something immediately wrong with this

#

have you checked if it reaches that if clause?

minor junco
#

Could you explain what the issue is

#

The helmet is not put on?

frail crystal
#

so i click to pick up the knowledge book, and i click my helmet slot and it doesnt leave my cursor

rotund ravine
#

Did u register ur handler 👀

frail crystal
#

it doesnt place on the helmet slot

#

its registered

minor junco
#

I mean first things you should do when you encounter such issues start debugging, so I assume you've done that and the deepest if clause is reached?

frail crystal
#

uhh

echo basalt
#

I'm looking at some fairly easy ways to improve your code

frail crystal
#

ok so when trying to place it on the slot it doesnt pass if(item.hasItemMeta())

echo basalt
#

Most are covered here

frail crystal
#

ok

echo basalt
#

I'd probably rework it as such

frail crystal
#

ok

#

well right now i want to fix this

#

so when placing it item.hasItemMeta() returns false

minor junco
#

well that's what programming is about, finding solutions to problems or workarounds. What do you need of the meta data exactly? I mean you only test if it has custom model data right

frail crystal
#

yeah

#

i mean

rotund ravine
#

?jd-s

undone axleBOT
rotund ravine
echo basalt
#
@EventHandler
public void inventoryInteract(InventoryClickEvent event) {
    ItemStack item = event.getCurrentItem();
    HumanEntity player = event.getWhoClicked();
    PlayerInventory playerInventory = player.getInventory();
    
    if (item == null || !item.hasItemMeta()) {
      return;
    }

    Material type = item.getType();
    ItemMeta meta = item.getItemMeta();

    boolean hasModel = meta.hasCustomModelData();

    if(!hasModel) {
      return;
    }

    switch(type) {
      case DIAMOND_HELMET:
        item.setType(Material.KNOWLEDGE_BOOK);
        // fall-through
      case KNOWLEDGE_BOOK:
        ...
        break;
      default: 
        // no-op
        return;
    }
}
#

type deal

#

bit cleaner

rotund ravine
#

He wants to click his cursor onto the helmet slot

echo basalt
#

I'm not fixing code just making it acceptable

rotund ravine
#

Aær

#

Alr

wet breach
echo basalt
#

true

#

doesn't do much but sure

minor junco
echo basalt
#

I haven't used switch in years

wet breach
minor junco
#

That is just over engineering to make it look more organic but it isn't

wet breach
#

remove that extra if

echo basalt
#

that's the syntax right?

minor junco
#

that?

wet breach
echo basalt
#

fuck

minor junco
#

Ah you edited it

echo basalt
#

there

wet breach
#

yeah I won'd use switches a lot either

#

there is updated switch stuff too now

#

which I forget the usage for

minor junco
#

I know nobody asked for my opinion but a switch case for this instance just makes it look awful if I'm completely honest xD

wet breach
#

some of us here don't program based off looks

#

rather ease of use most times 😛

echo basalt
#

which is why I don't use switches

minor junco
#

Well you write an entire default block without any usage or gain out of it

wet breach
#

I can read code if it contains 100 if statments just the same if its some other thing that condenses it

minor junco
#

With 2 cases and one fallthrough

wet breach
#

you could do 1 case and fallthrough instead if I remember right

#

don't think it actually has to have a 2 cases specifically outlined, just 1 case and a default as that counts as 2

minor junco
#

So idk it just doesn't click for me why you should prefer a switch case over the more simplistic approach of if else clauses

wet breach
#

never said you should prefer it

minor junco
#

you would*

wet breach
#

however if I was doing it, I would have used an || on that item type comparison

#

since it can only be one or the other

echo basalt
#

well

wet breach
#

and I would have done a reverse check on it

echo basalt
#

you can just do an || and set the type regardless

#

I'm worried about side effects regarding item meta

minor junco
#

This is similar on how I would've done it, going after google's approach

@EventHandler
public void inventoryInteract(InventoryClickEvent event) {
    ItemStack item = event.getCurrentItem();
    HumanEntity player = event.getWhoClicked();
    PlayerInventory playerInventory = player.getInventory();
    
    if (item == null || !item.hasItemMeta())
      return;

    // just overseen a possible nullpointer lmfao
    ItemMeta meta = item.getItemMeta();
    if (!item.hasCustomModelData()) return;

    Material type = item.getType();
    if (type == Material.DIAMOND_HELMET)
      item.setType(Material.KNOWLEDGE_BOOK);
    if (type == Material.KNOWLEDGE_BOOK) {
      // ...
    }
}

#

i think this is much more expressive and fitting than a switch clause and unnecessarily using locals when only used once

wet breach
echo basalt
#

wonky code flow

river oracle
minor junco
echo basalt
#

future changes yada yada

molten hearth
#

have you lentlemen seen a working implementation of custom block hardness using mining fatigue in 1.20? All of the resources I could find are outdated

echo basalt
#

switch is inferior because it provides incompatibilities with the new registry stuff

wet breach
river oracle
#

so if people decide not to head and have a lot of maitenance Shrug on them

minor junco
#

but functionality wise aesthetics have no impact (if we define aesthetics the same)

echo basalt
#

frosty has been throwing some wild takes lately

wet breach
#

enterprise doesn't care how it looks, just whether it works or not and meets the requirements needed

minor junco
#

that is just wrong tho

wet breach
#

idk what teams you are working on that cares about looks

echo basalt
#

Enterprise cares about future-proofing and consistency on top of just functionality

river oracle
minor junco
#

google, netflix have entire guidelines on how their code should look and is done

echo basalt
#

You don't want to dig yourself a grave

#

Don't mine straight down

river oracle
#

😎

minor junco
#

but i get your point, if you're the only programmer on a project then it doesn't really matter yh

echo basalt
#

At work I'm fairly strict on maintainability and stuff

river oracle
#

mining straight down is safe above y 12

minor junco
#

but it will matter when you come back

wet breach
#

and other stuff

echo basalt
#

If you're working by yourself no one cares, if you're working with others you want to make sure you are not hated by your peers

#

If you're the only one that understands how the code works you become a liability

minor junco
smoky oak
#

yea i try to avoid writing code like that but i cant even understand my own code half of the time

minor junco
#

but on small projects it really doesnt matter

echo basalt
#

It leads into 3 scenarios:

  • You get fired and your entire project is recoded from scratch
  • You lead a team that recodes it
  • You have to document and teach someone / a team on how to maintain your project
wet breach
#

format is not the same as defining other aspects of the language

#

that is to say, the format doesn't go on to say switches can't be used

minor junco
#

not just the formatting, but general guidelines on when to use what in what scenario, also naming conventions (which may fall under formatting tho)

#

erm well some guidelines define exactly that

echo basalt
#

code architecture matters

minor junco
#

it really depends on a team-by-team basis

echo basalt
#

You can't just throw everything in a class, slap static everywhere and expect to not get fired

#

"but it works bro"

minor junco
#

exactly 🤣

wet breach
#

There is no enterprises that forbid usages of stuff in a language

dusky prawn
#

Hi! Im new to Java, so please be patient.
Im struggling with this, and i dont really know what the problem is?

#

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public final class Discord extends JavaPlugin {


    }```

The end( } )  has a red line under it and it's a error..?
This isn't my 'main class'(or whatever - Its not the first class, that was made when i created this project)
echo basalt
#

They forbid the misuse of features

echo basalt
#

Your IDE tells you the problem

dusky prawn
#

It says that it is expecting a Interface or a Class, but i dont really know what it is ;p

smoky oak
#

extends

dusky prawn
#

whaats that :8?

smoky oak
#

youre only supposed to extend javaplugin on ur main class

dusky prawn
#

oh

#

ohh, its }

#

What shall i do now then? Remove it?

frail crystal
#
@EventHandler
    public static void onEntitySpawn(org.bukkit.event.entity.EntitySpawnEvent event) {
        if (event.getEntityType() == EntityType.WANDERING_TRADER) {
            Entity trader = event.getEntity();
        }
    }```
how do i add trades to this entity
smoky oak
#

well yes, the java plugin is where you tell the server 'look here for startup'

dusky prawn
#

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public final class Discord extends JavaPlugin {

    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {




    return true;
    }
}```

I mean, this is all of my code. Shall i remove the red thing bracket?
wet breach
dusky prawn
#

Ohhh.

frail crystal
#

oh

smoky oak
dusky prawn
#

Oh, yea. What shall i edit in this file? What shall i remove?

Do i use "shall" correctly? xD

smoky oak
#

(technically you can do both but then its just a mess)
also you need to do 2 things here
remove the first } because thats not supposed to be there
and change 'extends JavaPlugin' to 'implements CommandExecutor'

dusky prawn
#

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public final class Discord implements CommandExecutor {

    

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {




    return true;
    }
}```

So this?
smoky oak
#

yea

frail crystal
#

what event should i use for adding a trade to a wandering trader

dusky prawn
#

Thanks!!

smoky oak
#

then you just do your command stuff in that

frail crystal
#

i looked at some events but im not too sure what to use

smoky oak
#

the best one is probs to replace it on spawn

inner mulch
#

which packets sets an enitity to mount another entity?

lost matrix
frail crystal
#

yes

#

just once when it spawns

wet breach
frail crystal
#

or generated its trade

wet breach
lost matrix
#

EntitySpawnEvent and then add a recipe to him

dusky prawn
#

Uhm, hi again! I have trouble with defining the player... The last "player." you see, is the red one.

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        // /discord - Sending you a discord link
        if (command.getName().equalsIgnoreCase("discord")){
            Player p = (Player) sender;
            player.sendMessage("Discord link:");
        }

        return true;
    }
}```
#

It tries to make me define a player, but it doesn't really work.

dusky prawn
#

Relax. Im new

#

I litterly started 20 minutes ago

eternal night
#

names the variable p

lost matrix
#

Point out where you define your player variable

eternal night
#

is confused as to why there is no variable called player

dusky prawn
#

Oh, genius. Thanks :D

young knoll
#

You stole my player!

dusky prawn
#

I didn't know that the "p" was the actual name. I thought you just could use "player".. My bad :-}]

inner mulch
#

i cannot find the entity mount packet on the protocol wiki, what is it called?

dusky prawn
#

When i write /discord(the command is valid, yes!), nothing gets send to me :-[?

#

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        // /discord - Sender dig et discord link
        if (command.getName().equalsIgnoreCase("discord")){
            Player p = (Player) sender;
            p.sendMessage(ChatColor.BLUE + "Discord link:" + ChatColor.WHITE + "-");
        }

        return true;
    }
}```
#

Whoops, send discord link - Sorry!

smoky oak
#

well did you register it?

lost matrix
dusky prawn
rotund ravine
#

Din JavaPlugin class

dusky prawn
#

Hold up, du dansk? a hah

#

Hvad er JavaPlugin class for noget?

#

Er det den første class, som bliver lavet?

lost matrix
rotund ravine
#

Din Main ja

dusky prawn
#

Ohh, okay. How do i do that?

lost matrix
#

?command

#

?commands

rotund ravine
#

?cmd

#

?executor

#

Funny

dusky prawn
#

xD

lost matrix
dusky prawn
#

Thanks ;-]

#

this.getCommand("discord").setExecutor(new CommandDiscord());

I've added this under my main class, in the startup thing - Just like in the docs. But the "CommandDiscord" is red, and it doesn't help, when i hover over it.

pseudo hazel
#

import it

dusky prawn
#

How, what?

rotund ravine
#

Ur class is called Discord

dusky prawn
#

Yes

#

Cant send pictures, its annoying.

pseudo hazel
#

turn on auto imports

dusky prawn
#

Oh, i have imported. It isn't that.

pseudo hazel
#

oh

#

is the class called CommandDiscord?

dusky prawn
#

Nope, my main class is "Plugin5", but all the command stuff(Alll that i send above my newest), is in a class called "Discord"

lost matrix
# dusky prawn Yes

If your class is named Discord then you shouldnt expect to find anything if you create an instance of a class called CommandDiscord

dusky prawn
#

oh

#

is that what it means

#

Thanks <3

lost matrix
dusky prawn
#

Ej, føler mig lidt dum. Det jeg faktisk ked af :(

icy beacon
# dusky prawn Uhm, hi again! I have trouble with defining the player... The last "player." you...

Hey, if you are just starting with Java and you don't have experience coding, it's not always the best idea to start with plugins. You are going to run into a lot of very trivial problems just because you don't understand the basics and the syntax of the language. You can take any approach you want, but imo you'd be better off first getting familiar with the language. There are a lot of good resources online for that

#

?learnjava

undone axleBOT
smoky oak
#

welp im having this issue again, is the only way around this a builder method?
I'm trying to avoid a massive method call a la

this(center, new Location(start.getWorld(), start.getX(), center.getY(), start.getZ()), new Location(start.getWorld(), start.getZ(), center.getY(), start.getX()... distance);
pseudo hazel
#

just make more constructor overloads till you pop

drowsy helm
#

A builder would be infinitely cleaner lol

pseudo hazel
#

looks like you are going the wrong way around

drowsy helm
#

Why insist on constructors anyway

lost matrix
smoky oak
pseudo hazel
#

what is start

smoky oak
#

so i only need center, point on circ, distance

lost matrix
#

Then you only need a center and a radius

pseudo hazel
#

yeah what is distance xD

smoky oak
#

radial distance betwen points, im generating location lists to represent geometric shapes

pseudo hazel
#

if distance is radius then start needs to be on the circle?

smoky oak
#

yea, im generating my shapes from sets of points that define them

pseudo hazel
#

or is radius just the distance between center and start

lost matrix
#

Ok so you create a vector, going from your center to your point, and then extending until you reach the length "distance"?
But you can literally create an infinite amount of circles through that...

smoky oak
#

well no

lost matrix
#

Is your circle always parallel to the ground?

smoky oak
#

also no, hence me calling the super method, id like to avoid duplicating code

#

im using the distance to calculate the angle, and the vectors from the center to the circle surface to generate the plane the circle is in. Then i just rotate a vector around the center location with that angle and plane and mark the locations it hits until it completed one rotation

upper hazel
#

were exists note "id" for noteBLock

#

i have Note class

#

but not int

#

Octave?

lost matrix
smoky oak
#

its part of the blocks data i think

smoky oak
#

cuz i cant have two constructors with the same signature

pseudo hazel
#

that sounds really complicated for a circle

#

gotta be honest

lost matrix
pseudo hazel
#

but yeah you should probably use a builder

smoky oak
#

like the length of the circle segment

lost matrix
pseudo hazel
#

so you can make parts of a circle

smoky oak
pseudo hazel
#

yes

#

or just dont make builders that accept wrong arguments

smoky oak
pseudo hazel
#

so a distance can be the whole circle on a small radius but only part of it on a bigger radius

smoky oak
#

hence why it also accepts radians

lost matrix
# smoky oak

Ok so it is the step size of each iteration. Is it in radians or degrees?

smoky oak
#

again depends on the mode, sometimes you dont know both

#

for flat circles it assumes you know the distance

#

the reason im assuming that is that depending on the particle you know usually how far apart they can be before they appear disjunct

lost matrix
#

Alright, now if you have two points, A and B, then you can literally create an infinite amount of circles through those two points.
How do you know where to rotate towards?

smoky oak
#

cuz this constructor assumes the circle is flat

lost matrix
smoky oak
#

a circle rotated in 3d space

lost matrix
#

Which is still flat

smoky oak
#

with 'Flat' i mean that the circle's y values are the same

upper hazel
#

but note this class (

lost matrix
#

Ok so when i asked if the circle is always parallel to the ground, and you answered 'no' you lied.

upper hazel
#

and note has 3 int value

pseudo hazel
#

are both points a and b on the circle?

smoky oak
#

it isnt

#

it is for this constructor

lost matrix
lost matrix
#

For 'some' reason

pseudo hazel
#

oh

smoky oak
#

xz plane

#

but yea cuz i know its flat

lost matrix
#

Yes in minecraft coordinates its xz

smoky oak
#

(im now realizing theres a mistake in my math tho)

lost matrix
pseudo hazel
#

right, like a top down kinda view

smoky oak
#

because i once again assume you dont have the radius

#

or you wouldnt in the use case im making this for

lost matrix
# smoky oak because i once again assume you dont have the radius

Here. Just wrote that (For radians)

  public List<Location> getCircleLocations(Location center, double radius, double angleDeltaRadians) {
    List<Location> circlePoints = new ArrayList<>();

    for (double angle = 0; angle < 2 * Math.PI; angle += angleDeltaRadians) {
      double x = center.getX() + radius * Math.cos(angleDeltaRadians);
      double z = center.getZ() + radius * Math.sin(angleDeltaRadians);
      circlePoints.add(new Location(center.getWorld(), x, center.getY(), z));
    }

    return circlePoints;
  }
lost matrix
#
  public double getProjectedDistance(Location loc1, Location loc2) {
    return Math.sqrt(Math.pow(loc1.getX() - loc2.getX(), 2) + Math.pow(loc1.getZ() - loc2.getZ(), 2));
  }

Here. Thats your radius on the XZ plane for two vectors in 3D projected on the XZ plane of the first loc

smoky oak
#

thats true, but im creating the circle based on locations anyhow
tho isnt the code there not assuming your deltaRadians can be multiplied by a natural number to get 360?

#

for larger values of deltaRadians it may produce problematic results, like if u tell it delta = radius

lost matrix
#

Then just truncate

    angleDeltaRadians %= 2 * Math.PI;
    
    for (double angle = 0; angle < 2 * Math.PI; angle += angleDeltaRadians) {
      double x = center.getX() + radius * Math.cos(angleDeltaRadians);
      double z = center.getZ() + radius * Math.sin(angleDeltaRadians);
      circlePoints.add(new Location(center.getWorld(), x, center.getY(), z));
    }
smoky oak
#

no i meant this

pseudo hazel
#

or instead of specifying the angle between each location, just have an amount of locations

#

and then every point can have the same distance to the other points

smoky oak
#

yea that'd be the ideal case

#

the delta radians given >= delta radians required then

#

but whats the math to get that

lost matrix
#

Sure, amount of points on the circle works too.
Then you just pass an int and define double angleDeltaRadians = (2 * Math.PI) / pointCount;

smoky oak
#

im aware, it's just that if radians are given they might need to be 'smoothed out'

#

so that that up there doesnt happen

#
int points = Math.round(0.5 + (2 * Math.PI) / radians);

this sound about right?

odd adder
#

Hi , does anyone know why InventoryClickEvent doesn't called while shift clicking?

    @EventHandler
    void InventoryClickEvent(InventoryClickEvent event){
        Inventory inventory = event.getInventory();
        HumanEntity player = event.getWhoClicked();
        if (!(inventory instanceof AnvilInventory)){
            return;
        }
        if (!event.getSlotType().equals(InventoryType.SlotType.RESULT)){
            return;
        }
//        for (int i=0;i<inventory.getSize();i++){
//            System.out.println(inventory.getItem(i).getType());
//        }
//        event.getWhoClicked().setItemOnCursor(event.getCurrentItem());
//        System.out.println(event.);

//        inventory.clear();
        if (!inventory.getItem(1).equals(MoneyMendingBook.item())){
            return;
        }
        System.out.println(event.getClick());
        if (event.isShiftClick()){
            return;
        }
        player.setItemOnCursor(event.getCurrentItem());
        inventory.clear();
    }```
lost matrix
smoky oak
#

and add 1?

lost matrix
lost matrix
odd adder
#

whole function doesn't get called

smoky oak
#

k

lost matrix
odd adder
#

yes , i registered

#

and it get called when click without shift

lost matrix
# odd adder yes , i registered

If you registered the listener and added your EventHandler annotation then the method gets called or you get an exception.
Which one is it?

odd adder
#

it didn't throw any exception , and it doesn't get called(i see it using debugger)

#

it is ignoring shift click now

smoky oak
#

hm

odd adder
#

and the slot got clicking is result slot of anvil

smoky oak
#

im making a builder rn. Should i just have one 'build' method, or two separate methods for the flat and 3d circle?

molten hearth
#

what would be the best way to see NMS changes

lost matrix
river oracle
odd adder
#

spigot 1.20.2

lost matrix
molten hearth
#

where can i formally complain to mojang for changing nms too often

river oracle
smoky oak
#

oh right that aside, if i do make a builder, should i throw an IllegalArgumentException or fail silently if wrong values are passed?

river oracle
#

failing silenty lacks context!!!!

smoky oak
#

and on the build, if theres wrong data? IAE or RTE?

river oracle
#

IAE

smoky oak
#

k

#

wheres the difference anyway?

river oracle
#

specific

smoky oak
#

?

#

a RTE can also have information in it cant it?

#

is this something about testing?

river oracle
#

IAE is more specific

smoky oak
#

ah

molten hearth
#

alright now i have a question about obfuscation

lost matrix
# odd adder normal click work , i tried it both creative and survival
public final class SpigotSandbox extends JavaPlugin implements Listener {

  @Override
  public void onEnable() {
    Bukkit.getPluginManager().registerEvents(this, this);
  }

  @EventHandler
  public void onClick(InventoryClickEvent event) {
    getLogger().info("Clicked: [" + event.getClick() + "]" + event.getSlot());
  }

}

Clicking into an anvil result and getting an item from there, fires the event. Doesnt matter if its a shift click or not.

odd adder
#

🤔

molten hearth
#

why does 🅱️lud use the obfuscated field name in one place and deobfuscated in the other

#

can I use either obfuscated or mojang when working with NMS?

#

or should i stick to one of them

lost matrix
river oracle
#

its way easier to update and maintain

river oracle
#

most of the time you just copy paste code xD

molten hearth
molten hearth
#

oh alright

#

thank uu

river oracle
#

you also need to use obfuscated with reflection

#

just a heads up

molten hearth
#

oh

river oracle
#

if you do multiple modules you can use the mappings

molten hearth
#

well then i do need to use the obfuscated ones

#

rip

weak meteor
river oracle
#

InfiniteKits line 34

river oracle
molten hearth
river oracle
#

unless you need to specifically use reflection to change field values or something that you usually can't access

weak meteor
smoky oak
#

should i still use IAE for if the chunk isnt loaded or something else?

rotund ravine
weak meteor
#

OH

river oracle
weak meteor
#

THAT IS

#

LOL

molten hearth
river oracle
river oracle
#

its just a hastle

molten hearth
river oracle
rotund ravine
#

Mojmap is the sane mans way

#

Deobfuscates the ugly sjit

molten hearth
odd adder
river oracle
lost matrix
river oracle
#

if the field is private static final pretty sure you'll need unsafe

rotund ravine
odd adder
#

hold on , i'm adding debug code on prepareAnvilEvent

molten hearth
#

the resource had like half broken code so im trying to update the gh version instead

smoky oak
#

im still tilted we cant just register a handler to Event

molten hearth
#

did you ever end up solving this btw lol

odd adder
smoky oak
#

you cant register a handler to Event. It would make certain things SO much easier to test

rotund ravine
#

What handler

#

Oh

smoky oak
#

just Event

rotund ravine
#

Why would you need that

smoky oak
#

oh you want an example?

rotund ravine
#

You can jsut register all events easily

smoky oak
#

it is possible for left clicking to neither trigger entityDamage nor PlayerInteract

#

took me a few hours to find the only event that still fires if you do

#

that being ArmAnimationEvent

#

like seriously wtf

rotund ravine
#

val reflections = Reflections(nameSpace)
            reflections
                .getSubTypesOf(Cancellable::class.java)
                .filter {
                    it.declaredFields.any { field -> field.type.name.endsWith("HandlerList") }
                            && !ignored.contains(it.name)
                }
                .forEach {
                    EventRemapper.remapAndSubscribe(it as Class<out Event>, isCancelledMethod)
                }

👌🏻

smoky oak
echo basalt
#

wallah ever heard of jesus?

rotund ravine
# smoky oak

It uses implementation("org.reflections", "reflections", "0.9.12")

sullen wharf
#

hello

#

you called?

rotund ravine
#

Ur lukas not jesus

echo basalt
#

ever seen him irl?

sullen wharf
#

that's what u think

rotund ravine
smoky oak
#

i honestly forgot that channel exists

echo basalt
#

should rename it to shitposting

smoky oak
#

eh fair

#

dont think i got an answer for this earlier btw

#

do i throw an IAE for data mismatch in the build method?

#

or smth else?

frail crystal
#
@EventHandler
    public static void onEntitySpawn(EntitySpawnEvent event) {
        if (event.getEntityType() == EntityType.WANDERING_TRADER) {
            WanderingTrader trader = (WanderingTrader) event.getEntity();
            trader.setRecipe(trader.getRecipeCount() + 1, new MerchantRecipe(CreateHat.createHat(), 1));
        }
    }```
so how do i add a trade to this guy? this didnt seem to work and i didnt find anything on the javadocs
hazy parrot
smoky oak
#

1sec

#
@EventHandler
    public void onVillagerPrepare(VillagerAcquireTradeEvent event){
        MerchantRecipe recipe = event.getRecipe();
        ItemStack result = recipe.getResult();
        //Item manip in progress...
        recipe.adjust(result);
    }

the setRecipe might only work if you do it on an already existing recipe
is there an addRecipe method?

odd adder
smoky oak
#

hm theres not

frail crystal
#

hmm

smoky oak
#

you might get somewhere adding something to getRecipes and setRecipes

odd adder
#

it got called

smoky oak
#

maybe viabackwards parses the event wrong

rotund ravine
#

Via things are always a little broken

smoky oak
#

cough negative y values cough

river oracle
#

I mean via everything is scuffed asf

frail crystal
#

casting the entity?

smoky oak
#

i mean if it does run and doesnt throw yes

frail crystal
#

does EntitySpawnEvent work with spawn eggs

rotund ravine
#

If you look at spawn reasons

#

Do you see an egg?

#

?jd-s

undone axleBOT
molten hearth
#

does anyone know if its possible to send NMS Packets via protocollib

#

specifically im trying to send a ClientboundBlockDestructionPacket but since the sendPacketNearby method got removed im wondering if protocollib supports sending it

frail crystal
#

-.-

main barn
#

hey! anyone know how i can override the default bukkit ban msg? right now i have this code:

@EventHandler
    public void onPlayerLogin(PlayerLoginEvent event) {
        if (event.getResult() == PlayerLoginEvent.Result.KICK_BANNED) {
            event.setKickMessage("You are banned from this server.");``` but it just does the default bukkit ban message, how do i make it custom?
upper hazel
#

the issue of saving a large number of blocks to the database. Do I check that they are still in the world or trust completely on events?

river oracle
#

What's wrong with PDC here

#

It seems like the logical choice when dealing with the world

upper hazel
#

to save in the chunk?

river oracle
#

Yeah or use

#

?blockpdc

undone axleBOT
upper hazel
#

it's just that databases are faster

river oracle
#

What

#

No they aren't

upper hazel
#

yes

river oracle
#

Where the fuck did you get that from

upper hazel
#

So you think saving to a file is faster than saving to a database?

river oracle
#

Your saving to PDC which then the server saves to a file. When working with the world PDC is your best option as far as storage goes

#

Also yes it will be faster depending where the db is hosted

#

You deal with latency when working with databases

upper hazel
#

Lol then why do you need databases if you have files?

#

lets say this discorde dev

river oracle
#

Because databses scale much better than a file system

#

It also allows the data to be replicated and avaliable across many nodes

#

But the thing here is your dealing with a mc world store the data where it belongs

upper hazel
#

oh i was read post, file save really faster

river oracle
#

I'm not saying database suck just know when to use then

eternal night
#

the chunk PDC is a full in-memory structure

#

now, PDC has its downsides

#

its data is bound to the Chunk which is great if you have the chunk. It is not great if you don't

upper hazel
eternal night
#

when a chunk is loaded, the chunks PDC is loaded by the server from file

#

the PDC and all its values hence exist in memory when its chunk is loaded

#

memory access is multitudes faster than a database connection, simply due to the fact that no IO is involved

#

now, PDC might not be the best solution anyway tho. It depends entirely on your usecase

upper hazel
#

hm

eternal night
#

if you need that data when the chunk isn't loaded, PDC is terrible

#

as well, it only exists when the chunk does

#

at which point, do a DB

#

but if you have extremely block specific data (idk, custom items stored in the thing or something)

#

pdc is great

upper hazel
#

I just heard that the database is 1000 times faster

#

almost everyone has said that to me.

eternal night
#

i have no idea who in their right mind said that a database is faster than PDC

#

it may be faster than files on disk

#

for some usecases

upper hazel
#

or is it a moot point and it's hard to say which is faster.

eternal night
#

for others, not so much

#

no, PDC access for a loaded PDC is magnitutdes faster

upper hazel
#

hm

#

ok i will try

eternal night
#

PDC is literally just a Map<NamespacedKey, Value> internally

#

like

#

you are just using a fancy map really

#

the server loads that map for you

#

you use persistent data types to ensure the data you store in that map can be written to the server specific format

#

but beyond that, it is just a Map

wet breach
#

I doubt anyone said DB was faster then PDC and I doubt you even asked the question in regards to this as well

upper hazel
#

PDC uses files as far as I know, that's why I compared

pseudo hazel
#

just like how any game uses files

young knoll
#

Even databases use files

slender elbow
#

I'll invent a filesystem that doesn't work with files

#

a system

upper hazel
young knoll
#

Chop Suey by System of a Down?

pseudo hazel
#

yes but online games also use files to store information too

upper hazel
pseudo hazel
#

its optimized for a lot of data

upper hazel
#

the question is how much big data

pseudo hazel
#

more than you need for your plugin

amber palm
#

hey guys i have a dumb problem if i use player.getInventory.setItem(Equipment Slot, Itemstack) and i insert the Options it always changes to player.getInventory.setItem(int, Itemstack). idk if its a problem of my IDE or im just to stupid.

upper hazel
#

well then files always win in speed and the database in quantity

#

This means I was in vain connecting the database to my plugin....

#

and I only kept the id there

glossy venture
#

i always find the bug when i try to complain about it here so ill try again lmao
note that the manager.getService(qualifiedSourceKey) eventually calls the create method, and qualifyServiceKey sets the remote channel name.

now tell me how the value changes bruh

#

this is prob vague as shit

upper hazel
#

then are there cases when a database is needed for a plugin (not cross-server plugins)

wet breach
#

flat file storage is one of the slowest ways to store and read from

upper hazel
#

what?

#

you said otherwise.

#

what the "flat"

#

file

wet breach
#

flat file storage is human readable format, IE yaml for example is flat file storage

#

it is one of the slowest ways to store data and read from

upper hazel
#

yml slow for save data? this what you mean?

smoky oak
#

i just store stuff in PDC bc i usually only need a boolean array

inner mulch
#

i cannot find the entity mount packet in the protocol wiki, does somebody know what it is called?

wet breach
#

as this point you are better off just using which ever is easiest and works for you

smoky oak
inner mulch
#

thats what i want to do

#

but i dont know the packet for it

smoky oak
#

no like literally

#

tell the entity 'your location is this now' and the other entity 'your passenger is this entity'

upper hazel
wet breach
inner mulch
#

im working

#

with packets

#

and i need to

wet breach
upper hazel
#

which is why I was surprised

wet breach
#

so yaml is one of them because you can open it and read it without using anything else to do so

#

ini files same thing

glossy venture
#

yaml might be the worst option i cant imagine the syntax being very efficient/parsing being very fast

wet breach
#

however, while it is one of the most convenient for your end users it is the slowest way to write/read from

upper hazel
#

then json i gess?

#

so yml is an exception.

wet breach
#

no?

#

do you not read?

inner mulch
#

i cannot find the entity mount packet in the protocol wiki, does somebody know what it is called?

glossy venture
#

or at the very least a binary format

#

tho thats prob more difficult to set up

wet breach
#

json isn't really a storage format, its a data format. You can save this format to a file if you want, but it will still be flat file unless you are saving it as binary

glossy venture
#

u should check out sqlite or hikari

upper hazel
#

what format does minecraft use to store chunks of blocks, etc.

glossy venture
#

mysql/mongo/any other if u need cross-server support

wet breach
#

binary

#

specifically NBT

glossy venture
#

nbt is like binary json almost

#

the actual block data is encoded as a byte/short array im pretty sure

rotund ravine
#

Snbt

#

💪🏻

storm crystal
glad prawn
#

uh outdated

storm crystal
#

both?

upper hazel
#

and if I store data in files in the form of bytes, will it be faster than databases, provided that huge data is stored?

inner mulch
#

can someone help me on how to use the enitity mount packet?

rotund ravine
#

Some databases depending on location are just as fast as some files

upper hazel
#

Yes it seems to be a really controversial topic I just want to identify the criteria when to use regular files and when to use a database.

rotund ravine
#

Whenever you feel like it 👌🏻

#

If you want smth crossserver etc etc. Go for databases

upper hazel
#

logically...

rotund ravine
#

If you got something extremely huge

#

Go for databases if it’s singular but a lot of data

river oracle
rotund ravine
#

Yes

river oracle
#

this isn't what is better in general, this is what is better and makes more sense in your case

rotund ravine
#

Though. Don’t overdo it

river oracle
#

you provided not a lot of information so I responded with the best response with the information you provided

#

you said you were storing something to do with blocks so PDC makes much more sense than a Database here

rotund ravine
#

I agree fully with Y2K 💪🏻

#

?blockpdc

undone axleBOT
upper hazel
#

Yes, but I was thinking about other situations when storing user data, for example.

rotund ravine
#

Depending on the usecase for the data

upper hazel
#

or action

rotund ravine
#

Depending on the usecase for the data

river oracle
#

you have to beable to make an informed decision on what data storage you will use depending on what data you have

upper hazel
#

hash, save, upload

#

this all

#

for example, an auction needs to store data about the item

#

time, player, price etc

#

if this not cross-server plugin file system better?

rotund ravine
#

Auctions can be both just fine

river oracle
#

unless you want it to work cross server you could go either way

upper hazel
#

I just thought that if I stored them in files, it would take a long time to load the items when opening the inventory.

#

than the database

river oracle
#

you need to load files on server start

fossil flax
#

player.isInvulnerable() doesn't exits in 1.8?

river oracle
#

put them in memory

rotund ravine
river oracle
upper hazel
#

all loading must take place during runtime

#

when player add, delete item

#

not in start

river oracle
#

files aren't databases

upper hazel
#

or stop ver

river oracle
#

you have to load them on server start

#

and save on server stop

rotund ravine
#

You load previous auctions on start

#

When a player opens you display them

#

When a player adds you add to them

#

When a player deletes you remove from them

upper hazel
#

hashing store?

rotund ravine
#

When a player buys you remove from tjem

#

Caching yes

smoky oak
#

how come multipe accounts can connect to a server but only one debug hook can be applied?

river oracle
#

Hashing is a one way function which turns some object or data into a number

storm crystal
inner mulch
#
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
        PacketContainer packet = manager.createPacket(PacketType.Play.Server.MOUNT);

        packet.getIntegers().write(0, entityID);

        int[] passengerIDList = new int[passengerID];

        packet.getIntegerArrays().write(0, passengerIDList);

        manager.sendServerPacket(player, packet);

    }```

why does this code doesnt work, it doesnt set the entities ass a passenge :(
rotund ravine
#

You are sending an empty list

inner mulch
#

really?

#

ohh

rotund ravine
#

You a creating an int array of size ID

inner mulch
#

i need to say new int in .write ?

rotund ravine
inner mulch
#

jantuck

rotund ravine
#

Yes

inner mulch
#
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
        PacketContainer packet = manager.createPacket(PacketType.Play.Server.MOUNT);

        packet.getIntegers().write(0, entityID);

        packet.getIntegerArrays().write(0, new int[passengerID]);

        manager.sendServerPacket(player, packet);

    }```
this doesnt work too
rotund ravine
#

Still sending an empty array

inner mulch
#

for real?

rotund ravine
inner mulch
#

ok

compact haven
rotund ravine
inner mulch
#

jan how do i add stuff into it now?

compact haven
#

sorry that ur lame like that

#

when ur on computer try it out

#

its actually really cool

rotund ravine
#

Just int[] stuff = { passengerID }

inner mulch
#

ok thanks

compact haven
rotund ravine
#

Ah k

inner mulch
#

thank you bro

frail crystal
#
@EventHandler
    public static void onEntitySpawn(EntitySpawnEvent event) {
        if (event.getEntityType() == EntityType.WANDERING_TRADER) {
            System.out.println("trader spawn");
            WanderingTrader trader = (WanderingTrader) event.getEntity();
            //trader.setRecipe(trader.getRecipeCount() - 1, new MerchantRecipe(CreateHat.createHat(), 1));
            List<MerchantRecipe> recipeList = trader.getRecipes();
            ArrayList<MerchantRecipe> recipes = new ArrayList<>(recipeList);
            MerchantRecipe recipe = new MerchantRecipe(CreateHat.createHat(), 1);
            recipe.addIngredient(new ItemStack(Material.DIAMOND_HELMET));
            switch ((int) (Math.random() * 10)) {
                case 1: recipe.addIngredient(new ItemStack(Material.DIAMOND, 6));
                case 2: recipe.addIngredient(new ItemStack(Material.GOLD_INGOT, 12));
                case 3: recipe.addIngredient(new ItemStack(Material.IRON_INGOT, 32));
                case 4: recipe.addIngredient(new ItemStack(Material.NETHERITE_INGOT, 1));
                case 5: recipe.addIngredient(new ItemStack(Material.DIAMOND, 16));
                case 6: recipe.addIngredient(new ItemStack(Material.REDSTONE, 64));
                case 7: recipe.addIngredient(new ItemStack(Material.ANVIL, 1));
                case 8: recipe.addIngredient(new ItemStack(Material.DIAMOND, 12));
                case 9: recipe.addIngredient(new ItemStack(Material.EMERALD, 16));
                default: recipe.addIngredient(new ItemStack(Material.EMERALD, 12));
            }
            recipes.add(recipe);
            trader.setRecipes(recipes);
        }
    }```
why does this keep saying that im using more than 2 recipes, the only ingrediant that doesnt say that is when it chooses the default one
worldly ingot
#

Because when you work with switch statements there's a concept called fall-through

#

If you don't have a break statement it's going to fall through to the second case, then the third, then the fourth, etc.

frail crystal
#

ohhhhh

worldly ingot
#

You need an explicit break if you don't want it to fall-through to the next case

frail crystal
#

yeah thats right i completely forgot

worldly ingot
#

What you could do to resolve that without needing a break is to use a switch expression which doesn't have fall-through

#

Basically just replace the : with a -> instead

#

Java 16+ though

teal walrus
#

Do you think it's more reasonable to use a single skript plugin instead of many small plugins and write these features as a skript?

rotund ravine
#

Script?

teal walrus
rotund ravine
#

I would always choose a plugin over a skript

#

But you can make a plugin that runs kotlin scripts and write lots of those

teal walrus
rotund ravine
#

Yes it does

#

The amount of times i have seen skript in spark logs are insane

#

People do dumb ass shit with it

teal walrus
#

Oh thanks a lot

young knoll
#

ByteSkript time

teal walrus
young knoll
#

It compiles to bytecode

#

So in theory it should be about as fast as a plugin if your script isn't a mess

slender elbow
#

and if the compiler is any good :^)

young knoll
#

that too

#

ASM jank yay

molten hearth
#

does anyone know where i can find documentation for sendPacketNearby

bitter rune
#

in intelij is there a way to make it so theres predefined code inside a java file when i make a new one

molten hearth
smoky oak
#

can someone explain why typing 'sha' then hitting enter for auto complete results in this

#

like whats that

#

its nowhere else in my code either

molten hearth
#

okay so uh

#

i have the nms stuff i wanted to do ready but

#

now my issue is actually getting it to work on the server lmao

#

the plugin cant find the NMS classes

#

did i miss a step-

smoky oak
molten hearth
chrome beacon
# smoky oak hm

Looks like it's a comment used when you want to avoid pushing known bugs to prod

dry hazel
molten hearth
smoky oak
#

im on maven tho

dry hazel
#

you should probably have some build logic in charge of reobfuscation

molten hearth
#

oh fr

chrome beacon
smoky oak
#

hm true, seems weird tho

#

cant believe i randomly found something like this again

#

i managed to crash myself in 4dminer the other day by finding just the right wrong orientation

molten hearth
#

i guess i need something like alex's remap-obf for gradle

dry hazel
#

paperweight-userdev lol

young knoll
#

^

wanton lynx
#

is it possible to write an algorithm to detect if a given player is underground? I was thinking about first checking the x & z coordinates of the player's location for any large amounts of air above a given block, and if that fails due to a tower or smth then analysing the entire chunk that a player is in, find the average surface y level by checking for large amounts of air above any given block, and then check if the user is below that?

molten hearth
#

oh right thats what the plugin did

#

i added the plugin but i never understood what it did 💀

smoky oak
dusky prawn
#
    discord:
      description: Få tilsendt et link til vores discord
    info:
      aliases: information
      description: Få tilsendt info om serveren```

Is this done right? /Discord and /info is 2 different commands.
young knoll
#

An easy underground check is just to check the heightmap

dusky prawn
#

heightmap?

young knoll
#

But that’ll also count if they are just under a random block

dusky prawn
#

Are you writing to me?

smoky oak
#

heightmap is just highest non air block isnt it?

molten hearth
#

so uh

#

is this plugin used by first running build and then remap

smoky oak
#

i dont think thats meant for underground checks lol

young knoll
#

I believe there is also one that ignores leaves, but yeah

young knoll
#

Looks fine

#

You might need quotes around the description because of the special characters

dusky prawn
#

Im trying. Its only the "Info" command, that doesn't work.

wanton lynx
#

shouldnt aliases be an array

young knoll
#

Oh yeah

#

Missed that

quaint mantle
#

do you guys think its ok to make your own preconditions framework

eternal night
#

isn't guava even exposed by the spigot-api 😅

eternal night
#

reinventing the wheel is usually not the smartest idea

river oracle
#

Preconditions works pretty well

river oracle
#

preconditions libraries are boring and repetative

#

legit they just evaluate boolean statements and throw exceptions if they're false it doesn't get much more boring than that

glossy venture
#

isnt it also like one class though

river oracle
#

legit just a ton of boring administrative work for what

glossy venture
#

maybe you dont have access to spigot everywhere in ur project

river oracle
glossy venture
#

true

river oracle
#

also wait its 5 miliseconds in a tick right

#
    public long ticksBetween(long now) {
        long between = now - current;
        return between / 5;
    }``` pretty sure this would get ticks between 2 milisecond time stamps right?
young knoll
#

50

river oracle
#

oh

#

so I need to divide by 50

young knoll
#

1000 / 20 = 50 :p

river oracle
#

Imperial System baby muscleright

#

Sorry I prefer my units in random arbitrary increments

exotic obsidian
#

is there any specific event to select random player to be the target?

hazy parrot
#

Just.. Get random number from 0 to currently online players

#

And use it as index for Bukkit.getOnlinePlayers

molten hearth
#

is there any event fired when a player stops digging a block

young knoll
#

Yes

#

PlayerBlockDamageAbortEvent

molten hearth
#

thankz 🅱️ig man

#

i accidentally did an oopsie

molten hearth
#

is there any builtin methods to check if something is the best tool for breaking a block

young knoll
#

Tags

#

Tag.MINEABLE_<tool> iirc

inner mulch
#

is there a way to only generate entityids that arent currently in use?

eternal night
#

Use nms.Entity.ENTITY_COUNTER

inner mulch
#

nms?

eternal night
#

well entity ids are not a concept in the API really

#

you generate an "unused" entity id by incrementAndGet the AtomicInt

#

so you'll need internals

inner mulch
#

and this would be bulletproof, so it wouldnt return numbers even though an entity just spawned with the exact number?

eternal night
#

well its an atomic int

#

incrementAndGet is atomic

inner mulch
#

okay, how do i get nms entity counter

#

i have never used nms

eternal night
#

what do you need an entity id for then ?? o.O

inner mulch
#

im using protcollib maybe i jsut dont understand the term nms correctly

eternal night
#

hmm maybe PL has a helper for this ?

inner mulch
#

idk

#

i dont know what the term nms stands for

eternal night
#

net.minecraft.server

#

pretty much just "server internals"

#

so follow any run of the mill tutorial for those

young knoll
#

I can’t believe Mojang just leaves radioactive variables hanging around in their code, this is a kids game!

inner mulch
#

?

eternal night
#

:woosh:

#

awww

#

where did my emoji go

young knoll
#

I need to learn how to properly make use of atomic variables

#

Mostly because they have like 10 get and set methods and idk which one to use

inner mulch
#

coll

#

do you know how i can get the entity count?

inner mulch
#

but with protcollib?

young knoll
#

Protocollib doesn’t give access to internals

#

That’s kind of the point

inner mulch
#

how do i create a entityid that isnt currently in use then?

young knoll
#

Use NMS or reflection

worldly ingot
#

random.nextInt() Kappa

young knoll
#

Chance of conflict is technically low

#

Smh api expose get next entity id when

half arrow
#

Hi all,
i'm looking at create a head hunting plugin for my server, can anyone suggest the best way to supply mob heads? for those that aren't items for example Pig heads?

young knoll
#

PlayerProfile api

#

And the magic of minecraft-heads

molten hearth
#

is this multiplier additive?

#

like

#

if someone has a diamond sword is it 1.5 + 8 or is it just 1.5

river oracle
half arrow
young knoll
#

Minecraft heads has a ton of heads you can browse

#

And grab the link of for use with the api

#

Yeah nothing wrong with that

half arrow
#

Okay, so essentially, we get all the mob/animal head IDs from Minecraft Heads, store them hardcoded, and call them when needed through the API? It feels wrong for some reason

young knoll
#

You can have them in a config if you want them to be customizable

half arrow
#

Ok, i guess if they never change its fine

young knoll
#

They don’t

#

If you use the custom heads section rather than player heads

half arrow
#

ok thanks

molten hearth
#

what da fuck is a dig speed 😭

#

is that efficiency?

young knoll
#

Yes

molten hearth
#

thankz

#

alright ima be honest

#

i dont feel like recoding the whole vanilla breaking speed calculation system

#

is there any resource or library for it 😭

young knoll
#

there’s a method to get the breaking speed for a player

#

If that helps at all

molten hearth
#

i guess man i guess

#

im trying to do this tbh

young knoll
#

Doesn’t look too bad

molten hearth
knotty locust
#

I have this issue: when I start the plugin for the first time and it creates the config files, it creates a fake value - let's say 'b', but it should be 'a' (b is used as well and it's stated in the next line), but next time I run it with the config created already, it works normally.

I assume it's some loading issue but the all config stuff is called before creating the thing that causes the issue.

young knoll
#

Show the code

knotty locust
#

can't now but do you know what it can be?

#

I forgot to push it 💀

young knoll
#

Maybe weirdness with defaults

wet breach
# knotty locust I have this issue: when I start the plugin for the first time and it creates the...

creating config and loading config are two different things. Just because it creates the configs doesn't mean it loads it, therefore you can have a situation where in memory values are not synced with saved values, more so the case if you start changing the in memory values. Restarting the server would cause the in memory values to go away and instead pull values from the config since the config exists.

knotty locust
#

and it's weird bcs the 1.6 is actually on the next line so it's loaded afterwards

knotty locust
wet breach
#

well we won't know without code 🙂

#

Null values in regards to numbers count as 0

knotty locust
#

ik ik

wet breach
#

just fyi

#

so 1 + null = 1

#

because null defaults to 0

#

because primitives can't be null is one of the reasons, if however you were to be using the object form you get an NPE instead

knotty locust
#

I'll send the code in the morning

river oracle
#

How do you make a persistent data container? I need to make a PersistentDataContainer because I need to put a tag within a tag

#

nvm

#

I'ma just make a custom type

young knoll
#

container.getAdapterContext.newPersistantblahblah

river oracle
#

if only the list stuff was merged

#

be so convient rn

#

alas its not ready

young knoll
#

?morepdc

undone axleBOT
young knoll
#

:p

river oracle
#

true thanks jeff

#

I forgot about this library

fading gull
#

I have to store a bunch of animations. One animation contains one implementation of a shape class. An animation also contains stages which can be static, rotation, etc.
I'm using json (for the ability to edit data) and storing each animation in a json array. To get the specific implementation of shape used i could add "type": "star" . But then what...i dont want to make a giant switch structure. same thing goes for animation stages.

young knoll
#

Use a lookup map then

fading gull
#

ill look that up

young knoll
#

It’s just a map

#

Have the shape type as a key and then whatever as the value

fading gull
#

i have to instantiate the shape class when retrieving data. also the data varies based on the shape type, so I could have a method in each shape which retrieves its own data from a jsonObject and returns a new class. Idk how to get from "star" to a variable of star.class without using reflection.

tender shard
#

ShapeFactory

molten hearth
#

is there an event fired for the fishing line breaking

young knoll
#

Have it be a Map<String, Consumer<JsonWhatever>>

grand flint
#

what event triggers for a fishing rod to break

young knoll
#

Are you the same person

#

O_O