#help-development

1 messages Β· Page 1920 of 1

quiet ice
#

because it is far nicer to see for a developer

drowsy helm
#

its more compact

grim ice
#

0x716161616161616

#

or am i fucking

quiet ice
#

You have no idea what the decimal value of 2^31 is, but you instantly know what 0x7F_FF_FF_FF is

drowsy helm
#

no

grim ice
#

i dont get it

drowsy helm
#

i'd suggest reading into different base number systems

grim ice
#

thats what im trying to do but i dont get it

quiet ice
#

0x7_16_16_16_16_16_16_16
Yep, you are fucking

drowsy helm
#

it's a bit hard to explain just in a few sentences

grim ice
#

why is it 7 and 7 16's

quiet ice
#

oh

#

0x means "everything after it is hexadecimal"

grim ice
#

yes

quiet ice
#

0xb means "everything after it is binary"

drowsy helm
#

7FFFFFFFF is the same as 34359738367

grim ice
#

what

quiet ice
#

so 0xFF is 0b1111_1111

grim ice
#

but thats past integer limit

drowsy helm
#

sorry 2147483647*

#

put an extra f in my converter

tardy delta
#

πŸ€”

grim ice
#

so how does ur converter do it

#

is it 16*16*16*16

#

or something

drowsy helm
#

so every place in a hex digit is 16^n

grim ice
#

so its

quiet ice
#

converts hex into binary (rather easy), then binary into decimal (not so easy)

grim ice
#

16^16^16 etc

quiet ice
#

Meh

forest path
#

Hey, does anyone know why pushEntities is called when isCollidable is false? (For a LivingEntity)

It's a problem for big mob farms.

grim ice
#

aaaaa

#

i dont get it at all

quiet ice
#

0xFF = 15 * 16^1 + 15 * 16^0 = 15 * 16 + 15 = 255

grim ice
#

tf

#

why is it different when u add 2 F's

#

wasnt an F a 16

drowsy helm
#

if i want to convert for example F13FE to base 10 i would do

16^4|16^3|16^2|16^1|16^0
128 |64  |32  |16  |0

and times each value by the corresponding column

quiet ice
#

F is 15

grim ice
#

what

quiet ice
#

16 would be 0x10

young knoll
#

Base 16

#

123456789ABCDEF10 etc

grim ice
#

then whats that

#

Oh theres a 10 at the end

drowsy helm
#

thats all the digits in hex

grim ice
#

u forgot '10'

#

right?

drowsy helm
#

no 10 isnt a digit

grim ice
#

]

young knoll
#

10 is 2 digits

quiet ice
#

0 = 0x0
1 = 0x1
2 = 0x2
...
10 = 0xA
11 = 0xB
12 = 0xC
13 = 0xD
14 = 0xE
15 = 0xF

young knoll
#

Believe it or not

grim ice
#

i know but like

#

whats difference between

#

0xA

young knoll
#

In base 10, 10 is 10

grim ice
#

and 0x10

quiet ice
#

0x10 is 16

grim ice
#

my brain

young knoll
#

In base 16, 10 is 16

drowsy helm
#

like i said read up on it

#

its hard to explain in a few sentences

grim ice
#

so 10 is bigger than A,B,C, and the other letters and numbers

#

but 10 isnt a digit

drowsy helm
#

dont think of A,B,C as letters

grim ice
#

how does it exist

drowsy helm
#

they are numbers aswell

grim ice
#

yes

quiet ice
#

Do you understand binary?

grim ice
#

not really

quiet ice
#

Bummer, if you did it would've been easier to convert hex into bin and back

grim ice
#

i kinda get it

#

but not that much

drowsy helm
#
16^4 |16^3 |16^2|16^1|16^0
65536|4096 |256 |16  |1
F     1     3    F    E
15    1     3    15   14
=
983040 + 4096 + 768 + 240 + 14
=
988159

Thus (hex)F13FE = (dec)988159
#

so you are multiplying each number's place by 16^n (n being it's place) and adding them together

quiet ice
#

^

grim ice
#

its read right to left?

drowsy helm
#

it's easiest to do it right to left

#

to calculate it

quiet ice
#

Well, like dec and binary the symbol with the highest value is the leftmost

drowsy helm
#

so for example F is the 5th place so you do F x (16^4) = 15 x (16^4)

#

oops

quiet ice
#

E would be 14

drowsy helm
#

14

young knoll
#

I saw that edit :p

drowsy helm
#

shh

grim ice
#

that makes sense

drowsy helm
#

its the same with binary

grim ice
#

but why is 10 not a 1 and a 0

drowsy helm
#

10 = A

grim ice
#

didnt 10 mean 16

drowsy helm
#

lemme write a table for 10

wet breach
#

you just need to learn the trick to converting between bases

#

binary is base 2 decimal is base 10

drowsy helm
#
16^4 |16^3 |16^2|16^1|16^0
65536|4096 |256 |16  |1
                 1    0 (HEX DIGIT)
                 16   0 (DEC DIGIT)
=
                 16 + 0
=
16
wet breach
#

and give me a minute

quiet ice
#

And what is this tick?

wet breach
#

and I will teach the easy method

drowsy helm
#

1x(16^1) + 0x(16^0) = 16

young knoll
#

Isn’t the easy method to use an online converter

quiet ice
#

Right now I only know that you can consecutively divide by 2, but that takes ages to do

drowsy helm
#

its the same method for binary except you use base 2

#

so each digit in hex is 16^n-1, binary is 2^n-1

quiet ice
#

Oh no, bin -> dec would be multiplying

wet breach
#

    First, divide the number by the base to get the remainder. This remainder is the first, ie least significant, digit of the new number in the other base
    Then repeat the process by dividing the quotient of step 1, by the new base. This time, the remainder is the second digit, ie the second least significant.
    Repeat this process until your quotient becomes less than the base. This quotient is the last digit, ie the most significant digit.
