#help-development

1 messages Β· Page 2054 of 1

desert musk
#

Have the jar now, using IntelliJ Ide, what do I do with the jar if you don't mind?

#

do i replace it as my SDK?

hasty prawn
#

Add it as a dependency

silent timber
#

What's the event for opening an enderchest?

pliant oyster
silent timber
#

Thanks

#

Just compare inventory type?

pliant oyster
#

check if the inventory is a enderchest

#

yeah

desert musk
#

the thing is i'm already using a jar

#

it just doesn't have that class

hasty prawn
#

You're definitely doing it wrong then

desert musk
#

added it as a module, added an artifact

#

that's all i did

tawny otter
#

I cant seem to use addPotionEffect on an Entity, is there a alternative to it that works for Entities?

vague oracle
#

What version are you on?

tawny otter
#

Spigot API 1.18.1-R0.1-SNAPSHOT

vague oracle
#

Nvm I thought you could as well

hasty prawn
#

What are you trying to do

vague oracle
#

I think you need to cast it to a living entity

tawny otter
#

using the EntityDamageByEntityEvent to apply a potion effect to the victim if the attacker is on a list

arctic moth
#

these are some nice cliffs (if you ignore the giant block of water)

#

dont even ask what i did with the water...

hasty prawn
#

Check and cast to that

hasty prawn
arctic moth
#

bruh why my ttroll emoji

#

basically i made it so every flowing water turns into a source

#

ram be like:

#

btw State.getData() isnt deprecated but returns materialdata

#

im guessing they forgor πŸ’€

#

anyways how do you check if grass is snowyt

hasty prawn
#

isSnowy

arctic moth
#

block, blockdata, etc.?

hasty prawn
#

BlockData I think

arctic moth
#

nope

#

not in block either

hasty prawn
#

It's in Snowable

#

Which extends BlockData

#

So you have to cast

desert musk
#

Ok how could i be doing this wrong

#

the API has worked perfectly for me until now

arctic moth
desert musk
#

i installed a new craftbukkit jar and it's literally the same

arctic moth
#

and Water could have the Levelable stuff

desert musk
#

I still cannot extend from EntityZombie or any other of its type

vague oracle
#

If you built it properly with build tools all you have to do is add it as a dependency in your pom.xml if you are using maven

#

or gradle.something if you are using gradle

desert musk
#

shit

#

i thought that was the case but i couldnt find any pom.xml stuff for craftbukkit

#

thank you though

#

yeah how am i supposed to add it to pom?

#

i don't understand

vague oracle
#

you can add it to a folder in your project and use

#

<dependency>
<artifactId>..</artifactId>
<groupId>..</groupId>
<scope>system</scope>
<systemPath>${basedir}/lib/dependency.jar</systemPath>
</dependency>

desert musk
#

tysm

tender shard
#

never do that

desert musk
#

o

desert musk
#

aight πŸ™

#

ok this is more what i was expecting

tender shard
vague oracle
#

didn't know that, although when I used to use it I was very lazy lol

tender shard
#

yes I also did it like that 1-2 years ago

#

but maven throws a ton of warnings if you do it like that

#

and every of those warnings say "yo this works now but pls don't do it, future versions of maven won't allow this anymore"

#

so better just install the .jar to the repo πŸ™‚

#

it's just one command

desert musk
#

1.18.2

tender shard
#

okay then check out the first link of my last message pls

desert musk
#

alright

tender shard
#

it's very important to use "--remapped" when running BuildTools

desert musk
#

hmm

#

idk if i did that

#

should i build it again

tender shard
#

yes pls

desert musk
#

ok

#

[WARNING] The requested profile "remapped" could not be activated because it does not exist.

#

?

tender shard
#

is this a message from buildtools?

desert musk
#

yeah

tender shard
#

delete your whole buildtools folder

#

then redownload the latest buildtools

desert musk
#

ok

tender shard
#

?bt

undone axleBOT
desert musk
#

alright it seems to be doing its thing

tender shard
#

that's good πŸ˜„

#

but, you have to keep this in mind: all the names have changed

desert musk
#

names of what?

tender shard
#

e.g. it's not called EntityZombie anymore

#

it's now just Zombie

desert musk
#

ah

#

ok

tender shard
#

net.minecraft.world.entity.monster.Zombie

desert musk
#

finna blow my retina out

#

ok i'll keep that in mind

tender shard
hasty prawn
# tender shard

Can I make a blog post on your site about how to enable dark theme and then you follow it? πŸ˜„

arctic moth
tender shard
tender shard
#

which is "the sun"

#

try to read something in dark mode when the sun is shining onto your screen 6 hours a day πŸ˜›

arctic moth
#

when in light mode

tender shard
#

and everyone who gets blinded by my screenshots should really see a doctor

#

but it's better to be mocked for using light theme than people yelling at me for being gay or drunk all the time or sth lol

#

but yeah I have a legitimate reason for using light mode, just check this:

#

good luck reading something there in dark mode πŸ˜›

hasty prawn
#

Why is your monitor so dark monkaS

tender shard
#

it's not dark, the surrounding is just very bright

hasty prawn
#

Atleast you have Discord dark theme

tender shard
#

sometimes

desert musk
tender shard
#

my discord is bright again since 2 days lol

desert musk
desert musk
#

uh yeah

#

<version>1.2.2</version>

tender shard
#

did you click the "maven reload" button?

desert musk
#

uhhh

#

no i kinda just copypasted everything from the website into my thing

#

oh shit ok that worked nvm

#

awesome

tender shard
desert musk
#

lol

#

thanks

tender shard
#

np

desert musk
#

yes!!

#

finally works

#

πŸ™ tyty

silent timber
#

How would I go about saving data in this format using FileConfiguration?

<uuid>:
  <another uuid>,
  <yet another uuid>,
  <and another uuid>
<uuid>:
  <another uuid>
desert musk
#

oo

#

that's an interesting problem

#

unless it's not

tender shard
#

you can't have two keys both being called "uuid"

silent timber
#

Would something like this work?

players:
  <a player uuid>:
    <another uuid>,
    <yet another uuid>,
    <and another uuid>
  <another player uuid>:
    <another uuid>
tender shard
#

yes, sure

desert musk
#

right that's what i interpreted it as

silent timber
#

Yeah

tender shard
#

YamlConfiguration yaml = new YamlCOnfiguration();
yaml.set("players." + uuid1,yourListOfUUIDsForFirstPlayer);

#

yaml.set("players." + uuid2,yourListOfUUIDsForSecondPlayer);

#

then save it to a file

proud forum
#

i wanna learn how to make minecraft plugins, what would be my best resource for learning how?

tender shard
silent timber
#

and then reading it, how would i get the list of uuids back into a list?

tender shard
#

