#help-development
1 messages · Page 806 of 1
it builds some more complex object
should I learn it now
idrk what to learn now tbh
havent stumbled upon a mechanic that I wouldnt know how to make currently
Can i do smth like: Map<Kit, <UUID, Cooldown>>?
Make an object to hold stuff instead
^ way fucking better
youll end up like me
fr stuff like this is cursed as hell
private final Map<ChunkCord, Map<RelCord, WorldboundGenerator>> cache; try to stick to one map at once
Needs more nesting
this is nested believe it or not 🥲
private final Map<UUID, WorldGeneratorCache> serverCache;
adding bungee suport be like
private final Map<String, ServerGeneratorCache> networkCache;
private final Map<String, Map<String, Map<String, Map<String, Map<String, Map<String, String>>>>>>
I'm trying to import my library into my project, and I can, I am doing it through jitpack and github. It passed all the tests. IntelliJ does see the library and i do get type sense with it, but when i compile with the library i get a no class found error.
Are you shading it
i can do that with jar tf irc?
Unsupported class file major version 61
when i did shade i got this... they are both using Java 17...
?paste the error
Make sure shade plugin is up to date
it is, it's mine.
the library that I am using. it's mine. It's Java 17 and my project is also using java 17.
The library you are shading or the shade plugin itself
both. they are both Java 17.
maven
maven wont reload...
What happens?
wrong message
If the tool and enchantments immediately exceed the hardness times 30, the block breaks with no delay; otherwise a 6 tick (3⁄10 second) delay occurs before the next block begins to break.
this 6 tick delay is server-side, right?
ya i think it is
When it comes to thread safety, if I were to use a thread executor and I have a class to edit stuff in cache
should I use consumers
so like
SomeManager#editConfig(String configID, Consumer<Config> configConsumer);
executorservice*
can I do something that can be directed to a special gui with keyboard keys for example: there are 54 slots, I can use the back and forth right and left keys on the keyboard to navigate the slots, that is, I came to the 23rd slot using the back and forth right and left keys on the keyboard and when I press enter, can I command it to enter a different gui....
i have send wrong message, sorry
i want to get the right recipe position in shaped recipe
You cannot detect client key presses
Other than the few that are bound to something
I mean, logically it can be done, but is it extremely difficult?
or is it completely impossible?
.
ahh now I understand, so when the gui is opened, the keyboard is disabled because the character does not play
Yes
it is possible?
The ingredients array for a shaped recipe is in order
From top left -> top right and then down each row
I hope they make the plugins more flexible in the future. 😭
well its likely they're moving towards more data driven registries and stuff so its possible it'll help plugins
mostly because they have a small incentive to improve Datapacks and such
Keybind registry
near future I'd say its unlikely, but maybe eventually
Coming 1.69
exactly
you are a junior developer!
thx uwu
the maximum plugin I have made so far is 1920x1080 animated market menu
but I wanted to know the order of each one counting on the empty spaces
diamond sword for example:
{a=ItemStack{DIAMOND x 1}, b=ItemStack{DIAMOND x 1}, c=ItemStack{STICK x 1}}
i want something like:
(air) (diamond) (air) (air) (diamond) (air) (air) (stick) (air)
What does the ingredient array for that return
but it is private in ShapeRecipe class
There should be a method
what method?
Ah no you can only get the choice map
Well you can use the shape array and the choice map to calculate each slot
how?
Is the shape array always size 9?
Ah wait no it’s 3 strings
Which are presumably 3 characters long
that is the return of ingredientMap
i only want to know what slot dont have anything to show the right recipe
Alright, then check the strings in the shape array
If each one is only 1 character long then you can just use the middle column
yes, but it only return 3 instead of 9
i dont know what method i use to get empty the right shape with empty space char
?
You don’t need them
If you seed the line is only 1 character long you know it can be in any column
Then just pick whichever one you want
the recipe of slab and sword will be the same
?
[ItemStack{STONE x 1}, ItemStack{STONE x 1}, ItemStack{STONE x 1}]
[ItemStack{DIAMOND x 1}, ItemStack{DIAMOND x 1}, ItemStack{STICK x 1}]
same
This is why you look at the shape array like I said
@young knoll public String[] getShape() ?
Yes
This is what I'm using, it doesn't return the space characters
fun createItemStackList(recipe: ShapedRecipe): List<ItemStack> {
val shape = recipe.shape
val ingredientMap = recipe.ingredientMap
val itemStackList = mutableListOf<ItemStack>()
for (row in shape) {
for (c in row) {
itemStackList.add(ingredientMap[c] ?: ItemStack(Material.AIR))
}
}
return itemStackList
}
Correct, but it has the shape
i want this: [ItemStack{AIR x 1}, ItemStack{DIAMOND x 1}, ItemStack{AIR x 1}, ItemStack{AIR x 1}, ItemStack{DIAMOND x 1}, ItemStack{AIR x 1}, ItemStack{AIR x 1}, ItemStack{STICK x 1}, ItemStack{AIR x 1}]
not: [ItemStack{DIAMOND x 1}, ItemStack{DIAMOND x 1}, ItemStack{STICK x 1}]
How can I do this?
You can analyze the size of the array and the size of each entry to determine where items should go
It shouldn’t be
The slab should be a 1 length array with a 3 length string
Where the sword should be a 3 length array with a 1 length string
the shape size of sword and slab is equal 3
That doesn’t seem right
Is there any current software that already can read mapping files like
https://piston-data.mojang.com/v1/objects/dced504a9b5df367ddd3477adac084cea8024ba4/server.txt
or am I best off making my own
for reference I don't need to map actual java code I just need to read the mappings Ig
ig I should just make my own reader
They look different to me
can you show me the code?
NamespacedKey key = NamespacedKey.fromString(args[0]);
ShapedRecipe recipe = (ShapedRecipe) Bukkit.getRecipe(key);
System.out.println(key);
for (String s : recipe.getShape()) {
System.out.println(s);
}
Ignore the unsafe code I was lazy
really worked, I was doing logic the opposite of that
but how can I make logic to work across all the different recipes?
Can I code a plugin that can execute commands of other plugins from console?
The plugin has an API, but I would prefer using console. How can I make it execute the command?
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command);
Got it, thx
the method is executed it sends me a msg of starting the edit mode it's ig something to do with the isInEditMode() method
Is there a way to make TextDisplays rotate to a player?, idealistically without events
yep
lol should not have overlapped names with my lib and bukkit
final sh.miles.ironpipe.api.inventory.item.ItemStack betterStack = IronPipe.newItem(Material.AIR);
betterStack.setName(MineDown.parse("[Close](color=red format=!italic)"));
return betterStack.asBukkitCopy();
``` end up with stuff like this
Someone who knows how to make a display entity go smoothly upwards with a player as a passenger
Ok
I have been trying to fix this issue for hours and finally came here
I have followed the Create a Simple Command wiki page on spigotmc.org to the T
But i constantly no matter what i do always get
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "dev.allusive.mulesmp.MuleSMP.getCommand(String)" is null
I have watched multiple videos and tried everything
I looked through a few spigot threads aswell and applied the solutions but it did not work
command is not in your plugin.yml
it is ;-;
name: MuleSMP
version: '${project.version}'
main: dev.allusive.mulesmp.MuleSMP
api-version: '1.20'
authors: [Allusive, allusive-dev]
description: MuleSMP plugin, coded by Allusive provided under Creative Commons
website: https://allusive.dev
commands:
pick-hunters:
description: Select hunters with a 5 minute timer
I have done absolutley everything i could find
Here is my command and main class
open your final jar with any archiver and look at it's plugin.yml
Ok, everything looks fine
?paste your main class
remove the - from the command and try without
I already have tried that but i'll do it again
Exact same error just tested now
I also confirmed after extracting the jar that both the plugin.yml are the same
if the plugin.yml is as you have posted there is no reason for your error
I know lol
Thats why i came here
It makes no sense
drop your jar in here
I can't upload files in this channel
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
I linked that top show you the verify command
so i need a spigot forums account?
!verify if youw ant
Usage: !verify <forums username>
i didn't even use the command before and it says Rate limited
yeah Y2K used it 😦
delete the paper-plugin.yml
Same error
Yeah same error
thern the jar on your server is not the one you posted here
I'm going to guess you have been trying to update the jar on your server with it still running
No i stop it everytime
And also delete the world files everytime (i know i dont need to btw)
Ghosts
np
How do I use "Interpolation" to teleport a display entity smooth?
block.getDrops() this metod just for read?
yes
who dug into the states of a note block in a json file? In addition to notes, can you change the tone? Because in the bukkit api it’s possible
Have seen that several plugins usually use this api
Well, you wont be able to change the tone via textures (i think thats what you mean by "json file")
But you can change the tones etc through a databack or via spigot.
somebody knows why i get this when opening a book to a player by doing
BookMeta meta = (BookMeta) book.getItemMeta();
assert meta != null;
meta.setTitle("Enter reason");
meta.setAuthor(playerName);
eventPlayer.openBook(book);```
you didn;t set teh meta back to the book
yeah no pages
yeah i see
Open a Material.WRITTEN_BOOK for a Player``` yeah but i cant open writable to a player i think
iirc writable books are client side
could type in chat or use an anvil
Hello! I'm trying to get a player to fly up as a passenger on an ItemDisplay, right now I'm teleporting the ItemDisplay every tick to make it come up with the player as a passenger, but how can I make it a smoother experience for both the player and the ItemDisplay? Therefore right now the player cannot move freely as they are teleported every tick.
how can you cancel the blokBreak event and then place another block there?
One tick later
oh it means it’s impossible right away
Hello! I'm trying to detect when a player is duplicating items via the creative menu, for some reason I don't think inventory click event is getting fired when I middle click on the item, I've attached a video of my current state, heres my code:
@EventHandler
public void onInventoryClick(InventoryClickEvent p_inventoryClickEvent) {
if (!(p_inventoryClickEvent.getWhoClicked() instanceof Player p_player)) {
return;
}
getLogger().info("1");
if (p_inventoryClickEvent.getAction() != InventoryAction.CLONE_STACK) {
return;
}
getLogger().info("3");
the logger 3 statement never reaches the console, any help?
Creative mode has its own events
And its fked
what the event called my internet is being slow with the javadoc rn
InventoryCreativeEvent i think
Let me double check
yep it is
no need for any changes code wise it looks, just bc its a subclass of the same event i was previously using
still doesn't seem to pick up the action or get called during clone :/
Print out the actions to check
why is every action PLACE_ALL
the event doesn't even get called when i duplicate/middle click the item
Quite a bit of creative stuff is completely client authoritative. The server doesnt have a saying in it.
That's why you should use my plugin for beta 1.7.3 that adds a completely server dependant creative inventory!
yeah I get that, seems like there is no remorse for this
I would rather play a minecraft clone within roblox, built by kids, than running a 1.7.3b server.
It's not bad at all
Believe me, it's really cool actually
And the server starts in moments
And programming for that version would be an absolute, complete nightmare for me
Like, why would you ever do that?
I did, wasn't that bad. Just that inventories were 98% nms, 2% bukkit
bleh
Yes, cancelling the event has no impact on your codeflow.
?paste
https://paste.md-5.net/purubavaza.cs some reason i not can cast block to noteBlock state
Hello , iam having a problem with stats system i made .. a map with String (Type of stats ) , and int (value)
but it keep telling me null every time i tried to get the stats
so for example i can do
SWuser.getStats().put("SWKill",+1);
Because its not a BlockState but BlockData
but the map is always null
oh
How do you initialize the map?
in the constructor of the SWUser
Is your map final? -> if not, make it final
map = new concu... hashmap
i dont think so no
oh oky
Gonna try that
but isnt final mean its not editable?
The variable wont be editable. The object itself is not impacted.
oky great
Another very important thing:
Under no circumstances should you have a setter or getter for mutable objects.
So never for Lists, Sets, Maps, etc.
They should never leave your class. This is very important to write robust code.
so i need to make a method , like public void addStats(String type,Int amount) ?
You got it 🙂
Nesting the encapsulation is also a decent idea. Depends a bit on your schema.
i gess block paste/break not can be changed?
What does that mean?
Ah i think we already talked about this, but make your stat types not a String but an Enum.
It will save you problems which can easily emerge from typos, where you get nothing from your
Database because the name has a typo in it.
Sure, you can change the sound.
What if I have a plugin, thats implemented by the Core plugin, which does everything with storing and loading data? I have a particleTrail plugin, that has a selectedParticle-Map and the main plugin stores everything
for custom block
A sound packet is sent to the player. Not 100% sure if the client predicts it and plays a sound on his side instead.
this is just another approach to the same issue
Doesnt matter. There is literally no exception to this rule.
Never expose your collections.
brb
hiding your collections means creating methods and functions that act as the inbetween from your code and the collection
If I had a hashmap that stored the uuid of a player in relation to their currency, I would make functions removeAllBalance addBalance etc, and not just interact directly with the hashmap.
Hello! I run "cancel" on the Entity Damage Event as the player can take damage from FireRocket explosion but the player still takes damage even though I run cancel
oh alr ty
Could you explain the concern again? So you have a data class with a bunch of collections, and another object which needs to serialize your
data class, but doesnt have access to your fields?
I have a map with data and its saved and loaded by another plugin
In this case you need to introduce a standard for serialization. There are multiple approaches to this.
Either an interface which returns an intermediate object (Like spigots ConfigurationSerializable interface which returns a Map<String, Object>)
Or an external intrusive approach with reflections.
i mean the map is just UUID, String
String is the name of the selected particle
and it will probably be stored in an sql table
Then this is probably the way to go:
public class ParticleSelectionManager {
private final Map<UUID, String> particles;
public ParticleSelectionManager() {
this.particles = new HashMap<>();
}
public String getSelectedParticle(UUID playerID) {
return this.particles.get(playerID);
}
public Set<UUID> getPlayersWithSelections() {
return Set.copyOf(this.particles.keySet());
}
...
}
It allows you getting all data from within your class without exposing the internal structure.
*This is the solution that doesnt require you to introduce a serialization standard.
wow looks good, ty. Just another question: Is there a reason why the map is initialized in the constructor and not with the declaration?
I kind of dislike initializing non-primitive object fields with their declaration because an exception there can be quite nasty.
Its also for consideration for possible future changes. Thats also the reason why i always create brackets for each new scope.
So
if(something) {
return;
}
Instead of
if(something) return;
Its for code consistency as well.
smart. Tysm
This would be a possible future change
private final Map<UUID, String> particles;
public ParticleSelectionManager() {
this(true);
}
public ParticleSelectionManager(boolean syncSafe) {
if (syncSafe) {
this.particles = new HashMap<>();
} else {
this.particles = new ConcurrentHashMap<>();
}
}
And i would be annoyed if the fields where initialized without a constructor then 🙂
perefence until logic is needed
Hi, please @ me once this support has finished :)
I have a question to ask but dont want to interrupt
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Help with making variables per player
Hello! Am I stupid, or why does the Entity Damage Event not work, but the PlayerQuitEvent works correctly?
public class PopListener implements Listener {
@EventHandler
public void onPlayerDamage(EntityDamageEvent e) {
if(e.getEntity() instanceof Player){
Player player = (Player) e.getEntity();
if (PopManager.getPopPlayers().stream().anyMatch(r -> r.getVictim().equals(player))) {
e.setCancelled(true);
}
System.out.println(PopManager.getPopPlayers().stream().anyMatch(r -> r.getVictim().equals(player)));
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
if (PopManager.getPopPlayers().stream().anyMatch(r -> r.getVictim().equals(e.getPlayer()))) {
System.out.println(PopManager.getPopPlayers().stream().anyMatch(r -> r.getVictim().equals(e.getPlayer())));
PopManager.removePopPlayer(e.getPlayer());
}
}
}```
you should compare UUIDs and not direct Player objects
e.g. r.getVictim().getUniqueId().equals(player.getUniqueId())
I feel like that's not the issue
doesn't players have reference equality ?
Yeah
since when?
forever afaik
:? I've always had issues of comparing player to player in the past and using uuids instead solved it
why he uses stream and not a contains check is something to question as well though
You should never expose your collections like that.
If only one player can have one victim, then an internal
Map<UUID, UUID> victimMap
would be the way to go.
This allows instant access to your victims, without having to stream every time.
There can be several victims and only one, and a player can have several victim, because when a player shoots another player, the player who was shot becomes the player's victim. What is the best way to do it then?
side note, the m_ thing for your variables should be omitted from your getters
What are you trying to achieve?
this, And think 7 smile 7 said that the way I did to save the players was not optimal
Right, but what's the end goal of the entity damage event
so why don't you check the entity type?
or the damage cause
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
I want to check for a certain player not for all players
So you want to disable firework damage from a certain player?
Yes 🙂
Well you can store a list of player's uuids who a currently immune to firework damage, then if that list contains the player in the entity damage event and the cause of the damage is a firework, cancel the event.
I already have my "private static final List<PopTask> popPlayers = new ArrayList<>();"
iirc firework sends entity explosion as the type?
But it didn't work with this code:
and PopTask contains the uuid of the player?
"if (PopManager.getPopPlayers().stream().anyMatch(r -> r.getVictim().equals(e.getPlayer()))) {" Works with PlayerQuitEvent, but not with EntityDamageEvent
final List<UUID> convertedPopList = PopManager.getPopPlayers().stream().map(popTask -> popTask.getVictim().getUniqueId).toList();
if (convertedPopList.contains(e.getPlayer().getUniqueId()) {
// run logic
}
once again as 7smile7 said, you should probably make a method or store a list of uuids alongside your pop task so you dont expose collections
Hey guys so you have seen this error where exploit clients send a container click packet with -1 slot and cause a server crash.
I am trying to fix it from NMS checks but I cannot seem to be able to achieve this.
i think you can intercept the packet before it gets to mc with protocollib or just using netty pipeline injection
I am not sure what exactly I have to check, because -1 is a legit slot, I check for -1 and non-valid actions, but this does not seem to work
@glossy ventureMy problem is not about injection or order
But I don't now what exactly I have to check to fix that exploit
never heard about that exploit, have you checked wiki.vg?
it says the action table there
of valid shit
it was fixed 1 month ago in latest spigot
A crash report would be useful
but I am trying to fix it from a plugin
oh
I thought you guys knew it because its popular
I will search for the original github issue
Is someone able to quickly explain the difference between these 2?
` Map<Player, ItemStack> playerItemStackMap = itemInSlot;`
` playerItemInSlotMap.put(player, (ItemStack) itemInSlot);`
To me they do the same thing but im not sure
hes trying that
@chrome beaconI dont know what to block
yeah
-1 Is a legit slot unless its combined with something else that I dont know
they dk what to check
That makes the crash happen
i know that window id -1 and slot id -1 is the cursor
in a set slot packet
im pretty sure thats the only valid use
you can't just cast a map to an itemstack
oh wait I dont check for window id
maybe check if the window is != -1 then cancel it
let me try that
note that some actions, at least in 1.8 i think, use slot id -999 im pretty sure
like a click outside the inventory window
yh
yes ik
i think the problem is the window id
which i havent checked
i see
goofy
yeah ig just check
private boolean cancelPacket(...) {
int mode = ...;
int slot = ...;
int window = ...;
if (slot < 0) {
if (mode == MODE_CLICK_OUTSIDE) return false;
return window != -1;
}
return false;
}
in the 1.8 mappings the mode field is called shift for some reason
the problem is not with 1.8 tho
look
pickup quickmove and clone are valid with -1
there is no such thing as click_outside in my case
oh true
wait is action a part of the packet?
isnt there some kind of mode field
swap isn't
I havent added it as valid, but it still crashes
nah this is latest
tf
look
action isnt even a field in the network packet
maybe minecraft deserializes the mode and button data into an action enum
Compare different mappings with this website: https://mappings.cephx.dev
1 sec
c is the button
what version are u on
in a 1.8.8 context
version: 1.20.2, hash: d7aa9ad2cb
1.8 and 1.20
the one i sent is for 1.20
for 1.8 i use button
ah ok
so
d = slot
e = button
f = mode (click type)
you can also cross-check someone's implementation, like grim or paper
true
i did check paper implementation but ididnt know the mappings tbh
np im doing shit with the same exact packets rn but on 1.8 for inventory guis so yh
there you dont get the click type or action tho u have to decode it manually from the integers which sucks
thx man
Yes
I will add you as friend so we can collaborate in anything we need
are you cool with that?
How to spawn ArmorStand only for one player and sense if this player is interacting with it
How to do that using this remapped version of spigot because this is meance
sending packets is easier in remapped, but you have to do a packet listener to listen for interactions
Yea i know it's easier in NMS i have whole API's for that but i have to work with remapped version and these API's does not apply to this
im doing that
but doesnt seem to work
Hey, is there any API for updating resources? If no, why not?
Ideally a rest endpoint which would allow me to post an update to my resource
what are the available options?
My current idea is to act as an user updating the resource. However, I'm afraid I will have issues with Cloudflare and authentication
So I'm looking for a simpler way
updating requires 2fa, so a simpler way via an API would not be possible
Not necessarily
I can spoof the xf_tfa_trust cookie
I mean, if other platforms can have an update API, why can't spigot?
:<
And no-one that works on spigot is really a web dev
So I have no other option than trying to reverse engineer the mechanism?
As far as I know, yes
ewwwww
?paste
https://paste.md-5.net/ugiveposox.xml
java.lang.NoClassDefFoundError: shaded/pine/toast/toastrpg/ToastRPG
Had this issue last night it was fixed, but now this morning when I go to work on it again it's not working.
I am shading my library it does say
But why aren't the classes actually in the jar file
why does instructions like aload_index, astore_index exist why dont they just use the default one with index?
wtf us that
ASM
is it hard to learn asm
performance
ig
If you have no previous experience with memory and how the CPU works yes
aload_0 is the this instance in instance methods so its referenced often
how does bro know what
What you mean
ive worked with bytecode a lot for some project
this is a pointer that is passed to method invocations
where did u start to learn asm
idk i think its a fun project to learn asm
idk i just read some tutorials and got started
code was dogshit at first
but now i think i understand how it works
also to learn about java bytecode decompile java code into bytecode and read that or reference the official jvm specification
well theres multiple bytecode versions yeah
There's one for every cpu architecture.
thats not assembly
so does that mean
java instructions
ryzen and intel have different asm versions
Not necessarily
x86 is x86
CPU architecture would be x86-64 ARM
nah they both usualy use x64 or x86 standard
oh
wait so is that what that means
like when u install an installer
it has some random x64 and x86
Yeah it isn't it's bytecode
Yes it's your cpu architecture
oh that's nice to know
I mixed up bytecode and ASM lol
i think i understand assembly now
Assembly is pretty fun but it's challenging to find good resources on
I'd highly reccomend an understanding of binary and your cpu before you start
Binary is especially important
Not necessarily but it can be a eye opener for what's happening at an insanely low level compared to java
how hard is it to send an http request with asm
No clue never tried its not trivial though I can send you my hello world code in a bit
my friend
did advent of code
in asm
lol
well just one problem
it took him like a month
this is pretty meh asm but its the Hello World code
section .data
text db "Hello, World!",10,0
section .text
global _start
_start:
mov rax, text
call _print
mov rax, 60
mov rdi, 0
syscall
; input: rax as pointer to string
; output: print string as rax
_print:
push rax
mov rbx, 0
_printLoop:
inc rax
inc rbx
mov cl, [rax]
cmp cl, 0
jne _printLoop
mov rax, 1
mov rdi, 1
pop rsi
mov rdx, rbx
syscall
ret
that's pretty trash implementation though imho you can really shorten it
%macro print 2
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, %1
mov rdx, %2
syscall
%endmacro
are you basically moving something into a stream
no
buffer
you're moving stuff into a CPU registry
oh
for my networking class I got registries
as a little thing to teach the class abt
aren't those like
memory sockets kinda
then you can take user input
%macro input 2
mov rax, SYS_READ
mov rdi, STDIN
mov rsi, %1
mov rdx, %2
syscall
%endmacro
but faster than the ram
most of the "actual" "work" is going to be handled by the kernel anyway through syscalls, you aren't going to be interacting with the hardware because of privileges and stuff the kernel won't let you, you'll ask the kernel to open a socket, you'll ask the kernel to connect to an address, you'll ask the kernel to read from/write to the socket etc, what you'd be doing most is just moving values between memory and registries to adapt for the syscall parameters and return types without losing the data you're handling
yeah there are so many syscall instructions I can't keep em straight xD
Keep in mind you shouldn't program big projects in ASM if it isn't out of "fun"/niche reasons. Use C or C++ instead which compiles to ASM
ASM is just the lowest programming language there is besides ones and zeros (if you count that in)
+1 you really only need a small if your working at such low levels with such resource restrictions that C doesn't make sense which really isn't often now adays xD
punchcards through powerpoint
Lmao
beat them to death

does somebody know if i can stop inellij to combine empty packages with parent packages?
lmao bytecode
has anyone made anything in bytecode
project file view -> options -> tree appearance -> compact middle packages
can i set it as default so every project has this?
Bytecode is intermediary and used for the VM it's the lowest programming language for the JVM, but ASM is the overall lowest language I know of
Bytecode != ASM. Different thing. Somebody has probably made something in bytecode but it would be sorta stupid given, y'know, the existence of a high level language that generates it for you automatically
People have made plenty in ASM though. Rollercoaster Tycoon was infamously made in ASM
yup games back in the 90s were made with ASM
oh that makes sense
yeah I heard abt the rollercoaster game
idek how u organize code in asm atp
ASM for a long time was the only thing there is
Roll coaster Tycoon
But then people catched the drift of making higher level languages as soon as the tech sdvanced
An impressive asm game
No one rights raw asm either there are usually plenty of macros involved
yeah or just C, C is actually a fun language imo
I used to and it was fun, but annoying too
People dislike C but I like the low-level access without the low level ASM code
Could someone explain me why sending these 2 packets make one of them not getting interpeted by client?
NMSPacketWrapper.PlayOutEntityLook.of(
armorStand.getHandle(),
(fW),
armorStand.getHandle().getBukkitYaw(),
true,
PacketData.of(PacketSendType.SINGLE_PLAYER, player)
).sendPacket();
NMSPacketWrapper.PlayOutEntityRelMove.of(
armorStand.getHandle(),
(short) (dX * 32),
(short) (dY * 32),
(short) (dZ * 32),
false, PacketData.of(PacketSendType.SINGLE_PLAYER, player)).sendPacket();
In this example client totally ignore PlayOutEntityLook packet
NMSPacketWrapper.PlayOutEntityRelMove.of(
armorStand.getHandle(),
(short) (dX * 32),
(short) (dY * 32),
(short) (dZ * 32),
false, PacketData.of(PacketSendType.SINGLE_PLAYER, player)).sendPacket();
NMSPacketWrapper.PlayOutEntityLook.of(
armorStand.getHandle(),
(fW),
armorStand.getHandle().getBukkitYaw(),
true,
PacketData.of(PacketSendType.SINGLE_PLAYER, player)
).sendPacket();
But in this example the PlayOutEntityRelMove is ignored
I assume RelMove may have the possibility of having 2 floats representing the rotation thus leading to the look packet being ignored
At least it's the case for client's LOOK, LOOK_POS and POS
Those have the same underlying packet iirc.
You either send rot, pos or both
yeah try that
how would I get an entitytype's id, nms question
in 1.16 I used to do it with IRegistry but now idk how, IRegisstry.ENTITY_TYPE doesnt exist anymore pretty sure
are you using mojmaps
im using the ones that have weird chars idk what its called exactly i keep mixing them up
but yeah instead of words its chars
@silent topaz what version are you on
im doing nms wrapper for 1.20.2
alr one sec
(registries moved to nm.core.registries.Registries by the way)
yep Registries.ENTITY_TYPE
The ResourceKey should just be Registries.ENTITY_TYPE
thank you
meh its not that hard for me im just comparing it with version of it that has words
alright time to finalize this custom model plugin, finally
Does anyone know if the enchantment table only lets in certain items for inputs?
It's not letting me insert regular items that should be enchantable.
I mean
You tried and it said no.
The obvious answer to your question is yes it does filter
should I do methods to manage stuff and then commands that use them or just make commands that manage stuff and use those commands in code
Methods
Preferably you shouldn't be executing commands to invoke logic
guys, is there some guide on how to run a mc server with my plugin right from ij idea so I can hotswap or something?
does anyone know if reading the persistentdatacontainer of a chunk requires a lot of cpu power?
basically, i made a very fast rail item that if placed down and ridden, the minecart checks if the rail below it has the persistentdatacontainer tag and if yes it will go very fast
it's like a single access to ram if the chunk is loaded afaik
so its not read from the disc?
well, if the chunk is in ram, why would it read from disc
i see
so i dont need to try to cache it
in a list or sth
its basically the same then
yeah ig
well if the chunk that the pdc belongs to isn't loaded, you will need to load it to do anything further. How useful your cache is depends on whether the data needs to be live for prolonged periods of time or not. But you will need to have the data live if you intend to write to it.
you will need a java agent to do hotswapping
is there some guide for that shit
not entirely sure, let me see if I can find you a link
on the left it seems they have a guide on how to use it with intelliJ
hopefully this works out for you, so have fun 🙂
Will probably be funky working with a live server if ur testing stuff on it
any better way to set enemy health bar colour based on their missing health?
or would those 4 ifs suffice?
Hello, I have a small problem with the meta data in 1.7.10 spigot when the item is corrupted and there is a meta data (id) getDurabilty() and item.getData().getData() it returns the durability but I don't see how to recover the meta data (id)
Can you help me please thank you in advance
1.7.10? 😳
whats the ip 😈 there is definitely no exploit with logging on that version
lmao
I never got a chance to play with log4j it'd be fun come on man I can just run rm -r on your server folder or something
good?
Yes 🙄
Guys!!! its only 10 years old give him a break!
the PVP worked better!!!
come onnn
have a positive attitude
the logging exploits worked better back then too 😈 still waiting for that IP
maybe, maybe you'd get help for 1.8 here from a few gracious souls, but anything below that forget it xD you're on your own
I mean saying you'll get good help for 1.8 is really generous too
Okay
Does C have any kind of generics? I'm trying to make a linked List implementation so I can make a HashTable for my project
preprocessor macros are your friend
I'm brand new to C confused how preprocessor macros would help here
you can make typed variants of your linked list
expound please
I've used these doubly-linked lists before: https://github.com/vnmakarov/mir/blob/master/mir-dlist.h
(project is irrelevant, it just has good lists)
Some english grammar otherwise it looks fien
this stuff goes way above my head xD
like wat
#define DLIST_LINK_T(T) \
typedef struct DLIST_LINK (T) { \
T prev, next; \
} DLIST_LINK (T)
I thought C didn't have generics
what is this header file magic
that's a macro lol
???
I thought the point of header files was to not do implementation
macros are not really implementation, they just define, well, macros
to use in other files
I sent that way too early, sorry
yeah but would woukd T even be since generics do not exist
if you do DLIST_LINK_T(int), the preprocessor replaces it for
typedef struct DLIST_LINK_int {
int prev, next;
} DLIST_LINK_int;
iirc
create a variable
called health
make them all else if's
soooo do I need to make my own preprocessor for that???
I kinda just want a simple linked list 🥲
and remove the second check in the second statement after that
didn't think it'd be this hard
no lol, that's available basically in every C compiler
what for?
I can't decide whether I want to cry or just quit right now :*)
maybe I'll do both
What is their name set as?
enemy name + current health / max health
more readability
if damage dealt makes their hp less or equal than 0 then just 0 / max health
and is probably slightly faster
Show me
because I couldnt find a better method?
if (healthLeft > 0.66* entity.getHealth()) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.GREEN + " " + healthLeft + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + enemy.getMaxHealth());
if (healthLeft > 0.33*entity.getHealth() && healthLeft <= 0.66*entity.getHealth()) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.YELLOW + " " + healthLeft + ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + enemy.getMaxHealth());
if (healthLeft <= 0.33*entity.getHealth()) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.RED + " " + healthLeft + ChatColor.DARK_GRAY + "/" + ChatColor.RED + enemy.getMaxHealth());
if (healthLeft <= 0) entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + ChatColor.DARK_RED + " 0" + ChatColor.DARK_GRAY + "/" + ChatColor.DARK_RED + enemy.getMaxHealth());
You do repeat quite a lot
like what
What’s healthLeft btw
health left?
What is it declared as
as well as the diabolic if statements
Okay.I am assuming ur if statements are meant to use maxhealth then?
I was asking if there is a better way to handle checking whats the value of it, not how to make it sound better in case a 8 year old decides to read my source code
I dont get the point of making separate variable for entity.getmaxhealth()
its like a few letters difference
dont forget to mention how awful it is again
is enemy and entity the same?
ChatColor color;
if (healthLeft > 0.66 * health) color = ChatColor.GREEN;
else if (healthLeft > 0.33 * health) color = ChatColor.YELLOW;
else if (healthLeft <= 0) {
color = ChatColor.DARK_RED;
healthLeft = 0;
}
else color = ChatColor.RED;
entity.setCustomName(ChatColor.DARK_RED + enemy.getName() + color + " " + healthLeft + ChatColor.DARK_GRAY + "/" + color + enemy.getMaxHealth());
I am cofnused is enemy and entity the same?
use this
it works exactly the same
but better
and faster
and stronger
@storm crystal
Why is entites name set based on enemies hp/maxhealth?
relevance?
So i can make sense of what i need to write
THIS
use this
please
double healthLeft = enemy.getHealth() - damage;
var maxHealthAttr = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (maxHealthAttr == null) {
return;
}
var maxHealth = maxHealthAttr.getValue();
var color = healthLeft > 0.66*entity.getHealth() ? ChatColor.GREEN
: healthLeft > 0.33*entity.getHealth() ? ChatColor.YELLOW
: ChatColor.RED;
entity.setCustomName(color + enemy.getName() + " " + color + healthLeft + ChatColor.DARK_GRAY + "/" + color + maxHealth);
we love var
the last else is not needed
just start the variable as red
ye
Also getMaxHealth is deprecated over the use of the attributes api
no
it still works
so don't care
Circling back to
listen here you-
Nomnomnom
private void bar(LivingEntity entity, float damage){
double healthLeft = enemy.getHealth() - damage;
var maxHealth = retrieveMaxHealth(entity);
var color = healthToColor(healthLeft);
entity.setCustomName(color + enemy.getName() + " " + color + healthLeft + ChatColor.DARK_GRAY + "/" + color + maxHealth);
}
private ChatColor healthToColor(double health) {
return health > 0.66*enemy.getHealth() ? ChatColor.GREEN
: health > 0.33*enemy.getHealth() ? ChatColor.YELLOW
: ChatColor.RED;
}
private double retrieveMaxHealth(Attributable attributable){
var maxHealthAttr = attributable.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (maxHealthAttr != null) {
return maxHealthAttr.getValue();
}
return 0;
}
Why are you doing
entity.setCustomName(color + enemy.getName() + " " + color + healthLeft + ChatColor.DARK_GRAY + "/" + color + maxHealth); then?
because I can
VAR
WAT
Ur useless then sigh. Well whatever, try not to repeat ur self so much.
NO
I am a big kotlin nooby, so i like my val or var
I wrote that java code with so many vals and syntax errors at the start
enemy has stored values of name, type, max health, static statistics
You use kotlin and u don't cringe when write var in java xd
Well, obviously java likes their mutable values
because, as the name suggests, its a fucking dao lol
It doesn't make sense though ur setting the name of "entity" to something releated to enemy
anything that happens to entity happens to that entity that is living right now
Okay, so entity and enemy represent the same thing?
enemy is a row taken from enemyStats db
gl with that attitude
entity is that particular entity that's living and happens to have stats of said enemy
Alright, name it enemyEntity then
well you just went with trashing me all the time and saying how you cant look at it
"Why did you kick that pregnant woman?"
"Cuz I can"
and the enemy to enemyStats
dont expect me to take you seriously after that lol
no
We want to be able to know what is going on based on naming
I'll try to restrain myself from saying my thoughts out loud next time
you said that you enjoy helping people
so dont guilt trip me
about me supposedly wasting your time, it was your conscious decision
Instead of wasting our time do something productive with ur code so we can help you instantly instead of needing wayy too many followup questions.
always good to name your variables something people understand; common practice and however you learned coding; it should have stated that as well
im not going to post all of my classes as context everytime I ask for help in a piece of code
its like
totally, completely irrelevant
We do not need that.
what they mean
they might as well be named variable1 variable2
I wasnt asking for that at all
with variabels and methods that are named in a way people understand what they do you dont need everything
My followup questions were.
What is healthleft? We didn't see a declaration.
What is ... for the setCustomName? Cause we didn't see ur methods setting them.
What is enemy? Cause apparently entity was set to something related to enemy?
These three would have been answered if first, ur questions was asked properly.
you didnt need anything because I was asking about something else
execution of checking if a numbers is between X1 and X2
thats it
any better way to set enemy health bar colour based on their missing health? Image or would those 4 ifs suffice?
Was your original question.
which was literally what it meant
Which isn't really the best question, but we got there.
4 ifs that compare numbers
For that we needed to know what healthleft was.
Since you were comparing it to entity.getHealth
not really
We certainly did.
what happens if you dont know it
Then we would be thinking that it is some arbitrary number that can't be compared to getHealth
healtLeft and getHealth sortof means the same.
ifs are literally made out of if (var1 >/</>=/<= var2)
would you assume they are strings
or arrays
I could assume you're comparing the current health to the current health.
Which is why my first question was what is healthLeft
A perfectly valid assumption might i add.
Then i would assume you mixed up entity and enemy cause they're so close together in spelling in ur setCustomName.
Perfectly valid assumption again.
And it could be, cause we don't know they were different variables.
why would I write 4 ifs to compare same numbers
next time ill throw entire jar and make variable names entire paragraphs in case someone might think otherwise, if only it was any relevant lol
To enhance clarity and streamline your code, consider the following suggestions:
Variable Naming: Instead of using generic names like "entity" and "enemy," differentiate between them for clearer understanding. For example, use "enemyEntity" for the entity with stats from the enemyStats database and "enemyStats" for the row from the database.
Method Refactoring: Break down your logic into separate methods to improve readability and maintainability. Your bar method could be split into smaller methods, such as healthToColor and retrieveMaxHealth, making the code more modular.
Use Attributes API: While getMaxHealth may work, consider using the Attributes API for better practices. Since getMaxHealth is deprecated.
Document Your Code: Add comments to explain the purpose of your methods and any unconventional coding decisions, making it easier for others (or yourself) to understand your code.
These changes aim to enhance code readability, maintainability, and adherence to best practices.
im doing solo code and I get what I write
Then don’t ask us for help.
also you are overexaggerating
You’ve now been told how to somewhat make it readable.
I am a little. But explaining it now versus later is better.
Aren’t i nice?
bipolar a little, not really nice lmao
I wish i was bipolar when dealing with this.
It appears you may have encountered some challenges with accessing online resources for learning Java. Allow me to guide you without providing specific links; it should be sufficient unless, of course, you're operating on zombie mode.
I had my problem resolved so I dont need anything else lol
pretty funny how it could've been answered with "no, if/else is good enough for that"
uh
I mean this is just the perfect response
to that
Got your ego hurt a little, a?
if you say how much you are not going to help but still gonna then how else am I supposed to look at it
I literally
sent you
@young knoll He called me bipolar, can i get such a role?
a formatted version
you get what you write but obviously java, and spigot does not understand what you write
of your code
It’d be funny to roleplay as bipolar
so that you can understand
why it was awful
and how you can learn better coding hazards
I said that it sounds a little bipolar
and by exagerrating I made sure you'd remember
but I guess you like overexaggerate whatever I say
but I didn't know you were so
with a ton of unnecessary comments
then why does it compile and work exactly as intended
hey
so good you mentioned you are developing a ban command
It would probably br Console
hello
and <reason>
then the player name you wanna get is an argument, no>
why do you want the command sender's name?
prob for notifications
broadcasts to all online staff the ban reason and who banned them
yeah
i just use sender instanceof Player ? ((Player)sender).getDisplayName() : ChatColor.AQUA + ChatColor.BOLD + "CONSOLE"
usually
Ohoh, what about when a Zombie does it
XDD
are you sure that code compiles
hmm wait I just realised
Method to get player forward vector for ray tracing?
no
im too lazy to add a "" inbetween the chatcolors tho
args[1] wont work for my ban reason if my ban reason is multiple words long
as it will only take the first word
concat it with string builder
StringBuilder reasonBuilder = new StringBuilder();
for (int i = 1; i < args.length; i++) {
reasonBuilder.append(args[i]).append(" ");
}
String reason = reasonBuilder
.deleteCharAt(reasonBuilder.length() - 1) // remove trailing space
.toString();
ok thanks
String.join exist
Imagine using stringbuilder
StringBuilder is great!
though in this case oyu probably should do String#join
Need to skip the first one
use copyOfRange ig
idk the signature for String.join tho so thats pseudocode
possibly
if you're going to skip the first one your best off just using a for loop then
if you copy it you're doing extra unecessary work
doesnt really matter when its run on a command but just showing different options
id join it using the loop yeah then u can also process potential flags or smth
Totally
String result = list.stream().skip(1).collect(Collectors.joining("")
Well
100% compiles yes
With an arraysaslisg
lol
i love arraysaslisgs
Close enuf
also isnt there supposed to be a space in the string arg to joining() and another closing paren
also can I not combine two colours?
ChatColor.WHITE+ChatColor.BOLD
Ok thanks
to string one of them or add a string
even that won't work well as the second color would take affect unless you have a character to show the first color
ChatColor.WHITE.toString() + ChatColor.BOLD
toString is even longer tho
i mean yeah but it looks better
ig
how do I make enemy ai
That’s a loaded question
not chatgpt ai type deal lol
Ur asking without context