#help-development
1 messages · Page 2232 of 1
Thanks! I did it as follows, don't know if this is the proper way of doing it
@EventHandler
public void onOreDestroyed(BlockBreakEvent e) {
var pickaxes = Arrays.asList(
Material.NETHERITE_PICKAXE,
Material.DIAMOND_PICKAXE,
Material.GOLDEN_PICKAXE,
Material.IRON_PICKAXE,
Material.WOODEN_PICKAXE);
var itemInMainHand = e.getPlayer()
.getInventory()
.getItemInMainHand()
.getType();
if (e.getPlayer().getGameMode() == GameMode.SURVIVAL
&& pickaxes.contains(itemInMainHand)) {
e.getPlayer().sendMessage("You a pickaxe equipped");
}
}
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
final boolean isPickaxe = item.getType().toString().toLowerCase().contains("pickaxe");
Would've also worked
awesome, I like yours better, thanks!
if (Tag.MINEABLE_PICKAXE.isTagged(itemInMainHand)) {...```
type not the actual item
so like this?
Tag.MINEABLE_PICKAXE.isTagged(e.getPlayer().getInventory().getItemInMainHand().getType());
yes
thank you!
oh no sorry wrong tag, thats for blocks mineable BY a pickaxe 😦
you will have to use Septicuss version
gotcha, thanks for the explanation
just check if the type of the mainhand item, the name from that ends with "_PICKAXE"
ah i see ElgarL has smth too
no well I meant, it doesn't provide the data in the "PDC" format. his lib also uses PDC to store information but doesn't allow you to retrieve it as a PDC container
are you trying to simulate teh breaking of a block?
it won't break teh block, it will display the cracking effect on it
Im trying to cancel an event outside of the event handler but to no sucess, is this possible, as im trying to have a switch case statement inside my runnable and have the checks in there.
yes?
well
pass the event as an argument
assuming that youre cancelling the event the same tick
Let me proviide some code
new ShieldReactions<>(event.getDamager(), player, itemStack, EntityDamageEvent.DamageCause.SONIC_BOOM, event);
private class ShieldReactions<E extends EntityDamageByEntityEvent> extends BukkitRunnable {
event.setCancelled(true);
lol
Its snipits but theres nothing really else important
i hope youre cancelling it the same tick
i guess we need to see more code lol
public ShieldReactions(Entity attacker, Player player, ItemStack itemStack, EntityDamageEvent.DamageCause damageCause, E event) {
this.attacker = attacker;
this.player = player;
this.heldItem = itemStack;
this.damageCause = damageCause;
this.event = event;
runTaskTimer(moreShields, 16, 20);
}
Heres the constructor, i have a feeling due to the 16 tick delay im not cancelling it in the same tick -_- big derp
no lol
Thought as much
you are passing an event instance which is already handled ig
cheers
and you shouldnt really be extending bukkitrunnable and then calling runTaskTimer in the constructor :/
What would you suggest
either call runTaskTimer outside or use the scheduler internally to run this::somethingToRun
Sorted, thank you.
class SomTask implement Runnable {
SomeTask() { Bukkit.getScheduler().runTaskTimer(plugin, this, delay) }
void run() {}
}```smth like this
i still recommend the first thing
So new ShieldReactions<>(event.getDamager(), player, itemStack, EntityDamageEvent.DamageCause.SONIC_BOOM, event).runTaskTimer(plugin, delay, ticks);
yes..
Hey guys, am I doing something wrong?
GameProfile gameProfile = ((CraftPlayer) player).getHandle().getGameProfile();
Property property = (Property) gameProfile.getProperties().get("textures").toArray()[0];
String signature = property.getSignature();
String texture = property.getValue();
npc.getGameProfile().getProperties().put("textures", new Property("textures", texture, signature));
I wanted to create a npc with the same skin as I have, but for some reason it appears with a different one, not a default steve or alex one tho
event doesn't seem to be firing (message isn't showing up in console) whenever i press Q to drop an item, any idea why?
public void onItemDrop(EntityDropItemEvent event) {
Player player = (Player) event.getEntity();
ItemStack droppedItem = event.getItemDrop().getItemStack();
Material configMaterial = Material.valueOf(config.getString("material"));
Bukkit.getLogger().info("entity drop item event fired");
}```
did you try clearing the old properties first?
Can anyone recommend me a library for creating GUIs
i keep getting this error when building my project, is this something i should worry about? all the overlappings come from my own plugin so i dont understand whats happening lol
maven-shade-plugin has detected that some class files are
present in two or more JARs. When this happens, only one
single version of the class is copied to the uber jar.
just ignore
Kody Simpson's GUI manager was very useful to me
oh yeah sorry its a warning
its just that im not sure if i should worry about it apparently overlapping 1600 classes or so
oh no I didn't, just by clearing the properties map right?
try it and see?
could you give me a link?
?trysee
how do i enchant block-items? when trying to add an enchant it says that this enchant cant be applied to that item
is it only possible with packets?
(just the glint effect i mean)
Spigot has updated their inventory API!!!!! Watch this video too: https://www.youtube.com/watch?v=Qj66KDQucp8&list=PLfu_Bpi_zcDNEKmR82hnbv9UxQ16nUBF7
In this video, I show you how to make a GUI menu using Inventories and ItemStacks. GUI menus allow you to make it so that users can choose options in a menu-like manner. It makes your plugins extra...
you should be able to add enchantments to blocks just fine with addEnchantmentUnsafe
or addUnsafeEnchantment i dont remember
and just apply a HIDE_ENCHANTMENTS flag to the item
do you have to use unsafe to bypass the normal limits?
ah yeah unsafe works thanks
yeah
if you just do addEnchantment i believe it cant go above like efficiency 5 for example
String signature = property.getSignature();
String texture = property.getValue();
npc.getGameProfile().getProperties().get("textures").clear();
npc.getGameProfile().getProperties().put("textures", new Property("textures", texture, signature));
Tried it like this - if you meant that, which doesn't work
No clue then. It was just a suggestion.
can i make mobs have more reach
i think you'd have to do custom entity shenanigans with nms to do that
otherwise no
at least not in a pretty way
i guess you could accomplish it by having a runnable regularly check mobs on the server that have a target and if that target is within a certain distance you can have em attack
can someone explain 'clazz'?
Is there any specific hub command that is neccessarry to the plugin
clazz is teh variable representaiton of a Class as you can;t use class as a variable name
I checked the texture and signature. So the texture itself is the same string, but the signature is different, any idea why?
Wrong signature will result in the texture being rejected
is there any mojang remapped for 1.19?
Since i cannot get build from a remapped nms
harry potter fans
I'm really confused then, it shows me this skin all the time with different signature and same texture. But that's not mine :D
run buildtools
i did ... should i do it again ?
--remapped
i've also added that before
did you run it for 1.19?
yeah
java -jar BuildTools.jar --rev 1.19 --remapped
no no, please no
you just need the correct pom
'cant find spigot 1.19'
<!--Bukkit/Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${project.spigotVersion}</version>
<scope>provided</scope>
</dependency>
<!--Bukkit/Spigot NMS -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${project.spigotVersion}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>```
and in the plugins section xml <plugin> <groupId>net.md-5</groupId> <artifactId>specialsource-maven-plugin</artifactId> <version>1.2.2</version> <executions> <execution> <phase>package</phase> <goals> <goal>remap</goal> </goals> <id>remap-obf</id> <configuration> <srgIn>org.spigotmc:minecraft-server:${project.spigotVersion}:txt:maps-mojang</srgIn> <reverse>true</reverse> <remappedDependencies>org.spigotmc:spigot:${project.spigotVersion}:jar:remapped-mojang</remappedDependencies> <remappedArtifactAttached>true</remappedArtifactAttached> <remappedClassifierName>remapped-obf</remappedClassifierName> </configuration> </execution> <execution> <phase>package</phase> <goals> <goal>remap</goal> </goals> <id>remap-spigot</id> <configuration> <inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile> <srgIn>org.spigotmc:minecraft-server:${project.spigotVersion}:csrg:maps-spigot</srgIn> <remappedDependencies>org.spigotmc:spigot:${project.spigotVersion}:jar:remapped-obf</remappedDependencies> </configuration> </execution> </executions> </plugin>
lemme try this
in the properties section add xml <project.spigotVersion>1.19-R0.1-SNAPSHOT</project.spigotVersion>
oh i think i forgot this
thats just something I added so you only need set the version in one place
oh lmao right
so long as you ran buildtools --remapped and it finished with no errors you are good to go
I think I found the problem. So as it seems, the skin itself is working. But the skin has some kind of overlay which isn't copied, any idea on that?
no clue
I hoped so but its not... gotta delete the previous datas and rerun the buildtools
a quick google says there is a second layer
yea found that aswell, just trying to figure out, how to copy that / show that
I see stuff about datawatcher, but no idea where that class comes from
PacketPlayOutEntityMetadata
its off by default i think
you need to say that its active
I've found reference to it with GameProfile but the only way they have said to display it is with sending a EntityMetadata packet
send after spawning the npc
Does this come from some other lib or something? Can't find these classes on my ide
I've not used them but I belive they are nms
ehhhhh worked dunno why but probably because of not having spigot-api dependency anyways thank you
Hey, if i block the chat event and then i let the server write the message, the player was writing, will then the uuid of the player be removed out of the message?
No idea, I can't find either the packet or datawatcher - which seems to be used together often
Okay I am doing that now as well. It's has a different naming with mojang mapping
ps.send(new ClientboundSetEntityDataPacket(npc.getId(), npc.getEntityData(), true));
but it still doesn't work
Hi, is anyone familiar with how bungeecord communicates with other servers?
What do you understand by communicating ? Do you mean plugin messaging ?
No, how it generally communicates with servers and clients. What happens if a client connects to the proxy? Where does the client send its packets to? How does a client communicate with the proxy if it is connected to a sub server?
Well basically Bungee is just a tunnel between the client and a server. The client connects to the bungee instance like if it wanted to connect to a real minecraft server (follow the handshake protocols and go on), then bungee redirect all the traffic to a specified server, and vice versa
So bungee does not really communicate with servers, actually it doesn't. It just copy paste the traffic from the client
(well there are some stuff behind but not important)
Yea bungee is in principle one directional in the way it’s designed
It uses player connections for servers to talk back to it
Exactly, that's called Plugin Messaging. The server sends a packet to the player, but it first go through bungee so it catches informations like that (players can't even notice cause it's filtered)
(so if there isn't any players, it can't communicate) (except if you make it happen by using sockets, or redis, etc .)
Does the sub server the player is on communicate directly with the client or do all packets first go through the proxy, which just redirects them?
all go thru the proxy which redirects it
Everything go through the proxy
So that you can switch servers without getting disconnected
ok nice, thanks
(bungee simulates a world change for that)
The whole idea of a proxy is to proxy packets. If client and server could send packets around the proxy then it would be useless.
ye ok, did not thought about that. I thought the proxy is maybe only responsible for connecting/disconnecting/sending a client to/from/through servers.
bedrock has stuff for that
java sadly not
for like a full server redirect
tho that feature is pretty hard to implement properly anyway, I think in bedrock it is just a "connect to this ip"
which, eeeek, security loves those
Speaking of "connect to this ip".. Log4J... Hopefully it has been patched 🥲
Yes pretty much very patched
basically days/hours after it went public
Hey even legacy versions got updated
Yep hopefully, cause trust me it was really easy to use
should have literally not patched 1.8
Which did sadden me. Could have been a soft cleanse.
🥲
people would have at least moved for a maintained 1.8 fork
which, better than unmaintained 1.8
Would have been wonderful
If i would use 1.8 i would first take some time and fork the heck out of it.
No way im using this version as it is.
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>me.saif.pluginname.hikari</shadedPattern>
</relocation>
This needed to stop conflicts with possibly older versions?
I asked before but imajin said no
Myes
private List<ItemStack> getItemList(Player plr) {
List<ItemStack> items = new ArrayList<>();
for (ItemClass i : dataConfig.getPlayerListMap().get(plr.getUniqueId())) {
ItemStack item = new SpawnerFactory(plugin,
EntityType.valueOf(i.getEntityType()),
i.getMultiplier(),
i.getCreatorName(),
i.getXp(),
i.getLastGen()).getSpawner();
items.add(item);
}
return items;
}
private ItemStack resetItem(ItemStack item) {
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
ItemStack items = new SpawnerFactory(plugin,
EntityType.valueOf(itemData.get(plugin.ENTITY_TYPE_KEY, PersistentDataType.STRING)),
itemData.get(plugin.MULTIPLIER_KEY, PersistentDataType.INTEGER)
, itemData.get(plugin.OWNER_KEY, PersistentDataType.STRING),
itemData.get(plugin.XP_KEY, PersistentDataType.INTEGER),
itemData.get(plugin.LAST_GEN_KEY, PersistentDataType.LONG)
).getSpawner();
return items;
}
private List<ItemClass> getItemClassList(List<ItemStack> items) {
List<ItemClass> itemClassList = new ArrayList<>();
for (ItemStack i : items) {
PersistentDataContainer itemData = i.getItemMeta().getPersistentDataContainer();
itemClassList.add(new ItemClass()
.setCreatorName(itemData.get(plugin.OWNER_KEY, PersistentDataType.STRING))
.setEntityType(itemData.get(plugin.ENTITY_TYPE_KEY, PersistentDataType.STRING))
.setMined(itemData.get(plugin.MINED_KEY, PersistentDataType.BYTE) == 1 ? true : false)
.setMultiplier(itemData.get(plugin.MULTIPLIER_KEY, PersistentDataType.INTEGER))
.setXp(itemData.get(plugin.XP_KEY, PersistentDataType.INTEGER))
.setLastGen(itemData.get(plugin.LAST_GEN_KEY, PersistentDataType.LONG)));
}
return itemClassList;
}
Linkage errors could occur
I hate ?paste
i feel like this is very unnesscesary
leme explain
do i need to also put slf4j in a shaded package?
When quoting code, PLEASE ADD JAVA so at least there will be colors
since it gets put in the root direcctory of my jarfile
i did lmao
```java
Minion probably
would that mess up hikari since hikari shades that in there
Well if it only relies on the api then you might not need to shade it at all
i dont have it in my pom
No you shade it in there
one sec
so i dont have to shade it?
Unsure
If i need to save a spawner type (It doesnt need to be placed so i dont have to edit the blockdata), and other custom variables whats the best way to do that?
But try and see if it’s possible to not have it shaded
dataConfig.getPlayerListMap()
You should never expose any data structures (like lists, sets and maps) like that.
Currently
how do i override it then
ok and put provided
ik, io made this a long time ago. Im getting it working before i fix all that stuff
its gonna be a lot of work
wow
your very helpful
this colon triggers me
almost as if it did work the first time, and a version change broke it
Tho usually when you write code getting it to work is one thing… then cleaning the code usually takes another iteration per say
Btw thats not how you use "factories". Bit misleading this name.
currently i am deserializing and serializing a spawner using persistant data, and a file
Yep
Honestly. Im at a point where i use a Gson singleton with all my type adapters registered and im just serializing a whole class into the PDC.
This also fixes versioning issues because Gson can handle class model changes.
ty, database starts up fine without it
jar size also smaller
Pog
Well i dont think im using gson but i keep running into an issue where it doesnt know how to serialize certain classes from spigot
im using jackson, how easy is it to switch over
Jackson naming conventions 😵💫 but yeah it’s trivial
All you need is a serializer for ItemStack and Location.
You can also register a type adapter factory that serializes the Map<String, Object>
if the serialized object is of type ConfigurationSerializable.
But the spigot serialization for ItemStack is a bit ass.
So how do i get a serializer for ItemStack and Location
also item meta?
Or do you mean make a custom one?
and every meta subtype
Hold up
https://github.com/Silent-Program/BetterSpawners
do you think its better to scrap all of the inside logic and redo it?
@lost matrix
And why exactly is the name factory misleading there?
Because it’s a design pattern
When you include the label "Factory" in the name of a class you weakly expose the intention of that the class is gonna follow the design pattern
what am i looking at?
So if said class does not follow the pattern you’re gonna end up trolling a bunch of devs
Myes, the factory pattern aims to decouple instantiation from creation
ur storing itemstacks?
Which your class there does not really do
got it
what would it be called then
im in the middle of figuring out the best way to store things
Currently it deserializes all the nesscesary information
and saves it to a file
i store items as a byte[]
wdym
Using BukkitObjectStreams
encoded as Strings, scrambled using Base64
public static String serialize(ItemStack[] obj) {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream)) {
dataOutput.writeInt(obj.length);
for (int i = 0; i < obj.length; i++) {
dataOutput.writeObject(obj[i]);
}
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
public static ItemStack[] deserialize(String str) {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(str));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) {
ItemStack[] items = new ItemStack[dataInput.readInt()];
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
return items;
} catch (Exception e) {
return new ItemStack[0];
}
}
u can ofc just change ItemStack[] to ItemStack
forget the exception
well it is a list of itemstacks
itemstacks get saved as
rO0ABXcEAAAACnBzcgAab3JnLmJ1a2tpdC51dGlsLmlvLldyYXBwZXLyUEfs8RJvBQIAAUwAA21h
that's an itemstack^^
Base10 has 10 characters for data
yes it will get longer ofc
base64 has 64
Is Base64Coder a different class you have
Really?
base64 strings can store data in less space
the byte[] will get longer
But if i need to grab the values from these itemstacks
deserialize them like on player join or whatever
an itemstack doesnt rly take up much space
So make like a map of player to itemstack array?
servers have tens of thousands of itemstacks loaded when the server is running
and change it on join and any other changes that need to be made
what exactly are u making?
i just need to keep track of the spawners a player puts into or takes out of a gui
the spawners also have nbt saved
ohh
through persistentdata
nbt data is saved this way
so ur fine
also
you can literally store the ItemStack[]
load it on join, save on leave
any changes when player are online can be made to the array
i forget why i didnt save the itemstacks
i think it was just because i needed the data in the itemstack more than i need it itself
should i just grab the nbt value whenever i need it?
is the gui some sort of spawner storage?
yea
but it generates xp
over time
by storing the last time it generated xp
and doing the math on inventory open
that's fine
alterantively, u can create a data class that stores the spawner type, last use, whatever
wich is what i have now
and u read the data array and generate spawners
it shouldnt be
i feel like it can be much better
it's easier to just save the spawners tho
these are essentially serialize and deserialize
private ItemStack resetItem(ItemStack item) {
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
ItemStack items = new SpawnerFactory(plugin,
EntityType.valueOf(itemData.get(plugin.ENTITY_TYPE_KEY, PersistentDataType.STRING)),
itemData.get(plugin.MULTIPLIER_KEY, PersistentDataType.INTEGER)
, itemData.get(plugin.OWNER_KEY, PersistentDataType.STRING),
itemData.get(plugin.XP_KEY, PersistentDataType.INTEGER),
itemData.get(plugin.LAST_GEN_KEY, PersistentDataType.LONG)
).getSpawner();
return items;
}
private List<ItemClass> getItemClassList(List<ItemStack> items) {
List<ItemClass> itemClassList = new ArrayList<>();
for (ItemStack i : items) {
PersistentDataContainer itemData = i.getItemMeta().getPersistentDataContainer();
itemClassList.add(new ItemClass()
.setCreatorName(itemData.get(plugin.OWNER_KEY, PersistentDataType.STRING))
.setEntityType(itemData.get(plugin.ENTITY_TYPE_KEY, PersistentDataType.STRING))
.setMined(itemData.get(plugin.MINED_KEY, PersistentDataType.BYTE) == 1 ? true : false)
.setMultiplier(itemData.get(plugin.MULTIPLIER_KEY, PersistentDataType.INTEGER))
.setXp(itemData.get(plugin.XP_KEY, PersistentDataType.INTEGER))
.setLastGen(itemData.get(plugin.LAST_GEN_KEY, PersistentDataType.LONG)));
}
return itemClassList;
}
Dear god
alr
cuz spawner type etc will be saved with that
alr
You can save ItemStacks in config
Alternatively I have a library that provides methods to serialize and deserialize items
nbt get's converted to base64 and yml files just scream open me and edit
Hence
ppl are generally stupid
^^
Btw are you sure about that? Because i have something like a 25% overhead in my head.
And the encoded String will get bigger (when the underlying data size increases)
think the unencoded strings are shorter
a serialized object is WAY smaller than a Base64 encoded one
as you can see the black line
that is current Direction in which the ship should be facing
but it doesn't match
any ideas for better working code?
public static Vector fromRot(float yaw) {
return new Vector(Math.sin(yaw), 0, Math.cos(yaw));
}
just read more on it yeah it seems to remove convenrt 8bit characters to 6bit so that's a 33% increase in text length
ig i was wrong
i thought it was a way to shrink the string
What is the yaw you put in?
blue line is direction
red line is Vector from the yaw
How do you translate the blocks ?
currently its on 0
talking about 2nd photo
In the first
32 ~
Add PI to the yaw and see if it helps
public static Vector fromRot(float yaw) {
return new Vector(Math.sin(yaw + Math.PI), 0, Math.cos(yaw + Math.PI));
}
Hm you might need a modulo in that case...
sin(x + pi) is - sin(x)
it alligned it self
After adding PI?
what abt when its 32
yep
Nice. Now see if it also fixed the other issue
ok now it unfixed it self
even in straight position
private static final TWO_PI = Math.PI * 2;
public static Vector fromRot(float yaw) {
return new Vector(Math.sin((yaw + Math.PI) % TWO_PI), 0, Math.cos((yaw + Math.PI) % TWO_PI));
}
Not sure if the java impl does this internally already but you should cap full rotations like that.
bfr I used when calling the method
`...(yaw+Math.PI)
and worked
sure thx
is yaw in degrees or radians?
might sound stupid but neither 😄
im addind/decressing 1 when holding A/D
are you trying to calculate teh Vector of rotation about Y for the Yaw?
you'd need to send a message with a click event + command run
beyond that the client does not notify the server about clicking chat messages
@eternal oxide
Totally useless. Cos and sin are 2pi periodic
or i dont get what u mean
PS: You can build a command -> method bridge by using generated tokens
Yea sponge has something like that build in
public static void createGizmo(Location at, Vector dir, Color color,float length){
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
Location curLoc = at.clone();
for (int i = 0; i <= length; i++) {
curLoc.getWorld().spawnParticle(Particle.REDSTONE, curLoc, 5, new Particle.DustOptions(Color.fromRGB(r, g, b), 1));
curLoc.add(dir);
}
}
public static void createGizmo(Player at, Vector dir, Color color, float length){
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
Location curLoc = at.getLocation();
for (int i = 0; i <= length; i++) {
at.spawnParticle(Particle.REDSTONE, curLoc, 5, new Particle.DustOptions(Color.fromRGB(r, g, b), 1));
curLoc.add(dir);
}
}
feel free to use this
hi,
how to set operation for itemstack on NBTTagCompound ?
for example = Head - Chest and more ..
NBTTagCompound damage = new NBTTagCompound();
damage.set("AttributeName", new NBTTagString("generic.attackDamage"));
damage.set("Name", new NBTTagString("generic.attackDamage"));
damage.set("Amount", new NBTTagInt(10 * 10));
damage.set("Operation", new NBTTagInt(0));
damage.set("UUIDLeast", new NBTTagInt(894654));
damage.set("UUIDMost", new NBTTagInt(2872));
modifiers.add(damage);
just be carefull
it might lag out the server
i actually meant the vector
does the API not have attribute API ?
Use the attribute system from spigot and store custom data in the PDC of the ItemStack. Miss me with that nms.
for item stacks
what's the most efficient way to store an array of UUIDs in a PDC
blue line is bassically *-1
I mean, byte[] ?
Version is 1.8.8