drowsy helm
#

n being the place

wet breach
#

It is that simple πŸ™‚

grim ice
#

@drowsy helm ty i get it how it works now

#

so like

quiet ice
#

That is how it works with dec -> bin/hex, but not bin -> dec iirc
At least, that is not how I have done it

drowsy helm
#

yeah the base^n-1 rule is only for decimal

grim ice
#

0xAB332
means
A is 10 so
(10*(16^4))
B is 11 so
(11*(16^3))

#

etc

#

is it right

drowsy helm
#

yes

quiet ice
#

But eh, bin -> dec is just a lot of addition, not complicated just takes a lot of time

grim ice
#

ayyy

#

a dec is a hexademical

#

right?

wet breach
#

so lets say we want to convert 1208 to base 26

quiet ice
#

no, decimal

drowsy helm
#

once you get the initial concept its the same for all bases

wet breach
#

this is the math for it

grim ice
#

whats a demical

quiet ice
#

0-9

drowsy helm
#

decimal is referring to our base 10 system

grim ice
#

and why is it 16

#

that we multiply by

#

is it cuz a char is 16 bits

young knoll
#

Because it's base 16

grim ice
#

so for base 64

drowsy helm
#

yeah its useful because its a power of 2

#

programmers like powerse of 2

grim ice
#

its 64*

quiet ice
#

Let's use regex:
bin = [01]+
oct = [0-7]+
dec = [0-9]+
hex = [0-9A-F]+

grim ice
#

or am i dumb

sage dragon
#
if (!(plugin instanceof org.bukkit.plugin.Plugin) || !(plugin instanceof net.md_5.bungee.api.plugin.Plugin)) 
  return false;

Will this throw any exceptions, or will it work just fine?

grim ice
#

hex allows anything from 0 to 16

#

bin from 0 to 1

#

oct from 0 to 7

#

dec from 0 to 9

#

?

drowsy helm
#

yeah

quiet ice
#

hex allows anything from 0 to 15 (both inclusive)

grim ice
#

then where did the 10 go

#

in hex

#

isnt there a 10 that meanas 16

quiet ice
#

it's A

drowsy helm
#

10 isnt a digit

grim ice
#

then how do u say 16

young knoll
#

10

quiet ice
#

0x10 (hex) = 16 (dec)

grim ice
#

f is 15

grim ice
drowsy helm
#

sorry im wrong lol

young knoll
#

10 isn't a single digit though

#

It's 2, just like in decimal

#

0-F are all single digits

quiet ice
#

in hex that is

grim ice
#

how

#

what

quiet ice
#

Well, per character

grim ice
#

so 10 is an exception

drowsy helm
#

1*(16^1) = 16
0*(16^0) = 0

#

16+0 = 16

grim ice
#

its 2 characters

quiet ice
#

1 would still be between 0 and 15 and 0 would be still between 0 and 15

#

so still valid

quaint mantle
#

can i freeze a particles movement?

#

or make it only move on a certain axis?

grim ice
quiet ice
#

no you cannot

grim ice
#

and 1 will mean 16

#

what

drowsy helm
#

thats like saying you can remove the zeros from 100 because its the same

quiet ice
#

For example 100 (dec) is not 1 (dec)

quaint mantle
#

does anyone know a certain particle thats white-ish that doesnt move

#

just falls down

grim ice
#

is there a 0 in hex

drowsy helm
#

yeah 0

grim ice
#

so how do i know its a 10

#

not a 1 and a 0

#

or is it the same

drowsy helm
#

if you're talking hex 10 will always = 16

#

if you want decimal 10 in hex it would be A

grim ice
#

and 1 will also mean 16

#

?

drowsy helm
#

no the digit placement matters a lot

grim ice
#

0x1

#

what does this mean

drowsy helm
#

= 1

grim ice
#

and 0x10

#

means 16?

drowsy helm
#

yes

#

11 is 17

#

12 is 18 etc

grim ice
#

wasnt it base 16

#

how are we on 17

drowsy helm
#

1x(16^1) = 16
1x(16^0) = 1
16+1 = 17

grim ice
#

OH LMAO

#

I GOT IT

drowsy helm
#

the table method helps a lot

grim ice
#

SO LIKE BECUZ NOW ITS A SECOND PLACEMENT

#

ITS ^1

#

so its 16

#

i get it

drowsy helm
#

yeah

grim ice
#

that makes a lot of sense

#

okay

quiet ice
#

it's pretty much your standard decimal but with other symbols

quaint mantle
#

does anyone know any particle that doesnt move

grim ice
#

we couldve added 1 or 2 or anything but then it would make it a second placement but also add a number

#

so we dont want that

#

so we add 0

drowsy helm
#

yeah exactly

quiet ice
#

I never really understood how people don't understand it, but then I also learned hex/bin really early in my life

grim ice
#

how old

quiet ice
#

8-ish I belive

grim ice
#

damn

#

brb btw

drowsy helm
#

i only learnt this stuff last year

grim ice
#

i gotta learn oct and other stuff when i come back ig

drowsy helm
#

my uni teacher taught it super well

#

all the other base systems are the exact same concept

quiet ice
#

to be honest, it makes more sense to just learn binary and then only learn the conversion between binary and hexadecimal/octal

drowsy helm
#

Converting non dec to non dec can get confusing sometimes

wet breach
#

223 base 10 to base 5  = 1343


first we figure out the powers
125   25   5     1
5^3  5^2  5^1  5^0

(1)  (3)  (4)  (3)  

223/125 = 1 R 98

98/25 = 3 R 23

23/5 = 4 R 3

1/3 = 3
quiet ice
#

Yes, but usually you'd only work with powers of two

wet breach
#

hope this illustrates better

drowsy helm
#

Yeah thats true

wet breach
#