for example this (one second, gotta type it quickly)

#

imagine you have this:

#
players:
  firstplayer:
    - aa00000151251258612581528615
    - aaaa725115723651976135976153

then it's actually a List<String>. but you can just use a stream->map to turn it into a list of UUID objects:

List<UUID> uuids = getConfig().getStringList("players.firstplayer").stream().map(UUID::fromString).collect(Collectors.toList());
silent timber
#

Great, thanks

tender shard
#

if you never used streams before, look for a tutorial about how they work

#

streams are awesome

#

oh no the chocolate guy is typing D:

#

did I say sth wrong

#

lol

worldly ingot
#

Nah you're fine lol

tender shard
#

baeldung is such a weird site

#

50% of their articles are good and the other 50% are garbage

lavish hemlock
#

I believe they're community-contributed

tender shard
#

you sure?

#

some of their articles exactly explain stuff while others are just "you can do this or that" but they don't explain why or how

tidal hollow
#

Can somebody help me? I want to do that during the storm there is a bossbar that tells you the time that the storm has left
If it's not too much trouble to pass the code xD...

tender shard
#

e.g. their "java 8 streams" article is worthless unless you already know what streams are and if you know that, you dont need the article anyway

tender shard
#
  1. Get the world's clear weather duration
worldly ingot
#

Yeah. baeldung's got some good resources most of the time

#

They cover a pretty hefty variety of stuff

tender shard
#

then create a bossbar and update it every tick/second/whatever until the wheather is clear again

tender shard
#

this doesn't help anyone IMHO unless they know streams anyway

#

this explains it way better imho

#

for example, I didn't know for 2 years that streams are actually "lazy", e.g. if you do "map" and findFirst, it only maps one thing if the others aren't needed

worldly ingot
#

Doesn't seem terrible. The first part of that is mostly bleh, but the latter half does touch on a good pipeline for streams and how to use them with decent performance

tender shard
warm light
#

Can I get help about GriefPreventionAPI here?πŸ‘€

#

how to get claim details of a player?
like claimed block, remain claim block, total claim, trusted player, claim date etc

vocal cloud
#

Only if someone here has used it

#

Cause you'd be best off reading the wiki on it

warm light
#

They only have a mvn dependency on there API wiki and discord channel look like dead

desert musk
#

moving my entire workspace over to my laptop now, is it true that you have to use OpenJDK17 and not OpenJDK18?

young knoll
#

17 is LTS

#

And it’s what minecraft uses

amber marsh
#

quick q. does this sound right?

moveCard.teleport(targetPointer.getLocation());

desert musk
young knoll
#

Long term support

desert musk
#

oh i see

silent timber
# tender shard then save it to a file

Should it be looking like this? (please ping me when responding, am going to sleep shortly :P)

players:
  f7c77d99-9f15-4a66-a87d-c4a51ef30d19:
  - !!java.util.UUID 'af74a02d-19cb-445b-b07f-6866a861f783'
worldly ingot
#

Not quite. Call .toString() on the UUID when you save it

#

Right now you're doing set(String, UUID) but that's going to serialize it as a UUID type. Though you can just save it in string form

#

(please ping me when responding, am going to sleep shortly :P)
@silent timber

silent timber
#

Thank you lol

worldly ingot
#

thumbsupparrot After that you're good to go

terse mason
#

command /resetmines: permission: mine.reset permission message: You need VIP to use this trigger: set {_waited} difference between {resetmines.%player%.lastused} and now if {_waited} is less than 20 minutes: message "You have to wait %difference between 20 minutes and {waited}% before you can use this command again!" stop execute console command "/mrl reset diamond" execute console command "/mrl reset wood" execute console command "/mrl reset obsidian" execute console command "/mrl reset iron" execute console command "/mrl reset amethyst" execute console command "/mrl reset ancient_debris" execute console command "/mrl reset NETHERITE" set {resetmines.%player%.lastused} to now
uhh can someone tell me why this isn't working
i am trying to make a command that resets all mines with 20 minute cooldown but it has 2 errors

smoky oak
#

if you spawn two Particle.DustTransition at the same location they appear as one with their colors merged.
The more you know...

nimble torrent
#
    public void onPlayerHarvestBlock(PlayerHarvestBlockEvent event) {
        Player player = event.getPlayer();
        Block block = event.getHarvestedBlock();

        if (block.getType().equals("diamond_ore")) {
            player.sendMessage("mined diamondeeee");
        }
    }```

tthis doesnt do anything when a player harvests a block
smoky oak
#

bc youre equalling a enum with a string

#

if(block.getType() == Material.DIAMOND_ORE)

#

that checks it

terse mason
#

can u help me out with the command

smoky oak
#

that looks like its gonna take more than 30 seconds so no

#

i dont have much time atm

terse mason
#

i can tell u where are the errors

smoky oak
#

might be useful to see said error

#

just saying

terse mason
#

cant send image

smoky oak
#

copy it from the logs

terse mason
#

line 5 and line 6

smoky oak
#

knowing where it appears doesnt help

#

you usually need the stacktrace

terse mason
#

line 5
'set {_waited} difference between {resetmines.%player%.lastused} and now' is not an entry (like 'name : value')

#

line 6
Unexpected entry 'if {_waited} is less than 20 minutes:'. Check whether it's spelled correctly or remove it.

#

here

amber marsh
#

what are alternatives to .teleport?

visual tide
#

not a lot

#

i mean

#

you can give someone the exact velocity to yeeeett them over to the location you want them at

eternal night
#

Lol

visual tide
#

or spawn a pig with a pathfindergoal to push the player to the desired location

visual tide
amber marsh
#

.teleport is not working for me, and nor is any workaround do to different issues

eternal night
#

Probably best to figure out why .teleport isn't working for you

#

It is rather unlikely that the logic itself is broken

visual tide
#

maybe your teleport is in an if statement that isnt actually gonna ever be true

amber marsh
#

nope, I teated for that

visual tide
#

is it a cmd, eventhander or smth else?

eternal night
#

Any exceptions? Share code if possible

visual tide
#

because if it's an event, did you register it

#

?didyouregistertheeventhandler

#

@undone axle command missing pls fix

amber marsh
#
        {
            ArmorStand moveCard = (ArmorStand) mainscript.GetTag(targets,mainscript.TagCard'Move);
            Location moveTo = new Location(targetPointer.getWorld(), targetPointer.getLocation().getX(), targetPointer.getLocation().getY(), targetPointer.getLocation().getZ() );
            moveCard.teleport(moveTo);
            mainscript.ConMessage("Moving " + moveCard.getCustomName());
        }```
#

this is a small example of my slow decent into maddness. notice the location moveto = new location {target pointer loctation }

#

its been 3 hours

waxen plinth
#

Is there a player riding the armor stand

