#help-development
1 messages Β· Page 1920 of 1
its more compact
You have no idea what the decimal value of 2^31 is, but you instantly know what 0x7F_FF_FF_FF is
no
i dont get it
i'd suggest reading into different base number systems
thats what im trying to do but i dont get it
0x7_16_16_16_16_16_16_16
Yep, you are fucking
it's a bit hard to explain just in a few sentences
why is it 7 and 7 16's
yes
0xb means "everything after it is binary"
7FFFFFFFF is the same as 34359738367
what
so 0xFF is 0b1111_1111
but thats past integer limit
π€
so every place in a hex digit is 16^n
so its
converts hex into binary (rather easy), then binary into decimal (not so easy)
16^16^16 etc
Meh
Hey, does anyone know why pushEntities is called when isCollidable is false? (For a LivingEntity)
It's a problem for big mob farms.
0xFF = 15 * 16^1 + 15 * 16^0 = 15 * 16 + 15 = 255
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
F is 15
what
16 would be 0x10
thats all the digits in hex
no 10 isnt a digit
10 is 2 digits
0 = 0x0
1 = 0x1
2 = 0x2
...
10 = 0xA
11 = 0xB
12 = 0xC
13 = 0xD
14 = 0xE
15 = 0xF
Believe it or not
In base 10, 10 is 10
and 0x10
0x10 is 16
my brain
In base 16, 10 is 16
dont think of A,B,C as letters
how does it exist
they are numbers aswell
yes
Do you understand binary?
not really
Bummer, if you did it would've been easier to convert hex into bin and back
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
^
its read right to left?
Well, like dec and binary the symbol with the highest value is the leftmost
E is 5 now?
E would be 14
14
I saw that edit :p
shh
that makes sense
its the same with binary
but why is 10 not a 1 and a 0
10 = A
didnt 10 mean 16
lemme write a table for 10
binary to decimal is easy
you just need to learn the trick to converting between bases
binary is base 2 decimal is base 10
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
and give me a minute
And what is this tick?
and I will teach the easy method
1x(16^1) + 0x(16^0) = 16
Isnβt the easy method to use an online converter
Right now I only know that you can consecutively divide by 2, but that takes ages to do
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
Oh no, bin -> dec would be multiplying
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.
n being the place
It is that simple π
That is how it works with dec -> bin/hex, but not bin -> dec iirc
At least, that is not how I have done it
yeah the base^n-1 rule is only for decimal
yes
But eh, bin -> dec is just a lot of addition, not complicated just takes a lot of time
so lets say we want to convert 1208 to base 26
no, decimal
once you get the initial concept its the same for all bases
this is the math for it
whats a demical
0-9
decimal is referring to our base 10 system
Because it's base 16
so for base 64
its 64*
Let's use regex:
bin = [01]+
oct = [0-7]+
dec = [0-9]+
hex = [0-9A-F]+
or am i dumb
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?
hex allows anything from 0 to 16
bin from 0 to 1
oct from 0 to 7
dec from 0 to 9
?
yeah
hex allows anything from 0 to 15 (both inclusive)
it's A
10 isnt a digit
then how do u say 16
10
0x10 (hex) = 16 (dec)
f is 15
then
sorry im wrong lol
10 isn't a single digit though
It's 2, just like in decimal
0-F are all single digits
in hex that is
hex allows anything from 0 to 15 (both inclusive)
0x10 (hex) = 16 (dec)
how
what
Well, per character
so 10 is an exception
its 2 characters
1 would still be between 0 and 15 and 0 would be still between 0 and 15
so still valid
but then u can get rid of 0
no you cannot
thats like saying you can remove the zeros from 100 because its the same
For example 100 (dec) is not 1 (dec)
does anyone know a certain particle thats white-ish that doesnt move
just falls down
is there a 0 in hex
yeah 0
if you're talking hex 10 will always = 16
if you want decimal 10 in hex it would be A
no the digit placement matters a lot
= 1
1x(16^1) = 16
1x(16^0) = 1
16+1 = 17
the table method helps a lot
yeah
it's pretty much your standard decimal but with other symbols
does anyone know any particle that doesnt move
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
yeah exactly
I never really understood how people don't understand it, but then I also learned hex/bin really early in my life
how old
8-ish I belive
i only learnt this stuff last year
i gotta learn oct and other stuff when i come back ig
my uni teacher taught it super well
all the other base systems are the exact same concept
https://www.rapidtables.com/convert/number/hex-to-decimal.html?x=10 check out the conversion table at the middle of this page
Hex to decimal converter and how to convert.
to be honest, it makes more sense to just learn binary and then only learn the conversion between binary and hexadecimal/octal
Converting non dec to non dec can get confusing sometimes
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
Yes, but usually you'd only work with powers of two
hope this illustrates better
Yeah thats true
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
Does unsafeenchant "overwrite" old enchants
it shouldn't, unsafe just lets you use a higher value for the level of the enchant then what is natively supported
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
oh, it automatically changes the level
π
Dont think itβs possible to have multiple of the same enchant on an item anyway
and that ^
kk, its just visual then because of how I add my lore
Should I be using
item.getItemMeta().hasEnchant()
or
item.containsEnchantment()
I'd use latter unless it is deprecated
As #getItemMeta clones itemmeta
how do I trigger a sound?
public boolean containsEnchantment(@NotNull Enchantment ench) {
return meta == null ? false : meta.hasEnchant(ench);
}
Oh, and it is good if the item is air
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.
(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)
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?
?stash
is there an equivalent for PlayerAttackEvent or do i have to use EntityDamageByEntityEvent?
latter
anyone?
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/inventory/ItemStack.java#333 okay, the cb ppl aren't that dum
You probably need to include them manually
no the cb people are actually dumb sometimes
take a look at their CraftBlockData
which is why I used not that
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
PlayerAttackEvent would be redundant useless ... you need EntityDBEEvent
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?
the minecraft jar include netty
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
check if damage instanceof Projectile
get ProjectileSource (check if not null)
check if ProjectileSource instanceof Player
oh damn i forgot there is projectilesource
well thanks
actually if you check instanceof i dont think you need to check not null?
hmmm well you can check B instanceof A where A is the projectile source
maybe ^^
but you cant "null instanceof Player"
projectilesource can be null
you can
it will just return false
it includes nullity check
hmm ... yeah dont know if you can check null ^^
using tryit editor because i still havent figured out how to use that same feature in intellij
Create junit tests lul
easy game
guilty of doing that
now that i know hexademical, how does Unicode and binary and ASCII work
you wanna learn some C?
im not learning C these are just topics I do not understand
For a runTaskLater Bukkit izΓ© a simple public JavaPlugin plugin; is not enough?!
is there a temporary (until restart) variation of the PDC? I need to store for some entities a timer
it isnt
its not initialized
some kind of meta?
and dont use JavaPlugin use ur main class i think its better
so private final Main plugin then initialize it in ur constructor
You think using the main class is better, but the reality is something else.
no no no
isnt metadata persistent?
what do you mean by not knowing how they work?
I want to understand them more
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.
what
ur main class is a java plugin
Yes
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);
}
}```
But it won't have any respawn events in it
use MyPlugin.getInstance() to access it
I don't think I understan what you're talking about
they are just conventions/ways of representing data, I guess what you want to know is how data types make use of these representations?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
which is usually better
I can set different server types inside the config. If it is KITPVP, then the server will be a KitPvP, or if it is a LOBBY, then the server will be a Main Lobby.
ok you know binaries? strings of bits? 01000101
for example, Hexademical
0xAB
is A = 10
10*(16^1)
ahh
B is 11
11*(16^0)
thats what i meant
and other information that you think is useful
ok so for binaries it is just base 2 decimals
Yes it is a base 2 is what i heard
so 101 is 1x2^0 + 1x2^2
read them on startup
once you know what base is it shouldn't be hard to understand other bases too
set to variables then access variables
o
this is basic concept of binary
not getting into data representations and signs
yes
you can search up on 2-complement representation of integers
wait i think that exists in my todolist 1s
that's a bit more complex
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
bytes are just 8 bits
yeah ive figured that out
ok task one completed
lol
i wanna get into details tho
the extreme details if possible
idk if i can but i want to
i dont think the point of your plugin is to change the world to f.e. a lobby? but only to set the world where you spawn in?
When I move this is the kind of stuff I will be making videos for π
wat
giv youtube channel
There are no multiple worlds...
Reason I am waiting on my move is because I will have an office and I don't have a channel yet
But there is things like this
I want to talk more in depth and teach people
where its hard to find the clarifications
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
I gave up my Dedi a couple of months ago so don't have a place for a site
use spigot kek
will be getting it back though π
or do tha
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
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.
because I don't believe things need to be hard
SolarRabbit seems to be writing a ton, ty rabbit :)
and most of the time it isn't hard just needs to be better explained to be better understood π
Using this shit just makes the plugin event do nothing.
oh thats what i know
its not shit
u just dont know how to use it
show me ur code
then I think you are kind of set to go, next learn bit operations
okay
what are bit operations now
i should google it
but live chat is much more fun
it is a manual way of manipulating bits
with vast applications
and computational advantages
can u give me an example
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?!
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
sir
if u dont want help u can take ur leave
you're the one who want to get help, not us
^
dont be so hostile
like i am rn, i cannot just scream at solar
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
cuz first thats not nice and second hes helping me
technical term to learn this is called bitwise operators
oo
oh yes, bitwise operations, my bad
oh sso 0100 will be 1000
how can this help me in code tho
it depends, you can look at java random for one such application
yeah, but dont try to scream at them after you done it lol
yeah
why would u even scream at anyone here
anyways
is that how they generate stuff
do they make a random of 0 or 1
And how could you help, if even the world is a bugged shit?
and make an array of 0s and 1s
Read #help-server
then they turn it into numbers or something
You will know why I need all this crap
Even executing a fucking spawn command doesn't do aynthing
Being upset isn't going to help so maybe calm down first
IT ALL IS USELESS AS FUCK
thats the server problem then
sorry but you're useless ok that was mean sorry
Sure?
How do i share large code
?paste
no, it is a long story but it is how nextInt() works for extracting only the first 32 bits from 48 bits
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
in Minecraft, when you convert from chunk coords to block coords you can do bitshifting π
how to assign that to a variable and stuff
bounding boxes can use bitshifting too
idk how's that done or whats that
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]```
for example chunks are 16x16
nvm bad example i was thinking of
Int A = 100;
//this shifts the int's bits to the right by 1.
Int B = 100 >> 1;
o
so it will become 010
its okay xd
<< and >> are arithmetic shifts
>>> is a logical right shift
frostalf is using decimals
is there a way not to use them
unfortunate with bitshifting in java you have to use int or long
you can't use byte to do it
but you can represent them with suffix b
^
i think
I will show you an example project where I use bitshifting
100b >> 1 will do
so ur not shifting it by a bit, ur shifting it by a number?
you are shifting by one position
ive heard B is byte and b is bit is that true
Alright
yes, in most context
oh yea, colors are good examples
I created that project because someone wanted me to compress colors into 8bit
how do you check if MetadataValue.getOwningPlugin() returned your plugin? Doesn't the main class extend JavaPlugin?
that plugin will extends javaplugin iirc, use instanceof?
But bitshifting makes a lot of the math super efficient π
since technically there is none XD
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
do you mean if(n.getOwningPlugin() instanceof MainPluginClass)?
i think that will work
decimal representation of the color
the colors are RGB
that is a bit masking, where you mask certain bits in your favor
whats masking
you have ffffff as color white
yes
r value of ff, b value of ff, and g value of ff
so because RGB is technically base 3 and hex is base 6, I have to use offsets to fill the gaps π
its in decimals now
yes
wat
it will append
okay
neither add nor append
if ((args.length > 0) && (args[1].equalsIgnoreCase("chunk"))) {}
This line throws an the error how do i fix
LOL
you got the error message you need, array out of bound 1 for length 1
you are trying to access position 1 of array with only 1 slot
You need to learn java.
positions are however 0-based
Ok, Then i can't do args[1] if it is not present?
No because arrays start at 0
yes this is not c
uh

