#help-development

1 messages · Page 717 of 1

valid burrow
#

?dontwork

#

it was something like that

upper hazel
#

bruh

valid burrow
#

?doesntwork

pseudo hazel
#

?notworking

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.

pseudo hazel
#

got it

valid burrow
#

ahh

upper hazel
#

how can I say I haven’t tried this code yet but I’m sure there will be errors and I would like to ask in advance ahaah

#

i "fill it"

smoky oak
#

bruh

#

?tas

undone axleBOT
upper hazel
#

oh i see

smoky oak
#

correct

upper hazel
#

ok

smoky oak
#

he doesnt

#

yet

upper hazel
#

So a problem has arisen: there is a possibility that a player may disappear during the cyclic flow, what should I do? Check for null every time?

smoky oak
#

i mean yea?

#

if i do anything with player its either in the same tick or its a if(player.isOffline()) return

#

i dont think the player object itself gets nulled

chrome beacon
#

Don't keep a reference to the player if you want to do something over multiple ticks

#

Store the uuid and use getPlayer

smoky oak
#

oh

#

im keeping a ref to the player in a handler

#

im using that

upper hazel
valid burrow
#

what would be the most resource efficent way to create a new completly empty world and load a scematic into it (for mini games if that isnt obvious)

smoky oak
#

dont

#

create the world once and reset it afterwards

valid burrow
#

alright

smoky oak
#

hey yall it finally happened

#

I got the exception without reload

#

?paste

undone axleBOT
smoky oak
#

Way it works is that every player is assigned an implementation of the interface PatronHandler. It contains the method bodies for all methods called but no implementations

#

so my question now is: wtf is going on here?

topaz cape
#

does anybody know why does it just print 0

eternal oxide
#

you seem to have issues with your package naming case

topaz cape
#

it just prints 0 everytime

#

smh

#

i want to get the message

smoky oak
eternal oxide
#

its probably not causing your issue, but it makes even your stacktrace hard to comprehend

smoky oak
#

ah

#

side note

#

this error only happens sometimes

#

i have yet to figure out a consistent trigger for it

#

even if i dont change the code where it happens

eternal oxide
#

?paste your EventPlayerMove listener

undone axleBOT
smoky oak
#
public class EventPlayerMove implements Listener {
    @EventHandler
    public void onMove(PlayerMoveEvent event){
        Echo.getInstance().getPlayerHandler(event.getPlayer()).moveEvent(event);
    }
}
#

like

#

its just passing through the event to the interface implementation

#

all listeners in the project do that

eternal oxide
#

line 11 is?

smoky oak
#

some players have different things happen when they move so i was like 'this is simpler than one massive event method'

#

the one starting with echo

eternal oxide
#

so your getPlayerHandler returns a PatronHandler?

smoky oak
#

ye

#

internally theres a hashmap uuid, handler

#

which just caches em

eternal oxide
#

is that in teh same project or in a dependency?

smoky oak
#

same project

#

ive been trying to figure it out for a while now

#

if it were after a reload it could be some weirdness with not being in the registry thingy like what happened with the log handler

#

but this is right after server start

eternal oxide
#

if it's after a restart you are not clearing your hashmap in onDisable

#

its looking at teh wrong class instance after a reload

smoky oak
#

server start

eternal oxide
#

fresh start?

smoky oak
#

yea

#

whcih is why im a tad confused

#

like normally this is where u thorw at me the 'of course it breaks with reload' but

eternal oxide
#

in that case create a local variable in your move event

#

{PatronHandler handler = Echo.getInstance().getPlayerHandler(event.getPlayer());

smoky oak
#

what'd that change?

eternal oxide
#

then only call the moveEvent if not null

smoky oak
#

cant be

#

for two reasons

#

one, the error'S a classNotFoundException

#

two, if there's no handler it returns an empty implementation

#

NullHandler, all empty method bodies

eternal oxide
#

do you have the same class in another plugin?

smoky oak
#

no

eternal oxide
#

then no clue

smoky oak
#

bleh

eternal oxide
#

your error seems impossible

smoky oak
#

story of my life bruh

#

@ivory sleet i think we spoke about this like one or two days ago and either you or mfnalex were like 'its a restart issue', apparantly not

#

any clue?

ivory sleet
#

wait what issue

#

:o

smoky oak
#

uh

#

ive been having this on and off sometimes

#

like sometimes it happens and sometimes not, even if i dont change any relevant code

#

it appears random

eternal oxide
#

its impossible for a Class to be unloaded at runtime while there are references held

smoky oak
#

sooooooooo now what

#

did i somehow break the JRE

eternal oxide
#

it seems like an impossible error

#

show where you fetch/return your PatronHandler

#

your getPlayerHandler

smoky oak
#
private HashMap<UUID, PatronHandler> playerHandler;

public PatronHandler getPlayerHandler(Player player){
    return playerHandler.get(player.getUniqueId());
}

public void setPlayerHandler(Player player, PatronHandler handler){
    playerHandler.put(player.getUniqueId(),handler);
}

@Override
public void onEnable(){
  playerHandler = new HashMap<>();
}
#

its part of the class extending JavaPlugin cuz the map's supposed to be a singletron

eternal oxide
#

This getPlayerHandler(Player player) can return null

smoky oak
#

no

#

like i said it sets up empty handlers

eternal oxide
#

yes, its just a hashmap

#

what if someone sends a move packet before you managed to add them to your map?

smoky oak
#

im pretty sure packets get handled sequentially, correct?

#

if that is the case, then the player entry CANNOT be null cuz I'm doing this in onJoin

#

also

#

its not a NPE

eternal oxide
#

well, yes and no

smoky oak
#

its a 'class loader missing this'

eternal oxide
#

it kinda is

smoky oak
#

well not of the handler

eternal oxide
#

do the local variable as I said and I bet you don;t get any more errors

smoky oak
#

we'll see

eternal oxide
#

just check for null before calling event

smoky oak
#

alright as usual the error's gone now

#

but

#

its always done that

#

be there, then vanish, then reappear even if im not doing anything different

eternal oxide
#

time will tell

smoky oak
#

elgar

#

it happened in other spots too

eternal oxide
#

are you running Spigot?

smoky oak
#

yea

#

spigot latest

#

from like yesterday or two days ago

eternal oxide
#

you are using a HashMap so you could use getOrDefault instead of get

#

then you can guarantee never getting null

smoky oak
#

that... doesnt help if the error isnt a NPE but a class not found

#

I'd be returning something the jre thinks is non-existent

eternal oxide
#

class not found makes no sense as it's in teh same plugin

#

you can open the jar and the class does exist

smoky oak
#

yea so tf is going on here

eternal oxide
#

PC out window

smoky oak
#

?

#

actually

#

you might be onto something here

#

what are these and why are they empty

eternal oxide
#

run a clean

smoky oak
#

already did

eternal oxide
#

you are not keeping the target/build folder open in a window are you?

smoky oak
#

why would i

#

i just go into IJ and hit the button

#

also just to be sure i manually ran the clean and package profiles

#

the classes are still there when i look into them with the decompiler

smoky oak
#

oh hey someone new's here

#

u got any clue?

jade stump
#

No, I'm new to minecraft plugin development

#

came here to ask

#

What's the best way to check when an empty glass bottle gets filled with water from a block of water? There doesn't seem to be a Fill event like there is for buckets. And I had trouble using "OnPlayerInteract" because you can't right click a block of water.

smoky oak
#

actually you can

#

it counts as right clicking the block behind it, and it also triggers if you right click while holding an item

#

so you just need to check if a) the item in main hand is a glass bottle and b) the block the player is looking at is water