amber marsh
#

I do get the "Moving cardname," telling me that this block IS run

#

yes

waxen plinth
#

Also why are your methods named in PascalCase

eternal night
#

Rip

waxen plinth
#

You can't teleport entities with passengers I believe

#

You gotta dismount, then teleport the entity, then teleport its passenger back to it and re-mount it

#

It's very annoying

#

But it's not ".teleport not working" and you should have been more specific

amber marsh
#

T_T its a stack of armor stands that is needed for thiiingggs!!!

waxen plinth
#

Then either kill them and respawn them where they are needed

#

Or do it the hard way with dismounting and remounting

waxen plinth
#

Huh

#

I dunno if you're tyring to be passive aggressive or what

#

I'm just saying that you should give as many details as possible when asking for help because if I hadn't asked about that then you wouldn't have specified it, and we wouldn't have been able to help you

glass mauve
#

Hi, I try to create a new Command with the CommandExecutor in Spigot for 1.18.1. I just created my first command and now I want to create a command with extra args. How can I cast a String Argument to a Material.X?

waxen plinth
#

Material.valueOf(String)

#

All enums have valueOf for that

eternal night
#

Material.matchMaterial might also work out well for you

waxen plinth
#

Careful though, because it throws an exception if a value is not matched rather than returning null

#

Yeah honestly that's probably a better idea

#

I always forget that method exists

glass mauve
#

and Material.getMaterial(String)?

waxen plinth
#

?jd

waxen plinth
#

I'm not sure how getMaterial differs from matchMaterial

#

I'm guessing matchMaterial is more what you want though

glass mauve
#

ok thanks πŸ˜„

waxen plinth
#

It seems like getMaterial might need to include minecraft: in the names

#

Not 100% clear though

glass mauve
#

yea I read the docs, getMaterial needs the precise name and matchMaterial will format b4 checking:
This is a match lookup; names will be stripped of the "minecraft:" namespace, converted to uppercase, then stripped of special characters in an attempt to format it like the enum.

amber marsh
#

Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),"tp @e[tag=" + mainscript.TagCardMove + "] " + targetPointer.getLocation().getX() + " " + targetPointer.getLocation().getY() + " " + targetPointer.getLocation().getZ());

#

that worked

waxen plinth
#

Interesting workaround

#

Not sure how advisable it is

primal crow
#

Im New Java Developer , How do I get the coordinates of a dead player?

opal juniper
#

well is this in a listener?

primal crow
#

yes

opal juniper
#

if you have the player reference you can just call getLocation

primal crow
#

no

#

with PlayerRespawnEvent

opal juniper
#

based on the fact that playerrespawnevent doesn’t implement cancelable, i’m not really sure - try getting the players location when the event is called and see where it is

#

otherwise you might need to have a death listener and save the locations

sharp flare
#

are there no ways of cancelling an armor equip on right click, tried interact event

quaint mantle
#

How do I find out the main class in which the Java Plugin extends?

low temple
#

thatll get their death location rather than their location where they spawn

quaint mantle
#

MainClass.getProvidingPlugin(MainClass.class);

quaint mantle
low temple
#

Are you trying to get the plugin instance?

quaint mantle
#

yes

low temple
#

if so do <MainPluginClass>.getPlugin(<MainPluginClass>.class)

#

replace <MainPluginClass> with the name of ur class

quaint mantle
low temple
#

Like u want it to autoupdate when u change ur class name?

#

why?

quaint mantle
#

I'm doing ChestGUI

#

Using lambda

low temple
#

ok show code im so lost as to why youd ever do this

quaint mantle
#

Okay

low temple
#

?paste

undone axleBOT
low temple
#

The name of ur plugin class shouldnt be dynamic

#

doesnt make sense for it to be

buoyant viper
#

not only should it not be, it couldnt be

#

unless u feel like doin a whole lot of bytecode hackery

proper notch
#

Why not just pass in OwnExperienceWorld in the constructor of the ChestGUI class? is that not possible in this case?

buoyant viper
#

?di

undone axleBOT
low temple
#

I guess u can just pass it into the constructor

quaint mantle
#
ChestGUI gui = new ChestGUI(6, Component.text("Test-gui"));
        
        gui.fillingEmptySlots(new ItemStack(Material.VINE));

        gui.setItem(1,1, new GUIButton(new ItemStack(Material.EXPERIENCE_BOTTLE), event -> {
            event.getWhoClicked().sendMessage("1");
        }));

        gui.setItem(2,2, new GUIButton(new ItemStack(Material.EXPERIENCE_BOTTLE), event -> {
            event.getWhoClicked().sendMessage("2");
        }));

        gui.open(p);
low temple
#

if for whatever god forsaken reason you need it to be dynamic, pass the plugin instance into the ChestGUI class constructor as a Plugin parameter

low temple
#

but changing the name is????????

buoyant viper
#

alternatively: Bukkit.getServer(), but people dont like that around here

low temple
#

thats for the server

#

he needs the plugin instance

buoyant viper
#

that is the sole reason hes getting the plugin anyway

low temple
#

doesnt make sense in any context

quaint mantle
low temple
#

then if ur using intellij make it into a live template if ur gonna reuse code

#

and make the name a parameter of the live template

#

but just name it Main?

#

why do u NEED it to be anything else

quaint mantle
#

There will be no 1 class with GUI

#

Is it possible to do this?

low temple
#

it is not possible to have a java class name dynamic

#

without it being extremely counter-intuitive

quaint mantle
#

Maybe the name of the class in which extends JavaPlugin?

low temple
#

Yeah you can’t change that

#

There is literally no reason for it to be dynamic

#

You haven’t explained an actual reason as to why you need this to be possible

quaint mantle
#

This is something like a GUI library

low temple
#

But why do you need it to be dynamic

#

It makes zero logical sense to make it dynamic

#

Also in a library you wouldn’t have a plug-in instance class in a library, also wouldn’t make sense

quaint mantle
#

I just need to make everything work when copying GUI classes to another project where the name of the main class is different

low temple
#

Ok so do what I said before, pass the plug-in instance into the ChestGUI class

#

Best way to do it

quaint mantle
#

It will not be convenient all the time

low temple
#

How…?

quaint mantle
#

Plugin plugin = OwnExperienceWorld.getPlugin(OwnExperienceWorld.class);
plugin.getServer().getPluginManager().registerEvents(this, plugin);

#

It works, but if I suddenly move this class to another project, it won't work

low temple
#

Yeah because u need to pass it as an parameter

#

Create a plugin parameter in ur default constructor and set the plugin variable to it

quaint mantle
#

How can I, for example, get the name of the class in which JavaPlugin is extended

low temple
#

Bro, you really shouldn’t need to

#

I’m telling you, pass the instance

#

