#help-development
1 messages · Page 385 of 1
Well i could simply let pullers not pull from other pullers and pushers not push into other pushers
I guess it depends how you want to be handling stored energy...
If it's in a consumer do you want it able to be pulled and used elsewhere or is it then stuck
Fk you brought a point to my attention. I will have energy storage devices which contain energy.
But not actively consume/produce energy
Energy in a consumer device is stuck
To me those seem simple. You have an input side and an output side. By default they just store energy. So only pull energy out when a device is hooked up and input energy when it's receiving energy.
thats partly why I recommended only to pull.
Which means a push strategy makes no sense for them...
if a machien is full it does nothing
producers don;t push, just get pulled from
lots less logic
and it means batteries work simply
Hm this would be very hard to implement because then i have to consider circuit shorting.
shorting?
Could you give an example?
oh right
How does a battery work in this case?
I'd get storage/distribution workgin before considering directions 🙂
a battery pulls if it has room
thast it
I wont introduce directions honestly
no device can pull more than the source has until they are balanced in energy
so battery has 100% energy, machien is empty, the machien will pull until they are 50/50
Well then there is again the problem with fairness. Every puller needs to pull the same amount from
all energy stores
Only if there is a surplus of energy
each machien will pull until they are all equal in energy
there is one downside though
Well if a machine consumes 100e/tick and draws all the energy from
the network (50) then he simply consumes all the energy all the time and
no other machine ever gets to work
with a push system, push only happens if there is energy to distribute so only ticks producers. With a pull any consumer which is not full will attempt to pull each tick
But with 5 machines i want each to get 10e/tick in this scenario
Yeah i think push only is a better strategy than pull only
Ok but how do i handle batteries now...
batteries are consumers and producers
So generators will push into batteries because they see them as consumers.
And batteries push into all consumers. I think this makes sense.
You could also view consumers as pullers if you go that direction.
Even if batteries were connected, wouldn't the result just be zero if they were put in a loop?
Assuming it's just the batteries in the loop
if you have balancing then they would just distribute power between them until equal
Was thinking about that. I just need to think about how to implement this logic.
Maybe there are 3 types of machines. "generator" "storage" "worker"
generator -> push into storage/worker
storage -> push into worker
worker -> does nothing and just consumes its internal energy source
else one battery woudl push to another and then in it's tick it pushes back
yep
sounds a plan
Hm ok i think ill implement this. It also saves my problem with chunk loading as
unloaded nodes simply get not traversed. Lets hope the O(n) scaling is not a huge
problem

do you guys also see this in your startup?
i clicked open file location and it claims to be discord
i dont have discord....
i use browser
I just realised that this is actually O(n^2) because every machine has to traverse the tree...
Consumers should not be traversing
?1.8
Too old! (Click the link to get the exact time)
Yeah with n being producers. But i can actually cache the traversal of one machine for all other machines so its fine
did u install it at some point and thne uninstall it
since burning my disk i dont remember installing discord again...
u has written reason why it dont work
PlayerInteractEntityEvent
read docs lol
i think its from vscode?
maybe
I'm working on mines and I need to store information about them. Mines are placed by PlayerInteractEvent. Firstly I wanted to store their location in player's PersistentDataContainer, but I found it quite inconvenient. Now I'm thinking about adding a static field to this event and store location of mines in this field. Is it a good solution?
When i have already declared File and check if no is exist then when i save Resource i need to declare new file or this one still work and has content from saved resource?
It would definitely work, but it seems to me it's not the best practice...
A File is just a pointer/handle, you can reuse it.
ty
Well if you interact with an entity you cant exactly have clicked a block, can you.
PlayerInteractEvent has getClickedBlock
ugh what's wrong with my build.gradle
Isnt compileOnly from the gradle shadow plugin?
i dont think so
I followed this https://www.spigotmc.org/wiki/spigot-gradle/#build-gradle
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
But if its a default method then wtf
Yeah according to gradle its a standard task
Well then you broke your gradle again...
it's freshly generetad with "gradle init", i just added the spigot repo and dependnexy
What gradle version is it
@eternal oxide You still around? Im thinking about an implementation problem for STORAGE types and their max transmission rate.
Every machine has a max transmission/tick so if a battery recieves its max transmission rate in one tick then it wont be able to push out
any energy afterwards...
8,.0.1
Eg a rate of 100/t and it receives 20, 30 and 50 from three producers. Then its the batteries turn but it cant push out energy
as the max transmission has been reached
Why are you using gradle
sounds like that transmition limit should only be on sending then
just to learn it
All the weird bugs that I encountered when using gradle were ij fault
No i cant do that. Receivers need to be limited as well.
For example I couldn't setup paperweight in intellij but I could outside of it
also happens outside of Ij
That's not gradle 8
Capturing all logs
Yeah that was my initial thought as well... i guess its needed
I have tried 8.0.1 and 7.5.1
Perhaps delete .gradle
so basically you have two types producer and consumer with batteries implementing both
usin 8.0.1 has the same proble,
each type implementing a transmission limit
didnt change anything
try adding the java-library plugin
I doubt it does anything, but better be safe than sorry
thanks, that fixed it
weird that it's not mentioned in the spigot docs
it should be present on any java applications
For me it was generated by default
But that could be because I use Minecraft plugin for intellij
It depends on the template you use
mfnalex used the most minimalistic template out there - which is not meant for java development
no clue - I just know it exists and that one of the two is deprecated
Ah no, java-library is a superset of java
Hence java is technically inferior to java-library
The key difference between the standard Java plugin and the Java Library plugin is that the latter introduces the concept of an API exposed to consumers. A library is a Java component meant to be consumed by other components. It’s a very common use case in multi-project builds, but also as soon as you have external dependencies.
i got nothing to do
smh