-.-
Then you need to > 2
so had no problems with it
You really need to learn java. Sigh
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
I spent 12 hours on it
hey, how can i get player skulls wothout loading time?
does anyone have problems with 1.18 dependencies
minimum
i can't find netty classes anymore
Ate this whole guide https://www.programiz.com/java-programming
Which goes to show you need to learn java because this issue is such a basic issue that's 100% avoidable
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
how do you access it as an integer
anyone??
no but it has an integer in there π
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 π
o
you would constantly have to keep filtering the result XD
can anyone help?
The project doesn't use any API's π
its universal
can be used in anything if you want π
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
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
essentially yes
think about it in exponents
remember how we demonstrated how to convert bases? and showed exponent representations?
well bitshifting is an exponent operation
did we do that tho
yes like a while back XD
well I did anyways
but remember bases in code still is binary though
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?
so because I am down converting to base 3 or from 16bits to 8bits, I have to pad with 0's to the left
how do u even convert binary to hex and vice versa
anyone????
thats why i dont understand this
idk how to convert binary to hex and vice versa
you don't convert
it is just a matter of representation
moreover, bitwise operators operate on bits
so you should do the conversion yourself
how do i know what is the result of
0xFF0000 >> 16
that should be 0x0 iirc (edit wrong)
what does Permission#getPrimaryGroup in vault get? the group with the highest priority or what
bit right shift by 4*4 is equivalent to right shifting hex 4 times
whats bit right shift by 4*4
1 hexadecimal digit is 4 bits
oh ok that makes sense
hence 0xabcdef >> 16 = 0xab (shift by 4 positions in hexadecimal sense)
depends on the data structure
wha
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
anyone from here code plugins for 1.18?
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
o
so, while although I am working with 8 and 16bits, there is more bits being represented then what is being messed with XD
yes
I mean lets not mind the talks about coding going on and assume we are not developers π
i can't seem to find netty packages anymore
?bootstrap
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
are you depending on spigot or spigot-api
the thing is, i'm using paper
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 theGameManagerclass frommanagerpackage otherwise?
Any help would be appreciated.
?DI
?dependencyinjection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
there we go
so
paper-api or paper
wait actually you are using the userdev i assume
well their build system is different too
hm
but I mean, this is the wrong discord to come to, and asking how to properly depend XD
yeah ok so go to paper
Is anyone willing to help me make a custom world gen plugin? from a datapack.
@wet breach @hardy swan
you two
are better
than all the teachers ive met in my 15 years of life
lol
an plugin that can generate custom worlds like datapacks can but api not ?
Yes
Well only because the datapacks make use of functions
this is not what i am looking for
hmmm then i dont understand what you want to do else ...
I have a datapack that I would like to reproduce as a plugin
// | 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
yes .... but the API i linked can exactly do that ....
oh oki
or do you want to let the plugin read your datapack ?
I would just like to have custom world generation without lag ;-;
shouldnt that be 100 | 10
this can generate an custom world like an datapack can ... mostly ...
how is it 001 | 010
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
lag ? if the datapack creates lag its not optimized
remember I said |= is the same as += but you can't use += in bitwise operations
so you have |=
the only thing that i have heard issue about are datapacks using functions
010 + 001 = 011
OH MY BAD I THOUGHT U MEANT DEFAULT VIBRATE
if it's pure world gen it should be less laggy
its not 5min of work since datapacks "not just simple" interact with the server ... recreating worldgen datapack stuff was a hard work of weeks and days to figure out
wait, so you want someone to do that for you?
so it adds them as binary
or you want to learn to do that yourself
oki well that came from a developer of purpur
well both?
if you want someone to do that for you then
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
basically yes
just done on the bit level instead
ayyy that feels so good understaanding it
?learnjava first if you want to do it yourself
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
i remember having a mental breakdown over it (exaggeration)
lol
ik how to do java,,,
well now everything becomes clearer for you hopefully π
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
:o
yeah, i feel like the support for datapacks are from nms, which means you have to use nms now
totally relate
must write cool code that normies cant understand
That may be worded a bit confusingly
no you just ascended
and sadly the bukkit api for WorldCreation will not expand in the future to support more configuration details of worlds .... thats why i needed to create the API which is not nice
ayyy
101 | 110 is 111, not 1011
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
yes
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 π
:')
this is because it is not an addition
Good
btw
there are some stuff i dont understand in the second answer
what do you not understand exactly
The AND or XOR?
ye
a bitmask defines which bits you care about
or the bits you really want
so & only removes
i dun think you should think that way
Well,
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1
Repeat that with every digit, and you have the result
yes so 0 only applies to 1 and removes it but 1 cant add
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
there is only removing and the only one capable of removing 1s is 0
It's booleanic algebra iirc. (which is why booleans are named booleans)
OHHH
right cuz false and false is false but false and true is false and true and true is true false and true is false
yea
i see
what is XORing tho
similarly, || can be an analogy for | in the same way
And for xor
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0
geol is on top of it π
Basically like OR, but results 0 for a bit if both input bits are set
Or better said, returns 0 if both input bits are the same, 1 otherwise
exclusive or
So technically a reverse AND
yeah that is better put
not really, not true for reverse of 0&0
basically reverse anding but 1 on 1 is 0
isnt this then XOR ?
oh wait you wrote that
ah yeah, forgot that
Reverse equals then
but bitwise
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
i recommend to understand it as it is named, exclusive or, this or that but not both cuz im being exclusive
nothing is stronger than anything
ik
its like an analogy or smth
idk
its like saying 0 is a black hole so anything u multiply with it dies
guess this is one way to put it sometimes
Unicode is basically a giant map
value -> some symbol
oh
The bigger question is how UTF-8 works
Not always :)
UTF-16 can also be bigger than 16 bits
yeah, minimum size per codepoint
nothing is represented under 8 bits
isn't a char 4 bits
16 bits
In C, but in java it is 16
utf 16 is useful for arabic characters too right
or am I C++ing
correct
cuz one arabic character can have 2
oh fk
on a different topic
for example ba in arabic is one letter, and you add a line above it
can i store persistent data in a block somehow without utilizing the chunk it's in?
if it is a tile entitiy, yes I think, otherwise no
but less wastefull than UTF-8 for more obscure texts
4 terabyte would be 1 terabyte in utf 8
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
or am i bsing
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.
oh right
ah.
Just flag the chunk if there's that kind of block in it and dont run the check unless that flag's there
btw
u can use utf 16 characters with utf 8 encoding
right
itll just take 2 bytes instead of 1
oh are you shitting me
UTF-8 encodes larger codepoints like
0b1111DDDD
0b111DDDDD
0b11DDDDDD
0b1DDDDDDD
where as D are data bits
(So UTF-8 has some waste)
block doesnt have PDC and chucnk doesnt have metadata
chunk has PDC nowadays though
what are data bits
chunk and block with tilestate have pdc
well bits used to encode the codepoint
not metadata
in unidcode the first 128 characters use 1 byte, the next 1,400 some odd characters use 2 bytes, the next set of characters after that take 4bytes
i need a temporary flag in a chunk
why not just in memory objects instead of metadata?
o
so if u loop through all unicode characters
in UTF-32 you could represent a 4byte character easily, but in UTF-8 you would need 2 codepoints for it
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
I want to have my old building in 1.15 back to 1.8 does anyone know how to do that?
well there is a limit to each UTF size
then you would obtain the ascii table
what would be the point of storing something in metadata instead of like a collection of things in the plugin?
in how many characters can be represented
metadata isnt persistent iirc
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
Then why not use an external HashMap?
because i dont know when the chunk gets unloaded
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
do you know the O(n) for HashMap.hasKey by chance?
O(k/n)
WAIITTT
k is capacity, n is the number of keys
oh no, they just had a moment of clarity
uh
is that binary?
the weird stuff in boxes are ASCII Chars under 32
a hash map has a really big capacity
Then go with a small load factor to keep it relatively near the actual size
wait
Just means you have a lot of lag spikes when the hashes need to be recomputed
what is the load factor of a hashmap?
this is just the text editor trying to convert the binary data into text when the data isn't text but numbers that represent color related things π
thats binary from an image opened as a text
yeah i realized hat
wdym recomputing?
The amount that the hashmap grows when it hits the capacity
ah what would you expect
when the map gets changed?
is there a way i can do the opposite
the text that i found
the hashes need to be recomputed when the capacity is increased
ah then its not an issue
then use binary to make the image
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
therefore if you know the expectable capacity beforehand the hashmap performs the best
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?
Geol?
you cannot really
you just said it performs best if you know the capacity beforehand
if you cant tell the hashmap that
then why would that help?
im gonna use a website
to make it into binary
then ill make the binary into an image
will that work
π₯
HashMap<String, String>(size);
Because the hashmap would not need to rehash as often
even if you don't know the exact size
Oh I misunderstood
if you know approximately how large it will need to be initially it is better to set the size first
I thought you meant how to get capacity of the hashmap at a certain point
.size()?
huh. can i tell a hashmap what size to rehash to if it exceeds capacity?
That returns the amount of actually used elements
Not the actual capacity. The same applies to arraylists
ah not the actual size