There is zero reason why you would ever do that

#

You logically can’t without jumping through 70 different wacky programming hoops

quaint mantle
#

I just thought it was possible to get the name of the class in which JavaPlugin is extended.

#

Bukkit.getServer().getPlugin(String name);

low temple
#

Not really, not without passing the instance

#

And if you pass the instance there’s no reason to do it the way you suggested

#

Bro please, just pass the instance, it’s not more complicated

quaint mantle
#

Okay, thanks

buoyant viper
#

so what could be done actually is something like

#

in the constructor of ChestGUI, u add a param like Class<? extends JavaPlugin> pluginCls and then in the constructor method u do JavaPlugin ownerPl = JavaPlugin.getProvidingPlugin(pluginCls);

#

?jd

buoyant viper
#

that should let u still use it as more of an API rather than part of a specific plugin i think @quaint mantle, whatdya think @low temple ?

quaint mantle
#
Class<? extends JavaPlugin> pluginCls = null;

            Plugin plugin = JavaPlugin.getProvidingPlugin(pluginCls);
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
#

Right?

buoyant viper
#

no u put Class<? extends JavaPlugin> pluginCls in the constructor params

low temple
buoyant viper
#

not necessarily

low temple
#

Basically the same thing

buoyant viper
#

to pass the actual object vs the class

#

oh wait yeah u could do just JavaPlugin then

low temple
#

true but wouldnt it just make sense to just to JavaPlugin

buoyant viper
#

yeah bc then it avoids having to do a lookup every time u make a gui

low temple
#

unless you only need the class, even then you can get it from the object

buoyant viper
#

ur getting the object from the class in the end so if u could provide the object then u bypass a whole step

low temple
#

he just needs the plugin instance, the class is irrelevant since its used to get the plugin instance

buoyant viper
#

yeah

#

for convenience i think mine would win since u wouldnt need to worry about having the instance stored somewhere, could literally just do like new ChestGUI(other params, MainPluginClass.class), but for optimization (and probably sanity), ur idea is the way to go

quaint mantle
#

I wanted to get an instance without entering anything

low temple
#

But either way you need to pass something in and store it

low temple
quaint mantle
#

I understood. Thanks for the answers

low temple
#

Np man

sharp flare
#

any way of making this work for offhand

#

nvm it works on both hands, just making bad checks

sullen marlin
#

?

#

yeah

sharp flare
#

dumb I was checking mainhand only xD

summer scroll
undone axleBOT
sharp flare
#

I think this is not the right place to ask for that ig

drowsy ledge
#

I've been looking in the Spigot page, but I can't find where I can make a thread.

modern valley
#

I am getting this error

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "result" is null
    at org.bukkit.inventory.ShapedRecipe.<init>(ShapedRecipe.java:46) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at com.init.test.items.ItemManager.createWand(ItemManager.java:36) ~[Plugins.jar:?]
    at com.init.test.items.ItemManager.init(ItemManager.java:19) ~[Plugins.jar:?]
    at com.init.test.TestPlugin.onEnable(TestPlugin.java:16) ~[Plugins.jar:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:562) ~[paper-1.18.1.jar:git-Paper-216]
    at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:476) ~[paper-1.18.1.jar:git-Paper-216]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:736) ~[paper-1.18.1.jar:git-Paper-216]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:503) ~[paper-1.18.1.jar:git-Paper-216]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:313) ~[paper-1.18.1.jar:git-Paper-216]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1211) ~[paper-1.18.1.jar:git-Paper-216]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-216]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]

createWand() [it was getting long so used pastebin] https://paste.pythondiscord.com/otisosibuk

glossy venture
#

why in the fuck does it use org.bukkit.inventory.ItemStack for the implementation and not org.bukkit.craftbukkit.v_.inventory.ItemStack

#

thats so fucking stupid

#

why copy all data twice

#

the craftbukkit one just holds a handle to the nms stack

modern valley
#

I am using the spigot api

modern valley
sharp flare
#

remove it

modern valley
#

ohk

sharp flare
#

when watching yt tutorials make sure you understand what the guy is doing

quaint mantle
#

wand = item;?

sharp flare
#

or its a copy paste in the end

modern valley
sharp flare
#

but why can't u fix it yourself then by looking at your code?

modern valley
sharp flare
#

just asking though

#

do not mean to demean you in any way πŸ™‚

modern valley
#

np πŸ˜„

#

but how do i fix it?

sharp flare
modern valley
clear raptor
#

Can I somehow add same hover hologram effect as itemframes with named item in them have on other blocks?

sharp flare
#

did removing it work?

modern valley
#

wait lemme try

primal island
#

are you know Java?

sharp flare
#

atleast I can still help you while im here

#

if it didnt work

modern valley
#

Yup, it worked

#

tysm πŸ™‚

sharp flare
#

aight awesome goodluck

clear raptor
#

This is not invisible armorstand right?

sharp flare
#

But I think frames are entity

clear raptor
#

Rly?

#

:/

#

you are right...

sharp flare
#

it has hitboxes when placed

clear raptor
#

I am trying to make PLAYER_HEAD with hologram when placed, but without complicated logic of handling the armorstand holograms

#

Do not want bunch of "dead" unconnected holograms around map when something goes wrong

sharp flare
#

just place an armorstand when the skull head is placed

#

when head is broken, remove the armorstand too

clear raptor
#

yea, but then I need to handle like dozen of events of block destroy

sharp flare
#

cache the holograms

#

use block location as key

clear raptor
#

and remove them on launch if there is no head right

#

on that place anymore

sharp flare
#

wdym on launch

clear raptor
#

when plugin start

sharp flare
#

Use #setPersistent(true) and #setRemoveWhenFarAway(false)

clear raptor
#

for the armorstand?

sharp flare
#

and you can try saving the hashmap inside a file

#

onDisable

#

and restore it onEnable

clear raptor
#

yea... and that way I can also remove armorstands when head is no longer on that place

#

for some reason.

sharp flare
#

or use pdc and make ur life easier

clear raptor
#

pdc?

sharp flare
#

PersistentDataContainer

chrome beacon
#

?pdc

sharp flare
#

Blocks can hold pdc

chrome beacon
#

Not all blocks

clear raptor
#

I know. I hold NBT tags of that Head in there

#

So they can be recovered into item after drop

#

Holding it in pdc does not fix the problem when head block gets destroyed in some weird way, tho... Armorstand will persist

raw ibex
#

why does new GameProfile() not work

sharp flare
#

yeah not all blocks can do pdc mb, only some with tilestates

tall dragon
#

they can if you use the resource by @tender shard

sharp flare
#

You can try saving it in hashmap, just like I said before

chrome beacon
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

clear raptor
raw ibex
chrome beacon
#

Are you on 1.18.2

raw ibex
#