I'm looking at the NBT data for a horse and idk wth this is
Memory or CPU?
wdym
blue line is -ve red line?
oh memory
Well then go dig in old forum posts from half a decade ago. Support for that version was dropped years ago
and nobody plays it anyways.
thanks
yeah
its little complicated method but it just calculates wrongly location and sets direction that is -1
Then a long[] by splitting the UUID in lsb and msb
right PDC has long[] 
i'm confused weren't you trying to get the lines to point the same way?
A bit more info on that.
UUID is in essence just a 128 bit number. This means you can split it
in two 64 bit longs.
point same direction as the ship does
?stash
so this is fine?
how do you split a UUID and what is lsb and msb lmao
well blue is indeed -1 of red
but it doesn't point onto the front part ( dont know the name rn ) of the ship
Rotating Vectors
lsb = least significant bits
msb = most significant bits
Ill show you an example
also can i store nested arrays in a PDC because i need to store multiple UUIDS
new long[] { uuid.getMostSignificantBytes(), uuid.getLeastSignificantBytes() }
i think its best if i write my own persistentdatatype right
or use alex' lib
just zero pitch
also how am i supposed to do this
public class UUIDListTagType implements PersistentDataType<long[][], ArrayList<UUID>> {
@Override
public Class<long[][]> getPrimitiveType() {
return long[][].class;
}
@Override
public Class<ArrayList<UUID>> getComplexType() {
...
}
what am i supposed to put for the getComplexType body
public static long[] toPrimitive(UUID... uuids) {
long[] primitives = new long[uuids.length * 2];
for (int index = 0; index < uuids.length; index++) {
long msb = uuids[index].getMostSignificantBits();
long lsb = uuids[index].getLeastSignificantBits();
primitives[index * 2] = msb;
primitives[index * 2 + 1] = lsb;
}
return primitives;
}
public static UUID[] fromPrimitive(long[] primitives) {
Preconditions.checkArgument(primitives.length % 2 == 0);
UUID[] uuids = new UUID[primitives.length / 2];
for (int index = 0; index < uuids.length; index++) {
uuids[index] = new UUID(primitives[index * 2], primitives[index * 2 + 1]);
}
return uuids;
}
This is more the solution than an example... anyways. Consider yourself fed 
damn thanks
dw i'll study it
i hate copying code that i dont understand
?paste
wrong ping
https://paste.md-5.net/ridefelapu.java was the intended
Interesting. I would assume that using a byte[] is less efficient as pretty much every machine nowadays uses a word
length of 64 anyways.
probably
why is the syntax highlighting gone
Not that those microseconds would matter
but not forever. 64 will be redundant
oh on that topic
is it faster to do a for loop iterating by one and copying & bit shifting the variable to the left by 9, or to do a for loop which adds 512 per iteration
byte[] also just looks worse in game
like, you do crab on the /data command with it xD
thanks
would it be possible to use an ArrayList<UUID> instead of UUID[] though?
or does this not support it
obviouly
Sure
You cna pass in any way you want. Just rewrite it
alright
^
Show us your code.
If the compiler sees something that can be optimized then it will optimize.
multiplying should be faster than bitshifting
Hm?
im planning to check one block at input coordinates per mca. Also isnt bit shifting invented to literally make division and multiplication by 2 faster?
just got one question
what do i put here
yeah
bit shifting always faster
Im just thinking about the last ALU i assembled and the multiplication was hella expensive.
But it was super primitive.
Just ArrayList.class
its a List.class
i tried that already
Well cast it also perhaps
function return type is an arraylist class though
actually you can't parameterise teh class
i thought this was valid syntax :c
so i can't use ArrayLists at all?

One way would be with a type token
no but SomeClass.<Something>.method() is
But that’s smelly
ye thats why i thought
Class.class is a singleton so not able to pass types to type params (since there are none)
still not
SomeClass.<Type>method()
oh ye mb
grr
soo should i resort back to UUID[] instead then
Oh mb
valhalla wen
tho I think even with specific generics the class type won't support that
aaaaa
that looks cursed
also
@SupressWarnings("unchecked") ehhhe
Alternatively
Class<ArrayList<UUID>> dodo = (Class<ArrayList<UUID>>)(Type)ArrayList.class; maybe
Why the hustle? Just use an array.
so i dont have to manually convert it to an arraylist every time
You can convert a List to an Array by simply calling toArray
😳 ElgarL once told me to put 'java' before everything i wanted to know
This is accepted but it does bitch about a blind cast
ye
do you guys use protected for exposing final fields for subclasses
yes
depends
inheritance is kinda cringe
🙏
composite your way through
i feel like exposing protected field code smells
i cant get rid of this feeling
but sometimes i need some kind of field
well dovidas, I try to keep the coupling between a super and sub class minimal as the relation between the two classes is already extremely coupled
How? Thats literally what protected was invented for.
What really smells is the friend keyword... (C++)
sometimes i have complete implementation in base class but i need to further extend it in subclasses
friendly class
pardon?
or fun
I mean you have a set of design patterns dovidas
like proxy, adapter, delegate, chain of responsibility and also functional interfaces with hot sugar syntax
idk why it needs to exist
i dont want to expose the field further than to subclass
do you even need to expose the field?
I dont want to even expose its existance to end user
it might be enough with getters and setters
man i really wish java had built-in getters and setters
records
like python's @property and .setter
records or lombok
lombok -> delombok -> boom you have setters
lol
what is lombok
annotation processing lib
a hot pile of steaming shit
ill look into it

but it's still just a rough bandaid
i love how lombok is reduced to "getters and setters"
kinda true
Someone still needs to explain their lombok hate to me.
All ive gotten so far was "its bad because i dont understand it properly. Too complicated"
Ive had a bad experience with it
i hate it because it hides stuff, which some do not like
its just a bandaid to cover up java's flaws
like source and decompiled code mismatch
and then back in the days you could get some wizard-like stacktraces
but through out the years its a pretty solid java boilerplate reducer library
It has more implicit declarations.
Everyone that worked with enterprise java know what "hiding stuff" really looks like.
I just find it meaningless as we do have code generation keybinds etc in ides
and like the entire "when code isnt written by you, but inferred the code is hard to maintain"-argument is kinda bullshit
lombok has become a preference I believe
What does the itemflag Hide_Attributes do, becuase on the docs it says hides damage but durability still shows?
Im not sure about complicated, its pretty straight forward imho. But it just seems like such a stupid efficiency thing to write @Getter than just start typing get and intellij will autofill it. and also the names that it gives the methods dont always sound very "good english"
attack, speed, etc.
I just find working with lombok way faster than using the bindings of my ide,
Attack Damage +7
mye hence preference Id say
that kind of stuff
Ohhh..
well
I find it fine to use
but for public libs still a bit no for me
since not everyone is familiar with it
Do you know if its possible to stop it showing the currently durability when the player shows advanced tooltips
Yeah its fine™️ but i would never choose to use it
so it would ultimately increase complexity of said library
that's clientside
its impossible
Not possible
Not even with NMS?
no
Nope. its all client side. Are you concerned about them finding out the exact damage values or do you just want to hide them?
Does unbreakable still show durabilities?
only items which do not have durability do not show that
The problem with this is that they then also dont have the bar that indicates the damage.
values are hardcoded into client
while its durability is simulated in server and sent back to client
Yea but if you had custom durability
Because i was thinking i could change the lore when it takes damage, and send packets?
durability isn't part of the lore 😅
No i know
Durability meter is not part of lore sadly
its a separate thing
But its one way i could visualise it if i set it as unbreakable
Dont do it like that. Let the custom durability live in the PDC and
modify outgoing packets to the player that convert whatever is stored in the PDC to the items lore.
This way you can change your display design without having to update any ItemStacks in the game.
PDC?
Delegate design pattern wouldnt work for me, since i extend the class, its not as if I wrap some kind of class
so guys using protected for subclasses is fine
its fine
but keep it minimal
since it becomes hard to maintain through out a nested sub class relation
personally if its a read only field Id make a getter/accessor and keep that thing protected, just to make the design a bit more robust
are primitive ints initialized to zero by default?
yes
primitives can not be null
if they initialized to zero by default why you can use operators like i++ without initializing it to zero first
i mean if values like int i; have predefined values like boolean has value false by default
well no. you can;t use an uninitialized primitive
They only have as fields
should i do this to prevent potential hackers?
i mean the ones who aint trying to hide it
does optifine count as forge?
just clean optifine
The amount of people actually running forge to run their hack clients might be rather small
and idk what isForgeUser is
its on bungeecord
ah
that's useless
I have doubts this will be effective yea
any good hack client will bypass that
even if they for some reason use forge
you can hide the client branding with like 2 lines of code
and also people could just use fabric instead of forge or whatever
but the dumb ones will still be catched or at least delayed to hack
no
You would also block any other forge user
if you only want vanilla clients, then yea
go for it
but, most if not all of those users will not be hacking
its for a building championship, to prevent printer as much as possible
printer?
Well both fabric and forge announce themselves don't they ?
so if you wanna clap all mods, sure
many clients install forge so they can have a map
i just need to prevent schematica
if they run forge you can query what mods they have
oof
eeh fuck it. lets allow players to connect with forge. our eyes are good enough to detect players who cheat
Why not use an heuristic anti cheat?
isnt that machine learning?
we just need to detect schematica autobuild. thats it
just check the modlist ig
wont stop everyone tho since they can just change the mod name
not everyone is going to go through that
ig i can make modlist list
and then if player mods contain something
i throw them out?
ye
also should i give them a reason why they got kicked out?
or stop them from building
tell them that they are using schematica
which is not allowed
litematica's fast place feature can also easily be detected by checking the clicked blockface in blockplaceevent
if it's always BlockFace.SELF then they have it enabled
an ac is prolly made for that already. i dont wanna reinvent the wheel
i thought u just wanted to stop 1 thing tho
anticheats arent lightweight
and it isnt very hard to implement
a map that maps uuid to integer to keep count
or maybe 2 so u can get a percentage of BlockFace.SELF placements
eh fudge it. im allowing anyone to join.
even cheaters. they will just get detected sooner or later by my laser eyes
Randomly ban 2% of your playerbase to scare the cheaters away.
ima ban my alt on purpose
if (ThreadlocalRandom.current().nextInt(100) < 50) user.ban() hehe
make fake bans 😄
and make fancy announcements like "our anticheat has banned 435 cheaters this week!"
excelent idea
nah its for like a building championship
xX_puxxySlayer69_Xx got banned for slaying some
which might get like 100 participants
im sorry i dont understand could you finish that sentence
some inferior opponents
1am is peak productivity time
what are animatronics?
fnaf
it was 2am yesterday
Thats when you start the really big projects
thats usually when i start falling asleep in front of my pc
idk why
Apply as hypixel anticheat dev now
theres no way they gonna refuse me now right
i mean you'd be doing the same stuff they already do
yep
they've had that anticheat role open for around a year now I think lol
don't seem to require much for a so called machine learning anticheat
of the final jar?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>${project.basedir}/../out/</outputDirectory>
</configuration>
</plugin>
i use this
bruh i wanna add something simple to the plugin before going to sleep. what should i add?
or plugins, since i have 1 for the game server, 1 for lobby and 1 for proxy 🤣
make creepers explode cows everywhere!
Hey I got a question. I started to use remapped-mojang for package related things. But I found the procolib. So I am kinda confused which of both is better, or if it's recommended to use them together? I am pretty new in that kind of topic so I wanted to ask for an opinion
protocol lib is version independent whereas nms is
but sending packets with protocol lib is a pain
it's really nice to listen to incoming packets tho
so I would still use protocolib i guess?
depends on ur use
tbh isnt that kind of a weird question. protocollib will help you with packets. but u can do plenty other stuff with nms. which you could need remapped for no?
well I need to send packets and listen to some
basically something about npcs
I used remapped right now
everything worked fine till finding a way to listen to packages
that's why I found protocolib which seems like everyone uses
use protocollib to listen to packets
well if ur only needing to interact with packets i'd suggest protocollib yea
that's why I was confused if I can combine them, or need to use one of them
alright thank you guys
is there an event for when a player jumps on a horse
You mean if the player mounts a horse?
declaration: package: org.bukkit.event.entity, class: HorseJumpEvent
can i cancel it?
will it even be fired still?
i'll see what happens
if its wonky i can just like forcibly teleport the horse back down
why dont u want the horse jumping
u can give it a jump potion of max amplifier to disable jumping
and remove when u dont want it to jump
i remember trying to do that before on a player
not sure if it'll work tho since horses are contrllable
and?
yeah it works on player
it was buggy though, sometimes if the player took damage they'd go flying up into outer space
that's not supposed to happen
well it does happen
Thanks everyone i solved the issue with
Code (Java):
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 250));
but the problem was when i quit and rejoin i could jump so i remove the potion then give the potion and that worked.
250 is the amplifier
another problem though is if the horse already has a genuine jump boost potion affect on
wait cant i use an attribute modifier
cache the time remaining, and the effect and the time when u remove it and u can add the effect back when u remove the permanant jump boost
messy but may work
still dont know if player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 250)); works on horses so u can start by testing that
could maybe also directly edit the horses jump power
yeah thats what i was thinking
Whatever was just there: I tried base64 decoding it.
뮺뮺뮺뮺뮺뮺뮺뮺뮺뮺뮺뮺yʞu^w;@@]w<P zzܮ
lul
Uhm about protocolib again. I will need it on my server for my plugin using it to run properly correct? Is there a way with maven to shade the plugin into mine, so protocolib doesn't need to be on the server?
i was cleaning my keyboard
yes
128 should be enough
tbh idk if this is a public plugin but 90% of servers have protocollib installed anyways
there's alternative made by protocollib team called tinyprotocol which could be shaded
but by using that you will need to manage NMS dependant code by yourself
more of a java question but should i be using Random#nextDouble or Math#random
id use TheadLocalRandom
I use ThreadLocalRandom
alright
i would use Random only in the case I would like to use seeding
but that's only the preference by using ThreadLocalRandom you dont need to maintain random classes by yourself
but it doesnt support seeding
also randomness is thread dependant
its just a matter of architectural design
yeah
non reproducible
altho hopefully any modern java code depends on RandomGenerator rather, in which the impl can be substituted at will
so i have an event handler which will randomly stop the player from leashing a horse:
https://mystb.in/ControversyProveFame.csharp
the problem is that if the leash does get cancelled, the player gets automatically mounted on the horse
how would i prevent that
entitymount event?
yeah but like
i dont want to stop all players from mounting horses
the main this is how do i determine if the player's leash got cancelled or not
so check if they are clicking on a horse
then check if they have a leash
in their main hand
if so -> do random
yea
and ditch the playerleashentityevent?
yes
k lemme try
whats the difference between PlayerInteractAtEntityEvent and PlayerInteractEntityEvent
what should i listen to
use PlayerInteractAtEntityEvent
ok
declaration: package: org.bukkit.inventory, interface: PlayerInventory
oh getItem(slot) is a thing
Ye
@tall dragon ok your solution worked, thanks
👍
i dont see how this prevents the horse mounting though
the leash event is bassically a fancy PlayerInteractEntityEvent with a leash check xd
so are all damage events
yep
i found it
lol
ENTITY_VILLAGER_NO
ig
thanks
LOL fun fact
its saying mew mew repeatedly
in korean
also I'm still working on finding the damn pathfinding algorithm
if anyone could help that'd be great lmao
isnt a villager saying no the same thing as a green one
dont think so
i assume green one means the villager bein happy
i should make an app that will help me learn russian
more interactability
with ui's
this would be great for help info custom gui's with resource packs
oh ye
also i separated NMS from bukkit api code so there are nms interfaces rn, in order to make this more platform independant
enough work for today
could be really epic
im assuming that switch's intended. What about using the first trade in the UI to switch between different villagers?
like
on clikc
Interesting idea. Matter of fact im gonna steal this idea and think about using this to display the quests for my current project.
that progress bar switching is just dummy code that i've placed to test on
you can do whatever you want
there's InventoryActionContext interface which invoke method returns
so you can execute whatever you want
including switching inventories
is that nms or api btw? i dont recall how much you can manipulate guis without diving into nms
mix of both
ah
NMS is mostly not needed
but in order to preserve items in the trading slots (which do not stay in bukkit merchant implementation)
you need to implement custom NMS menu class
but for example Merchant without villager entity in bukkit api can not hold levels
so you need to do some nms to bypass
i see. Interesting, though i doubt it'll come up for me
What im working on atm is interactions in the world
like checking blocks powers of two apart if they're the same
long story
hence my question about bit shifts earlier
if i can make it fast without much effort
im going to make it fast
oh on that note
would it be faster to bit shift i and bit shift it back, or to copy it into another variable and bit shift that variable?
im not sure how assignment or variable initialization compares to bit shifting in speed
Are you doing millions of those instuctions every minute?
in this specific case no
its possible that it'll come up en masse in a different one
particle stuff
allocating space for a new variable is for sure more expensive than using an exisiting one and doing a shift on it
and if i just assign it in the loop? allocate it before the loop?
im aware that doing that inside the loop is a dumb idea - initialization - but im not sure about assignment
i think its slower
but i dont know for sure
also i cant test it right now
I am trying to interact with this npc right now, and it's only working on the shadowed position on the legs (cause it would be the normal location if the pose was standing). Can I make it somehow, so I can interact with the whole laying body?
also i'd take a guess and say that accessing unloaded chunks takes up a few orders of magnitude more processing time than bit shifting or variable assignment
show hitboxes. I'd recon you can't interact cuz the hitbox is still up
yes. its like adding a teaspoon of salt into a lake and worrying about converting it into an ocean.
hah fair enough
im mostly worried because ill start working with a research institute in the future. I'd rather have my code optimized there, especially considering how much modern research relies on a buttload of math being done
modern neural networks got what
like
a few billion nodes? and they all run math
Youll probably be using something more low level then
And better hardware
I'll most likely be forced to use c or c++ anyways
and then ill pull out my hair because neither of those has a garbage collector
to be honest
i really dont understand how people think using python for data science is a good idea
Neuronal networking is done on GPUs because the workload relies on strong parallelisation.
And all of that is abstracted away from you. Data science is mainly done in Python for whatever reason.
what i dont get is
["", "&fPlace the block to", "&fprotect an area", ""] this can parsed with YamlConfiguration#StringList() ?
yes
It seems that throw an excpetion
python is interpreted not compiled. So why do people use something three to four orders of magnitude slower than a compiled language for something that relies so heavily on speed???
Yes. When in doubt use an only yml syntax checker
lazy idiots
LOl what a nice staff
python isnt necessarily that bad
especially when the modules you use are natively written
oh right
like numpy
it has its uses, like sorting and stuff
i forgot
Because all the libraries use heavily optimized low-level implementations in C
Like Pandas, Numpy and Torch
anyone got an idea?
yee
huh for some reason i recall that name
every lang is bad if you dont give the correct usage
theres some languages you cant use correctly
That the only thing i have learned around my own experience
piet, chief, shakespeare...
yeah
Whitespace, Brainfuck, Moo
Cobol for example
but any normal language usually has a use case
Another esoteric language: Javascript
I dont know how still exists cobol devs
banks, insurance companies, airlines, ...
Because there is a demand
theres that one language you cant prove or disprove to be turing complete cuz it was made on a hex grid for some reason too
they're soon to be relinquished
Legacy machines needs to maintained thats why they still use it
to be fair the military runs win xp cuz their software is so old
most systems running on cobol are planning or are getting re written
snowflake servers are an interesting thing
no, xp is more barebones and thus more easy to maintain and ensure security
my country's military probably doesn't even have computers lol
No working ones at least
to be fair i always thought that xp was kind of 'meh', it looks so... i dunno how to say it... lazy?
win seven wasnt much better tho
yeah idk why they dont just manufacture hardware to their needs
they're the damn government
yeah ursula learnt "how to maintain a military" by playing minesweeper
see thats the issue
governments never manage to make progress on semi important things
no
dont think so. Arent destructors doing what the GC already does in java?