#help-development
1 messages · Page 152 of 1
and 4 events that remove mending from the game
so i split all of those into their separate handlers?
if you have the PlayerInteractEvent twice, and they both start with the same 10 different lines for checking (e.g. was a block clicked, is the player OP, does the player have a certain item, ...) then I'd have one eventhandler and then decide which of my other methods to call
if however both eventhandlers are totally different, I'd just use two event handlers
well i dont have any duplicate events yet
@EventHandler
public void onInteract(PlayerInteractEvent event) {
// 10 lines of if statements that doLeftClickThing and doRightClickThing would have in common...
// ...
if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
doLeftClickThing(event);
} else if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
doRightClickThing(event);
}
}
yea i see
this might make sense if you have many checks before the first if that would otherwise be "duplicated" in both things
but if they do TOTALLY different things, e.g. one InteractEvent is to check whether a block was clicked, the other is to check whether a player uses some very special item, then just make two event handlers
in the end, it doesn't really matter. unless you register A SHIT TON of event handlers since ofc if the HandlerList gets very long, this is not very good for the server performance
but I doubt that you wanted to register 5000 eventhandlers in one plugin
yeah im weirdly obsessed with small performance things so i try to optimize even the smallest things even if they dont matter at all
readability > getting the last 0.00001% of performance
which is usually a good thing but it does take time away from actually doing anything productive
exactly
its not that it doesn't matter at all, it just doesn't matter until you hit a certain threshold
im not experienced enough in java to optimize anything small anyway
my minecraft plugin is not gonna profit from a single saved allocation
and it might take me a few minutes to do
which could be spent doing something more productive
when doing some embedded low level stuff its definitely important
even in high level it matters
that one extra allocation, means another object for the JVM keep track of, another pointer being used, space in the stack being used, and now the GC at some point might need to handle it
but is it really going to matter for a small plugin, most likely not. But it does matter on systems where they have like thousands of players though
GC? The listener is only created once
because mass amounts of resources are already spent for those players
And then stays there for ever
that wasn't the point I was making
Okay but we only talked about listeners
but it really doesnt make a noticable difference on modern hardware
ok, my point was that all objects whether small or not do have an impact, just the impact is not seen until you hit a certain point
exactly
so, yes 1 extra allocation of an object can make a difference, just doesn't for small plugins
exactly my point
what i meant was that its not worth it spending 10 mins on optimizing a single allocation away when you could spend that time doing other stuff
I sometimes even listen to the same event for every priority separately lol
exactly this, however if you are mostly done and that is really all you have, then I say go for it
because while small plugins generally don't see such benefits, if you get enough small plugins together
then it does matter
this applies if you are making public plugins
because what some devs forget, your plugin isn't the only one going to be on the server lol
what do the priorities even do?
LOWEST gets called first, HIGHEST second latest and MONITOR is latest
e.g. imagine you wanna check if a player is trying to place a block on NORMAL priority
a plugin on LOWEST might have already cancelled it
so on normal, you can just ignore it if the event was already cancelled on LOWEST
how does it handle multiple handlers on the same level
the first registered listener gets it first
fair
the HandlerList is basically nothing more than a list of methods to call, ordered by priority, or ordered by "time of registering" when same priority
okay in fact it's an EnumMap, but still, same idea
its 2:30am and youre on light mode
good night
found the issue with hex colors- you have to use ComponentBuilder from 1.19 onward
im tryina make a method for my hashmap so I can access it in another class and not have to use static but its not working at all
HashMap<UUID, String> particlesMap = new HashMap<>();
public String getParticlesMap(UUID uuid) {
return particlesMap.get(uuid);
}
When I try to use getParticlesMap(uuid in here) it doesn't work just red in IntelliJ and no options to import anything
you obviously need to learn about OOP
class files are objects
you would need to hold a reference to the class that is accessible to access the methods within it
really quick question, you should be able to get the location off of a dead living entity right?
yes
how is it dead and living ;-;
oh ok
can someone show me how to do this
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.
lol knew someone would do that
every time
I already did the sololearn.com one
and I literally remember none of it
so uh im not doin it again
probably because you didn't take time to apply between each lesson
exactly
you learned incorrectly
mk ig ima be reading for a while
OOP can be a hard to grasp concept at first so it may take a bit
honestly took me my first 6 months for it to finally click
mk
two primary uses for static Constants (Never changing Variables)
and Singleton Classes (An instance where only one object of a certain class should exist at one time) This principle is generally used for something like Databases as you wouldn't want to open multiple connections
https://www.geeksforgeeks.org/singleton-class-java/
Also I reccomend skipping all the basic shit and gimicky projects and jumping straight into OOP design polymorphism etc
in freecodecamp?
no just in general
hm?
I taught myself how to code using google and stack overflow idk any of those websites
omg ppl on stack overflow are so confusing
or im just stupid
prob that
but
I dont understand anything they say on there
Like what
this is a shitty example
also a shitty practice wtf
oh ok
oh nvm I see he explained it but the code example is poor
I mean it's fine I guess it just depends on the use case
It's still pink for me
same
Weird im seeing al people with white name
again matters on usecase but i'd, model it something like so
public class DataStorage {
private static DataStorage instance;
private final Map<String, Integer> people;
private DataStorage(){
this.people = new HashMap<>();
}
public int getPerson(String person){
return this.people.get(person);
}
public static DataStorage getInstance(){
if(instance == null){
instance = new DataStorage();
}
return instance;
}
}
public class PluginName extends JavaPlugin {
@Override
public void onEnable(){
final DataStorage dStore = DataStorage.getInstance();
System.out.println(dStore.getPerson("Miles"));
}
}
}```
In this use case I'm assuming you'd never want another instance of DataStorage under any circumstances thus it being singleton
Hey, is it possible to make an async task run on the same tick? (The bukkit scheduler "schedules" the task to run on the next tick, but I need to cancel an event on the same tick that it happens, and it needs to happen inside an async task)
If not, can someone teach me how to make my own scheduler, and if schedulers generally cannot run tasks on the same tick by definition, is there any alternative? Maybe a java thread?
Another option to add to this is using DI instead of Singleton btw
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
I use singleton for this stuff 🤷♂️ I prefer singleton pattern for data storage as i feel its much more explicit that you shouldn't use that again
I use DI for pretty much everything else
Oh, I didn't mean to say your way was wrong or less right, I was just saying that DI is another way to achieve the same thing.
so on here u use static for ur getInstance() method so this is useless and we're gonna use static in the end anyway so just use it on the map
Why do you need to cancel an event async?
It's a pretty long story
shouldn't matter though
Singleton is different than using it on a variable
^
it allows the use of restriction to define what people are able to do
?xy
Asking about your attempted solution rather than your actual problem
the reason why is not related to the problem
it may seem unintuitive by it does make sense once you better understand patterns
I'm just generating code
ok
The getter makes sure the instance isn’t null, for one
I'm basically taking code from a language built inside of minecraft and generating java code for it through a website
the reason why I need an async thread is for synchronous waiting (Thread.sleep in this case)
that is no way related to what I need though
Can’t you wait sync with schedulers
and stacking schedulers will not work specifically inside if statements and loops, unless I use a pointer-like system where each action points to the next, but I don't want to do that
no, they just delay the code inside them
Well as far as I know you can't cancel events async at all
so in my original problem all I would need to do was make a method to get the instance of the class so I can use that in the other class?
depends why / how you are using the data
The only way you can cancel an event is within the handlers themselves, anything async and the event would be finished by the time you went to cancel it.
So the origin of the issue is how cancelling events works
(Event happens in mc world)
(Call event method)
(If event was not cancelled, Minecraft Stuff here)
async threads happen after the event method, so that's why this is a problem
what I'm asking is if I can run an async thread on the same tick instead of scheduling them for the next
if not with the bukkit scheduler then with my own or any alternative
Uh, I doubt it.
im using it for a command /particles and in particles if u use the cmd it adds a ur user and a string of the particle u used in an arg in a hashmap and in another class listener it makes particles at ur feet if the hashmap contains that key with that value when u walk
That's not really how async works afaik
The bukkit scheduler just waits for the next tick and executes the runnable there
I just want it to run on the same tick instead of waiting, and this is probably not doable with the bukkit scheduler itself but are there any alternatives
What about the thread class?
ahhh I see okay so you'd want to make a cache class kinda like I displayed above you could also use DI which is what i'd recommend for a beginner. Than on quit make sure you save that data to a file and load it up on start so when players rejoin after server shuts down that data is still there
you should also make it more advanced but you can worry more about that later
from java.lang
I know, I didn't mean it literally
I just want the async code to run instantly rather than scheduling it
is what I meant
that makes no sense at all um isnt a cache like a hidden away stash im confused
Yeah but that's not how async works
Even if you somehow achieved that, there's no guarantee that your async task will cancel it before the server checks for cancellation.
so um would it not save the hashmap when the server turns off?
no HashMap is stored in memory
which means as soon as the java program terminates its emptied
code runs instantly so it should
It doesn't run in order when dealing with async.
it doesn't have to
Basically all variables in your program are emptied when the server shutdown
Sync, yes. That's why cancellation works the way it does currently. You start adding async into the mix and everything falls apart.
as mentioned, code runs instantly, so the second the async task is triggered it is done
how do I fix that
You know what ram is I assume
yea
all that data is stored in RAM
ye
as you may know RAM is temporary storage you need to do FileIO to write to the disk
Well, no. When you make an async task the Thread you created it on sole job is to ONLY make the task, not run anything inside it.
Once that async thread is created, that thread continues on its merry way to do whatever else it needs to do. The computer then decides when that async Thread actually runs what is inside it.
Like files on your computer
...
yk how some plugins have config files
oh ye
thats an example of them using fileIO
yep
so I store it in config file?
generally a bad practice but since your knew go for it it'd be a pain for you to learn databases
the async thread is created instantly I assume though?
bungeecord hex colours aren't working
Order is un-determined when you're working with async.
I have a config API you can use you can either add the maven repo to your project or just copy some code from my ConfigUtils class
https://github.com/Y2Kwastaken/config-api
https://github.com/Y2Kwastaken/config-api/blob/master/src/main/java/sh/miles/configapi/processing/ConfigUtils.java
databases would generally be easier imo, use mysql and do it. It is far easier and better for the future than using config file types
hex colours aren't working
non-hex colours are fine, hex colours round to another colour (e.g. a maroon hex colour becomes aqua)
(bungeecord not spigot)
hm how do I do that lol
generally shouldn't be a focus when you first start a lang I think its better to understand the language itself before trying to also learn Databases it'll slow down your progress and prob make u less interested was the case for me atleast
Cancel event async
Everyone is different, I believe that learning a databse earlier would be so much better than getting into the language then having to switch your project from file storage to database storage
going back and redoing it a lot is what I did 🤷♂️
it got me more familiar and writing more code
anyways yea if you wanna learn SQLite which is probably best for this small-scale project you can do that but you can also check out my config api
the annotations have no usecase for you so I reccomend just grabbing the ConfigUtils class
I am prob gonna need smthin for uh larger storage
im usin this for my server
network
hmmm okay yea that changes things
@quaint mantle I know literally nothing about SQL so your in charge here i've only ever used NOSQL
nosql and sql thats weird
no sql just means its not a type of sql database which is table based afaik
I've only ever used MongoDB as thats whats used at work
MongoDB has a JSON like structure but for something as you have table based works fine
SQL is also wildely more popular afaik
Yes
so sql is better for what im tryina do
I would use something like SQLite so you don’t need to host anything
a
public static String colourize(String message) {
String prefix = "&#";
final Pattern hexPattern = Pattern.compile( prefix + "([A-Fa-f0-9]{6})");
Matcher matcher = hexPattern.matcher(message);
StringBuilder buffer = new StringBuilder(message.length() + 4 * 8);
while (matcher.find())
{
String group = matcher.group(1);
matcher.appendReplacement(buffer, COLOR_CHAR + "x"
+ COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
+ COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
);
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}```
that's my method
i copied it off the internet because my previous method was having an issue too
do you even need to use ChatColor for bungee? I was under the assumption that was all handled by components
atleast in my experience I just used ComponentBuilder#color 🤷♂️
and that takes in an RGB value iirc its pretty simple to get RGB from HEX vise versa
hm oh wait yes
granted I'm not a bungee dev I've just tinkered with it
huh I just use new TextComponent(String) to get rid of the deprecated thing
Use components
they are hella useful
I remember when I used to use Skript for my servers it had a file that stored all of the variables
also more functional
Skript 💀 good thing your switching away I'm proud of you
Yeah you can’t just use ChatColor inside a TextComponent
bro it was so slow
I hated it
but this is so hard
like
so hard
compared to it lmao
like the logic of the code is so hard to understand
because ComponentBuilder is an array of components
ComponentBuilder#append
you can append more components to the builder
You could
Just send the component array as a message np reason not to
but generally you can just send the array
so I use luckperms for my server permissions... which one of these stores the variables and stuff for like ranks of players etc.? I think its the .mv.db one but idk im just wondering
oop hold on
Idk how hex works with components I use rgb but you could probably just do the math if there's nothing
You should be able to translate the text with ChatColor.of
It’s the .db one
It uses h2
ok
Which is a form of sql
No &
take a look at that
feel free to look at any other projects in my repo
I am not claiming I am the best, but you are free to use my projects as references
is there a way to get a ChatColor from something like "&c" or "&f"
you would need to have your own mapping of such things
which isn't hard since MC doesn't have that many colors for chat well not counting hex
they use ANSI colors
is there a way to update a skin on a tablist in nms
like i can set the textures just fine but i assume i need to send an update packet of some type to change it
Is there any event that get called when an item added/removed in inventory?
theres one when you pick up an item i believe
InventoryPickupItemEvent?
Called when a hopper or hopper minecart picks up a dropped item.
doesn't sound like it
or wait
if that's what you're wanting
but if you're thinking player wise, PlayerPickupItemEvent is your go.
OH
InventoryMoveItemEvent
Called when some entity or block (e.g. hopper) tries to move items directly from one inventory to another.
Its not getting calls all time. Randomly works
Want to run a task when player put/remove items in inv
doesn't mean the generic event is called itself
Did you have the optimized Hopper setting on in the server config?
@wet breach you can use ChatColor.getByChar(code.charAt(1)); (assuming it's guaranteed to be in "&..." form)
I suppose that works too
but doesn't hurt to have your own mapping
I mean its ANSI
just another thing to maintain when it's already in the spigot lib 🤷♂️
yes and no, JANSI provides it
how come my NMS NPC players don't have 2nd layers on their skins?
it's stated in javadoc
woke up btw
where are noobs
show me
You need to send another packet for that
oh, what is it?
i'm using mojang mappings
sorry i'm just on my flow
it doesn't say the generic event is implemented, just tells you what the interface represents. Also don't always believe everything from the javadoc. Just because it says it, doesn't necessarily mean it is implemented or implemented in the way you think.
always should check the source code
shouldn't it be like this
for every
most of the events state that they are getting called
and calling sub events as i can see
probably should check the implementation before assuming
isn't code like half-hidden
Generic events are not necessarily made to be used
no?
can you send me a link
?bt
to spigot repo
alr what should i do with bt?
compile spigot jar and decompile with JD-GUI or smth
use it to get the spigot server source?
or there is a link
why would you decompile
when buildtools gives you the source
the server source is the implementation of the API
i only used buildtools to literally build server jar of latest version
No abstract events are listenable
isn't it
Afaik
this one claims that it's called
i probably even tested it
and it was getting called
normally
same as it's 2 subs
so it's saved to some folder
when bt downloads it
can i just ask bt to download sources and not build spigot jar
with flag or smth
how are you commenting on API implementation and not know how java compiles crap
yes there is a flag
for just sources I think
java -jar BuildTools.jar --rev latest --iwannakillmyself
no
are you disgusted or smth
if that's the right word?
// Add data
SynchedEntityData data = npc.getEntityData(); // DataWatcher
data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 126);
sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
i've tried that
but it doesn't seem to work
the 2nd layer doesn't show up
:-:
¯_(ツ)_/¯
mfw "where are noobs" but no knowledge on bt
also no knowledge on implementation either
just going off what some words say
cuz why should i have it
i never used bt
for something other than building jar
because it literally helps you obtain the source
which is how you check how the API is implemented
this.getEntityData().set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);
works for me
until now when someone actually is questioning whether or not have you ever looked at the implementation
what's DATA_PLAYER_MODE_CUSTOMISATION meant to be
nah, never
just guesses
its just a byte
what byte ??
idk its on the remap
exactly my point and pretty much the reason some might be annoyed with you
look at the src
that is fine, but you should have checked to see if that was true
well if i want to check i just write and run
there is like a couple generic events if I recall that are indeed implemented, but it doesn't hold true for them all
is that mojang mappings?
yep
DATA_PLAYER_MODE_CUSTOMISATION = SynchedEntityData.defineId(Player.class, EntityDataSerializers.BYTE);
they use this
oh wait
bruh momento
nvm
i'm using the nms player thing
wait no i'm using bukkit one
i'm mentally broken
that's what i just asked
whats the package for nms player
moj mappings?
can't call abstract stuff
EntityDataAccessor<Byte> DATA_PLAYER_MODE_CUSTOMISATION = SynchedEntityData.defineId(net.minecraft.world.entity.player.Player.class, EntityDataSerializers.BYTE);
data.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);
sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
good?
i'll try it anyway
?tas
dont think that will work
i showed you how they do it, doesn't mean if you do the same it will work
oh
java.lang.NullPointerException: Cannot invoke "net.minecraft.network.syncher.DataWatcher$Item.b()" because "datawatcher_item" is null
InventoryEvent isn't abstact btw
and to check if it's getting called
i would just prefer writing a listener
not downloading bt, then downloading sources, then viewing them
sounds like a great waste of time
how to check if an entity is in the end?
entity.getWorld().getName().equals("world_the_end") is probably the most simple way
entity.getWorld().getName().equals("world_the_end")
or at least
3rd times the charm
but if the world isn't named like this?
them check dimension type or something like that
entity.getWorld().equals(plugin.getServer().getWorldConrainer().get(2));
entity.getWorld().getEnvironment() == World.Environment.THE_END
better
if end is world 2
all of our methods ignore that it can be custom world with same environment
but still
yes but also require the name to be fixed or it to be the second world
neither are reliable
yah
when forgot chcp 1251
waiting 99 hours for buildtools to do it's work
maven does not exist
writing own maven
pliz wait
hey @wet breach
how do i actually check if event is getting called
in sources
first time looking through sources
isn't it really getting called
even has own handlers
and actually just a base for other events to extend from
what are you trying to do?
you can just listen to InventoryEvent if that's what you're asking
yeah
is it gonna work like combined event of it's subs
listening to everything
related
yeah
so any event that extends InventoryEvent will also get called
this doesn't hold true for all generic events
ah doesn't it?
no, there is some generic ones that are implemented but not all of them
still
i was right
you can easily call InventoryEvent
so the guys who suggested it to me were right too
how is buildtools related to java core
i just ignored it
never used
and never really had to
is it implemented?
yeah
it has handlers and you can listen to it, and it's not abstract of course
I never said specifically that you couldn't use it either
that doesn't mean it is implemented
I can put a handler in any class I want
doesn't mean it is used
SynchedEntityData data = npc.getEntityData(); // DataWatcher
EntityDataAccessor<Byte> DATA_PLAYER_MODE_CUSTOMISATION = SynchedEntityData.defineId(net.minecraft.world.entity.player.Player.class, EntityDataSerializers.BYTE);
data.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 126);
sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
spigot devs be like
anyone know why it's not working?
let's put this thing here for no reason
generic events are mostly there to extend off of for the API or to make your own custom events
i remember i listened to it already in my multipaged gui plugin
anyways I never said you couldn't specifically listen to that event
all I said is that generic events generally are not implemented
and really should check to make sure that it is
but not all of them
my point was there are several
there isn't several
which are both implemented and have subs
alright
having subs has nothing to do with being implemented
you can have a sub, and the parent not be used
isn't it like the same
no
sorry for my bad eng
it sounds literally the same for me
several like more than one
but not much
several by definition means 3 or more and less then many
few means not many but more then one
sounds cringe
isn't English fun 🙂
well 2 is a couple
seems accurate
well russian language doesn't have many words like English
or rather have varying definitions for words
we just have forms for all that
The Displayed Skin Parts bit mask that is sent in Client Settings
Bit mask Meaning
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
0x80 Unused
how would i enable all of them
with those bytes
agh
add up the bits
russian dirty slang has so much forms
well what is that
ya know cyka bl
can i set entities' pathfinder goals after they have been spawned?
so well we were both kinda right
its going to be either 164 or 165
today i learned how to download sources without compiling
no
whats the usecase
what is that in funny 0x00 things
use a custom goal
pro tip: calling someone "dummy" will make them not want to help as much
i am
0xA4 = 164 0xA5 = 165
lmfao what
why do you need to change it then?
just so you know its hex
okay
just have the goal be dynamic so you can set the location whenever
can i modify fields of a goal?
ah ok thanks
can u sort a collection<integer> without casting it to a sortable x implements collection
Do I save my pathfind goal to a variable or can i access it through the goal selector?
Can you really sort a set
well treeset exists
You can bubble sort
So does HashSet
hashset isnt sortable
still doesn't work
bruh moment
// Add data
SynchedEntityData data = npc.getEntityData(); // DataWatcher
data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 0xA5);
sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
Could you help me please?
I have a bridge that sends commands to be executed to bungeecord and this is the way it sends them:
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(executor.getExecutable().replace("%player%", player.getName()));
System.out.println(executor.getExecutable().replace("%player%", player.getName()));
player.sendPluginMessage(plugin, "hqueue:inventory", out.toByteArray());```
The commands arrive this way (as attached) in the bungeecord channel and, rightly, are not dispatched
```java
@EventHandler
public void onPluginMessageReceived(PluginMessageEvent event) {
System.out.println("Data received: " + new String(event.getData()) + " --r");
if(!event.getTag().equals("hqueue:inventory")) return;
System.out.println("Data received: " + new String(event.getData()));
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), new String(event.getData()));
}
Do you have any idea to fix this problem?
(That char before queue randomly appears in the String)
dont quote me on this but try to use 0xa5 instead of 0xA5
It's the same
ah
@echo basalt has the answer, I can feel it
How to get distance of entity that I'm facing?
really confused on entity navigation, can anybody help? I've just set something up as a test, on PlayerInteractEvent i run this:
public void goTo(Location loc){
tracking.getNavigation().createPath(loc.getX(), loc.getY(), loc.getZ(), 1);
Bukkit.broadcastMessage(tracking.getNavigation().isInProgress()+"");
}
this returns false though
Anyone know some good config libs?
Just left the house and I'm walking to school
So yikes
:c
if i know the exact size of a collection, should i set the initial capacity to max * 1.33, or the load factor to 1 ?
frostttt you're my last hope, help me plz
did some research and you actually have to do this instead
byte bitmask = (byte) (0x01 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80)
have no idea, but it should automatically add up the bits properly
don't have my cheat sheet for bitmask calculations lol
SynchedEntityData data = npc.getEntityData(); // DataWatcher
byte bitmask = (byte) (0x01 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80);
data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), bitmask);
sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
so that will work?
i'm gonna try it
it should yes
waiting for someone to do ?tas
?tias
fail
?tas
when did it get changed to tas not tias
did you add it to the datawatcher?
oh well it's no secret
yes
data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), bitmask);
npc right? on recent version?
Location loc = new Location(world, x, y, z, 0, 0);
MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer worldServer = ((CraftWorld) main.getVotingUtils().world).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Random");
for (Player all : Bukkit.getOnlinePlayers()) {
EntityPlayer allEntity = ((CraftPlayer) all).getHandle();
GameProfile allGP = allEntity.getProfile();
Property skin = allGP.getProperties().get("textures").iterator().next();
gameProfile.getProperties().put("textures", skin);
EntityPlayer npc = new EntityPlayer(minecraftServer, worldServer, gameProfile, new PlayerInteractManager(worldServer));
npc.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
PlayerConnection connection = ((CraftPlayer) all).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc));
},5);
}```
try this maybe?
that's not mojang mappings though
wait, why include 0x80 in the calculations?
in the protocol wiki it says unused
because I copied what you had above
and just didn't really read what you had there
try it again without x80 then? lol
yep
what does >> do
and <<
also still doesn't work
ffs
why are packets so bad
is signed right shift << is left shift
and with three its unsigned iirc
>>> is the same as << but right shift
correct
it moves the bits of a value around, in the direction the arrow's pointing
so for example
0b00001101 is 13 (8 + 4 + 1)
if u do << on that
it turns into 0b00011010, which is 26 (16 + 8 + 2)
what's the difference between signed and unsigned??
fun fact, you only notice the difference between >> and >>> when the number is negative
with >> it will shift a 1 into the least significant bit area, where as >>> shifts a 0 there regardless
so >> can literally change a negative to a positive or vice versa because of a 1 being the next digit to shift over regardless if it is suppose to be negative or not
reason for that is that the first bit of a number is usually the sign bit (the marker if its positive or negative), and its a 1 for negative due to math reasons
bitshifting unsigned and signed does not or does account for that one bit
anyways how do i fix this stupid ahh npc thing
well I gave you some code above to try
but i already basically do that
no that's literally what i do
and that doesn't add metadata
then I am not entirely sure then 😦
?paste
hold on
I do know cape won't work unless you actually do have a cape for said UUID though
good
method
are you certain you are using the appropriate id?
wdym?
that isn't the ID I am referring to
17?
no, the byte
17 in the index, says it is 0 if its absent, otherwise it should be 1+id
117 is player
so 1+117 is what that byte should be
so are you certain it is appropriate? o.O
maybe try not using 0x80 in ur mask. I doubt thats the issue, but you shouldnt flag stuff thats marked as unused
i already use the one that adds it
without 0x80
yea no idea
What you tryna do @torn oyster
npc skin second layer
Are you using a packet wrapper
i'm using mojang mappings
Ah
but no wrapper like ProtocolLib if that's what you meant
i would rather not switch to it either
too complicated for me to read
Haha
it doesn't seem to do it the same way as i do it either
any ideas?
127 is the combined value, I actually looked at that like a week ago 😭
That’s to enable all of the layers
Because I solved this when I made my own npc’s too ahaha
What version is this for though? @torn oyster
1.19.2
yep
try 127
doing that atm
weird
this has consumed the last two hours of my life
does it show the 2nd layer at all?
nop
// Add info
sendPacket(sp, new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
// Add data
SynchedEntityData data = npc.getEntityData(); // DataWatcher
data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 127);
sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));
// Spawn entity
sendPacket(sp, new ClientboundAddPlayerPacket(npc));
that's my code
try set the data above the player info packet
oka
on a different topic, does anyone know if hex code can be read as an int via ConfigurationSection? I'm doing Color stuff
ye cuz im pretty sure the player info packet carries some data with it
weird
i'm gonna genuinely just throw the whole entire codebase away at this point
noo 😭
yes
why
damn I wish I had 1.19.2 buildtools rn
sounds like a skill issue
isn't it present?
yo check dms rq
Stop static abusing
What is your nickname
What do i have to call you
zacken02
I am reminding people to not using static
No, i even not use static on my main method
I dont have good thoughts regarding static keyword anymore
Can you code at school
Fuck man i wish i could study as a trial
I want to code at school
How i can block some enchant in one item on anvil and enchanting table but with a specific item
I used this event to make a custom enchantment and for some reason when I click on the result slot, nothing happens and I can't get the enchanted shulker box.
any ideas?
I used event.setResult(resultItemStack); to make the resulted Shulker appear in the result slot
static ❤️
i'm reminding people to not use Ving
public non-static void main(String[] args) {
}
imagine
anyone?
sendfullcode
?paste
and probably learnjava
aren't you cancelling invClickEvent somewhere else
in your plugin
or in other plugins on your server
cuz like if you can't take item from inventory it's probably cuz of e.setCancelled(true) somewhere
I don't use this event
I couldn't have canceled it
and I don't have any other plugins in the server
hmm
what events are you listening to? list them
PrepareAnvilEvent LootGenerateEvent
i think in older versions the prepareAnvilEvent can prevent you from picking up the resulting item if the event is cancelled
but it is not canceled
I don't have any cancelation line anywhere in the plugin
in any event
and you cant pick up items out of the anvil?
I just can't pick up the resulted item from the anvil
yes
mc version?
1.19.2
2 questions:
why is your enchant method capitalized
what does it do
- no reason
- it changes the lore of the item and makes it appear enchanted
sounds like a client-server desync
How does it make it appear enchanted
might return null or something, yeah
its the glowing effect on itemstacks, not sure of the exact method
the resulted item is exactly how it's supposed to look other than the fact that it doesn't appear enchanted and there are no error messages in console from this method
wdym
how about you try and output the item you set the result to before the listener is done
I have some problem with Player#teleport the player have some sort of invincibility for 2 second how i can fix it?
essentials config
I’m pretty sure the glowing effect just doesn’t appear on some items
increase tps
search teleport and you should find it
probs
actually
throw your pc out of the window
gonna fix 99% of life problems
or i'm gonna nuke your house
rip
unable to take the result after using PrepareAnvilEvent#setResult after build 288
same thread about ur problem
Tf is an akuma and a meed
F
ItemStack{SHULKER_BOX x 1, TILE_ENTITY_META:{meta-type=TILE_ENTITY, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"AutoPickup"}],"text":""}], enchants={PROTECTION_FALL=1}, ItemFlags=[HIDE_ENCHANTS], PublicBukkitValues={autoshulker:autopickup=1i}, blockMaterial=SHULKER_BOX}}
there is no problem with this
it's exactly what is should be
i'll try
Stfu static abuser
oof XD
Its public static' void main(String[] args){
}
it didn't fix it
What about setting it to 1
still
Int
varargs
Have a look at this, maybe your problem is the same
https://www.spigotmc.org/threads/prepareanvilevent-cant-set-result-if-result-item-has-attribute.431858/
kms
What about List<List[]>…
List[] 💀
Throw some maps in there
if it’s not List<List<List<List<String>>>> don’t talk to me
4D lists
Tuple<List<T>, Vector<K>, Stack<O[]>>
What will OfflinePlayer#getLastPlayed return if the player never played?
dude that looks confusing
Yeee, keep forgetting, sorry 😬
Hereforth
RTFM
this
HE ALLISON @echo basalt
Arrays.asList(varargs)
Collections.singletonlist
just doing some research. for the guys using Redis. what library do you use and why do you feel like its the best one?
I use jedis but people hatin
Collection.solidQueue
jedis
redisql
people like lettuce
what about a knuckle sandwich
i currently use Jedis as well but i heard some people saying the other ones are way better
use whatever you prefer man ❤️
it hurts so much. I go away from my screen for 3 minutes and here you guys are breaking the geneva conventions on java
yea i just find the jedis api a little bit weird in some parts
keep myself safe you mean
jedis is special
spigot itself is weird sometimes
«AGREED
i mainly use Redis for pub sub. do yall know if the other libraries do that better?
InfluxDB, Redis, MongoDB
college is poopy
no you
Pac-Man
yes
university is great
no u
L
hugs
same here
based mousepad
but my phone has no charge
Both uni and college kinda succ
So i can't take a photo
Don’t @ me
no u
powerbank go brr
these college computers are poggers tho
10k mAH for like 7 bucks
RTX2070 in all of em
im charging from laptop
sheesh
charging laptop from wire under the table
Nah the best room in my college was when I walked into a bathroom and discovered a swimming pool with a water feature
btw @torn oyster is no longer in pain
he sent the metadata packet before the spawn packet
😭
i just made Etalon yesterday
never!
The cleanest sexy code
yo is anyone able to join my server rq and give me some feedback?
pog
i'm re-launching late november but need some feedback before i move onto the next minigame's development
give feedback yourself
genius idea right here
what r u making?
Ban Hammer which makes you ride invisible armor stand on top of pen*s made from orange wool
Then pen*s goes to the sky with you
You get banned
yall are planning your servers? i just say "random bullshit go" and it somehow works out
sometimes
and there are a lot of fireworks exploded at ban location