Now there is something about converting, you will notice that when I converted to base 5

#

I have 4 digits

#

this is because by default bases are base number minus 1 because of the sign

#

if you don't care about the sign and want only positives, then you have to do a bit extra math for that to ensure nothing ever is negative πŸ™‚

#

give me some more time to find some of my formulas

#

because I have it written on another trick for converting too

#

what I illustrated is the so called proper method

#

there is another method that isn't considered proper but it is generally faster XD

obtuse ferry
#

Does unsafeenchant "overwrite" old enchants

wet breach
#

it shouldn't, unsafe just lets you use a higher value for the level of the enchant then what is natively supported

obtuse ferry
#

For example if I have my custom enchant ABC level 1 and then i apply level 2 is level 2 now there or are there both and i need to remove the old one

wet breach
#

oh, it automatically changes the level

obtuse ferry
#

πŸ‘

drowsy helm
#

Dont think it’s possible to have multiple of the same enchant on an item anyway

wet breach
#

and that ^

obtuse ferry
#

kk, its just visual then because of how I add my lore

#

Should I be using
item.getItemMeta().hasEnchant()
or
item.containsEnchantment()

quiet ice
#

I'd use latter unless it is deprecated

hardy swan
#

LoD

#

although i don't even care about that while developing plugins haha

quiet ice
#

As #getItemMeta clones itemmeta

alpine barn
#

how do I trigger a sound?

quiet ice
#
    public boolean containsEnchantment(@NotNull Enchantment ench) {
        return meta == null ? false : meta.hasEnchant(ench);
    }

Oh, and it is good if the item is air

ivory sleet
# hardy swan LoD

A good principle, but if one follows it, one must be aware of the cons such as that you will have to write (a lot of) adapters, proxys and other ways to delegate and propagate.

quiet ice
#