is there anything that spigot does differently from forks like paper or purpur when it comes to comparing items
the question should be the other way around
Spigot is the base so it's, do they do things differently
i got a list of items and im trying to check if it contains a certain item, if i do .toString() on both the list item and that certain item i see that they are both identical, yet if List#contains() is used on spigot it will be false
and on paper/purpur its true
i know, but it feels like it's working the wrong way on spigot
toString is not an instance comparison
i know but why does it work on paper/purpur
do they compare with hashcodes while spigot compares with instances or smtn
the #contains will only be true if that specific item is in the Collection
new ItemStack(Material.STICK) != new ItemStack(Material.STICK)
so spigot doesnt use hashcode for comparison then
everythign about them is identical btu they are not the same ItemStack
i understand how that works but why does it work like that
because oop
no i mean why was that choice made
because that is how all oop works
it seems more sensible to do it with hashcode
a hash code would only compare data not the item itself
it seems more sensible for spigot to compare items using their properties and not their instances
yeah thats the point
Why?
There are 2^32 possible hashcode values, but almost infinite amounts of possible object configurations
you have ItemStack.isSimilar for data comparisons
Using hashcode for comparision would be a SERIOUS security risk
HashCode allows collisions. Two objects which are not equal can have the same hashCode.
how is it a security risk
Password comparision could easily be brute-forced
my example before would mean those two items would be the same
Because you could tinker an ItemStack with the same hashCode as your custom item but in reality its not your custom item.
well yeah but does this not make more sense for itemstacks specifically
two distinctive objects can return the same hashcode
2^32 is an incredibly small number for today's computers
a hash of two ItemStacks could give the same value when they are actually different items
Yes, but java works in a way that ==/!= use the object's identity
It kinda is like comparing the identity hashcode (I call it the system hashcode, but that is the wrong name :P) but that isn't truely correct
i.e. if you allocate more than 2^32 objects you are guaranteed to have a colliding identity hashcode somewhere, but no distinct objects will == each other
im just having trouble understanding why its not done with itemstacks, if you have a custom item and someone somehow makes an item with identical properties, allowing their hashcode to match, why is that a bad thing?
There's .equals for that anyways
players arent capable of that anyway, obviously depending on how you define your custom items
if I have two apples in my hand. they can LOOK identical btu they are not the same apple
its not bad, its that the same hashcode can be created not only for identical objects
but also for random objects too
A player could do that actually by changing the name of the item
so using the same comparison you could have an apple and a banana and they could still have the same hashcode?
You put your items in a List if i read that correctly. Then contains doesnt use the hashCode anyways
yes
ah i see
hashcode is used primarily for maps, which guarantee amortized O(1) access to an object using .get() method
but its not constant O(1)
just because the hashcodes could collide (if it collides, it uses linear search to find the item)
so if i want to use List#contains to check for an identical item i would have to use something like list.stream().anyMatch(equals/isSimilar)?
Well its used for hash buckets which are not exclusive to Maps. But yeah those are mainly used to implement most Maps.
List#contains uses Object#equals
No List.contains calls equals on every single object
i think you're fine with contains()
If you want to get the same identity you'd need a for loop or something and use ==
just dont use == operator in this case if you want to find similar items
what method aside from isSimilar can be used to compare an items properties
equals.
Do you want to check for custom items?
For comparing two objects it's always equals.
this list is basically a recipe's ingredients and i want to check if the crafting grid contains all these ingredients (shapeless recipes arent compatible with exact meta requirements)
i dont care for item instances
only the properties
then isSimilar
Then you need to use isSimilar
i guess i could check for amounts after the fact
But be aware that you must be aware of stack sizes that are not "ideal" in that case
yea ^^ using .equals() you would check stack size too, so use isSimilar to detect if the itemstack is present regardless of the quantity
is it normal for intellij to index my project everytime i open it
its slow af (in my terms :D)
it takes at least 2-3 minutes
Yes
Thank god I upgraded my HDD to SSD
now i need to upgrade my cpu from i3 to at least i5 and i will be good to go
but it works for now
How can i use &<color code> instead of ChatColor.<color name> in messages?
Is it possible to adjust the player movement and possibly jump height of the player, via a code?
I want a player to jump a maximum of 6 to 7b jumps in 0.55s before the floor is removed, however this is barely possible on my server, any solutions?
declaration: package: org.bukkit, enum: ChatColor
Potion effects or attributes will change movement speed or jump height
stripColor?
translateAlternateColorCodes
ok thanks
My server doesn't support attributes, and without potions since the player must only have speed 2
It's java 8
String colored = ChatColor.translateAlternateColorCodes('&', "&cRed message.");
?1.8
Too old! (Click the link to get the exact time)
Yes, I'm looking for another solution but I think it's really complex
with viaversion support
I dont think it is. Try to explain it in more detail.
i send u in dm
what channel does forge use to reveal itself?
uses brand i think
restart
How to fix this Teams bug? I have nametag visibility set to NEVER, but if I'm on a different team I can see the nametags of other people in that NEVER team still
have you tried turning it off, leaving it off for 20 seconds, counting from zero and then turning back on?
it's only teams created by spigot with the issue
maybe you have other plugins
that modify the scoreboard?
scoreboards created via bukkit api are shared among the plugins
Player players = (Player) Bukkit.getOnlinePlayers();
PotionEffect effectEyes = new PotionEffect(PotionEffectType.WEAKNESS, 10);
players.addPotionEffect(new PotionEffect(effectEyes));
``` I would like to add an effect to all players, this effect can not let them see the map around them and I do not remember :(.
It seems like the bug was I did getNewScoreboard instead of getMainScoreboard and that was causing the issue?
blindness?
Ah yes!
lol
PotionEffectType.BLINDNESS
since 1.18 or 1.19 i dont remember there's also another blinding effect
that pulsates
And how I set it with no end?
specifically made for the warden
I mean infinite duration.
1.19.2 darkness
Ah ok and what's the last argument, I do not understand it : amplifier 🤔 .
im surprised that bukkit api doesnt have constructor for infinite potion effect, and we should use hacky ways like Integer.MAX_VALUE to set the potion effects lmao
level of your potion effect
How can I "browse" Bukkit.getOnlinePlayers();?
loop through it?
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 do not kow what I did but it was not working but ok...
why we call WORD 32 bits nowadays
when we have mostly 64 bit computers today
on windows Double word is 32 bits
and QWORD is 64 bit
microsoft being microsoft
In the terms WORD is the big as the maximum size of bits of cpu architecture can process at the same time
And windows being very old - large parts were written in the 16 bit era
iirc
32bit should be deprecated by now
tbh
i havent seen any consumer pc which still uses 32 bit architecture today
apart from embedded systems
I believe Win 11 no longer supports 32 bit
32bit support for me personally should be a separate module from windows
that you can install as an update
like with other optional features
Some windows internals are probably still 32 bit
Windows really screams for refactoring
Microsoft never removes old features - they just tape over it
and i cant even imagine how much spaghetti code there is there
every game released before 2012 pretty much was 32 bit so idk haha
yea, but it should be a separate module
like C++ runtime libraries
you can uninstall them
the fact that windows still had 16bit app support in windows 10 32 bit version bogs me down
Why though? There are pretty much no operating systems that don't support running 32 bit applications
Remember that linux still supports devices from 20 years ago.
maybe you're right
Windows removing 32 bit support would be the most windows thing ever
To make windows good again, they need revamp NTFS and refactor some old shell code
oh, they need to do MUCH more than that
kind of the same reason that GPU drivers still always include DX9
There is a way to do a waiting?
If you are aware of what you are doing: Thread#sleep
Otherwise, don't wait and instead schedule tasks which are processed in the future.
My axe is not breaking multiple blocks. How do i fix it?
Yes.
I'll never get behind some of the command names
well idk what's the problem, but i can say that you dont need .equals() in order to check if the enum is correct
you can simply use == because you're using enum statically, thus the same object will be returned
ive got similar class with a pickaxe and its working
https://paste.md-5.net/iciwodiviy.cs
Alright thanks.
I recommend against such a practice with the material API
why not
While of course it probably won't break anytime soon it is likely that your IDE will complain sometime soon
why
it would anyways break the api
Registries prob would be used
and prob materials would be still supported as a deprecated feature
ah, yes, Microsoft tape everything tactic
Well the old API is no longer available, so not really
Theres a pr open for it atm
Yeah, if only I had access to PRs so I had some knowledge of what is going on.
So right now I'm just guessing based on my own experience with refractoring enums into regestries via ASM and the release announcements that warn of the change
The worst thing about the change will most likely be entirely compile-time with switch-on-enums not being a thing.
If they don't wish to do ASM hackery, EnumSet and EnumMap will also not be available.
However if one is really smart the entire change can be done in a way that the only thing that really breaks is reflection.
(And with that ObjectOutputStream & ObjectInputStream)
does any of you know why my void world generator-settings do not work on the server
generator-settings={"layers"\:[{"block"\:"minecraft\:air","height"\:1}],"biome"\:"minecraft\:the_void"}
it generates normal world for some reason
fixed it
apparently minecraft:single_biome_surface (buffet mode) does not work with the generator-settings (at least with my settings)
private void GiveTiem(Player plr) {
plr.setExp(15);
Bukkit.getScheduler().runTaskTimer(plugin, new BukkitRunnable() {
@Override
public void run() {
if (plr.getExp() == 0) {
cancel();
} else {
plr.setExp(plr.getExp() - 1);
}
}
}, 0, 20);
}
``` Just I am not sure I setExp and getExp work like this, is it good or no? I want to do a timer with levels of the player, 15s.
get the xp level of the player
multiply it by 20
add it to period field of runTaskTimer()
wait no
lol
player can quit while run this, add check
Ah bruh I can use setLevel and getLevel?
private void GiveTiem(Player plr) {
plr.setLevel(15);
Bukkit.getScheduler().runTaskTimer(plugin, new BukkitRunnable() {
@Override
public void run() {
if (plr.getLevel() == 0) {
cancel();
} else {
plr.setLevel(plr.getLevel() - 1);
}
}
}, 0, 20);
}
``` this will be better no? 🤔
yeah
can i somehow add just bungee chat api to my gradle project?
what does packet id 154 stands for in minecraft protocol?
Comes with spigot api iirc, or spigot buildtools
Otherwise check krypton mc repo on net md
Check wiki vg
wheeere
this can be problematic
there are so many things
why
im pretty sure ids are different for different versions
...
usually it works tho
there are so many things. where are packet ids?
https://hastebin.com/share/lekotedeka.java why I have this error: https://hastebin.com/share/oyifoziyeb.css
First you need to know whether your packet is clientbound or serverbound @charred blaze
Then convert your id to hex and grep for it over at https://wiki.vg/Protocol
server sends me the packet
if you mean that
then it's clientbound
how do i
Are you sure that it's 154?
Because that is an awfully high number for any packet (largest clientbound packet is 0x6A - which is 106 - at the moment).
Also, what is the protocol version?
Yeah then you are improperly getting the packet id
that is no a valid packet
Unless you are using modded minecraft, at which point I can only say: GL have fun
am i getting packetID wrongly?
Are you parsing packets at all?
Are you accidentally using a compressed connections when you shouldn't?
why shouldnt i
anyway
Yeah your code is completely wrong
whats wrong with my code?
why
Nah, it's entirely wrong
Bukkit.getScheduler().runTaskTimer(plugin, new BukkitRunnable() {
@Override
public void run() {
plr.setLevel(plr.getLevel() - 1);
if (plr.getLevel() == 0) {
cancel();
}
}
}, 0, 20);
``` why I have an error about this sheduler?
That is the protocol for minecraft beta
And trust me I know that since I attempted to write a minecraft server on that version
where is the error
might complain about the numbers being ints instead of longs but i dont think that will cause a compile error
why did u
plr is null
you cant call methods on a null object
Noone did it yet (outside of truecraft - but that's beta 1.7) and wanted to have a fun learning experience
Wait it's not the good one 🤣.
for (int i = 1; i < 4; i++) {
String config_p = (String) plugin.getConfig().get("roles.loup-"+i);
if (!Objects.equals(config_p, "None")) {
Player loup_p = Bukkit.getPlayer(config_p);
if (loup_p != null) { GiveTiem(loup_p); }
}
}
This is teh current code.
For call the function with the getScheduler.
good god
can you rewrite my code correctly? i just want to have fun too
first check if player lvl equal 0 and next minus 1
or teach me how to read from that wiki
Uh, I'd need to look very deep into my minecraft projects. It's been years since I last worked with the protocol
okay never mind :(
how do i compress packet?
wiki.gv does not provides ANY of sample code for anything
I never worked with compression, so I can't give insight on that one
https://hastebin.com/share/kicojovoti.css ```java
private void GiveTime(Player plr) {
plr.setLevel(15);
Bukkit.getScheduler().runTaskTimer(plugin, new BukkitRunnable() {
@Override
public void run() {
if (plr.getLevel() > 0) {
plr.setLevel(plr.getLevel() - 1);
}
if (plr.getLevel() == 0) {
cancel();
}
}
},0,20);
}
```java
for (int i = 1; i < 4; i++) {
String config_p = (String) plugin.getConfig().get("roles.loup-"+i);
if (!Objects.equals(config_p, "None") && config_p != null) {
Player loup_p = Bukkit.getPlayer(config_p);
if (loup_p != null) { GiveTime(loup_p); }
}
}
return true;
you code in an incredibly strange way
?
Deprecated code and not following naming conventions
naming conventions ?
?conventions
Ok and?
why do you cast config.get() to string instead of just using config.getString()?
why do you do Objects.equals() instead of just string.equals(otherstring), and why is your string null check after the equals check
makes no sense
minecraft source code looks scary.
because?
It does not matter lol 🤣.
And because maybe getString is for String value?
work harder, not smarter
loup: None != loup: "None"
@charred blaze Yeah looks like my old projects have not stood the test of time
@hushed spindle
it does matter, it makes your code more readable
this is a mess
what do you want
Not my problem if you do not know how to read a code :/.
lol
yeah if you want people to help you thats a nice attitude to have
i understand your code and thats why i understand it looks like shit
good luck
So you as soon as you see a complicated code, you will not try maybe lol?
thats okay
complicated he says
very complicated code yes yes
i am stupid wahh baby i dont know how to read
i understood the first code block, it looks like a countdown timer, but what is the second code block?
The second is getting all player from the config file with the roles loup- + number (i in the loop), then I use GiveTime to set them a "timer" if the player "exist".
Yaml doesn't care about quotation marks
Unless you have some special char
why doesnt bukkit implementations allow uppercase commands?
is there any limit defined in the nms for that?
so, what is the problem?
Discord also doesn't allow that for slash commands, ig it's convention so you can't have two different commands named help and hElp
that is not css.
Yeah
Yeah and I replace it to what?
doesn't the lambda have a task argument?
u have got it, its not hard
BukkitRunnable#runTaskTime(...)
It does not exist :>.
after a google search the main issue people seem to have is that they're using a deprecated method
does the method you're using get a strikethrough line
// code is written here.
});``` is the code.
😭 I am using it -_-.
Without the BukkitRunnable there
Either you use a BukkitRunanble with the run method on it or you use the scheduler with a normal runnable (or lambda)
I mean, it's auto?
MainTestTask is class with extends BukkitRunnable
just write lambda without the BukkitRunnable.
runtasktimer requires two long arguments right, delay and period
Dont do that, use scheduler
id say just use Bukkit.getScheduler().runTaskTimer(() -> { //your code }, 0L, 20L); for every seconds
fml
they also need to cancel the task so add a task argument.
Alright.
plugin instance 😛
lol
what is a difference and why not this?
Only in the BukkitRunnable
ah
i didnt use these normal methods for a long time since my lib exists lol
Cannot resolve method 'runTaskTimer(<lambda expression>, long, long)'
Bukkit.getScheduler().runTaskTimer(yourPluginInstance, () -> {
//your code
}, 0L, 20L);
and pass it as the first argument.
i fucked up
BukkitRunnable will call scheduler under the hood anyway, no need to create new object
It's fine if you want to extend the class and add things to it
Talking about this use case
is there an easy api like bukkit for writing mods?
what you mean like forge or fabric?
client mods? use fabric
that is what i am currently on.
way easier in terms of compatibility with other mods
and also more lightweight than forge
at the docs ig
that is where i started, and i can do a lot of stuff but not everything it seems.
not sure if there is a documentation that covers all of minecraft's codebase.
ofc not
Yeah.
that'd be way too much
I did not use fabric but forge is very... strange for older versions.
minecrafts codebase is way too big to be covered, also why would you need to cover everything
Minecraft’s codebase is also mostly intentionally undocumented for third party developers, modding isn’t officially supported
i know, mojang allows it but does not support it.
i mean... what do you need mojang documentation for
yarn covers a lot of documentation by now
yarn?
the fabric mappings
aka the stuff that makes it not look like ass
by default stuff is obfuscated, aka fields and stuff are called field_ir93i932f and similar
good luck working with that lol
I do not understand one thing as well: we can not share the code we see...
When are coding mods.
you cannot publish mojang code, yes
Because it's copyrighted.
thats the reason yarn exists
There is a difference between publishing and showing...
the yarn mappings are different from mojang, you can public mods using yarn without issues
Functionally not really
https://fabricmc.net/wiki/tutorial:mappings
maybe read this
Any way you would “show” it to someone online is a type of publishing
mojang half assess being mod friendly
so, how do i create a mod that uploads the world folder, to a cloud platform, let's say.
i know how to upload stuff to cloud platforms.
i know that
i am just trying to figure how to get the world folder then register a command that does it all in an async thread.
declaration: package: org.bukkit, interface: World
the folder is easy
File file = new File("./saves/yourWorldFolder/"); assuming you are using the default directory
?
but only upload chunks that have been modified.
ugh
Only chunks that have been modified are going to be saved on the file system anyway
so i only save the changes, not necessarily the entire world folder.
You can diff the old and new file
so i could do rollbacks and stuff.
The world is procedurally generated and saved as you explore it
so i would have to add like an event handler in case a block is placed or broken.
i mean, you could check for every file in the folder if it's edit date is new
and if it is, that chunk is added to the backup queue.
If you’re trying to do rollbacks you’re going to need to track when the types of changes you want to roll back occur and store them, the game won’t do that for you
just gonna have something like, make backups every 5 mins.
rollback changes made 45 mins ago.
just rerolls entire minecraft chunks.
that were modified.
much like git.
making a mod vs. making a plugin are so different.
do while will always execute once because it checks the condition after each execution, so if you try to read a byte from an empty stream it will throw the exception
i believe all the stream reader methods do
Well yeah, they’re two totally different APIs
well, fabric isnt an api by itself either
i first thought i would just look in the world folder
but no
they not saved in individual chunk files
they are saved in region files of 32*32 chunks.
fabric does have an api, but it's entirely optional when creating fabric mods
Yeah I wouldn’t know, I don’t use any of the third party modding tools when I’m doing client stuff for myself
main issue with the api beeing that people are too stupid to include the api-modules into their mods, so users constantly complain about having to download the api as well
while the api page even states that you should include the modules you need
fabric api does not seem to have a lot of events.
so what do i do instead?
is downloading automatically jars from the private repos against spigot tos?
im just curious
it should be right?
depends on the repo.
why would it lol
Not against it but annoya admins
is there an event for a block being broken or placed in the minecraft world?
uhh
BlockPlace and Break Event
in fabric or spigot now
Handle the exception
in fabric.
i dont think so
and itll fix?
How can I use Bukkit API plugin with BungeeCord?
its fairly easy if you learn it
The exception occurs when you reach the end of the stream and you’re still expecting data to be there. You need to handle the occurrence of that exception or your program will break when that situation happens
how do i learn it?
What do you mean?
lets say i have shadeable plugin api which you can access by using it as a plugin or shading it inside your project
mostly by reading the wiki, what exactly depends on what you want to learn
Is it possible to use Spigot plugin with BungeeCord?
i wonder if it possible to dynamically "shade" classes if the plugin does not exist inside the plugins directory
as a fallback
or smth like that
No, you can’t use a spigot plugin on bungeecord
loading plugin, would be an overkill
so just surround it with try catch?
and it would be annoying but loading specific shaded classes would be good, since no plugin instance would be created
If that’s what makes the most sense in your use case
Well.. How can I learn about BungeeCord Plugin?
There are not much informations. 😦
also, you can always just look at the code others have written, and learn from it
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
OH thanks 🙂
Probably use something similar as spigot libraries feature do
Download jar, and use classloader to load those classes in runtime if necceserry
Is there a way to use MythicMobs in BungeeCord?
No
BungeeCord is a proxy to connect users to game servers, it’s not the game server
It doesn’t have any of the gameplay functionality on it
You install that plugin on your nodes, and also it's not #help-development related
Ahha... Sorry 😦
still receiving exception
Yes, you’re going to receive the exception when you try and read data the stream doesn’t have
You now need to handle that exception and decide what your program is going to do when that happens
i cant understand what are you saying exactly
whats that
im trying to connect to a minecraft server with protocol
How to read a var int from a packet
I’m not going to write your code for you, no
Exception Handling in Java or Java Exceptions with checked, unchecked and errors with example and usage of try, catch, throw, throws and finally keywords.
i wonder if i should attempt to retrieve Reflection constructor to class field through a static block
or through a constructor
which option is better guys/gals?
https://paste.md-5.net/ebusuvinag.java
why it is not setting the sneak?
i already check, the TrollUtils.shift.contains(name) is true and when i'm sneaking it runs the code, i already try cancelling the event, setting the players walking speed, but nothing works
Because the client is constantly trying to make itself sneak and knows that the user is holding sneak, so it’s acting like it
Presumably
there is any way to like increase the player's speed when sneaking and when is in the edge of a block he can fall?
The client isn’t going to walk off the edge of a block if it thinks it’s sneaking
He can make them go faster but not walk off the edge of a block without teleporting them when he assumes they should which is going to seem jank
and if i create a mod? i can put a player's tag in the plugin and check in the mod right?
You can make a mod for it yes
They don’t necessarily need to
The server can run normal spigot
The client can run the mod
i don't have much experience in mod's but i'll try
if ((xCoord != 0 && zCoord != 0) && (xCoord % 30 == 0 || zCoord % 30 == 0))
For one thing worldedit can’t make an infinite wall
You’d have to keep running more worldedit
World generation is going to be a better bet for performance though
That’s not an infinite wall
Lol
If you’re making this setup one time then yeah use worldedit
If it needs to happen dynamically then do world generation
protocollib
why
lmao
why make your life harder
They might not be hard, but they are a bitch to
a) setup (debof)
b) handle (reflection)
How do i make an Axe that cuts down a whole tree?
loops my friend
BlockBreakEvent*
How else are you going to handle different NMS versions...
Multi-module 
that still requires reflection, no?
How does it work
Cause currently im using multimodule and i still have to use reflection to initiate a class by appending the version to the package
I have something like
v1_19_R1 module -> io.github.pulsebeat02.example.v1_19_R1.NMSClass
v1_18_R2 module -> io.github.pulsebeat02.example.v1_18_R2.NMSClass
and i would append to append the version name to io.github.pulsebeat02.example and then add NMSClass to get the class
https://github.com/Zedly/Zenchantments/blob/master/Zenchantments/src/main/java/zedly/zenchantments/Storage.java#L47-L75 this is how one plugin that I know of deals with selecting the right module
and use some sorta abstraction obviously
That’s technically reflection to be fair
Oh nvm we pretty much do the exact same thing
not really
Very very light but I would say it still counts
I mean yeah it is reflection for getting the version - but you could do it any other way
Either way, I would still use protocollib when possible 🤷♂️
You could use the bukkit method but that leads to unexpected behaviour with some stupid fork being stupid
That’s what we’re talking about though as far as I’m aware, using reflection to decide what module to use
i always use a pattern from the package name
Correct, that’s not needed, if that’s what they were talking about then you’re right
There is also that one stupid programmer that wants to have "SuperCoolVersion" in the top right corner or whatever cursed stuff they want
*top left
Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; this is what i use
Yeah until you have someone using that software. And those people tend to be rather entitled
Though I'm wondering, don't you guys get these weird IDE errors when you import NMS modules? (like with the NMS libraries itself)
As long as each module is it's own project - no
And of course the classes need to be uniquely named
Otherwise you need to reference them by their fully qualified name
I think i had to use reflection because i was dealing with submodules
and i couldnt import the NMS modules and instead made another "final" module to package everything together
but in the main module i would use reflection to get the specific adapter
I'm more talking about eclipse projects (they are still maven submodules) - no idea how IJ handles those.
Regardless, they shouldn't just differ by source sets
I'm takling about the wrapper implementations having unique names.
Unless you are talking about some witchcraft I am not familiar with
Intellij doesn't handle them as their own projects, maybe that's why
IJ moment.
ow, that might cause issues
using gradle shouldn't change anything
You should use a unique package for each module otherwise you are going to get issues
Yeah I was
does each submodule has its own pom.xml?
Yeah that's what I did
But with gradle
https://github.com/MinecraftMediaLibrary/EzMediaCore/tree/dev/ezmediacore this is how I've been handling it so far
Main depends on api module, and lib depends on main + nms modules
If I try to depend on the nms modules from the main module i get the annoying compile errors
What are the annoying compile errors you’re getting
Also just to satisfy my intense curiosity
Why
im too lazy to change it into multiple classes lmfao
Change what into multiple classes
Well no, but yes.
and also theres nothing to really shorten, its all pretty much algorithmic
@Contract and stuff doesn't work regardless
What are you talking about
@NotNull and @Nullable doesn't work by default, but you can configure so it works
The only issue is that Eclipse's null inference is a bit (read: very) pedantic.
I’m asking why you broke it up into field definitions and then immediately underneath assigning them values
Not line 137, line 96
I.e. a String constant that isn't marked as @NotNull will be considered to be of undefined nullability even though it is very obvious that it isn't null.
private final Map<K, V> mapField = new ConcurrentHashMap<K, V>();
I'm weird in that i like to make my own blocks, look at my static blocks lmfao
I'm having an issue with an ArrayList<> not appending properly,
when I add it, all the other values that existed are replaced with the value I just added. why this damn thing happen?
Well the static block is at least doing a try catch so that has to be there
nah in general
i usually initialize my immutable variables and stuff without try/catch or other functions
in static blocks
Show us your code
no particular reason, its easier to stare at less for my eyes side to side
Well that’s not a particularly satisfying answer but at least now I know
and also yes im aware a lot of people think it looks like shit too lmfao
lots of people flame me for it
i had considered but im going to be honest i was too lazy to implement it
quite a few exist out there
already using submodules
but with gradle
they're very cool
you can have multiple gradle or maven projects within the same window
I have no idea why this problem happens
I mean, you have static jsondata
catching a npe kek
neither of the fields in BlockWeapons$Data should be static
i love them when they are internal
I love how eclipse had that feature since the dawn of mankind and you are thinking it's something that's cool
is this includes Data
i believe ij has a hacky way to allow it too
the Data class itself can be static/should be
np
Yeah it's probably not new at all
JPMS/Jigsaw modules are different to the modules we know
Nah, those have been there for much longer
Java modules are different from intellij modules
Java modules allows you to partition jar files into modules
Maven 3.0 (which likely supports modules) has been release back in 2009
In what way do they differ?
allows cyclic dependencies between modules?
Okay - maven supports multi-module builds since maven 2.0 - so 2005
Yeah then pretty much maven's aggregation system
Can someone help me how to prevent moving items in the inventory. Because when my mouse is in the inventory and I press the number on my keyboard where the item is located, the item moves anyway.
No offense but that doesn't get me anywhere either. I have already come this far
Wrong events
You want the inventory click event: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryClickEvent.html
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
Also to prevent people dragging items use the InventoryDragEvent
That I need the InventoryClickEvent I know but I don't know which function I have to use
Read the docs?
You need to cancel the event
I don't think you know what I mean. Here is a video
Does this work in survival?
no
Then take a look at the InventoryCreativeEvent
handling creature stuff goes brr
This is my code: https://paste.md-5.net/axudecoraq.cs
declaration: package: org.bukkit.event.inventory, class: InventoryCreativeEvent
Thank you it worked. But how do I fix this:.
WorkloadRunnable 
Do you want to connect them with a certain color?
Should it be filled or be hollow?
setCursor(null) should do the trick
calling it before closing the inventory!
for (int x = startX; x <= endX; x += 30) { // Generate wall every 30 blocks
if (!this.concreteWalls.containsKey(x)) {
final Material concrete = this.getRandomConcrete();
if (concrete == null) continue;
this.concreteWalls.putIfAbsent(x, concrete);
}
for (int y = 0; y <= 255; y += 1) { // Generate wall from top to bottom
for (int z = 0; z < wallThickness; z++) { // Fill the wall along the z-axis
this.workloadRunnable.addWorkload(new PlacableBlock(world, x, y, z, this.concreteWalls.get(x)));
}
}
for(int sx = 0; sx <= 30; sx++) {
int globalX = x + sx;
for(int sy = 0; sy <= 255; sy++) {
for(int sz = 0; sz <= wallThickness; sz += wallThickness) {
this.workloadRunnable.addWorkload(new PlacableBlock(world, globalX, sy, sz, this.concreteWalls.get(x)));
}
}
}
}
Try this
How do I set the cursor to zero when I close the inventory with "e"?
No, not to zero, pass “null”
Share your code
*null
I’ll spoonfeed you i don’t mind it lol
I know you are interested to learn how to do it
for (int x = startX; x <= endX; x += 30) { // Generate wall every 30 blocks
if (!this.concreteWalls.containsKey(x)) {
final Material concrete = this.getRandomConcrete();
if (concrete == null) continue;
this.concreteWalls.putIfAbsent(x, concrete);
}
for (int y = 0; y <= 255; y += 1) { // Generate wall from top to bottom
for (int z = 0; z < wallThickness; z++) { // Fill the wall along the z-axis
this.workloadRunnable.addWorkload(new PlacableBlock(world, x, y, z, this.concreteWalls.get(x)));
}
}
if(x == endX) {
continue;
}
for(int sx = 0; sx <= 30; sx++) {
int globalX = x + sx;
for(int sy = 0; sy <= 255; sy++) {
for(int sz = 0; sz <= wallThickness; sz += wallThickness) {
this.workloadRunnable.addWorkload(new PlacableBlock(world, globalX, sy, sz, this.concreteWalls.get(x)));
}
}
}
}
?paste
Does anyone have example of ItemManager (ItemCreator or so). I mean this will create custom items, u know (name, lore, flags etc.). I'm struggling a little bit with it and i am trying to write down this like 7th time?
Before e.setCancellled
Call e.setCursor(null);
Just add that line
Let me know if it works
It is the same as before. Here is my code:https://paste.md-5.net/tebugacife.cs
yea
Ok, instead of before e.setCancelled, try before opening the inventory
It works thank you very much
wtf is bro trying to create 💀
something with walls
how can I parse minecraft .dat file as json/dict or whatever that's easy to edit?
does ascii show up in lore?
Best way to stop an entity from completely moving?
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, Integer.MAX_VALUE, false, false));```
I have this code but it's moving ever so slightly.
is there an event for me to set a custom tablist for each player?
list header and footer
declaration: package: org.bukkit.entity, interface: Player
You can set it on join or whenever you'd like it
ah okay
is this for 1.12.2?
how can i make hunger drain faster?
while loops are pretty much all you need
Although foreach is something I'd recommend to be able to understand as it's nice.
But I mean the syntax of a for loop is pretty easy
for (initializer; condition; operation) {
body;
}
which boils down to
initializer;
while (condition) {
body;
operation;
}
for loops can also be ```java
for (Type type : map/list/set/etc) {
type.something();
}
that is foreach
that gets classed as foreach?
Yeah
You rarely call Iterable#forEach anyways, so the collision in naming isn't much of an issue
However yes - the technical name is "enhanced for loop", but who is going to remember that?
?paste
[Java related] Java Swing
For arrays
for (var ref : src) {
body;
}
compiles down to
var copy = src; // Yes, javac does that - even if 'src' is a local variable in the first place
int i = 0;
while (i < copy.length) {
var ref = copy[i];
body;
i = i + 1;
}
Where as for Iterables it compiles down to
var iterator = src.iterator();
while (iterator.hasNext()) {
var ref = iterator.next();
body;
}
var 💀
just wondering but uh, is this good? Or should i use an Iterator?
it works but like im just wondering
since better memory management
None related but i would use a better name for plr
what do you mean with iterator?
Iterator<HologramLine> lines = ect;
If it is about your enhanced for loop, look up two messages before yours - enhanced for loops (at least those involving iterable - which in your case is the case) compile down to using iterators
where is the resoure pack for the magic plugin???
if allocations are an acute concern for you and your list implements RandomAccess you could use a traditional for loop. I.e.
int size = lines.size();
for (int i = 0; i < size; i++) {
var line = lines.get(i);
// [...]
}
what magic plugin
?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.
yeet thanks
wrong discord
are you sure that that plugin has a resource pack?
is having something like this a code smell:
public interface Foo extends Bar<Baz> {}
an empty interface
just for the sake of encapsulating generic types
probably depends on what you're using it for
not really tbh
For non-primitives? Yes.
For primitives? No, not at all
For absolutely huge generic signatures? Depends.
how would that help you with primitives
If you keep it empty not at all.
But once you add methods that accept the primtive you can reduce autoboxing ops and thus have a smaller memory footprint
how would you reduce autoboxing tho via default methods
concerning the underlying is using the wrapper
have extra methods being used
some1 know ?
See java's IntSupplier as an exmple.
that is a different implementation entirely
I need to somehow pass the Bukkit player object to the independent classes as an argument, problem is i dont want to expose the generic types of the underlying classes
now i have an independent interface Foo<T extends Bad> which allows me to pass T argument as a method
and i wrap it with the provided interface above
You can still continue to use Foo<T extends Bar> everywhere
yea, but i dont like to expose that

then what is the point in having the generics then?
how would creating an "alias type" help that
create a method that accepts a CommandHelp and annotate it with something with help
too long ago
Amazing answer
How can I change those colors?
Uh - I have no idea about what that is
At worst use the sun Unsafe to register a javaagent and use that to hotswap classes
Is there any good way to check if a player starts sneaking or stops sneaking other than maybe use playermovevent and check or a schduler that checks every few seconds if a player is or not sneaking?
Listen for the statistic change for crouching
Ty, that solved my problem, after adjusting it a little bit
Wouldn't stop crouching be ignored tho in that case?
Sorry was thinking of somethign else, use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerToggleSneakEvent.html
statistic increase was for jumping
yes
Oh nice, thanks a lot
What will be the best not so complicated option to make TIMER. I mean, when u place a block, hologram appears above it, and in one line, there will be Time Left: 5m 0s or diffrent time. And it count's to zero. I know i will have to update hologram every second, but how do i make a timer ?
Scheduler?
?scheduling