#

you're looking for the rayTrace method btw

jade stump
#

Hm ok. I'll look into that. Thanks a bunch!

white furnace
#

Hey, I'm making a plugin where you can right click a fireball to throw it. I've already made the fireball not be able to damage the terrain with a EntityExplodeEvent listener, but while the fireball is travelling it is able to break powdered snow, and I haven't been able to find a way to cancel that. Any ideas?

smoky oak
#

hm, maybe blockPhysicsEvent?

#

or BlockFadeEvent

#

its probably one of those two

white furnace
#

it was a physics event

smoky oak
#

iirc its a event thats extending on BlockPhysics

#

if it is you should use that

#

its a lot more specific

#

hm interesting

#

no guarantee, its not a physics event

#

but it is a block event

white furnace
smoky oak
#

alright then

#

its just that its better to use the specific events

#

less parameter checks

white furnace
#

yeah I was really hoping it was

#

because now I need to figure out how to see if a physicsevent is caused by a fireball

#

idk where to start w/ that tbh

smoky oak
#

actually

#

just print out this

#
event.getChangedType() + " " + event.getBlock() + " " event.getEventName()
#

should give you a nice starting point

#

and maybe a more specific event too

#

unfortunately you cant just do that with Event event cuz that one's an interface lol

white furnace
#

all the events fired when a powdered snow block is broken:

[21:37:03 INFO]: AIR CraftBlock{pos=BlockPosition{x=1242, y=-41, z=912},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
[21:37:03 INFO]: AIR CraftBlock{pos=BlockPosition{x=1244, y=-41, z=912},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
[21:37:03 INFO]: SNOW_BLOCK CraftBlock{pos=BlockPosition{x=1243, y=-42, z=912},type=SNOW_BLOCK,data=Block{minecraft:snow_block},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
[21:37:03 INFO]: AIR CraftBlock{pos=BlockPosition{x=1243, y=-40, z=912},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
[21:37:03 INFO]: AIR CraftBlock{pos=BlockPosition{x=1243, y=-41, z=911},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
[21:37:03 INFO]: AIR CraftBlock{pos=BlockPosition{x=1243, y=-41, z=913},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
[21:37:03 INFO]: AIR CraftBlock{pos=BlockPosition{x=1243, y=-41, z=912},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} BlockPhysicsEvent
#

not really sure how to narrow down if it's a fireball caused break or not

smoky oak
#

the third in there marks the block that actually got affected. Not sure why the other locations fire events

white furnace
#

yeah I thought that as well, dk why the air is there

#

but with the data from the third event, there is nothing there indicative of a fireball

smoky oak
#

💡

#

check projectileHitEvent

white furnace
#

first thing I tried

#

no luck

smoky oak
#

huh

white furnace
#

trying 1 sec

#

oh yeah changeblockevent is called

chrome beacon
#

Wrong channel. Use #help-server and make sure you're using Spigot

white furnace
#

here's what a changeblockevent looks like in the following format: event.getBlock() + " " + event.getBlockData() + " " + event.getTo()

#
[21:44:40 INFO]: CraftBlock{pos=BlockPosition{x=1242, y=-41, z=900},type=POWDER_SNOW,data=Block{minecraft:powder_snow},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5b8bfdd4} CraftBlockData{minecraft:air} AIR```
eternal oxide
#

cancel the event and the snow should not change

jade stump
#

@smoky oak Hey, real quick, are you sure raycast can pick up on blocks of water? I can only get it to return the blocks that are behind the water. The raycast goes right through

smoky oak
#

thats cuz you tell it to be transparent

white furnace
smoky oak
#

put into the raycast air only

white furnace
#

if getBlock == powdered_snow && getTo() == air?

eternal oxide
#

getBlock().getType()

jade stump
#

how?

white furnace
smoky oak
#

dont have my ide open

white furnace
#

it worked

#

thanks so much for all the help

#

really appreciate all of u

jade stump
#

I'm using RayTraceResult

smoky oak
#

no like

#

what type of object is calling the raycast

#

its not location

#

ah found it

#

youre looking for Player.rayTraceBlocks(distance, FluidCollisionMode.ALWAYS);

#

or SOURCE_ONLY

floral drum
#

nerds

smoky oak
#

depending if you want to hit flowing water or not

smoky oak
floral drum
jade stump
#

Ok ill try it. Thank you again!!

smoky oak
#

np

#

actually u probs want source only lol

#

player reach is ~5.1

#

*4.5

jade stump
#

Its starting to work! Only thing is if the raycast passes through water and doesn't hit a block after then it doesn't seem to return anything as if it didnt hit the water. Doesn't do that when it hits water then a block though, that still returns the water block

#

if u have any quick thoughts as to why lmk. otherwise i'll take it from here

smoky oak
#

wat

#

whats ur exact code to do the ray trace

jade stump
#

Location eyeLocation = player.getEyeLocation();
Vector direction = eyeLocation.getDirection();
RayTraceResult rayTraceResult = Bukkit.getWorld(eyeLocation.getWorld().getUID()).rayTraceBlocks(eyeLocation, direction, 50, FluidCollisionMode.ALWAYS);

smoky oak
#

uh look into how to format code

jade stump
#

lol

smoky oak
#

```java
then type ur code
then three more ticks and enter

jade stump
#
Location eyeLocation = player.getEyeLocation();
Vector direction = eyeLocation.getDirection();
RayTraceResult rayTraceResult = Bukkit.getWorld(eyeLocation.getWorld().getUID()).rayTraceBlocks(eyeLocation, direction, 50, FluidCollisionMode.ALWAYS);
smoky oak
#

yea just keep in mind. It might be an issue with using World, Entity has a raytrace method too

#

also

#

keep in mind player reach aint 50

#

its 4.5

jade stump
#

yea

smoky oak
#

hm

#

try adding another arg after the mode

#

'false'

#

the world ray trace might not use that by default

jade stump
#

ok whats it for?

smoky oak
#

not collide with non solid

jade stump
#

o

smoky oak
#

i do not claim to know why its not collide with solid instead

jade stump
#

FluidCollisionMode.False?

smoky oak
#

nah

#

just a boolean

jade stump
#

nvm

#

yea

#

same thing. no difference

#

Seems to ignore water if the raycast doesn't hit another block after the water

smoky oak
#

try the entity ray trace?

jade stump
#

How?

smoky oak
#

uh its entity... something

#

one moment

jade stump
#

rayTraceEntities?

smoky oak
#

not that one

#

LivingEntity should have a raytrace

jade stump
#

no idea what that is or how to use it

smoky oak
#

player.rayTraceBlocks

#

cant find anything on the docs unfortunately urgh

#

the docs tell me what youre doing should collide with water. dont have my ide rn so cant help you more than this unfortunately

jade stump
#

Yeah ok

#

I'll keep working on it

#

thanks a bunch for the help though!!

#

much love

opaque scarab
#

What is a good way to add items to a player without risk of those items getting lost in a full inventory. I need it to add items, but if you inventory is full, drop the remaining items on the ground.

#

Yes I know this is the most trivial thing ever

#

But is there an existing method?

lost matrix
# opaque scarab What is a good way to add items to a player without risk of those items getting ...

Adding itemstacks to an inventory will return a Map of items that did not fit in the Inventory.
You can simply use this map to drop overflown items:

  public void addOrDrop(Player player, ItemStack... items) {
    World world = player.getWorld();
    Location location = player.getLocation();
    Map<Integer, ItemStack> overflownItems = player.getInventory().addItem(items);
    overflownItems.values().forEach(item -> world.dropItem(location, item));
  }

Or simply

  public void addOrDrop(Player player, ItemStack... items) {
    World world = player.getWorld();
    Location location = player.getLocation();
    player.getInventory().addItem(items).values().forEach(item -> world.dropItem(location, item));
  }
#

*If all items are stored then the map will be empty, meaning the forEach wont do anything

young knoll
#

I always seem methods in here that would be useful in my lib

#

And then I promptly forget them before I add them

remote swallow
#

Kekw

#

Make a gh issue with it in

tacit drift
#

First argument is a Location, second is the direction

#

this seems useful

tribal quarry
distant wave
#

is there anyone who used NMS and has gradle?

chrome beacon
#

Probably

distant wave
#

i dunno how to apply it in gradle

#

can you show me

chrome beacon
#

but you can also use Paperweight if you want the Paper API

eternal oxide
#

Spigot is based around Maven so use maven if you use Spigot.

distant wave
#

what does even this mean

chrome beacon
kind coral
#

is there a way to forcefully disable a world in spigot? i am trying to delete the directory the world is in during runtime and sadly it doesn't let me

distant wave
chrome beacon
distant wave
#

where on mavenlocal is the nms placed?

#

oh i see

#

can i just add netty as dependency?

#

oh cmon

#

why dont i have stuff like ServerPlayer

rough drift
#

Should I cancel an event on MONITOR priority (I just redirect the output to somewhere else, no processing done)

lost matrix
#

No, MONITOR is only used to monitor the final outcome. It should never modify anything in the event.

rough drift
#

Yeah I know that part, but if I set to HIGHEST there is a chance my event gets ran before another plugin's event that modifies the data in that event

kind coral
rough drift
#

take the chat event, I would need to redirect it somewhere else AFTER all the plugins have processed it

lost matrix
kind coral
sullen marlin
#

?jira

undone axleBOT
sullen marlin
#

It's probably a bug then, report it

kind coral
#

instead during the login phase of the player, which event gets called first? PlayerJoinEvent or PlayerInitialSpawnEvent

rough drift
kind coral
#

because when i try to fetch the player elsewhere using the Bukkit.getPlayer(UUID) in the PlayerInitialSpawnEvent this causes a NullPointerException that makes me thing this event is called before the playerjoinevent itself

rough drift
#

it's not a full server crash

#

just an error

eternal oxide
lost matrix
eternal oxide
#

delete in onLoad

#

onLoad runs before worlds are loaded

kind coral
#

yep already done thats how i also managed

rough drift
#

That's odd, I just

// unload world with save false
// delete folder
#

and it works 100% of the time

rough drift
#

Yeah that's probably when it loads the location

lost matrix
rough drift
lost matrix
kind coral
#

uncle pear

granite olive
#

What do I need to provide in lootcontext if I want to use the fillinventory method of a loot-table?
I currently try to provide everything possible I see here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/loot/LootContext.html

chest.getLootTable().fillInventory(chest.getInventory(), random, lootContext);```
But I still get a missing parameters exception:
`java.lang.IllegalArgumentException: Missing required parameters: [<parameter minecraft:block_state>, <parameter minecraft:direct_killer_entity>, <parameter minecraft:block_entity>, <parameter minecraft:explosion_radius>]`
steel spindle
#

hello there, i have an trouble

I'am trying to start minecraft via console command (javaw)

error:

string(147) "Error: Could not find or load main class cpw.mods.modlauncher.Launcher

command:

lost matrix
steel spindle
#

man

sullen marlin
#

Also no version/stack trace given

granite olive
#

I tried just doing new LootContext.Builder(location).build(); before adding all the others

lost matrix
granite olive
steel spindle
#

which is why I'm trying to run the client through the command

lost matrix
lost matrix
quaint mantle
#

anyome know how to fix this

granite olive
#

just saw I'm not on the latest version so Im updating

halcyon hemlock
#

?whereami

halcyon hemlock
#

(was just testing something)

upper hazel
#

can i start in enable class when use config reload command?

lost matrix
upper hazel
#

??

#

I want to reload the plugin through its command

lost matrix
#

And what stops you from that?

granite olive
upper hazel
#

to reboot me need to run the enable method again

lost matrix
#

You dont need to disable the plugin to reload it

upper hazel
#

I know, but it will be easier than overwriting objects, etc.

#

bugs

lost matrix
#

It can mess up a ton of stuff and lead to bugs if you disable/enable a plugin on runtime

upper hazel
#

bruh but console do this end all normal

#

i no need disable plugion

#

i need restart

#

enable

granite olive
# granite olive so I updated everything to the latest version. I did realize that the server jar...

Do you think changing to a spigot jar would make a difference? Because I have some other plugins which would break and cause a mess. The trace from the pastebin is with LootContext lootContext = new LootContext.Builder(location).build(); instead of LootContext lootContext = new LootContext.Builder(location).lootedEntity(null).killer(null).lootingModifier(0).luck(0).build();. I want to fill chests when the chunk is loaded so thats why it starts with the chunkloadevent.

shadow night
#

is there a server reload event?

eternal oxide
#

no

#

but you can check Bukkit.getWorlds()isEmpty() in onLoad

slender elbow
#

yes there is

#

ServerLoadEvent

#

check the load type

eternal oxide
#

oh thats new

shadow night
#

how new?

#

I'm developing for a version a bit older

eternal oxide
#

I don;t belive its in 1.18

#

however its only useful for a reload

#

as you'd not be able to have an active listener for it during a startup

#

unless it fires after all plugins ran their onEnable.

hushed spindle
#

im trying to implement custom potion effects, what do you guys reckon would be the best way to display them? boss bars are an option, but i don't want to create a boss bar for each effect. if i fit all the potion effects into one boss bar it could also work, but you can't put multiple lines of text on one boss bar and the text will just go off screen. scoreboards maybe? action bar?

pseudo hazel
#

probably scoreboards

#

you can make it look pretty good with a custom reaourcepack

hushed spindle
#

yeah

#

though it doesnt strike me as the best option since you'll be limited to 15 items (not likely that you'll ever get that many but still) and it'll make my plugin incompatible with other scoreboard plugins

echo basalt
#

Hypixel just does it with tab

distant wave
#

can someone help me with nms? i dont have stuff like ServerPlayer

echo basalt
#

?nms

echo basalt
#

You probably want mappings

distant wave
#

damn it

distant wave
young knoll
#

?mappings

undone axleBOT
young knoll
#

Yeah you should

#

Do you have EntityPlayer?

distant wave
#

oh i do

#

the tutorial i followed had mojang mappings

young knoll
#

EntityPlayer is old spigot mappings

#

What version are you on

distant wave
#

1.18.2

young knoll
#

Hmm yeah that has mappings

#

Did you run buildtools with --remapped

eternal night
#

make sure your pom.xml defines the remappad artefact

distant wave
#

i use gradle

young knoll
#

Ah

distant wave
#

nobody is gonna stop me

eternal night
#

the tutorial is bad for you then

young knoll
#

You'll need to set up your own thing to remap then

eternal night
#

iirc there is some third party plugin for this

young knoll
#

Or use paperweight userdev

eternal night
#

@tender shard linked it somewhere here

#

or yea, userdev but that gets you paper

#

which you might not want, given you are in the spigot discord KEKW

distant wave
#

do i really want to switch to maven

#

just for this

#

bruh

young knoll
#

Wait did alex get something working for gradle?

eternal night
#

I think that was it

#

never used it

#

cannot comment on it

#

but I think that is what he used somewhere

young knoll
#

Even that tells you to use userdev

distant wave
#

alright but even tho im using spigot names, the plugin will still work right?

#

can i keep it like i have it now

eternal night
#

Yea I guess

#

but that is gonna be a terrible experience down the line

#

given those obfuscated names change on a per-version basis

distant wave
#

cant access org.craftbukkit.bukkit.v1_18_2 things for some reason

eternal night
#

I mean, doesnt hurt to try the plugin

distant wave
#

?nms

distant wave
#

is there any way to add mavenLocal to pom

young knoll
#

Should be automatically included

eternal oxide
#

a pom by default already uses local

distant wave
#

doesnt seem like it is

#

or am i missing somethingh

eternal oxide
#

did you run buildtools for it?

kind hatch
#

Did you run BuildTools?

distant wave
#

ive run what ?nms told me to do

#

see here

eternal oxide
#

?paste your buildtools log

undone axleBOT
kind hatch
#

IJ should be able to find the files if BuildTools completed successfully.

distant wave
eternal oxide
#

yep its in your local repo

kind hatch
#

Did you reload your pom?

eternal oxide
#

?paste your pom

undone axleBOT
distant wave
#

thats what im trying to do

#

ok

chrome beacon
#

/home/koblizek/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/spigot-1.18.2-R0.1-SNAPSHOT.jar

kind hatch
#

This button right here will reload the pom.

distant wave
#

bruh

kind hatch
chrome beacon
#

^^

#

Quite common

distant wave
#

oh frick

#

i think i know wheres the problem

#

i was running it from wsl

#

but thats weird

#

that shouldnt be a problem

#

well

#

it seems like it is

#

🤦‍♂️

chrome beacon
#

Yeah it installed to WSL m2

distant wave
#

can i just move the directories

chrome beacon
#

Should work

distant wave
#

is this normal

kind hatch
#

Sometimes lol

#

Try again in like 5 minutes

distant wave
#

yay

#

got it

#

serverplayer

#

YES

#

omg

#

got everything i need

#

hah

pallid stump
#

It's been a while since I created a plugin. Do the packages for net.minecraft.block and net.minecraft.entity no longer exist?

lilac dagger
#

they do exist

#

only now they have a different package

#

they're probably in world

chrome beacon
#

?nms

chrome beacon
#

^^

pallid stump
#

Ah thanks Olivo 😄 Looking for this

ember estuary
#

For Primed TNT, if the source is a dispenser, how can i get that block?

chrome beacon
#

Listen to the prime event or spawn event and store the block yourself

ember estuary
#

no method for it? oh damn

lost matrix
#

*Via pdc tag

ember estuary
#

ty

ember estuary
#

but there is no getWhoSpawned or similar on the EntitySpawnEvent

#

So how can i, when the TNT is spawned, get the dispenser that spawned it?

#

Can't find anything on google...

lost matrix
#

Im also thinking about how to track that. It must be possible but i cant think of a robust approach...

ember estuary
#

Maybe its just not possible with spigot? cuz spigot is missing an event for it?

lost matrix
#

There are plenty events being fired. Just need to connect the dots and get the source of the TNT spawn...

shadow night
#

Is there an event executed when a tnt becomes and entity?

ember estuary
#

it doesnt "become an entity", it always is an entity

lost matrix
ember estuary
#

the dispenser doesnt place it as a block

#

else i could use BlockDispenseEvent , that would be too easy

#

xD

#

is there a "dispenser getting activated" event with before and after state?

#

maybe i could use that, save it into a map, and then scan for tnt next to the dispenser

lost matrix
#

That would be the workaround. But there must be a non-hacky way for this

ember estuary
#

Can't think of one :/

leaden helm
lost matrix
#

What do you mean by "above the inventory slots"
You mean the hotbar?

lilac dagger
#

that's the actionbar

lost matrix
ember estuary
#

ItemStack getItem()

#

returns an itemstack not an entity ..

lost matrix
#

For what?

ember estuary
#

i dont think text above the inventory without a bossbar is possible

lost matrix
#

You cant really add text above the action bar without using highly modified resourcepacks

lilac dagger
#

yeah, sounds like something done from within a resource pack

lost matrix
ember estuary
#

Ahhh it actually gets triggered when placing tnt and returns the tnt as an itemstack??

lost matrix
#

Well yeah, the BlockDispenseEvent always gets triggered when anything is dispensed.

ember estuary
#

ah coool, alright, ill try that

lost matrix
#

Dont want to ask why a boolean is enough and a collection/map is not needed?

ember estuary
#

i was trying to find out via google, probably has to do with the MONITOR?. but yeah sure, explain pls :D

lost matrix
#

The events are all fired consecutively on the main thread, this means that the next EntitySpawnEvent after the BlockDispenseEvent will always
be the spawn event caused by the dispenser. There is no way that something else gets spawned 'in between' those two events.

ember estuary
#

ahh i see, that makes sense
So when i have two dispensers placing a TNT its
BlockDispenseEvent -> EntitySpawnEvent -> BlockDispenseEvent -> EntitySpawnEvent

lost matrix
#

Right

ember estuary
#

Instead of a boolean i'd use a variable that stores the dispenser location and then set that to null again, right?

#

cuz i wanna add the dispenser position to the TNTPrimed

lost matrix
#

If you need the dispenser in your context then yes. But manually setting a variable to null emits code smell to me.
There is probably a cleaner solution...

ember estuary
#

well i guess i can just not set it to null

#

it will be overwritten anyway

#

ah wait nah my bad, gotta tell how the entity was spawned

lost matrix
#

Then you have the problem that every TNT which is spawned normally will have the dispenser as its context.

ember estuary
#

true

#

I'll stick to this solution for now, can't think of a cleaner way :D

lost matrix
#

Me neither... Maybe a wrapper class which keeps a non-hard reference and a boolean.

robust helm
#

Any way to add additional tab completion to mojang commands? I want to make /gamemode 0 work

worldly ingot
#

Damn, I'm sorry you feel compelled to want to do that

robust helm
remote swallow
#

does the command already take /gamemode 0 with no tab complete

young knoll
#

No

lost matrix
# ember estuary I'll stick to this solution for now, can't think of a cleaner way :D
public class SingleUseUnit<T> {

  private T value = null;
  private boolean valid = false;

  public void renew(T value) {
    this.value = value;
    this.valid = true;
  }

  public T get() {
    Preconditions.checkState(valid, "Tried to gain access to invalid value.");
    this.valid = false;
    return this.value;
  }

  public boolean isValid() {
    return this.valid;
  }

}
public class TNTListener implements Listener {

  private final SingleUseUnit<Location> lastDispenseUnit = new SingleUseUnit<>();

  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onDispense(BlockDispenseEvent event) {
    if (event.getItem().getType() != Material.TNT) {
      return;
    }
    lastDispenseUnit.renew(event.getBlock().getLocation());
  }

  @EventHandler
  public void onSpawn(EntitySpawnEvent event) {
    if (!lastDispenseUnit.isValid()) {
      return;
    }
    Block dispenserBlock = lastDispenseUnit.get().getBlock();
    TNTPrimed tnt = (TNTPrimed) event.getEntity();
    // Do your stuff
  }
  
}
#

Woops, spam

#

This also has a bit of code smell because the renew and get methods have side effects...

lilac dagger
#

i was about to say

#

a singleuse unit sounds like trouble

lost matrix
#

I just dont like the idea of having to set a variable to null...

lilac dagger
#

yeah well

#

null is bug prone for sure

#

at least it saves on memory

#

i guess this was the reason null even was introduced to begin with

robust helm
#

rn im just replacing the first argument in the gamemode command from 0 to adventure, from 1 to creative and so on

timid hedge
timid hedge
lost matrix
#

You can either use the base64 value or the URL.
Btw the value is simply encodes some nbt into a base64 String.
Example:

eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTRkNDhhYzdlNjViOTE0Njc5MDRmMmY0ZDE1NDU1Njc3NmZmYTljZDJkNTI2YjEyYTA0OTliYjU5Y2M2NTZjNyJ9fX0=

Decodes to

{"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/54d48ac7e65b91467904f2f4d154556776ffa9cd2d526b12a0499bb59cc656c7"}}}
remote swallow
#

Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. I’ll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...

timid hedge
#

Can someone please help me with getting the center of a block?
When im trying to get the center of a end portal frame and place a head there it isnt in the middle it is placed where the center would be at a "normal block"

lost matrix
# timid hedge Thanks
  public void changeSkullTexture(Block block, URL textureUrl) {
    Preconditions.checkState(block.getType() == Material.PLAYER_HEAD);
    Skull skull = (Skull) block.getState();
    PlayerProfile profile = Bukkit.createPlayerProfile("_DUMMY_");
    PlayerTextures textures = profile.getTextures();
    textures.setSkin(textureUrl);
    skull.setOwnerProfile(profile);
    skull.update(true);
  }

The URL can be created by using

new URL("http://textures.minecraft.net/texture/54d48ac7e65b91467904f2f4d154556776ffa9cd2d526b12a0499bb59cc656c7");

for example

lost matrix
quaint mantle
timid hedge
timid hedge
lost matrix
shadow night
#

If I'm gonna be honest 1.8 is absolutely shit for dev

lost matrix
#

?1.8

undone axleBOT
lost matrix
acoustic hedge
#

hi is this server to help making a server and optimize the server for better performance

shadow night
quaint mantle
lost matrix
#

Isnt there a thread for performance tuning?

#

?performance

#

?spark

#

?optimization

acoustic hedge
ancient plank
#

Might be able to use display entities in 1.20 but idk I haven't used them yet

acoustic hedge
#

so I can ask any question here and people can help me because I'm new to this

lost matrix
ancient plank
acoustic hedge
ancient plank
#

Aye

acoustic hedge
#

oh ok👍

lost matrix
#

*Writing plugins, forking spigot, writing any tools. Anything dev related really.

#

Sometimes also just discussing general java

timid hedge
remote swallow
#
    @Override
    public void setTexture(SkullMeta meta, String texture) {
        GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
        PropertyMap propertyMap = gameProfile.getProperties();
        propertyMap.put("textures", new Property("textures", texture));

        try {
            Field profileField = meta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(meta, gameProfile);
            profileField.setAccessible(false);
        } catch (NoSuchFieldException | IllegalAccessException ex) {
            ex.printStackTrace();
        }
    }
young knoll
#

🥄

remote swallow
#

shut up choco

lost matrix
lost matrix
ancient plank
#

Crazy that there are people who were born after 1.8 was released who play Minecraft

young knoll
#

tbf like toddlers play minecraft

lost matrix
#

Pretty sure that the average 1.8 player is younger than the game version itself kappa

young knoll
#

3 years ago was 1.15

smoky oak
#

?1.1.8

#

?1.8.8

#

?1.8

undone axleBOT
lost matrix
#

Im still waiting for someone to actually write a decent new combat system.
It would also make hacking way more difficult if you just introduced completely new mechanics.

young knoll
#

Nah it's only 8 years 1 month

smoky oak
young knoll
#

only

lost matrix
#

Thats what i picture the average 1.8 player as.
8 years old, ADD driven, just wanna click and run fast.

young knoll
#

A mod would be much better for making a new combat system

#

Since you can modify the client as well

granite olive
#

Is LootContext not intended to be used for loot that is generated for chests? If so what should be used to pregenerate loottable loot in a chest (I need it generated before the player opens it because the loot determines the chest type)
I only found a couple of forum posts which use fillinventory to fill a chest inventory but they all failed and I cant find much related to pregenerating loot chests at all :(
This is what I currently have:

        chest.getLootTable().fillInventory(chest.getInventory(), random, lootContext);```
I am on the latest 1.20.1 version and this is the error I get:
```java.lang.IllegalArgumentException: Missing required parameters: [<parameter minecraft:block_entity>, <parameter minecraft:killer_entity>, <parameter minecraft:damage_source>, <parameter minecraft:explosion_radius>, <parameter minecraft:direct_killer_entity>, <parameter minecraft:tool>, <parameter minecraft:last_damage_player>, <parameter minecraft:this_entity>, <parameter minecraft:block_state>]
        at net.minecraft.world.level.storage.loot.LootParams$Builder.create(LootParams.java:132) ~[?:?]```
lost matrix
granite olive
#

the second one

lost matrix
dire bluff
#

hello how to execute

lost matrix
lost matrix
dire bluff
#

lol bro mean

granite olive
lost matrix
dire bluff
#

whatever

smoky oak
#

qq, can a itemStack that is specifically not air return null for getItemMeta?

smoky oak
#

ok

dire bluff
#

can someone at least help me with that

#

or fuck off

lost matrix
granite olive
dire bluff
#

dude i need to make when a player join first time console execute a command

lost matrix
smoky oak
#

my entire codebase is workarounds for spigot nonsense

ancient plank
# dire bluff or fuck off

don't get snappy when you ask a non-question and get a joke answer

hello how to execute
is not a valid question for this channel

#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

echo basalt
#

a hard location reference can cause memory leaks when the world gets unloaded

thin iris
#

hi so i tried this now and this is the result. it.. kinda works? it stops half way tho (loc is the end of the cable thingy btw, where the block intersects with the cable)
https://hastebin.com/share/iqufoqeqix.java

lost matrix
#

Decrease the gravitational strength in the calculation

thin iris
lost matrix
#
tensionForce.multiply(-gravityForce.length());

->

tensionForce.multiply(-gravityForce.length() * 0.1);

Or simply define

Vector gravityForce = new Vector(0, -0.1, 0);
echo basalt
#

are you sure it's not because you're flying

thin iris
lost matrix
#

Show result

thin iris
#

kk

#

give me a min my pc is slow and obs takes forever

thin iris
#

i think its cute

#

maybe you should make artificial spell mob particles around you

#

with custom colors

lost matrix
hushed spindle
#

you can do that..?

hushed spindle
young knoll
#

Core shader

lost matrix
hushed spindle
#

will core shaders not also remove those red numbers on scoreboards that aren't mine

fervent gate
#

Is there a way you can make an npc walk to a certain location using all packets? This is the code I have right now. I also have the issue that I can't get him to face a different way.
https://paste.md-5.net/uweparekey.java

smoky oak
#

cant you just tell it to walk there?

lost matrix
quaint mantle
#

Good check

pseudo hazel
#

lmao

fervent gate
echo basalt
#

you need a pathfinding algorithm

#

and then a lot of interpolation for it to look smooth

fervent gate
#

Oh true, but suppose I make sure all the paths are clear. Like I could just implement some points that he could walk to that are hardcoded

thin iris
fervent gate
#

would that make things easier?

thin iris
lost matrix
fervent gate
echo basalt
#

it's the interpolation that's the funky part

#

not making it look robotic n such

lost matrix
# thin iris <@220605553368498176>

Revert the gravity to 0, -1, 0 and simply add less on it to the total:

Vector total = tensionForce.clone().add(gravityForce);

->

Vector total = tensionForce.clone().add(gravityForce.multiply(0.1));
fervent gate
#

or replicate so to say

echo basalt
#

Uhh

#

Citizens has the best pathfinder imo

#

PlayerNPC is client-sided however

#

ZNpcs is client-sided too iirc

#

No clue if it has a pathfinder or not

lost matrix
#

Last time i looked at their code i uninstalled it from my server.
Might be better now...

echo basalt
#

citizens is doodoo in terms of code

#

it's really hacky

pseudo hazel
#

lol

echo basalt
#

It was so shit we switched our codebase to minestom

pseudo hazel
#

it got the job done I guess xD

fervent gate
#

damn

pseudo hazel
#

isnt there a citizens2 now? or is that the same one

echo basalt
#

same one

#

It's still shit

#

and if you have any suggestions they'll just tell you to PR

#

If you throw a tantrum about how the code is shit they just tell you they have a limited budget

#

even though they made like 80 grand in donations

fervent gate
echo basalt
#

uhh

#

head rotation is part of the movement packet

#

you have body rotation and head rotation

fervent gate
#

is that this?

public void lookGregory(int npcId, @NotNull Player player, int yaw, int pitch, boolean onGround) {
    ServerGamePacketListenerImpl ps = ((CraftPlayer) player).getHandle().connection;
    ps.send(new ClientboundMoveEntityPacket.PosRot(npcId, (short) 0, (short) 0, (short) 0, (byte) yaw, (byte) pitch, onGround));
}

public void moveGregory(int npcId, @NotNull Player player, int deltaX, int deltaY, int deltaZ, boolean onGround) {
    ServerGamePacketListenerImpl ps = ((CraftPlayer) player).getHandle().connection;
    ps.send(new ClientboundMoveEntityPacket.PosRot(npcId, (short) deltaX, (short) deltaY, (short) deltaZ, (byte) 0, (byte) 0, onGround));
}
thin iris
#

lookGregory

echo basalt
#

probably

thin iris
#

😭

fervent gate
echo basalt
#

I'd like

#

make an npc object

lost matrix
#

Yes for sure

echo basalt
#

tbh I'm pretty sure I did start work on a whole PacketEntities project

fervent gate
#

Yea that is what I'll do

thin iris
echo basalt
lost matrix
echo basalt
#

~30gb IdeaProjects folder

thin iris
#

video incoming

echo basalt
#

over the span of the last 7 years

thin iris
echo basalt
#

On average I make like 1.2 projects per week

#

something like that

fervent gate
zealous osprey
smoky oak
#

why does an abstract class need to instantiate final fields?

thin iris
#

fuck i can only send 25mb

echo basalt
#

something like that

thin iris
echo basalt
#

easy way is to just make an abstract method to create the field

thin iris
#

what does the final keyword actually do

echo basalt
#

and call it on the constructor

echo basalt
thin iris
#

it runs every tick

echo basalt
#

lower its duration maybe

thin iris
#

i cant do that

#

its a move for a api and that's like auto methods made when i extend the class

echo basalt
#

p sure the approach I'd take would be making a bezier curve between an intermediate point between the target block

#

but whatever

#

7smile7 knows maths more than I do

pseudo hazel
#

like making a function to initialize it instead and just making that function abstract

chrome beacon
smoky oak
tranquil beacon
#

?nms

tranquil beacon
#

?mappings

undone axleBOT
hushed spindle
#

oh does anyone have any up to date core shaders that hide the lil red icons from scoreboards?

#

the ones online either dont work or dont work fully

bronze flax
#

Hi, anyone can create for me a .jar for a project of github?

smoky oak
#

?work

bronze flax
#

I don't have idea how to make the .jar

smoky oak
#

ah

#

look up a plugin tutorial

chrome beacon
#

Pay for the plugin

smoky oak
#

clone github repo

#

done

bronze flax
#

Is a fork for one plugin to work in geysermc (bedrock users)

kindred sentinel
#

How to get open book event?

thin iris
#

playerinteract event

#

right clic

#

if item in hand is book

fervent gate
#
public void lookGregory(int npcId, @NotNull Player player, int yaw, @NotNull ServerPlayer npc) {
    ServerGamePacketListenerImpl ps = ((CraftPlayer) player).getHandle().connection;
    ps.send(new ClientboundRotateHeadPacket(npc, (byte) yaw));
}

Are there any problems with this code? The code is being ran but it doesnt work on the npc

kindred sentinel
#

ok

echo basalt
#

thing

fervent gate
#

Ok but it doesnt even rotate anything when I give it a random value

echo basalt
#

y'know

#

you'll have issues if the yaw is above like 255

#

just trust me on this one

fervent gate
#

Alright, I'll try that

lofty badge
#

Guys, hello. Maybe who knows, how place items like this? menu.setItem(0, item_6); menu.setItem(1, item_6); menu.setItem(2, item_6); menu.setItem(3, item_6); menu.setItem(4, item_6); menu.setItem(5, item_6); menu.setItem(6, item_6); menu.setItem(7, item_6); menu.setItem(8, item_6); menu.setItem(9, item_6); menu.setItem(10, item_6); menu.setItem(11, item_6); menu.setItem(12, item_2); menu.setItem(13, item_3); menu.setItem(14, item_4); menu.setItem(15, item_5); menu.setItem(16, item_6); menu.setItem(17, item_6); menu.setItem(18, item_6); menu.setItem(19, item_6); menu.setItem(20, item_6); menu.setItem(21, item_6); menu.setItem(22, item_6); menu.setItem(23, item_6); menu.setItem(24, item_6); menu.setItem(25, item_6); menu.setItem(26, item_6); menu.setItem(27, item_6);

echo basalt
#

oh fuck no

#

fuck no

lofty badge
fervent gate
lofty badge
kindred sentinel
#

forEach...

echo basalt
#

learnjava moment

fervent gate
#

A regular for loop would be good for this, I'd suggest you look into that

lofty badge
#

I can send all code

echo basalt
fervent gate
lofty badge
#
        Inventory menu = Bukkit.createInventory(null, 27, "Меню сервера");

        ItemStack item = new ItemStack(Material.ARMOR_STAND);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("§f§lПрофиль");
        item.setItemMeta(meta);

        ItemStack item_2 = new ItemStack(Material.ITEM_FRAME);
        ItemMeta meta_2 = item_2.getItemMeta();
        meta_2.setDisplayName("§f§lВарпы");
        item_2.setItemMeta(meta_2);

        ItemStack item_3 = new ItemStack(Material.BIRCH_SIGN);
        ItemMeta meta_3 = item_3.getItemMeta();
        meta_3.setDisplayName("§f§lАукцион");
        item_3.setItemMeta(meta_3);

        ItemStack item_4 = new ItemStack(Material.PINK_SHULKER_BOX);
        ItemMeta meta_4 = item_4.getItemMeta();
        meta_4.setDisplayName("§f§lКейсы");
        item_4.setItemMeta(meta_4);

        ItemStack item_5 = new ItemStack(Material.BOOK);
        ItemMeta meta_5 = item_5.getItemMeta();
        meta_5.setDisplayName("§f§lДонат и помощь");
        item_5.setItemMeta(meta_5);

        ItemStack item_6 = new ItemStack(Material.PINK_STAINED_GLASS_PANE);
        ItemMeta meta_6 = item_6.getItemMeta();
        item_6.setItemMeta(meta_6);

        menu.setItem(0, item_6);
...
        menu.setItem(12, item_2);
        menu.setItem(13, item_3);
        menu.setItem(14, item_4);
        menu.setItem(15, item_5);
        menu.setItem(16, item_6);
...

        player.openInventory(menu);
    }```
remote swallow
#

it is time to

remote swallow
#

?learnjava!

undone axleBOT
echo basalt
kindred sentinel
#

oh shit i thought that i don't know java...

echo basalt
#

my menu engine lets me work with selections directly

lofty badge
echo basalt
#

I can also load menus from the config

thin iris
#

someone did this to me earlier

echo basalt
#

:)

fervent gate
kindred sentinel
#

how to get player shift?

#

like

echo basalt
#

PlayerToggleSneakEvent

#

player.isSneaking

kindred sentinel
#

oh yeah, thanks

lofty badge
echo basalt
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

echo basalt
#

we're not your personal developers

lofty badge
quaint mantle
lofty badge
#

Rate my rewrited code: ``` ItemStack glassPane = new ItemStack(Material.GLASS_PANE);
ItemMeta glassMeta = glassPane.getItemMeta();
glassMeta.setDisplayName(" ");
glassPane.setItemMeta(glassMeta);

for (int i = 0; i < menu.getSize(); i++) {
    if (menu.getItem(i) == null) {
        menu.setItem(i, glassPane);
    }
}```
lost matrix
lofty badge
remote swallow
#

those panels wont be pink

#

they will be clear

wary harness
#

would it better be having

  1. items hashset and then loop thru them in one bukkitrunnable repeatable task to update what it needs
  2. would it be the same if each instance of custom Item has its runnable and check if item need to be update
    Second option would avoid checking if item is updatable and will not need to be looping thru all items in hashset
    I need to update place holder at that item instance once a second
chrome beacon
#

Personally I'd use 1

lost matrix
#

Keeping references to ItemStacks can be very miserable.

chrome beacon
#

Also you can just keep a hashset of only updatable items

#

To skip to update check

wary harness
lost matrix
#

If we generalize this problem, then having one runnable with many tickable objects is always preferable to having one runnable for each object

wary harness
#

and making one Hashset contaning updatable items

lost matrix
#

Why a hashset?

wary harness
lost matrix
#

Depending on how you implement the eviction i would maybe propose a LinkedList

wary harness
#

what is benefit of LinkedList ?

pseudo hazel
#

cant you initialize it by doing this.thing = determineThingValue()?

lost matrix
#

O(1) removal of elements while iterating

wary harness
lost matrix
# wary harness oh yeah I see
public class SomeRunnable implements Runnable {
  
  private final LinkedList<Something> elements = new LinkedList<>();
  
  public void add(Something element) {
    this.elements.add(element);
  }
  
  @Override
  public void run() {
    this.elements.removeIf(this::tickAndCheck);
  }
  
  private boolean tickAndCheck(Something element) {
    element.tick();
    return element.isDone();
  }
  
}

Something like this

lofty badge
lost matrix
lost matrix
glossy venture
#

you could order them on completion and use a linkedlist as a deque

#

so you can have O(1) tick time

lost matrix
#

What do you mean by "order them on completion" ?

slender elbow
#

void onComplete()
order()

lost matrix
slender elbow
#

you missed the part where you laugh at my humorous joke

lost matrix
#

Im tiered and confused

hushed spindle
#

added some core shaders to my resource pack and it broke all custom unicode characters

#

removed the shaders and they remain broken

#

no errors in logs

#

i hate this

lost matrix
#

Well thats bad

hushed spindle
#

i guess thats what they usually call a skill issue

smoky oak
#

and even if i make a method itll be like 'Cannot change final'

carmine mica
#

don't make them final? final fields have to be initialized in the constructor

lost matrix
#

final fields need to be either initialized by the class or a constructor

smoky oak
#

well yea but

#

this is an interface

lost matrix
#

interfaces cant have any fields at all

carmine mica
#

^

smoky oak
#

*abstract class

carmine mica
#

then it has to be initialized in the constructor for that abstract class

smoky oak
#

they're basically the same at this point

lost matrix
#

Or you do this:

protected abstract int getFirstCooldown();
protected abstract int getSecondCooldown();
#

Otherwise you need a constructor

smoky oak
#

oh thats smart

#

ill probs just keep them not-final and init them if appropriate

#

unfortunately u cant extend two classes which would solve this dilemma

floral drum
smoky oak
#

(and no, having an intermediary abstract class wouldn't work since i am already doing that for a much larger feature)

lost matrix
hushed spindle
#

oh i know why my icons werent working

#

minecraft deselected my resource pack

smoky oak
#

urgh i do NOT want to refactor my code for that

hushed spindle
#

fuck you too minecraft

smoky oak
#

but

#

i can make an interface for the timers

#

requires some instanceof but not much luckily

#

actually that wouldnt be instanceof would it?

#

can instanceof check if a class is implementing an interface?

lost matrix
#

No idea what you are doing but there is probably a clean abstraction model you could come up with that doesnt involve instanceof checking

smoky oak
#

well

keen basin
#

is there a way to place sugar cane without water ?

smoky oak
lofty badge
#

guys, who know how to make random? (let's say, drop1 = 50%, drop2 = 25%, drop3 = 25%)

smoky oak
smoky oak
#

i mean i could put a boolean in the parent class that is like 'you are implementing timer' but that still wouldnt give me access to the fields / methods of the interface

#

(the real joke here is that all but like 1 in 17 classes probably require said timer, and I'd rather not put it into the abstract class)

pulsar parcel
#

Can someone explain to me, why is my for loop not working? Like I have several checks, before and after the loop. It writes in the console, that it looped, but than it should type every player online to the console, but it does nothing. And yes, there are players online to loop through. Here is my method. https://pastebin.com/JYkHL0Dn

lost matrix
# lofty badge guys, who know how to make random? (let's say, drop1 = 50%, drop2 = 25%, drop3 =...

This is not so easy. This is usually solved by using weights instead of chances.
The general idea looks like this:

Given 3 choices (A, B and C) assign a weight to each choice:

A - 200
B - 300
C - 400

Every weight uses the prior weight as bottom. It uses the previous floor + its own weight as its own floor.

A: (0 - 200)
B: (201 - 500)
C: (501 - 900)

Now create a sum of all weights (max_sum):
200 + 300 + 400 = 900

Generate a number between 0 and max_sum to select a random item
from this weighted table.

Eg. random = 332 -> results in choice B as its within (201 - 500)

The actual chance of an element is calculated as (chance = weight / max_sum)
So the chance for
A: 200 / 900 = 0.222 = 22.2%
B: 300 / 900 = 0.333 = 33.3%
C: 200 / 900 = 0.444 = 44.4%

If you want to create an easy to follow chance system, then your weights should sum up to something like 1000 or 10000:

#

Best performance [ O(log n) ] can be achieved by using a NavigableMap.
I prefer to use either a TreeMap from Java or a RangeMap from google guava

heavy maple
#

how could I get the name of the block?

kindred sentinel
#

Help pls
result "Invalid Book tag"
book in hand: "ABC"
code:

    @EventHandler
    public void playerInteractEvent(PlayerInteractEvent event){
        Action action = event.getAction();
        if(action.equals(Action.RIGHT_CLICK_BLOCK) || action.equals(Action.RIGHT_CLICK_AIR)){
            ItemStack playerHandItem = event.getItem();
            Player player = event.getPlayer();
            if(playerHandItem != null && playerHandItem.getType().equals(Material.WRITABLE_BOOK) && player.isSneaking()){
                BookMeta bookMeta = (BookMeta) event.getItem().getItemMeta();
                if(bookMeta != null && bookMeta.hasPages()){
                    ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK);
                    BookMeta newBookmeta = (BookMeta) newBook.getItemMeta();
                    bookMeta.getPages().forEach(page -> newBookmeta.addPage(page));
                    newBook.setItemMeta(newBookmeta);
                    event.setCancelled(true);
                    player.openBook(newBook);
                }
            }
        }
    }
thin iris
#

my pendulum still isnt working.. 😦

lost matrix
lost matrix
kindred sentinel
#

if this block is container with inventory you can do Nameable block = (Nameable) block.getInventoryHolder()

#

or something like this

#

and block.getCustomName()

thin iris
#

get the material get the data get the name

kindred sentinel
upper hazel
#

Crimson - npc plugin?

heavy maple
kindred sentinel
#

oh shit i got it

#

oh

#

no

kindred sentinel
#

i didn't get it

#

sorry

lost matrix
kindred sentinel
# lost matrix Try to copy the pages in bulk and not with a for loop. Also set a title to the b...
@EventHandler
    public void playerInteractEvent(PlayerInteractEvent event){
        Action action = event.getAction();
        if(action.equals(Action.RIGHT_CLICK_BLOCK) || action.equals(Action.RIGHT_CLICK_AIR)){
            ItemStack playerHandItem = event.getItem();
            Player player = event.getPlayer();
            if(playerHandItem != null && playerHandItem.getType().equals(Material.WRITABLE_BOOK) && player.isSneaking()){
                BookMeta bookMeta = (BookMeta) event.getItem().getItemMeta();
                if(bookMeta != null && bookMeta.hasPages()){
                    ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK);
                    BookMeta newBookmeta = (BookMeta) newBook.getItemMeta();
                    newBookmeta.addPage("AAAA", "B", "CCC");
                    newBook.setItemMeta(newBookmeta);
                    event.setCancelled(true);
                    player.openBook(newBook);
                }
            }
        }
    }

event this don't work

smoky oak
kindred sentinel
#

but maybe i should really add title

smoky oak
#

check api

lost matrix
kindred sentinel
#

yeah ok, thanks

lost matrix
kindred sentinel
#

i know it, but i tried different methods to solve problem

kindred sentinel
lost matrix
#

You can still clone the book and replace stuff in there afterwards

upper hazel
#

Znpc plugin contains api for use?

kindred sentinel
kindred sentinel
#

oh

#

not to clone

#

to open book

pulsar parcel
kindred sentinel
#

How to close book if book was oppened? If i'm trying to do playerInteractEvent.setCancelled(true);
book isn't closing

upper hazel
#

CMI can create npc?

#

i use him api 💀

smoky oak
#

Does Bukkit#getWorlds() return a specifically ordered list? Specifically, if run on a server without extra worlds / less worlds than normal, is the order of the returned worlds always normal, nether, end?

echo basalt
#

getWorlds.get(0) usually returns the "spawn" world where new players are tossed

austere cove
#

(not part of the specs tho so this behaviour can change)

smoky oak
#

hm

#

ill iterate em and check their time then

#

is it better to do world.getfulltime twice per world, or to cache it in a local variable

#
    /**
     * Returns the time in the world with the highest time
     */
    public static long serverTime(){
        long time = 0;
        for(World world : Bukkit.getWorlds())
            if(world.getFullTime() > time)
                time = world.getFullTime();
        return time;
    }
echo basalt
#

cache on a local variable, always

#

I'd probably implement my own Comparator class

#

And just sort

smoky oak
#

actually

#

would saving em to a list and sorting the list work

#

or would that be slower

echo basalt
#

that seems slower

smoky oak
echo basalt
#

bros got no clue what he's doing

#

Just declare it in the loop

smoky oak
#

huh i just learned a for loop apparently isn't a separate 'namespace' or whatever you call it in java

upper hazel
#

Is it possible to add models to NPCs in Citizens?

echo basalt
#

technically yes

#

but in practice no

#

I have a plugin for it tho

#

because citizens is a bitch and likes to constantly respawn entities

#

you need to like

#

make an armorstand that constantly tracks the npc

#

when that armorstand gets hit, call the npc click event

#

damage it

#

whatever

#

WHen the npc dies, armorstand dies too

#

and then you just model that armorstand with modelengine

upper hazel
#

what obaut texturs

#

a wiat

#

customModelData