(that being said, that is the paper impl, I'd not be suprised if cb uses return getItemMeta() == null ? false : getItemMeta().hasEnchant(ench) which would be even worse)

mortal hare
#

so i finally managed to setup my project through gradle (it was pain in the ass, especially from the maven user's perspective.) and i've hit another bummer. io.netty classes missing in 1.18

#

do i need to include it inside as seperate dependency?

quiet ice
#

?stash

undone axleBOT
smoky oak
#

is there an equivalent for PlayerAttackEvent or do i have to use EntityDamageByEntityEvent?

hardy swan
#

latter

quiet ice
#

You probably need to include them manually

hardy swan
#

take a look at their CraftBlockData

quiet ice
#

which is why I used not that

mortal hare
#

i have spigot jar inside my maven repo installed

#

and spigot-api too

#

how tf does server uses netty if the maven repo jar file doesnt include one

spiral light
hardy swan
#

Say player A fire an arrow at C, then player B hits C, then the arrow hits C.

#

How do we get A from EntityDBEEvent?

quaint mantle
mortal hare
#

i dont get it

#

how can i include netty

#

it was so simple back in the days

#

now everything's so fragmented

#

since 1.18

spiral light
hardy swan
#

well thanks

quaint mantle
hardy swan
#

yea

#

but the idea there

spiral light
#

maybe ^^

#

but you cant "null instanceof Player"

#

projectilesource can be null

hardy swan
#

it will just return false

#

it includes nullity check

spiral light
#

hmm ... yeah dont know if you can check null ^^

quaint mantle
#

using tryit editor because i still havent figured out how to use that same feature in intellij

hardy swan
#

you can always use jshell for quick verification

#

that's if you hate creating files

vocal cloud
#

Create junit tests lul

hardy swan
#

easy game

hardy swan
grim ice
#

now that i know hexademical, how does Unicode and binary and ASCII work

hardy swan
#

you wanna learn some C?

grim ice
#

im not learning C these are just topics I do not understand

trim creek
#

For a runTaskLater Bukkit izΓ© a simple public JavaPlugin plugin; is not enough?!

tardy delta
#

printf("no")

#

dont expose variables please

smoky oak
#

is there a temporary (until restart) variation of the PDC? I need to store for some entities a timer

grim ice
#

and dont use JavaPlugin use ur main class i think its better

#

so private final Main plugin then initialize it in ur constructor

trim creek
tardy delta
#

no no no

smoky oak
#

isnt metadata persistent?

hardy swan
grim ice
trim creek
#

First of all: the main class just inits the whole plugin. Second of all: the plugin has more server types in it, so I cannot use the loader.

grim ice
#

ur main class is a java plugin

trim creek
#

Yes

tardy delta
#
public Class MyPlugin extends JavaPlugin {
  private static MyPlugin instance;

  @Override void onEnable() { instance = this; }

  public MyPlugin getInstance() { return instance; }
}```
Or dependency injection
```java
public class ClassThatNeedsPluginInstance {
  private final MyPlugin plugin;

  public ClassThatNeedsPluginInstance(MyPlugin plugin) { this.plugin = plugin; }

  void doSomething() {
    Bukkit.getScheduler().runTaskLater(plugin, () -> System.out.println("MOOOOOO"), 20);
}
}```
trim creek
#

But it won't have any respawn events in it

tardy delta
#

use MyPlugin.getInstance() to access it

grim ice
#

I don't think I understan what you're talking about

hardy swan
tardy delta
#

also ?di

#

?di

undone axleBOT
tardy delta
#

which is usually better

grim ice
#

no

#

I want to know

#

How do these things work

trim creek
hardy swan
#

ok you know binaries? strings of bits? 01000101

grim ice
#

for example, Hexademical
0xAB
is A = 10
10*(16^1)

hardy swan
#

ahh

grim ice
#

B is 11

#

11*(16^0)

#

thats what i meant

#

and other information that you think is useful

hardy swan
#

ok so for binaries it is just base 2 decimals

grim ice
#

Yes it is a base 2 is what i heard

hardy swan
#

so 101 is 1x2^0 + 1x2^2

hardy swan
#

once you know what base is it shouldn't be hard to understand other bases too

grim ice
#

set to variables then access variables

grim ice
hardy swan
#

not getting into data representations and signs

grim ice
#

its same for everything

#

then

hardy swan
#

yes

grim ice
#

oh poggers

#

ok can we get into data representations

#

and signs

hardy swan
#

you can search up on 2-complement representation of integers

grim ice
#

wait i think that exists in my todolist 1s

hardy swan
#

that's a bit more complex

grim ice
#

u mean

#

"- learn about twos complement numbers - 0%"

#

yep it is

#

I have this in my todolist

  • learn about bits and bytes - 15%
  • learn about IEEE-754 numbers - 0%
  • learn about twos complement numbers - 0%
#

so i guess ill learn it

grim ice
#

yeah ive figured that out

hardy swan
#

ok task one completed

grim ice
#

lol

#

i wanna get into details tho

#

the extreme details if possible

#

idk if i can but i want to

tardy delta
wet breach
trim creek
#

There are no multiple worlds...

wet breach
grim ice
#

ill watch ur vids 24/7 lmao

#

o

wet breach
#

But there is things like this

#

I want to talk more in depth and teach people

#

where its hard to find the clarifications

grim ice
#

maybe u can make forums until u move

#

then u can just read ur forums in ur videos

#

and u will alr gain some fame in the meanwhile

wet breach
#

I gave up my Dedi a couple of months ago so don't have a place for a site

grim ice
#

use spigot kek

wet breach
#

will be getting it back though πŸ™‚

grim ice
#

or do tha

wet breach
#

but, I love to teach though and math is one of my favorite things and people tell me I do so well in explaining it easily for people to understand

hardy swan
# grim ice the extreme details if possible

so basically all data is represented in units of bytes, not bit. This explains why a boolean is a byte and not a bit, cause using bit for it has some overhead on computation. integers are most of the time 32 bits, long long (or java's long) is 64 bits, char and boolean is 8 bits etc.

wet breach
#

because I don't believe things need to be hard

grim ice
#

SolarRabbit seems to be writing a ton, ty rabbit :)

wet breach
#

and most of the time it isn't hard just needs to be better explained to be better understood πŸ˜„

trim creek
grim ice
#

u just dont know how to use it

#

show me ur code

hardy swan
#

then I think you are kind of set to go, next learn bit operations

grim ice
#

what are bit operations now

#

i should google it

#

but live chat is much more fun

hardy swan
#

it is a manual way of manipulating bits

#

with vast applications

#

and computational advantages

grim ice
#

can u give me an example

trim creek
# grim ice its not shit

Oh sooo good.... -.-
I need a fucking respawn system because of a fucking bug that makes me always teleport to the fucking top of the fucking buildment, but I cannot, because the fucking plugin doesn't do anything without waiting a fucking tick (it doesn't teleports the player), and now even code share?!

quaint mantle
#

?learnjava

undone axleBOT
grim ice
#

if u dont want help u can take ur leave

quaint mantle
#

you're the one who want to get help, not us

grim ice
#

^

quaint mantle
#

dont be so hostile

grim ice
#

like i am rn, i cannot just scream at solar

hardy swan
# grim ice can u give me an example

For example, there is this operation called left shift (<<). It basically shift all bits of the data structure to the left. 0001 -> 0010. As you might realise this is equivalent to multiplying the number by powers of two, which is faster if you do bit shifts for large powers

grim ice
#

cuz first thats not nice and second hes helping me

wet breach
grim ice
#

OH BITWISE OPERATORS

#

I SAW THAT IN SOME CODE

#

|= or smth

hardy swan
#

oh yes, bitwise operations, my bad

grim ice
#

how can this help me in code tho

hardy swan
#

it depends, you can look at java random for one such application

quaint mantle
grim ice
#

why would u even scream at anyone here

#

anyways

grim ice
#

do they make a random of 0 or 1

trim creek
grim ice
#

and make an array of 0s and 1s

trim creek
grim ice
#

then they turn it into numbers or something

trim creek
#

You will know why I need all this crap

#

Even executing a fucking spawn command doesn't do aynthing

vocal cloud
#

Being upset isn't going to help so maybe calm down first

trim creek
#

IT ALL IS USELESS AS FUCK

quaint mantle
#

thats the server problem then

grim ice
trim creek
quaint mantle
cold tiger
#

How do i share large code

quaint mantle
undone axleBOT
hardy swan
grim ice
#

o

#

what does that mean

wet breach
# grim ice how can this help me in code tho

an easy example is if you wanted to do exponents of 10, you only need to shift the bit over instead of doing actual math. This skips the CPU doing any processing to figure out the result and instead you are saying this is actually the result

cold tiger
grim ice
#

and how to perform it

#

is it smth like

#

0100 <<

wet breach
#

in Minecraft, when you convert from chunk coords to block coords you can do bitshifting πŸ™‚

grim ice
#

how to assign that to a variable and stuff

wet breach
#

bounding boxes can use bitshifting too

grim ice
cold tiger
# cold tiger https://paste.md-5.net/onepuzeviz.cs
                    player.getWorld().getEntities().stream().forEach(e -> {
                        System.out.println("Running");
                        if (e.getType().name().equalsIgnoreCase(args[0].toUpperCase())) {
                            System.out.println("World: " + player.getWorld().getName() + " Entity Name: " + e.getType().name() + " Location: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ());
                            player.sendMessage("World: " + player.getWorld().getName() + " Entity Name: " + e.getType().name() + " Location: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ());
                        }
                        else {
                            //me.fanisus.tutorial.Main.getPlugin(Main.class).getLogger().log()
                            System.out.println("Cannot find entity with given name");
                            player.sendMessage("Cannot find entity with given name");
                        }
                    });
                }``` 
This throws me an error
ErrOr:```[18:38:20 INFO]: Fanisus issued server command: /tutorial:entity-location Boat
[18:38:20 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'tutorial:entity-location' in plugin Tutorial v1.0-SNAPSHOT
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:897) ~[paper-1.18.1.jar:git-Paper-175]```
hardy swan
#

for example chunks are 16x16
nvm bad example i was thinking of

grim ice
#

here u go

#

stop flooding pls

wet breach
#
Int A = 100;
//this shifts the int's bits to the right by 1.
Int B = 100 >> 1;
wet breach
#

yep

#

there is 3 bitshift operators

wet breach
#
<< and >> are arithmetic shifts

>>> is a logical right shift
grim ice
#

and <<

#

o but whats >>>, ik that === checks instances in memory but idk

hardy swan
grim ice
#

is there a way not to use them

wet breach
#

unfortunate with bitshifting in java you have to use int or long

#

you can't use byte to do it

hardy swan
#

but you can represent them with suffix b

wet breach
#

^

hardy swan
#

i think

grim ice
#

so

#

good practice is

#

Int A = 100b;
Int B = 100b >> 1b;

wet breach
#

I will show you an example project where I use bitshifting

hardy swan
grim ice
#

so ur not shifting it by a bit, ur shifting it by a number?

hardy swan
#

you are shifting by one position

grim ice
#

ive heard B is byte and b is bit is that true

grim ice
hardy swan
wet breach
hardy swan
#

oh yea, colors are good examples

wet breach
#

I created that project because someone wanted me to compress colors into 8bit

smoky oak
#

how do you check if MetadataValue.getOwningPlugin() returned your plugin? Doesn't the main class extend JavaPlugin?

wet breach
#

which is what most consoles support πŸ˜›

#

and specifically ANSI consoles

tardy delta
wet breach
#

But bitshifting makes a lot of the math super efficient πŸ™‚

#

since technically there is none XD

grim ice
#

public static String getHexValue(int num) throws IllegalArgumentException {
ColorChecker.checkColorCode(num);
int red = (num & 0x0ff) << 16;
int green = (num & 0x0ff) << 8;
int blue = (num & 0x0ff);
int red2 = (red / 8) * 256;
int green2 = (green / 8) * 256;
int blue2 = (blue / 8) * 256;
int hexvalue = (red2 >> 5) | (green2 >> 2) | blue2;
return Integer.toHexString(hexvalue);
}

#

sorry for flooding but

#

will

#

red return what

#

if num is uh

#

idk

#

what is num supposed to be

smoky oak
tardy delta
#

i think that will work

wet breach
#

the colors are RGB

grim ice
#

oh

#

so how

hardy swan
grim ice
#

whats masking

hardy swan
#

you have ffffff as color white

grim ice
#

yes

hardy swan
#

r value of ff, b value of ff, and g value of ff

grim ice
#

OH

#

16777215

#

that?

wet breach
#

so because RGB is technically base 3 and hex is base 6, I have to use offsets to fill the gaps πŸ™‚

grim ice
#

its in decimals now

wet breach
#

hence the 0x0ff

#

that is an offset

grim ice
#

arent ansi color codes like

#

"\033[0;33m"

#

and stuff

wet breach
#

yes

grim ice
#

wat

wet breach
grim ice
#

& will append right

#

or will it add

#

1 & 2

wet breach
#

it will append

grim ice
#

okay

wet breach
#

as I said I have to pad

#

because hex is larger

hardy swan
grim ice
#

ill print the values

#

lemme try the code

#

1s

wet breach
#

sorry bit tired

cold tiger
#

if ((args.length > 0) && (args[1].equalsIgnoreCase("chunk"))) {}
This line throws an the error how do i fix

hardy swan
#

get it?

#

nvm

grim ice
hardy swan
cold tiger
#

What does that mean

#

Google doesnt seem to help me out

hardy swan
#

you are trying to access position 1 of array with only 1 slot

vocal cloud
#

You need to learn java.

hardy swan
#

positions are however 0-based

cold tiger
vocal cloud
#

No because arrays start at 0

hardy swan
#

yes this is not c

grim ice
#

uh

vocal cloud
cold tiger
#

0 works fine, in else part

hardy swan
#

-.-

vocal cloud
#

Then you need to > 2

cold tiger
#

so had no problems with it

vocal cloud
#

You really need to learn java. Sigh

wet breach
#

so, using the & 0x0FF is essentially bitmasking. This will make the integer in binary representation have 0's all to the left except the lowest 8bits
@grim ice

cold tiger
vague nexus
#

hey, how can i get player skulls wothout loading time?

mortal hare
#

does anyone have problems with 1.18 dependencies

cold tiger
#

minimum

mortal hare
#

i can't find netty classes anymore

cold tiger
vocal cloud
grim ice
#

@wet breach but

#

\033[0;33m

#

is not an integer

wet breach
#

this is necessary for the bitshifting because remember, I am going from hex to rgb, one is greater then the other, thus I need the padding on the left to be appropriate so I can do the bitshifting

grim ice
#

how do you access it as an integer

mortal hare
wet breach
#

that is why I have the escapesecquence method

#

the reason I didn't automatically do that in the other methods is because then you couldn't use this color conversion code in other projects πŸ˜›

grim ice
#

o

wet breach
#

you would constantly have to keep filtering the result XD

vague nexus
grim ice
#

cant u just

#

Color.decode(hex);

wet breach
#

The project doesn't use any API's πŸ˜›

#

its universal

#

can be used in anything if you want πŸ™‚

grim ice
#

its built in

#

o

wet breach
#

its not a plugin, its designed to be depended on and shaded in or built as jar that resides in a directory with your main jar

grim ice
#

its in awt so

#

e

#

anyways

#

int hex = 0x123456;
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = (hex & 0xFF);

#

i found this in google

#

this is essentially what ur doing

#

right

wet breach
#

essentially yes

grim ice
#

i still dont get how it works

#

lol

wet breach
#

think about it in exponents

#

remember how we demonstrated how to convert bases? and showed exponent representations?

#

well bitshifting is an exponent operation

wet breach
#

yes like a while back XD

#

well I did anyways

#

but remember bases in code still is binary though

maiden briar
#

Anyone can help me with MySQL?
I am working with a points system. If a players wins a game he will get a point, losing will remove a point, etc. I also want to check what place the player is (For example, player Tvhee has 10 points, player Fool has 5 points. If I want to get the first placed player I want to get Tvhee)

#

How can I sort the table?

wet breach
#

so because I am down converting to base 3 or from 16bits to 8bits, I have to pad with 0's to the left

grim ice
#

how do u even convert binary to hex and vice versa

mortal hare
grim ice
#

idk how to convert binary to hex and vice versa

hardy swan
#

you don't convert

#

it is just a matter of representation

#

moreover, bitwise operators operate on bits

#

so you should do the conversion yourself

grim ice
#

how do i know what is the result of
0xFF0000 >> 16

mortal hare
#

that should be 0x0 iirc (edit wrong)

visual tide
#

what does Permission#getPrimaryGroup in vault get? the group with the highest priority or what

hardy swan
#

bit right shift by 4*4 is equivalent to right shifting hex 4 times

grim ice
#

whats bit right shift by 4*4

hardy swan
#

1 hexadecimal digit is 4 bits

grim ice
#

oh ok that makes sense

hardy swan
#

hence 0xabcdef >> 16 = 0xab (shift by 4 positions in hexadecimal sense)

grim ice
#

where the fuck did the cdef go

#

did they disappepar

hardy swan
#

to meet god

#

yea

grim ice
#

rip

#

so

#

0xabcdef << 16

#

0xef

#

?

hardy swan
#

depends on the data structure

grim ice
#

wha

wet breach
# grim ice thats why i dont understand this

alright, so in RGB, each color code, has a range from 0 to 255, which is an unsigned byte. however RGB in code isn't represented with 3 bytes, instead it is represented with an integer number instead. So how do we know where RGB is at? Well in 8bit colors, Red has 3bits, Green has 3bits and then Blue has the remainding 2bits

hardy swan
#

0xabcdef << 16 is 0xabcdef0000 for java's long

#

and 0xcdef0000 for integer

mortal hare
#

anyone from here code plugins for 1.18?

wet breach
#

so if we want to know the bits for red, we can shift 5bits out of the way

#

to get the left 3 bits

#

and doing this, I didn't need to know any math what the red color is

#

because I need to know the values of the colors themselves before I can do any converting

#

hence the additional math that does get done but on each bit color πŸ™‚

#

and then at the end if we are converting to hex, we need to shift the bits to pad because hex is larger then 8bits

#

if we didn't shift the bits with logical right shift, all the bits on the left would be F's

#

instead of 0's

#

FFFFFFF8 is not the same as 00000008

#

and remember these values are being held in an int

grim ice
#

o

wet breach
#

so, while although I am working with 8 and 16bits, there is more bits being represented then what is being messed with XD

mortal hare
#

no one develops 1.18 plugins here i guess

#

:/

opal juniper
wet breach
mortal hare
#

i can't seem to find netty packages anymore

wet breach
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

opal juniper
mortal hare
#

the thing is, i'm using paper

wet breach
#

then you shouldn't be here then

#

o.O

visual lichen
#

Hi, how I can import classes from manager package? I have GameManager class here and it's critical for the minigame plugin I work on. But when I try to refer to such class by code:

getServer().getPluginManager().registerEvents(new GameManager(this), this);
  • it's throwing an error 'registerEvents(org.bukkit.event.Listener, org.bukkit.plugin.Plugin)' in 'org.bukkit.plugin.PluginManager' cannot be applied to '(xyz.slavistapl.plugins.instagib.manager.GameManager, xyz.slavistapl.plugins.instagib.Instagib)'. How I can refer to the GameManager class from manager package otherwise?
    Any help would be appreciated.
undone axleBOT
wet breach
#

there we go

opal juniper
#

paper-api or paper

#

wait actually you are using the userdev i assume

wet breach
#

well their build system is different too

mortal hare
#

i don't

#

i built it via gradlew

#

and installed it inside maven .m2 folder

grim ice
#

hm

wet breach
#

but I mean, this is the wrong discord to come to, and asking how to properly depend XD

opal juniper
#

yeah ok so go to paper

brave goblet
#

Is anyone willing to help me make a custom world gen plugin? from a datapack.

grim ice
#

@wet breach @hardy swan

#

you two

#

are better

#

than all the teachers ive met in my 15 years of life

wet breach
#

lol

grim ice
#

lol

#

btw

#

whats |=

spiral light
spiral light
brave goblet
#

Well only because the datapacks make use of functions

brave goblet
spiral light
brave goblet
wet breach
# grim ice whats |=

//  | is bitwise or   |= is the same as += or works in the same way, just used in bitwise operation instead.
public static final int DEFAULT_SOUND = 1;
public static final int DEFAULT_VIBRATE = 2; // is the same than 1<<1 or 10 in binary
public static final int DEFAULT_LIGHTS = 4; // is the same than 1<<2 or 100 in binary

int myFlags = DEFAULT_SOUND | DEFAULT_VIBRATE; // same as 001 | 010, producing 011
brave goblet
spiral light
spiral light
#

or do you want to let the plugin read your datapack ?

brave goblet
#

I would just like to have custom world generation without lag ;-;

spiral light
grim ice
#

how is it 001 | 010

brave goblet
#

if there isn't you can usually find a dev anywhere thats willing to make a plugin to replace it. datapacks are generally fairly simple by nature, so recreating as a plugin is usually a 5 minute job for most plugin devs
This is what some one said if i can't find a world gen plugin similar to the datapack

wet breach
#

2 in binary is 010

spiral light
wet breach
#

remember I said |= is the same as += but you can't use += in bitwise operations

#

so you have |=

brave goblet
wet breach
#

010 + 001 = 011

grim ice
#

OH MY BAD I THOUGHT U MEANT DEFAULT VIBRATE

brave goblet
#

if it's pure world gen it should be less laggy

spiral light
quaint mantle
grim ice
quaint mantle
#

or you want to learn to do that yourself

brave goblet
brave goblet
quaint mantle
#

if you want someone to do that for you then

grim ice
#

basically a += binary edition

#

right

quaint mantle
#

?services

undone axleBOT
wet breach
#

just done on the bit level instead

grim ice
#

ayyy that feels so good understaanding it

quaint mantle
undone axleBOT
grim ice
#

i remember having a mental breakdown over it (exaggeration)

wet breach
#

lol

brave goblet
wet breach
#

well now everything becomes clearer for you hopefully πŸ˜„

grim ice
#

:D

#

now i gotta learn about ascii and unicode

#

if ur tired its okay btw lol

wet breach
#

yeah once you get the hang of bitshifting you probably will never go back to just regular math πŸ˜›

#

because its so much more optimal in some cases

#

and faster

grim ice
#

:o

quaint mantle
hardy swan
#

must write cool code that normies cant understand

quiet ice
grim ice
#

lol

#

then ig im a bit less of a normie :o

hardy swan
#

no you just ascended

spiral light
grim ice
#

ayyy

quiet ice
#

101 | 110 is 111, not 1011

wet breach
# grim ice ayyy

so while we are on topic of bitwise stuff, that recent example I showed?

#

well those are technically bit flags

#

those are all 3 bits and if we added them all together we know all 3 flags are being set

#

111

grim ice
#

yes

wet breach
#

so this is where bitshifting and bitwise operators start to come in handy because once you start learning to make these bit masking stuff

#

it is so much easy then just using booleans everywhere πŸ˜›

grim ice
#

yeah

#

:D

grim ice
#

so epic

quiet ice
#

this is because it is not an addition

grim ice
#

ik

#

lol

quiet ice
#

Good

grim ice
#

btw

#

there are some stuff i dont understand in the second answer

hardy swan
#

what do you not understand exactly

quiet ice
#

The AND or XOR?

grim ice
#

ye

wet breach
#

or the bits you really want

grim ice
#

so & only removes

hardy swan
#

i dun think you should think that way

quiet ice
#

Well,
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1

hardy swan
#

think of &&, where true is 1 and false is 0

#

but for every corresponding bits

quiet ice
#

Repeat that with every digit, and you have the result

grim ice
wet breach
#

basically your mask is equal in size to the amount of bits you want, the mask is either 0 or 1. 0 means we don't care about it, 1 means we do and get us the value

grim ice
#

there is only removing and the only one capable of removing 1s is 0

quiet ice
#

It's booleanic algebra iirc. (which is why booleans are named booleans)

grim ice
#

right cuz false and false is false but false and true is false and true and true is true false and true is false

hardy swan
quiet ice
#

And for xor
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0

wet breach
#

geol is on top of it πŸ™‚

quiet ice
#

Basically like OR, but results 0 for a bit if both input bits are set

wet breach
#

a reverse or

#

like how you have reverse if statements πŸ˜›

quiet ice
#

Or better said, returns 0 if both input bits are the same, 1 otherwise

hardy swan
#

exclusive or

quiet ice
#

So technically a reverse AND

wet breach
#

yeah that is better put

hardy swan
grim ice
spiral light
#

oh wait you wrote that

quiet ice
#

Reverse equals then

#

but bitwise

grim ice
#

in xor a 1 is stronger than 0

#

so 0 cannot remove something stronger

#

but a 1 and a 1 are equal strength so they kill each other

#

thats how to explain it to a 4 yrs old

#

lol

#

ill understand it that way ig

quiet ice
#

Poor fella

#

Already confronting him with death

hardy swan
#

i recommend to understand it as it is named, exclusive or, this or that but not both cuz im being exclusive

grim ice
#

but in anding

#

0 is stronger than 1

hardy swan
#

nothing is stronger than anything

grim ice
#

ik

#

its like an analogy or smth

#

idk

#

its like saying 0 is a black hole so anything u multiply with it dies

wet breach
grim ice
#

i gotta learn how

#

Unicode works

#

and ascii when i finish unicode

quiet ice
#

Unicode is basically a giant map
value -> some symbol

grim ice
#

oh

quiet ice
#

The bigger question is how UTF-8 works

grim ice
#

that makes sense but arent there details

#

is utf-8 just utf 16 but with 1 byte

quiet ice
#

Not always :)

grim ice
#

thats a guess

#

o

quiet ice
#

UTF-16 can also be bigger than 16 bits

grim ice
#

its a min?

#

minimum

#

or smth

#

idk

quiet ice
#

yeah, minimum size per codepoint

grim ice
#

so like utf 8 cant be under8 bits

#

damn i feel smart guessing it

hardy swan
#

nothing is represented under 8 bits

grim ice
#

(although it was very obvious a 2 years old can guess)

#

yes

#

cuz it would become bits

quiet ice
#

Well, ascii is technically 7 bits

#

But it does not encode the whole unicode table

smoky oak
#

isn't a char 4 bits

quiet ice
#

16 bits

hardy swan
#

8

#

1 byte per char

quiet ice
grim ice
#

utf 16 is useful for arabic characters too right

hardy swan
#

or am I C++ing

quiet ice
#

correct

grim ice
#

cuz one arabic character can have 2

hardy swan
#

oh fk

smoky oak
#

on a different topic

grim ice
#

for example ba in arabic is one letter, and you add a line above it

smoky oak
#

can i store persistent data in a block somehow without utilizing the chunk it's in?

quiet ice
#

if it is a tile entitiy, yes I think, otherwise no

smoky oak
#

dammit

#

okay then

grim ice
#

imagine utf 32

#

thaat would use a ton of storage

quiet ice
#

but less wastefull than UTF-8 for more obscure texts

grim ice
#

4 terabyte would be 1 terabyte in utf 8

smoky oak
#

what's the best way to run a check on every block when it unloads? I need to place a temporary block that gets removed when the server shuts down

grim ice
wet breach
# grim ice imagine utf 32

there is advantages to using UTF-32 like data transmission for instance. The reason is because UTF-32 is fixed encoding, meaning you can assume 32bits all the time. However when you start using UTF-16 or UTF-8 they are both variable encoding meaning their sizes are not fixed.

grim ice
#

oh right

smoky oak
#

ah.
Just flag the chunk if there's that kind of block in it and dont run the check unless that flag's there

grim ice
#

btw

#

u can use utf 16 characters with utf 8 encoding

#

right

#

itll just take 2 bytes instead of 1

smoky oak
#

oh are you shitting me

quiet ice
#

UTF-8 encodes larger codepoints like
0b1111DDDD
0b111DDDDD
0b11DDDDDD
0b1DDDDDDD
where as D are data bits
(So UTF-8 has some waste)

smoky oak
#

block doesnt have PDC and chucnk doesnt have metadata

quiet ice
#

chunk has PDC nowadays though

grim ice
#

what are data bits

smoky oak
#

yea

#

PDC

tardy delta
#

chunk and block with tilestate have pdc

quiet ice
#

well bits used to encode the codepoint

smoky oak
#

not metadata

wet breach
smoky oak
#

i need a temporary flag in a chunk

tardy delta
#

why not just in memory objects instead of metadata?

grim ice
#

o

smoky oak
#

?

#

wdym @tardy delta

grim ice
#

so if u loop through all unicode characters

wet breach
#

in UTF-32 you could represent a 4byte character easily, but in UTF-8 you would need 2 codepoints for it

grim ice
#

and check if they take more than 1 byte

#

and only take the ones that are 1 byte

#

i wanna try that

#

is it possible

zinc spire
#

I want to have my old building in 1.15 back to 1.8 does anyone know how to do that?

wet breach
#

well there is a limit to each UTF size

quiet ice
#

then you would obtain the ascii table

tardy delta
#

what would be the point of storing something in metadata instead of like a collection of things in the plugin?

wet breach
#

in how many characters can be represented

tardy delta
#

metadata isnt persistent iirc

smoky oak
#

thats the intention

#

i want a temporary block

#

and to prevent having to loop through every block in every chunk when its unloaded

#

i want to flag the chunks with those blocks in it

quiet ice
#

Then why not use an external HashMap?

smoky oak
#

because i dont know when the chunk gets unloaded

quiet ice
#

Map<Long, List<Integer>>

#

Where as Long is the X/Z coords of the chunk and Integer the X/Y/Z coords of the block in the chunk

grim ice
#

i see

#

now ascii ig

#

its just mappings

#

right

#

Dec : Char

smoky oak
#

do you know the O(n) for HashMap.hasKey by chance?

quiet ice
#

O(k/n)

grim ice
#

WAIITTT

quiet ice
#

k is capacity, n is the number of keys

wet breach
#

oh no, they just had a moment of clarity

grim ice
#

thats why when i open an image

#

like this

smoky oak
#

uh

tardy delta
#

is that binary?

grim ice
#

the weird stuff in boxes are ASCII Chars under 32

smoky oak
#

a hash map has a really big capacity

quiet ice
#

Then go with a small load factor to keep it relatively near the actual size

smoky oak
#

wait

quiet ice
#

Just means you have a lot of lag spikes when the hashes need to be recomputed

tardy delta
#

what is the load factor of a hashmap?

wet breach
grim ice
smoky oak
#

wdym recomputing?

quiet ice
tardy delta
#

ah what would you expect

smoky oak
#

when the map gets changed?

grim ice
#

the text that i found

quiet ice
#

the hashes need to be recomputed when the capacity is increased

grim ice
#

i wanna use it to make an image

#

cant i use it to make binary

smoky oak
#

ah then its not an issue

grim ice
#

then use binary to make the image

wet breach
# grim ice yeah i realized hat

what characters are displayed is dependent on the encoding of the text editor uses when opening said file. Most of the time this is ASCII however some editors default to UTF-8

quiet ice
#

therefore if you know the expectable capacity beforehand the hashmap performs the best

smoky oak
#

considering it's got a maximum number of entries at around 250 if you're really trying hard to push it

#

also how do i tell a hash map to have 'this much' capacity?

grim ice
#

its ANSI

#

rn

smoky oak
#

Geol?

quiet ice
#

you cannot really

grim ice
#

just made it utf 8

#

i wanna see how that goes

smoky oak
#

you just said it performs best if you know the capacity beforehand

#

if you cant tell the hashmap that

#

then why would that help?

grim ice
#

im gonna use a website

#

to make it into binary

#

then ill make the binary into an image

#

will that work

tardy delta
#

πŸ₯‰

wet breach
quiet ice
wet breach
#

even if you don't know the exact size

quiet ice
#

Oh I misunderstood

wet breach
#

if you know approximately how large it will need to be initially it is better to set the size first

quiet ice
#

I thought you meant how to get capacity of the hashmap at a certain point

tardy delta
#

.size()?

smoky oak
#

huh. can i tell a hashmap what size to rehash to if it exceeds capacity?

quiet ice
#

That returns the amount of actually used elements

#

Not the actual capacity. The same applies to arraylists

tardy delta
#

ah not the actual size