1.18.1

sharp flare
#

you need authlib for that if u dont have it

#

are u using nms or spigot api?

clear raptor
#

Is there any universal event for block being destroyed? I believe that BlockBreakEvent is not called for every possible way of block deletion right?

tall dragon
#

BlockBreakEvent is called when a player breaks a block

clear raptor
sharp flare
#

Block break event works on heads

tall dragon
#

why would you need a global one

clear raptor
#

Yea but Pistons, explosion, enderman, etc πŸ˜„

sharp flare
#

just gotta do checks and as much as possible the right block that is broken

tall dragon
#

they all have events

clear raptor
#

Sure πŸ˜„ But do you know all of them?

#

I dont πŸ˜„

#

And do not want players to loose their NBT tags on heads πŸ˜„

#

when they do something weird πŸ˜„

tall dragon
#

BlockBreakEvent, PistonExtendEvent, PistonRetractEvent, EntityChangeBlockEvent

clear raptor
#

BlockExplodeEvent, BlockBurnEvent

tall dragon
#

EntityChangeBlock is called for enderman picking up blocks and sheep eating grass i believe

clear raptor
#

That should be all?

tall dragon
#

well There is BlockFromToEvent i believe

#

for water, lava flowing

#

also called for dragonegg teleportation

clear raptor
#

Hopefully thats all πŸ˜„

tall dragon
clear raptor
#

πŸ˜„

tall dragon
#

there is also BlockFadeEvent

#

Called when a block fades, melts or disappears based on world conditions

quaint mantle
#

what is the best way to start if I want to start writing my own plugins

tall dragon
quaint mantle
#

Jup

modern valley
#

how to I assign function to my custom Item?

tall dragon
#

function?

sharp flare
tall dragon
#

youl need to elaborate

clear raptor
modern valley
tall dragon
chrome beacon
sharp flare
#

what kind of function u want

modern valley
#

when the user right clicks, a tnt summons and explodes

sharp flare
#

interact event

modern valley
#

ohk

sharp flare
#

you can spawn a primed tnt

modern valley
#

where can learn the spigot api?

quasi flint
#

spigot website

#

random guides

#

youtube

quasi flint
#

java doc

sharp flare
#

idk but a tag exist fot that

#

check the link above

#

try using the api version u have

clear raptor
#

Oh... I can use BlockDropItemEvent

#

That would cover everything πŸ˜„

#

Because I want the custom item to drop only if it actually drop from the action

#

So not e.g. when it burn in lava

chrome beacon
#

Yeah

#

Do note that event doesn't exist in old versions

clear raptor
#

I have 1.18 so thats no problem

chrome beacon
#

Good :)

jovial sparrow
clear raptor
#

Meh... it does work only for player breaks...

jovial sparrow
clear raptor
#

Yea... that seems promising

jovial sparrow
#

Though it is paper, so if you plan on the plugin ever being deployed without it you would have to do something else.

clear raptor
#

I mean... Who wouldn't use paper?

#

weird is that for some reason this event is not firing

modern vigil
#

How do I create a directory and example file with only the path of the dir?

#

Is it just

clear raptor
modern vigil
#

File#getParentFile()#mkdirs?

modern valley
#

I am getting this error

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getItemMeta()" because "com.init.test.items.ItemManager.wand" is null
        at com.init.test.events.testEvents.onPlayerRightClick(testEvents.java:22) ~[Plugins.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor5.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:git-Paper-216]

on using

   @EventHandler
    public void onRightClick(PlayerInteractEvent event){
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
            if(event.getItem() != null){
                if(event.getItem().getItemMeta().equals(ItemManager.wand.getItemMeta())){
                    Player player = event.getPlayer();
                    player.getWorld().strikeLightning(player.getLocation());
                }
hybrid spoke
#

ItemManager.wand is null

modern valley
hybrid spoke
#

it is. didn't initialized it?

modern valley
#

itemManager

public class ItemManager {

    public static ItemStack wand;

    public static void init() {
        createWand();
    }

    private static void createWand() {
        ItemStack item = new ItemStack(Material.STICK, 1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("Β§6Β§ Wand Of Thunder");
        List<String> lore = new ArrayList<>();
        lore.add("Β§7Β§oRight click to use");
        lore.add("Β§7Β§oSummon a lightning bolt");
        meta.setLore(lore);
        meta.addEnchant(Enchantment.LUCK, 1, true);
        item.setItemMeta(meta);

        //Recipe
        ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("wand"), item);
        sr.shape(" G ",
                 " N ",
                 " T ");
        sr.setIngredient('G',Material.ENCHANTED_GOLDEN_APPLE);
        sr.setIngredient('N',Material.NETHERITE_BLOCK);
        sr.setIngredient('T',Material.TRIDENT);
        Bukkit.getServer().addRecipe(sr);
    }
hybrid spoke
#

you created a new itemstack, but never initialized wand.

modern valley
#

i did ItemManager.init() in on_Enable

#

and moreover the crafting recipe works

hybrid spoke
#

ItemStack item = new ItemStack(Material.STICK, 1);
would have to be
wand = new ItemStack....

#

or in the end wand = item or whatever

modern valley
#

then why would the recipe work?

hybrid spoke
#

with that current code wand remains null

hybrid spoke
#

you just never initialize wand

modern valley
hybrid spoke
#

yes, in an other scope because this scope doesn't initialize the wand variable

modern valley
tall dragon
#

you are using the static keyword not what its meant for. but just for easy accessibility

modern valley
#

ok, I will remove it

modern valley
#

wht?

grim ice
#
  1. no abstraction
#
  1. static abuse
#
  1. using raw item stack api of bukkit (just use a library or smth)
modern valley
grim ice
#

and name stuff correctly

#

sr doesnt mean anything

#

call it wandRecipe

modern valley
#

ohk

tall dragon
#

yea 2hex is right. you might wanna make yourself to easily create itemstacks, this is how i make them for example

ItemCreator.of(CompMaterial.OAK_SIGN)
                .name("&e&lInfo")
                .lores(Arrays.asList(
                        "",
                        "&eCosmeticType: &7" + cosmetics.getCosmeticType().getFancyName(),
                        "&eCosmetic: &7" + cosmetics.getCosmetic().getCosmeticName(),
                        "&eCost: &7" + cost,
                        "",
                        "&eYour balance: &7" + cache.getRankedCoins(),
                        "&eNew balance: &7" + (cache.getRankedCoins() - cost),
                        ""
                ))
                .build()
                .makeButton();
modern valley
grim ice
clear raptor
#

What is the event when block gets destroyed by water flow and piston? BlockFromToEvent is not the right event, because it gets called on water flow, notp on block break.

grim ice
tall dragon
grim ice
#

Maybe

clear raptor
#

specifically player head

tall dragon
#

huh

#

since when do they break

#

by water

clear raptor
#

idk πŸ˜„ they do on 1.18.2

tall dragon
#

rlly?

grim ice
#

they dont afaik

clear raptor
#

they do

#

does not matter. should be same event as for torch

grim ice
#

wat

tall dragon
#

but im still pretty sure u can use blockfromto event. just check if the "to" location is something you dont want to break

clear raptor
#

yea but thats not actually break event

#

that is just that water moved TO the location of head

grim ice
#

and thats how it breaks

#

??

modern valley
tall dragon
#

i know

#

you will need to create something like that

clear raptor
#

But you cannot cancel this event

tall dragon
#

as i did

#

you can

clear raptor
#

Then water will not flow there

tall dragon
#
@EventHandler
public void onBlockFromTo(BlockFromToEvent e) {
    if (e.getToBlock().getType() == Material.TORCH || e.getToBlock().getType() == Material.WALL_TORCH) {
        e.setCancelled(true);
    }
}
#

this code would avoid torches

clear raptor
#

I want to alter the drop... So I want to cancel original drop and drop my own item

#

But still want water to displace the head as usual

tall dragon
#

ah

grim ice
#

Easy

#

use that event

#

EpicGod used

#

but break the block ur own way

#

and drop the item u want

clear raptor
#

yes... but then two items drop if I not cancel the flow event πŸ˜„

grim ice
#

Mhm

modern valley
clear raptor
#

see? block does not get destroyed

chrome beacon
#

Water doesn't destroy heads

clear raptor
#

OMG

tall dragon
#

by default it apperantly does

clear raptor
#

IT DOES

#

πŸ˜„

chrome beacon
#

It does?

clear raptor
#

yes. this is because of I disabled the event

modern valley
modern vigil
#

Does Kotlinx's serialisation support arrays of things that have a designated KSerializer?

tall dragon
#

it never used to

#

but now it does

clear raptor
#
@EventHandler
    public void onBlockFromTo(BlockFromToEvent event) {
        if(playerHeadBreak(event.getToBlock()))
            event.setCancelled(true);
    }
#

I cancel the event when my custom head drops

#

but then the above screenshot happens

#

I do not believe there is no event for piston and water breaks lol...

modern valley
#

How do I use ItemFactory?

tall dragon
clear raptor
#

Will try

hybrid spoke
tall dragon
#

yea its just psuedo code

clear raptor
#

yea... still drops two heads.

hybrid spoke
clear raptor
#

one default and one mine

tall dragon
#

so cancel the event as well

grim ice
#

Allman style

#

sucks to suck

raw ibex
clear raptor
sharp flare
tall dragon
#

it will probably just delay the water by flowing there by 1 tick

clear raptor
#

Only downside seems to be that it is 1 tick behind with fillinf that destination block

#

πŸ˜„

raw ibex
clear raptor
#

yes

tall dragon
#

well u could also work arround that

clear raptor
#

I think that it is not a big problem

tall dragon
#

by checking the neighbors of the To block

#

but if ur not bothered by it πŸ€·β€β™‚οΈ

clear raptor
#

thats too much work for no reason I think....

#

Hopefully same will work with piston

tall dragon
#

idk why there is no BlockBreakNaturallyEvent tbh

#

but there probs is a good explaination

clear raptor
#

yea...

sharp flare
clear raptor
#

already figured it out for both piston and water. thanks

#
@EventHandler
    public void onBlockFromTo(BlockFromToEvent event) {
        if(playerHeadBreak(event.getToBlock())) {
            event.getToBlock().setType(Material.AIR);
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onBlockPistonExtend(BlockPistonExtendEvent event) {
        for(Block block : event.getBlocks()){
            if(playerHeadBreak(block)) {
                block.setType(Material.AIR);
                event.setCancelled(true);
            }
        }
    }
#

(playerHeadBreak() actually drops the item naturally πŸ™‚)

grim ice
#

what is playerheadbreak

sharp flare
#

yeah whats inside of that

grim ice
#

thats some bad naming

clear raptor
#

wip

grim ice
clear raptor
#
boolean playerHeadBreak(Block block){
   
   if(!isMyCustomBlock)
      return false;

   Iterator<ItemStack> it = block.getDrops().iterator();

   // If there is actually head drop
   if(it.hasNext()){
      ItemStack item = // make custom head
      block.getDrops().clear();
      block.getWorld().dropItemNaturally(block.getLocation(), item);
      return true;
   }
   return false;
}
grim ice
#

if you name stuff like that while youre working on ur code

#

stuff will get messy

#

i would even name block "blockAffected"

clear raptor
#

ehh... wait

grim ice
#

what is it supposed to do anyways

sharp flare
#

not complete code it can be boolean if he send the modifiers

#

and return type if its not void

sharp flare
#

what, u using wrapper classes for the return type?

clear raptor
#

pseudo code lol

#

ignore details πŸ˜„

sharp flare
#

aight

clear raptor
#

I use this method on all drop events

#

so I not dupe code...

#

thats why it is weird a little

#

renaming it to dropPlayerHead πŸ˜„

sharp flare
#

why not just use only the

      return false;
#

to determine if its the right block inside the event listener

clear raptor
#

sure that is what I am doing πŸ˜„

#

But after that I drop my custom item and want to cancel drop of original one

#

I have custom PLAYER_HEAD item with custom NBT Compound... When I place it, NBT gets saved into PDC and then retrieved in every block break event so it can be used to create the original item again.

sharp flare
#

does your head drop the custom one when broken without any of these checks?

clear raptor
#

It does not thats why I need to check for every single one block break event what drops it

#

Because I cannot loose the NBT

#

and still give players ability to place and destroy the special head

sharp flare
#

so its making a new custom itemstack every break, I see

clear raptor
#

Yes

#

Or I can edit existing one?

#

I think that block.getDrops() is immutable right?

#

yea. it is...

sharp flare
#

you can edit existing drops

#

it returns a collection I think

clear raptor
#

So I can remove the original item and put there my new one right?

#

does not work...

block.getDrops().clear();
block.getDrops().add(myCustomItem);

And it still drops the original one...

wide coyote
#

isnt there a setDrops method?

clear raptor
#

nope

wide coyote
#

ah i guess it was in a event then

clear raptor
#

yea... because BlockPistonExtendEvent and BlockFromToEvent are not block break events, they cannot alter drops

#

it should work for other events, tho

#

why it does not play here?

#

its not virus I promise πŸ˜„

chrome beacon
#

Discord doesn't support mkv

clear raptor
#

oh

#

and mp4?

wide coyote
#

try BlockDropItemEvent it has a method that returns an mutable list of drops

chrome beacon
#

Anyways yeah that's some interessting behaviour

sharp flare
chrome beacon
#

I'd say it looks fine

#

Maybe call update on the piston after you remove the head

clear raptor
#

how?

#

cast block to piston or something like this?

sharp flare
#

#setDropItems(false) then modify the drops, drop it naturally

clear raptor
wide coyote
#

you are editing the list

chrome beacon
wide coyote
#

ah

sharp flare
sharp flare
#

actually you don't even need to do #clear on that since you set the block type to air and cancelled the event. since u make drops out of an new itemstack

#

#setDropItems(false) then drop the new itemstack naturally saves you some lines

clear raptor
#

Same with the Paper's BlockDestroyEvent

#

Yea... BlockDropItemEvent is called only for items destroyed by player, not naturally

clear raptor
chrome beacon
#

Hm alright

clear raptor
#

I must somehow cancel the drop and not the piston event

#

Seems like no other way here

chrome beacon
#

Try setting the head to air

clear raptor
#

Why would that help?

sharp flare
#

I thought it was working well?

chrome beacon
#

Then you don't need to cancel the event?

#

Or wait what's the goal here

sharp flare
#

Aight imma head out, im kinda lost here now

chrome beacon
#

Same

clear raptor
#

me too πŸ˜„

#

Hardcore stuff

sharp flare
#

Feels like im talking same shit for the pass 30 minutes

clear raptor
#

You dont

chrome beacon
#

Let's start over. What are you trying to do with the piston

clear raptor
#

give me second πŸ™‚

#

Thats the current problem πŸ™‚ everything else is solved

#

The problem is that it is not firing πŸ˜„

#

I am using PufferfishMC which is Paper fork...

sharp flare
#

you want the first one to make the stone move?

clear raptor
#

sure

#

thats normal behavior

sharp flare
#

video looks good to me

clear raptor
#

why?

sharp flare
#

whats the issue in the video?

clear raptor
#

stone should move to the place of dropped head

sharp flare
#

not sure if thats a vanilla mechanics or it can be changed

clear raptor
#

it is

#

vanilla mechanic πŸ™‚

#

it does not move the block because I cancelled the piston event

#

but If I not cancel it, I also get the default head drop I dont want

#

See the dilema?

sharp flare
#

cancelling it is the best option ig, as long as the relative block is the custom head

clear raptor
#

Yea... It works fine when piston directly push the head

#

but indirectly it gets broken

young knoll
#

Break the head manually instead of cancelling?

clear raptor
#

breaking head means setting it to AIR

#

thats what I did...

young knoll
#

And that stops the block being moved?

clear raptor
#

yea

young knoll
#

Weird

clear raptor
#

yes... I even removed the event cancel

#

And still...

young knoll
#

You could mark the location and then listen for the ItemSpawnEvent

#

And compare locations

clear raptor
#

wait a minute...

#

Oh I am stupid.. I miss looked the right event...

#

It seems to work when I not cancel the event and just replace block with AIR

#

yes πŸ˜„ it works...

sharp flare
#

yeah cuz u cancel the piston event

#

this is why I get kinda lost

clear raptor
#

yea but I thought for some reason that if I not cancel it it drops default head

#

Sorry for that

#

Fine πŸ˜„ So I covered BlockBreakEvent, BlockDestroyEvent, BlockFromToEvent and BlockPistonExtendEvent.. Hopefully there is no other way of destroying the block πŸ˜„

sharp flare
young knoll
#

Explosion events

clear raptor
#

Yea but you said cancel event

sharp flare
#

for the block break event

#

where did u use setType air then

clear raptor
#

block break event does not fire when piston removes item

#
@EventHandler
    public void onBlockPistonExtend(BlockPistonExtendEvent event) {
        for(Block block : event.getBlocks()){
            if(dropPlayerHead(block)) {
                block.setType(Material.AIR);
            }
        }
    }
#

this does the trick...

#

If we drop custom head, then we set the block to AIR

sharp flare
#

aight now im sure i got lost last time cuz of the two events

clear raptor
#

yea

sharp flare
#

there was no specific event stated last time

clear raptor
#

Thats possible, sorry.

sharp flare
#

great its already worked out

clear raptor
#

wtf... BlockExplodeEvent is also not get called on my server what is hapenning πŸ˜„

young knoll
#

EntityExplodeEvent

#

BlockExplodeEvent is for blocks exploding, like beds in the nether

eternal oxide
#

BlockExplode is for things like beds placed in the nether

#

beat me to it

clear raptor
#

and what about other explosions?

#

tnt, creeper?

#

entity explode event... got it...

eternal oxide
#

entity

clear raptor
#

yea. thx

quiet ice
#

tnt should also be entity

clear raptor
#

It is. yes

valid solstice
#

Hello, how do I find the 2 points that are perpendicular to one vector?

#

the point that connects the arrow and the dashed lines is what im finding

quiet ice
#

That is basic trigonometry

ocean hollow
#

hello guys. Why is this doesn t work?

valid solstice
quiet ice
#

But the question would be where?

granite owl
#

about beams?

quiet ice
#

there are infinite, 1 (not sure) or 0 points that are perpendicular between three vectors

valid solstice
#

the given is the vector that is pointing (the solid one)

quiet ice
#

If the vectors are parallel there is an endless amount of points

valid solstice
#

how would i do that

quiet ice
#

1 block away from where?

valid solstice
#

its parallel to the vector given

granite owl
#

then ur looking for if vector b is a multiple of vector a

#

u-> = v-> * r i think

#

it was xD

valid solstice
#

so i'm going to multiply the given vector by x where x is the distance?

quiet ice
valid solstice
#

its parallel

#

so no matter the origin point or any point of the vector its still 1 block away

quiet ice
#

Oh, then it's just pythagoras

granite owl
#

why dont u use a spigot api provided radius method then

#

if its +-1 block

quiet ice
#

just move the vector by 0.42 block left, 0.42 block up for example

#

Actually

valid solstice
#

what if the vector is not actually straight

#

as in diagonal

quiet ice
#

Oh right

valid solstice
#

it works in some extent

#

but it usually isn't reliable when the direction is diagonal

valid solstice
quiet ice
#

I think I know what you mean

valid solstice
#

in spigot api?

quiet ice
#

?jd-s

undone axleBOT
valid solstice
#

no, is there a method that creates a parallel vector of a given vector that is x distance away from the given?

#

thats what im trying to say xD

quiet ice
#

does bukkit's vector even have a direction?

valid solstice
#

no but you can get the Direction of something from its Location

ocean hollow
#

guysss

#

help please

granite owl
#

ive only learned the german terms for this so might be translated incorrectly

#

so

hybrid spoke
hollow aspen
#

wouldn't u just normalise the vector, invert it (f(x)->-1/f(x)), then multiple that vector by x?

valid solstice
granite owl
#

a vector can either be a point V(x|y|z) or a direction vector V-> x y z.

@valid solstice

if u know ur orig vector and u know the distance why dont u just add it to the point and keep the directional vector untouched?

eternal oxide
#

rotate teh vector 90 or 180, move (multiply by distance) and rotate back

granite owl
#

wanted vector * r = orig vector like ive said in the beginning

desert musk
#

which is better? IntelliJ remote development or github

valid solstice
granite owl
#

yes

#

it creates a new vector

#

which is the many of r of the orig point

quiet ice
desert musk
valid solstice
quiet ice
#

Do you mean Github desktop with github?

desert musk
#

yeah

#

intellij can link with git

quiet ice
#

Oh then no idea

#

I always used the CLI because my IDE sucks at supporting signing commits

granite owl
#

@valid solstice thats the formula to determine wheter or not it is parallel sorry

#

which needs to return true results

desert musk
#

Yeah i got the github project onto my other computer but it sends tons of errors when i try to build it

valid solstice
#

well im trying to find the parallel vector of x

desert musk
#

mainly that β€œno goals have been specified for this build”

quiet ice
#

Do you use maven/gradle?

desert musk
#

maven

granite owl
#

i think uhmm a-> + u-> * s + v-> * t @valid solstice

#

a being ur vector of the starting point

#

forget it needa get home first to check it properly

valid solstice
#

um alright ill look more into that

quiet ice
#

Well the formula to create a paralell function from function f(x) = mx + b would be p(x) = mx + b + (1 - 1/mΒ²) or something like that idk

#

actually no, that wouldn't work

granite owl
#

tbh ik its u-> = v-> * r to determine wheter or not theyre parellel

#

but i forgot how to derrive the formula to create one from it

valid solstice
#

i'm thinking that a good way to make this possible is to get the direction of the location

tender shard
#

are there any enum classes built in to java?

quiet ice
#

To determine whether they are parallel it is just m1 = m2, no?

valid solstice
#

add or subtract 90 to it to get the parallel vector points, then just multiply it by (x) for the distance and multiply it again from the original direction to form the line

quiet ice
#

StandardOpenOptions is one I know of

tender shard
#

okay thanks

quiet ice
#

StandardCopyOptions is another

tender shard
#

yes I'll use that

#

I just need some enums for a unit tests and didnt want to use Material etc since they are being removed SOME time

quiet ice
#

Alternatively, open up the javadocs and check which classes extends Enum

granite owl
#

if thats the case you compare a set point a with a wanted point b

#

and then theyre identical

#

if thats true

#

u have to add the multiplier factor if theyre parallel but not identical

quiet ice
#

I mean any linear function has to be f(x) = mx+b. b's value does not matter for determining paralellity

#

In other words, f'(x) = p'(x). Since f'(x) = m, only m matters

granite owl
#

to dertermine if theyre parallel u have to derterime if theyre a factor of each other

#

sorry hard to translate

#

they smashed it into my brain in german

#

and ive hated that topic xD

quasi flint
#

another german arrived

quiet ice
#

Ich denke du sprichst von normalen hier

quasi flint
#

optic is on high alert

#

🚨

granite owl
#

man muss rausfinden ob der neue vektor ein vielfaches des alten is

#

bzw

#

man muss einen neuen erzeugen der ein vielfaches des alten is

quasi flint
#

hab nich nie vektoren gehabt

desert musk
#

can't find a single updated tutorial on making a custom entity for a noob like me

quasi flint
#

in der schule

quiet ice
#

Vectors are Q1+ maths or physics afaik

granite owl
#

πŸ€·β€β™€οΈ sei froh

#

braucht man auch nich wenn man nich ne low level physics engine schreibt

desert musk
quiet ice
#

The stupid thing is that I cannot deal with vector properly yet, so I try to translate them to linear functions

valid solstice
#

plus they're 2 dimentional vectors, so exploring 3d vectors are a new thing to me

quiet ice
#

Actually math vectors are different to physics vectors - so disregard my previous statement

#

Oh right, vectors in mc are 3 dimensional 🀦

valid solstice
#

anyways i think i may have found a way to make this possible using the locations yaw instead of dealing with the vector itself

#

still going to experiment with it though

granite owl
#

a vector is an array

#

its just a different word for array

quiet ice
#

Yeah, but a physics vector is a linear function usually

#

It's really stupid that physics and mathematics use vector for two different things.

#

Technically they are kinda similar, yes - but noone will teach you those similarities

granite owl
#

laughs in electricity

#

electric charges

tender shard
#

for my lib I need to instantiate collections generically. I have until now just used CollectionClazz.getConstructor().invoke(). However, that won't work if the constructor requires an argument, e.g. EnumMap requires an Enum.class as parameter. I have now just added a method that doesn't only take a collectionClazz, but also a collectionSupplier, like this:

    /**
     * Turns an existing DataType into one that holds a {@link Collection} of the same class
     * @param collectionClazz The {@link Collection} to use.
     * @param collectionSupplier A {@link Supplier} that returns an empty instance of the given Collection class.
     * @param type The existing DataType
     */
    static <C extends Collection<D>, D> CollectionDataType<C,D> asGenericCollection(final @NotNull Class<C> collectionClazz,
                                                                                    final @NotNull Supplier<C> collectionSupplier,
                                                                                    final @NotNull PersistentDataType<?, D> type) {
        return new CollectionDataType<>(collectionClazz, collectionSupplier, type);
    }

Anyone maybe have an easier idea?

#

for example getting an EnumMap would now look like this:

    /**
     * Creates a DataType holding an {@link EnumMap} of the given Enum Class and DataType
     * @param enumClazz Enum class
     * @param valueType Existing DataType for the map's values
     */
    static <K extends Enum<K>,V> MapDataType<EnumMap<K,V>,K,V> asEnumMap(final @NotNull Class<K> enumClazz,
                                                                         final @NotNull PersistentDataType<?,V> valueType) {
        return new MapDataType(EnumMap.class, (Supplier<EnumMap>) () -> new EnumMap(enumClazz),DataType.asEnum(enumClazz), valueType);
    }
quiet ice
#

I'd just use a supplier

#

unless the class instance is required

ivory sleet
#

I mean you could pass a Collector<T,A,R>

#

and then handle that properly ofc

tender shard
#

wrong reply

#

how would a collector help here

quiet ice
#

I.e. so a call is something like asGenericCollection(() -> new EnumSet(Enum.class), type);

ivory sleet
#

you asked for easier ideas?

tender shard
#

yes but I have no idea how it would work using a collector πŸ˜„

#

so could you explain please how it'd work? πŸ˜„

ivory sleet
tender shard
#

thx. Of course I've used collectors before but I've never looked at their source nor did I ever wonder how they work