#help-development

1 messages · Page 257 of 1

echo basalt
#

isn't that just part of the InventoryClickEvent?

formal bear
#

I already made InventoryClickEvent, and cancelled when custominventory is opened

#

and setcancelled below

#

it works with mouse click or key from 0-9

#

but not on F (item swap)

ruby pebble
#

How do I cancel the results of a processed event and run the code and call the event again? the player will not have to do it again

remote swallow
#

dont cancel the event?

#

you would just create a loop

formal bear
ruby pebble
#

When an event runs, the event will be canceled, then the code will run and then I will call the event, but I don't know how to call it.

hybrid spoke
#

you just dont

#

what are you trying to achieve

formal bear
#

it would run in loop lol

ruby pebble
hybrid spoke
#

what

#

areyou

#

trying to do

formal bear
#

u want to call it once just make an variable or smh

ruby pebble
#

but I need to reflect the event results to the player

remote swallow
#

what do you want the event to do

#

or the code to do

ruby pebble
#

So, is the event data given to the player after processing or is it unprocessed? Do I need to set the variable before or after stopping the event?

hybrid spoke
#

if the event is cancelable, it will always fire before the action actually happened

#

otherwise canceling it wouldnt make sense except on twitter

formal bear
#

if (event.getClick().equals(ClickType.SWAP_OFFHAND)) event.setCancelled(true); I'm running of of ideas, how to disable swapping item to offhand 💀

formal bear
#
    public void onPlayerSwapping(PlayerSwapHandItemsEvent event) {

        Player player = event.getPlayer();

        if (player.getOpenInventory().equals(serverSelector.getInventory(player.getUniqueId()))) event.setCancelled(true);

    }```Still nothing
tender shard
#

then it's not the same inventory

formal bear
#

I i cannot move it in previous event, why i can swap it tho

cedar edge
#

got any idea how I can get the custom item in as an item stack in the spigot?

tender shard
#

wdym with custom item

formal bear
# formal bear I i cannot move it in previous event, why i can swap it tho
    public void onPlayerInteraction(InventoryClickEvent event) {

        Player player = (Player) event.getWhoClicked();

        Inventory inventory = event.getClickedInventory();

        if (event.getClick().equals(ClickType.SWAP_OFFHAND)) event.setCancelled(true);

        if (serverSelector.getInventory(player.getUniqueId()).equals(inventory)) event.setCancelled(true);

    }

    @EventHandler
    public void onPlayerSwapping(PlayerSwapHandItemsEvent event) {

        Player player = event.getPlayer();

        if (player.getOpenInventory().equals(serverSelector.getInventory(player.getUniqueId()))) event.setCancelled(true);

    }```java
#

One event works, the other does not

tender shard
cedar edge
tender shard
#

at least not right now

cedar edge
#

what are my options then?

hybrid spoke
tender shard
cedar edge
modern vigil
#

i don't think datapacks offer truly custom items

cedar edge
#

but how will I give them the custom texture?

cedar edge
remote swallow
#

that you can do

hybrid spoke
#

itemstacks have custommodeldata

hybrid spoke
cedar edge
#

so like there is no way for me to do it without remaking the items in NMS?

modern vigil
formal bear
#

if its fired

hybrid spoke
#

is it fired?

#

is it also the same inventory?

formal bear
#

it seems its not firing tho xD i even changed it to only one line of event.setCancelled

hybrid spoke
#

debug it and see

formal bear
#

idk im pressing F

hybrid spoke
#

dont wildguess

cedar edge
modern vigil
modern vigil
cedar edge
#

anyway

#

thanks

chrome beacon
#

You can

cedar edge
#

I can?

#

oh my savior

modern vigil
#

yea u can

cedar edge
#

how?

modern vigil
#

first get the nbt

cedar edge
#

nbt?

formal bear
chrome beacon
#

Use a recipe exact choice as a ingredient

formal bear
#

New discovery for me

modern vigil
#

yea the custommodeldata, custom item name, etc

cedar edge
#

ok

hybrid spoke
rich condor
#

permissions:
protectionstones.create:
description: Protect a region by placing a ProtectionStones block.
default: op
protectionstones.destroy:
description: Allow players to remove their own protected regions (block break).
default: op

hybrid spoke
#

but didnt even knew that you can just offhand swap items out of inventories

rich condor
#

how i can give permissions to players?

formal bear
#

So how to cancel inventory slot -> offhand

tender shard
#

or do you want to code your own perms plugin?

#

if so, you need to create a PermissionAttachment

cedar edge
formal bear
#

Ok it's shadow item lol

#

I was on creative

cedar edge
#

thanks

rich condor
formal bear
tender shard
hybrid spoke
tender shard
#

or lightperms

#

or permissionsEx

wooden garnet
#

why i can't change variables inside java lambdas

tender shard
#

or groupmanager

hybrid spoke
#

or groupmanager

wooden garnet
#

why this language is so retatded

hybrid spoke
tender shard
#

use Atomics if you need to change stuff in a lambda

#

e.g. AtomicReference<String>

wooden garnet
wooden garnet
rich condor
tender shard
rich condor
#

ok

tender shard
rich condor
#

thanks

wooden garnet
tender shard
#

in java you don't have to worry about memory management, pointers, and stuff

#

so yeah just use Atomics and you'll be fine

wooden garnet
#

pointers are extremely useful and helpful if u understand them

wooden garnet
#

haven't touched java for over 4 years lol

tender shard
#

what type does your variable have btw?

#

is it a primitive or an actual object?

wooden garnet
#

it was primitive int

tender shard
#

then you can use AtomicInteger

frail temple
#

Somebody can explain me this? Basiclly my problem is that I try get placed exact block coordinates with onBlockPlace it gets me these coordinates -135 64 -77 but when I teleport to them in coordinates shows that im in -134.500 64 -76.500?

frail temple
#

I should change to spigot?

tender shard
#

iirc paper does some weird "fixes" that make you unable to choose the exact target destination

#

please try whether it still happens on regular spigot

chrome beacon
frail temple
#

Now changed to spigot api and it says that package org.bukkit.persistence does not exist

#

But what... ;d how if it exist

#

I'm using 1.13

frail temple
#

To get them

chrome beacon
#

To get what

#

NBT?

frail temple
#

persistence

chrome beacon
#

What are you trying to do

frail temple
#

I set with them to blocks value

tender shard
#

who uses 1.13? o0

frail temple
tender shard
#

nonone uses 1.13 anymore

chrome beacon
#

The persistence api doesn't exist in 1.13

#

You will have to implement your own

tender shard
#

1.13 isn't even in the chart

#

I always code stuff for 1.16.5+

frail temple
#

hmm

tender shard
#

less than 10% use versions older than 1.16

hybrid spoke
#

1.5.2-1.19.3

tender shard
#

the only versions actually used are 1.8, 1.12, 1.16, 1.17, 1.18 and 1.19

#

noone uses 1.13 anymore, people are either stuck on pre 1.13 or are at least close to latest (1.16+)

faint sedge
#

hey ! i get an error damager cannot be resolved as a variable

@EventHandler
    public void onPlayerHurt(EntityDamageByEntityEvent event) {
        if (event.getEntity() instanceof Player && (event.getDamager() instanceof LivingEntity || event.getDamager() instanceof Projectile)) {
            Player playerHurt = (Player) event.getEntity();
            if (event.getDamager() instanceof LivingEntity) {
                LivingEntity damager = (LivingEntity) event.getDamager();
            } else {
                if (! (((Projectile) event.getDamager()).getShooter() instanceof LivingEntity)) {
                    event.setCancelled(true);
                    return;
                }
                LivingEntity damager = (LivingEntity) ((Projectile) event.getDamager()).getShooter();
            }
            for (PotionEffect effect: playerHurt.getActivePotionEffects()) {
                if (effect.getType().equals(PotionEffectType.SLOW) && effect.getAmplifier()> 200) {
                    double damage = event.getDamage();
                    if (damager instanceof Player) {
                        ((Player) damager).playSound(damager.getLocation(), Sound.BAT_DEATH, 1, 1);
                        ((Player) damager).sendMessage("Vous venez d'attaquer un joueur protégé par une §7Pierre de Stase.");
                    }
                        
                    damager.damage(damage);
                    playerHurt.playSound(playerHurt.getLocation(), Sound.ANVIL_BREAK, 1, 1);
                    event.setCancelled(true);
                }
            }
        }
    }```
I can't figure out why :/
wooden garnet
#

yes

tender shard
#

when you do a local variable, it only works until the }

#

so basically, move the declaration of "damager" to the top of the method and it will work

echo basalt
#

Think of code blocks as boxes

#

And variables as labels

tender shard
#

you declare "damager" and then you close the code block with }, rendering the variable useless again

echo basalt
#

You can't access labels outside of the box where it belongs basically

#

Also look into anti-nesting patterns

faint sedge
#
LivingEntity damager;
            if (event.getDamager() instanceof LivingEntity) {
                damager = (LivingEntity) event.getDamager();
            } else {
                if (! (((Projectile) event.getDamager()).getShooter() instanceof LivingEntity)) {
                    event.setCancelled(true);
                    return;
                }
                damager = (LivingEntity) ((Projectile) event.getDamager()).getShooter();
            }
            for (PotionEffect effect: playerHurt.getActivePotionEffects()) {
                if (effect.getType().equals(PotionEffectType.SLOW) && effect.getAmplifier()> 200) {
                    double damage = event.getDamage();
                    if (damager instanceof Player) {
                        ((Player) damager).playSound(damager.getLocation(), Sound.BAT_DEATH, 1, 1);
                        ((Player) damager).sendMessage("Vous venez d'attaquer un joueur protégé par une §7Pierre de Stase.");
                    }
                        
                    damager.damage(damage);
                    playerHurt.playSound(playerHurt.getLocation(), Sound.ANVIL_BREAK, 1, 1);
                    event.setCancelled(true);
                }
            }```
#

Like this ?

faint sedge
wooden garnet
undone axleBOT
ruby pebble
#

How do I get how much health an item has decreased using the PlayerItemDamageEvent event?

undone axleBOT
ruby pebble
#

I couldnt find it

#

No

remote swallow
#

type your event

ruby pebble
#

ok i'm blind

remote swallow
#

top right

#

type your event

#

first method

faint sedge
#

OnEntityDamagedByEntity

#

And I’m sending a message to the damager

remote swallow
#

if (event.getEntity() instanceof Player player) { send message }

#

no

#

if you arent using like 1.16 or higher no help from like a lot of us

royal hawk
#

Hello guys, how i can get default time potion in ticks from bottle after brew?
I'm tried read potion meta but i'm don't find default time.

 PotionMeta meta = (PotionMeta) item.getItemMeta(); // here not found default time
faint sedge
#

I mean, if it's a mob that's hurting a player, i have to check if it's a player, and if it's the case i'll send him the message, but if it's a projectile, then i have to check if the thrower is a player :)

vapid grove
#

no workie

ChestGui menu = findMenu.get(p.getUniqueId());
                        menu.getInventoryComponent().setItem(new GuiItem(item), 1, 1);
                        menu.update();
remote swallow
#

what lib is that

vapid grove
#

IF

tender shard
#

I always do GUIs manually

vapid grove
remote swallow
#

it looks so confusing

tender shard
vapid grove
#

also im too deep at this point so now i kinda have to

tender shard
#

that's me and ACF lol

stoic vigil
#

hey!
i got a .db file in my ressouces which i want to save in the plugin data folder, if not existing (on plugin start). my first question is, how do i do this?
my second question is how to access the .db file after saving it?
thy for your help ❤️

remote swallow
frail temple
remote swallow
#

whats going on?

remote swallow
#

@echo basalt do you know the 1.17 way of doing this

        public ItemBuilder skullTexture(String texture) {
        if (!(this.meta instanceof SkullMeta))
            return this;

        PlayerProfile profile = Bukkit.createPlayerProfile(UUID.nameUUIDFromBytes(texture.getBytes()));
        PlayerTextures textures = profile.getTextures();
        try {
            textures.setSkin(new URL(TEXTURE_URL + texture));
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        profile.setTextures(textures);
        ((SkullMeta) this.meta).setOwnerProfile(profile);
        return this;
    }
#

how does illusion appear wheni was about to ping him

molten hearth
#

hmm so i dont use reflection often but what could cause a NoSuchMethodException when the method is indeed in the class?

#
SwagCraftKit kit = this.kitMap.get(player.getUuid());
        Method applyPregameEffects = null;
        try {
            applyPregameEffects = kit.getClass().getMethod("applyPregameEffects");
            if(applyPregameEffects != null) {
                applyPregameEffects.invoke(kit, player);
            }
        } catch (NoSuchMethodException | SecurityException e) {
            System.out.println("No such method for kit " + kit.toString());
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
``` ```java
    public void applyPregameEffects(Player player) {
        Potion invisibilityPotion = new Potion(PotionEffect.INVISIBILITY, (byte) 0, 9999999);
        player.addEffect(invisibilityPotion);
    }```
remote swallow
#

if that can set a player heads skull texture yes

echo basalt
#

ye

remote swallow
#

can i have it

echo basalt
#

sure just copy it

#

from the screenshot

remote swallow
#

thanks

molten hearth
#

idk im not sure since if it wanted SwagCraftKit that would be getDeclaringClass and not getClass but also it says extends instead of implements so

remote swallow
#

jeff lib be like

#

very true

molten hearth
#

🅱️ruh what a useless feature smh smh

#

if I wanted the parent class I'd just get the declaring class

#

there seems to be no method to get the implementing class

#

I guess lol

#

so I guess I cant do this with reflection

#

pain

rotund ravine
#

@quaint mantle You always have the same freedom regardless

#

Nothing is stopping you from modifying the code

#

Nothing is stopping you from modifying the code

stoic vigil
rotund ravine
molten hearth
#

uh call a method from a class implementing something

vapid grove
#

ok

rotund ravine
#

It’s a little hard to from my phone.

vapid grove
#

but i got to school in 15 minutes so

molten hearth
#
class A {
}``` ```java
class B implements A {
    public void myOwnMethod(){}
}```
#

and I want to call myOwnMethod

rotund ravine
molten hearth
#

and I have B stored in a hashmap of A's

remote swallow
rotund ravine
#

Tag me rq so i can look in previous tags to find u @vapid grove

vapid grove
#

i msged u

molten hearth
#

so I did java A b = hashmap.get(...); // reflection that didnt work, whooo

#

well its telling me it never exists

#

when its clearly there lol

#

idk I feel like the reflection aint reflecting hard enough

hybrid spoke
#

cast a to b 🤔

rotund ravine
#

@molten hearth is it in a parent class?

remote swallow
#

anyone know what the format for Bukkit.getVersion() is

molten hearth
#

its not even invoking it, its not finding the method

rotund ravine
#

@molten hearth is it in a parent class?

undone axleBOT
molten hearth
#

uh what parent class its just in its own class implementing another class

#

I noticed when I do getClass it shows the class its implementing and not its own

smoky oak
#

important difference between implements and extends here

rotund ravine
#

@molten hearth That’d be wrong, but you’re using getDeclaredxxx right?

molten hearth
#

yeah, getDeclaredMethod

#
    private void setupKit(Player player) {
        if(!this.kitMap.containsKey(player.getUuid())) {
            this.kitMap.put(player.getUuid(), SwagCraftKit.DEFAULT);
        }

        SwagCraftKit kit = this.kitMap.get(player.getUuid());
        Method applyPregameEffects = null;
        try {
            applyPregameEffects = kit.getClass().getDeclaredMethod("applyPregameEffects");
            if(applyPregameEffects != null) {
                applyPregameEffects.invoke(kit, player);
            }
        } catch (NoSuchMethodException | SecurityException e) {
            // Your exception handling goes here
            System.out.println("No such method for kit " + kit.toString() + " with class " + kit.getClass().getName());
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }```
rotund ravine
#

You’d need to use it on the parent class if ur accessing a method from that

molten hearth
#

some SwagCraftKits have the method and some don't so im just checking it here

smoky oak
#

question

#

is swagcraftkit a class u wrote

molten hearth
#

only the class implementing SwagCraftKit has the method tho not SwagCraftKit itself

#

its not even a class its an interface

wooden garnet
#

is there an option to intercept incoming packet through bungeecord plugin api?

molten hearth
#

WAIT A MINUTE

#

no it isnt

#

checkmate

#

LMAO

#

brb

echo basalt
#

honestly IF s cool and all

#

but there are some things that can better done

molten hearth
#

I fucked up and I realised SwagCraftKit is an enum and not the SwagCraftPlayableKit class I meant to use

echo basalt
#

I'm working on my own menu engine which shares a similar structure to IF but there's a lot more abstraction

#

and a lot of room to expand on

#

dynamic placeholders, animations

smoky oak
#

similar how all collections share a few methods but u cant instantiate collection cuz its an interface

rotund ravine
#

It’s exactly as i said.

echo basalt
#

ye

#

sometimes it's nice to make empty methods that some implementations can override

smoky oak
#

ie

#

an interface

echo basalt
#

interface with a bunch of default empty methods that can be overriden

#

just so the subclasses don't need to override empty code blocks

rotund ravine
#

Well i wrote that answer before he specified it to me.

#

And i didn’t backread.

molten hearth
#

ahh alright wait so

#

now I see that its printing java.lang.NoSuchMethodException: me.paradise.swagcraftsg.kits.kit_impls.BatmanImpl.applyPregameEffects() instead of the parent interface

#

although the method is still not found kek

#

atm the code is ```java
private void setupKit(Player player) {
if(!this.kitMap.containsKey(player.getUuid())) {
this.kitMap.put(player.getUuid(), SwagCraftKit.DEFAULT);
}
SwagCraftKit playerKit = this.kitMap.get(player.getUuid());
SwagCraftPlayableKit kit = this.kitImpls.get(playerKit);

    Method applyPregameEffects = null;
    try {
        applyPregameEffects = kit.getClass().getDeclaredMethod("applyPregameEffects");
        if(applyPregameEffects != null) {
            applyPregameEffects.invoke(kit, player);
        }
    } catch (NoSuchMethodException | SecurityException e) {
        // Your exception handling goes here
        System.out.println("No such method for kit " + kit.toString() + " with class " + kit.getClass().getName());
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}```
#

I guess ill try Class<? extends SwagCraftKit> clazz = this.kitMap.get(..).getClass();

#

its uh still not found apparently

smoky oak
#

how does your class inheritance look like that u need to do reflection on your own code anyways

molten hearth
#
private void setupKit(Player player) {
        if(!this.kitMap.containsKey(player.getUuid())) {
            this.kitMap.put(player.getUuid(), SwagCraftKit.DEFAULT);
        }
        SwagCraftKit playerKit = this.kitMap.get(player.getUuid());
        SwagCraftPlayableKit kit = this.kitImpls.get(playerKit);
        Class<? extends SwagCraftPlayableKit> kitClass = kit.getClass();

        Method applyPregameEffects = null;
        try {
            applyPregameEffects = kitClass.getClass().getDeclaredMethod("applyPregameEffects");
            if(applyPregameEffects != null) {
                applyPregameEffects.invoke(kit, player);
            }
        } catch (NoSuchMethodException | SecurityException e) {
            // Your exception handling goes here
            System.out.println("No such method for kit " + kit.toString() + " with class " + kit.getClass().getName());
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }```
molten hearth
smoky oak
#

uh

#

put it on the interface like a command call

#

default just be boolean ... return false

#

and make it return true if its implemented

#

boom problem solved

molten hearth
#

that still wouldnt change the fact the method is not found

#

with reflection

smoky oak
#

which you then wouldnt need

molten hearth
#

yeah but then I have another useless method lol

#

I mean these are like survival games kits

#
public interface SwagCraftPlayableKit {
    SwagCraftKit getKit(); // enum
    void applyEffects(Player player); // potion stuff
    void registerListeners(Player player); // event stuff
    void giveInventory(Player player); // give items
    void registerGlobalListeners(); // event stuff that's called beforehand
}
#

but it does 😩

#

I just do uh this.kitImpls.put(SwagCraftKit.BATMAN, new BatmanImpl());

#

and it even notices its using BatmanImpl

#

and im BatmanImpl I have java public void applyPregameEffects(Player player) { Potion invisibilityPotion = new Potion(PotionEffect.INVISIBILITY, (byte) 0, 9999999); player.addEffect(invisibilityPotion); }

undone axleBOT
rotund ravine
#

What is being printed out @molten hearth

molten hearth
#

1 sec

#

nah bro

#

this reflection has a mental skill issue

rotund ravine
#

@molten hearth the method is public u don’t need declaredmethod

molten hearth
#

when I loop through the methods

#

it literally prints applyPregameEffects as one of the methods

#

but still throws NoSuchMethodException

#
Initializing kit for player xSpeziato
No such method for kit me.paradise.swagcraftsg.kits.kit_impls.BatmanImpl@42fd1ad5 with class me.paradise.swagcraftsg.kits.kit_impls.BatmanImpl
java.lang.NoSuchMethodException: java.lang.Class.applyPregameEffects()
        at java.base/java.lang.Class.getDeclaredMethod(Class.java:2675)
        at me.paradise.swagcraftsg.kits.KitChooser.setupKit(KitChooser.java:43)
        at me.paradise.swagcraftsg.kits.KitChooser.initKits(KitChooser.java:73)
        at me.paradise.swagcraftsg.match.Match.setPhase(Match.java:33)
        at me.paradise.swagcraftsg.match.MatchStarter.startMatch(MatchStarter.java:76)
        at me.paradise.swagcraftsg.match.MatchStarter.lambda$startCountdown$0(MatchStarter.java:58)
        at net.minestom.server.timer.SchedulerImpl.handleTask(SchedulerImpl.java:92)
        at net.minestom.server.timer.SchedulerImpl.lambda$processTick$3(SchedulerImpl.java:56)
        at org.jctools.queues.MessagePassingQueueUtil.drain(MessagePassingQueueUtil.java:39)
        at org.jctools.queues.BaseMpscLinkedArrayQueue.drain(BaseMpscLinkedArrayQueue.java:638)
        at org.jctools.queues.MpscUnboundedArrayQueue.drain(MpscUnboundedArrayQueue.java:23)
        at org.jctools.queues.MpscUnboundedArrayQueue.drain(MpscUnboundedArrayQueue.java:63)
        at net.minestom.server.timer.SchedulerImpl.processTick(SchedulerImpl.java:53)
        at net.minestom.server.timer.SchedulerImpl.processTick(SchedulerImpl.java:39)
        at net.minestom.server.timer.SchedulerManager.processTick(SchedulerManager.java:19)
        at net.minestom.server.ServerProcessImpl$TickerImpl.tick(ServerProcessImpl.java:280)
        at net.minestom.server.thread.TickSchedulerThread.run(TickSchedulerThread.java:24)
applyPregameEffects
registerGlobalListeners
registerListeners
getKit
giveInventory
applyEffects
wait
wait
wait
equals
toString
hashCode
getClass
notify
notifyAll```
rotund ravine
#

Use getMethod(“…”)

#

Also

#

Don’t call getClass twice

molten hearth
#

oh bruh there's probably a difference

#

I mean that is the whole exception

rotund ravine
#

He’s creating a class instance

#

Well

#

Not creating but setting it to a variable

molten hearth
#

yeah, i have two hashmaps, one maps an Enum -> Player and one Enum -> Class Instance implementing SwagCraftPlayableKit

rotund ravine
#

Then calling Class<? Extends BatmanImp> batmanpimpclass.getClass()

#

@molten hearth no

molten hearth
#

wdym no its what im doing lol

rotund ravine
#

That

#

Change from declared too if it’s public

molten hearth
#

uh

#

good question

#

I changed that so many times

#

atm its java SwagCraftKit playerKit = this.kitMap.get(player.getUuid()); SwagCraftPlayableKit kit = this.kitImpls.get(playerKit); Class kitClass = kit.getClass();

#

I was testing without the extends stuff

rotund ravine
#

Ur ide must have been mad about that raw type

molten hearth
#

I mean it complained about getClass being called twice

#

I assumed it was just being picky

rotund ravine
#

Well yes, but it’s not really needed when it’s public. As you said

#

Plus getMethod returns the method even if it’s in parent classes.

#

As long as it’s public

#

No

#

It does not

#

I can attest my knowledge to that.

#

Atleast not private parent class functions*

near night
#

so loc.getBlock().setType(Material.AIR) dosent update for the client like if a place a block next to it it will update or if i relog

rotund ravine
#

@near night version?

near night
#

1.19.2

remote swallow
#

if you want to change the block use sendBlockChange

near night
#

what dose that do?

ionic dagger
#

How would I check if a player died from fall from a player attack? Like the “[player] died whilst trying to escape [killer]” message

#

Would p.getKiller() return a player if the playerdeathevent damage cause was fall?

remote swallow
rotund ravine
near night
#

wdym kinda dumb?

rotund ravine
#

He is wanting to break something by setting it to air, his code should work.

rotund ravine
#

Just do setType(Material.AIR, true) if the other thing does not work

#

Usually setType should wrok tho

near night
#

ok thx

molten hearth
#

so I noticed im getting java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "kit" is null at me.paradise.swagcraftsg.kits.KitChooser.setupKit(KitChooser.java:39) at me.paradise.swagcraftsg.kits.KitChooser.initKits(KitChooser.java:68) at me.paradise.swagcraftsg.match.Match.setPhase(Match.java:33) at me.paradise.swagcraftsg.match.MatchStarter.startMatch(MatchStarter.java:76) at me.paradise.swagcraftsg.match.MatchStarter.lambda$startCountdown$0(MatchStarter.java:58) at net.minestom.server.timer.SchedulerImpl.handleTask(SchedulerImpl.java:92) at net.minestom.server.timer.SchedulerImpl.lambda$processTick$3(SchedulerImpl.java:56) at org.jctools.queues.MessagePassingQueueUtil.drain(MessagePassingQueueUtil.java:39) at org.jctools.queues.BaseMpscLinkedArrayQueue.drain(BaseMpscLinkedArrayQueue.java:638) at org.jctools.queues.MpscUnboundedArrayQueue.drain(MpscUnboundedArrayQueue.java:23) at org.jctools.queues.MpscUnboundedArrayQueue.drain(MpscUnboundedArrayQueue.java:63) at net.minestom.server.timer.SchedulerImpl.processTick(SchedulerImpl.java:53) at net.minestom.server.timer.SchedulerImpl.processTick(SchedulerImpl.java:39) at net.minestom.server.timer.SchedulerManager.processTick(SchedulerManager.java:19) at net.minestom.server.ServerProcessImpl$TickerImpl.tick(ServerProcessImpl.java:280) at net.minestom.server.thread.TickSchedulerThread.run(TickSchedulerThread.java:24)

rotund ravine
#

Kit is null

molten hearth
#

but its very clearly not null because I can print it me.paradise.swagcraftsg.kits.kit_impls.BatmanImpl@32dbdc65

rotund ravine
#

Show code @molten hearth

rotund ravine
molten hearth
#
private void setupKit(Player player) {
        if(!this.kitMap.containsKey(player.getUuid())) {
            this.kitMap.put(player.getUuid(), SwagCraftKit.DEFAULT);
        }
        SwagCraftKit playerKit = this.kitMap.get(player.getUuid());
        SwagCraftPlayableKit kit = this.kitImpls.get(playerKit);
        Class kitClass = kit.getClass();
        System.out.println(kit);

        for(Method method : kitClass.getMethods()) {
            if(method.getName() == "applyPregameEffects") {
                try {
                    method.invoke(kit, player);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(method.getName());
        }
    }```
#

I tried with a for loop instead lmao

near night
#

updating block dose nothing

#

right clicking it works tho

rotund ravine
#

@molten hearth just inline the declaration

molten hearth
#

OH WAIT

#

I didnt realise it skipped to the next kit

#

it works now tx lol

rotund ravine
#

Also why are you looping the methods

#

And using == to compare strings

molten hearth
#

idk the whole getMethod thing wasnt workin very well

#

also equals is stupid and shouldnt exist imo

#

why does java have to be special and be the only programming language on earth to use a method for comparing strings bruh

#

🥹

molten hearth
#

ive used python, js, php, cpp, go and none of them needed a method to compare strings

rotund ravine
#

Just do kit..getClass.getMethod

near night
#
[02:11:21 WARN]:        at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:16)
[02:11:21 WARN]:        at net.minecraft.world.level.block.state.BlockBase.a(BlockBase.java:155)
[02:11:21 WARN]:        at net.minecraft.world.level.block.state.BlockBase$BlockData.b(BlockBase.java:1010)
[02:11:21 WARN]:        at net.minecraft.world.level.chunk.Chunk.setBlockState(Chunk.java:588)
[02:11:21 WARN]:        at net.minecraft.world.level.World.a(World.java:551)
[02:11:21 WARN]:        at net.minecraft.world.level.World.a(World.java:513)
[02:11:21 WARN]:        at org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.setTypeAndData(CraftBlock.java:210)
[02:11:21 WARN]:        at org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.setTypeAndData(CraftBlock.java:195)
[02:11:21 WARN]:        at org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.setBlockData(CraftBlock.java:191)
[02:11:21 WARN]:        at org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.setType(CraftBlock.java:180)
[02:11:21 WARN]:        at base.jar//net.picklestring.base.Base.damageBlock(Base.java:78)
[02:11:21 WARN]:        at base.jar//net.picklestring.base.mm.DamageBlock.castAtLocation(DamageBlock.java:35)``` hmmm
chrome beacon
#

Yeah you need to do that sync

near night
#

how?

rotund ravine
#

Scheduler

#

Is easiest way

hybrid spoke
#

or dont go async

chrome beacon
#

?scheduling

undone axleBOT
near night
#

cant not go async cuz using a plugins api

molten hearth
#

if I do java try { Method applyEffects = kitClass.getMethod("applyPregameEffects"); applyEffects.invoke(kit, player); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } it throws NoSuchMethodException but if I do java for(Method method : kitClass.getMethods()) { if(method.getName().equals("applyPregameEffects")) { try { method.invoke(kit, player); System.out.println("invoked"); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } System.out.println(method.getName()); } it works

rotund ravine
#

Just do that then i guess

eternal night
#

Lol

molten hearth
#

i dont understand why it doesnt work but it is what it is I guess

eternal night
#

getMethod requires the full parameter types to be passed

#

You are certainly not doing that

molten hearth
#

oh thats why copilot was insisting on passing Player.class to it

#

I thought that was an extra filter

hybrid spoke
#

sometimes its better to listen to your codev

eternal night
#

When copilot is smart enough to solve it but the dev still fucks it up kekw

molten hearth
#

lmao

#

idk it seemed more logical to me to be an additional filter rather than a mandatory parameter

eternal night
#

I mean, overloading exists

smoky oak
hybrid spoke
onyx fjord
#

ik i asked before but sadly given answer cannot be applied to my scenario

i need blockbreakevent to respect fortune and silk touch

smoky oak
#

elaborate

onyx fjord
#

uh no

#

well i can get drops based on itemstack

#

but not on enchants

#

blockEvent.getBlock().getDrops(itemInHand)

hybrid spoke
#

so you want to still have more drops when fortune and silk touch is applied or what?

river oracle
#

I was making an autosmelt modifier for an item and getDrops got the extra drops.

smoky oak
#

cant
its a rng check on the time of mining iirc

river oracle
hybrid spoke
#

manually checking

river oracle
#

That or simulate the fortune enchant with math

remote swallow
#

dont you have to run the fortune calc urself

river oracle
remote swallow
#

ah

#

when i made my auto pickup stuff i just did the fortune myself because it was going over lvl 3

onyx fjord
#

ill recheck

hybrid spoke
remote swallow
#

sadly its after 1.16.5 so wont exist

#

because it uses real enchant level

chrome beacon
onyx fjord
remote swallow
#

what is the point of that

onyx fjord
#

i think its ripped from NMS

chrome beacon
#

?paste Send the full error

undone axleBOT
chrome beacon
onyx fjord
#
public int getDropCount(Material mat, int fortuneLevel, Random random) {
    if ((fortuneLevel > 0))
    {
        int drops = random.nextInt(fortuneLevel + 2) - 1;
        if (drops < 0)
        {
            drops = 0;
        }
        return a(mat, random) * (drops + 1);
    }
    return a(random);
}

^ full snippet

onyx fjord
#

i'd appreciate if spigot api had a way to predict drops lol

chrome beacon
#

I mean you can use the getDrops method

#

Just make a clone of the item stack and remove the silk touch enchant

onyx fjord
#

wut?

remote swallow
#

the real calculation

#

i found it to be (1 / fortuneLevel + 2) + (fortuneLevel + 1 / 2)

onyx fjord
#

not sure

#

its from old post

remote swallow
#

(1 / fortuneLevel + 2) + (fortuneLevel + 1 / 2)

#

and my pc dies

#

i found it on there

onyx fjord
#

but wheres randomness to it?

remote swallow
#

there isnt

chrome beacon
#

There is though

remote swallow
#

it would only be like 1/2 extra

remote swallow
smoky tinsel
#

trident.setDamage(1);

#

why this did not work?

remote swallow
#

?notworking

smoky tinsel
#

and trident is entity that already thrown

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.

smoky tinsel
#

um the damage is still 8

#

i mean it dealt 4heart

#

and i want to make it dealt 1 or more

#

but i cant ;-;

onyx fjord
chrome beacon
#

Make sure PlaceholderAPI is enabled

remote swallow
chrome beacon
onyx fjord
#

you mean the event?

#

because im hooking on a plugin that does certain things only on blockbreakevent

chrome beacon
#

The BlockBreakEvent fires before the drops are calculated

onyx fjord
#

i would happily implement it if it was open source or at least free as in price...

chrome beacon
#

So what is your goal

#

Why are you trying to get the drops

onyx fjord
#

to override drops from blockbreakevent

echo basalt
onyx fjord
#

dirty but theres no workaround as far as im concerned

chrome beacon
onyx fjord
#

yes

#

dirty, no workarounds sadly

#

the event list is strict

chrome beacon
#

I still don't see why you can't use the other event

remote swallow
#

weird question, has anyone ever experienced intellij making \'s the picture below?

chrome beacon
#

What is it that you need to access from the plugin you're hooking in to

onyx fjord
#

im making a custom enchant and the api is a fucking joke

#

its not even commented

#

but yea

#

it has action system

#

and it has defined list of actions linked to certain events

echo basalt
#
Random random = ThreadLocalRandom.current();
int fortuneLevel = ...;

double noDropChance = 2 / (fortuneLevel + 2);
int maxDrops = Math.min(2, fortuneLevel + 1);
int dropDelta = maxDrops - 2;

boolean shouldDrop = random.nextDouble() < noDropChance;
int dropCount = random.nextInt(dropDelta) + 2;
#

there might be a better way to do this

remote swallow
#

i have no idea

#

and i have no idea how to change it

#

if i type it in code its

#

\

#

if i type it in settings or lok at paths its yen

echo basalt
#

just invalidate caches and try again

#

also make sure you're using utf-8

remote swallow
chrome beacon
remote swallow
#

change project to utf-8?

chrome beacon
#

Yeah

#

Use UTF8

remote swallow
#

still yen symbol

sacred ridge
#

How do I put a repeat for a specific thing and if it is left the repetition is canceled (the repetition is in time for example every second)

onyx fjord
undone axleBOT
onyx fjord
#

no idea why that happens

#

i dont know internals of that plugin

chrome beacon
#

So what is your enchant trying to do

remote swallow
onyx fjord
#

drop stuff to inventory on block break

sacred ridge
chrome beacon
chrome beacon
echo basalt
#

and remove the item

remote swallow
#

anyone know if intellij has a discord server

#

unoffical or offical

onyx fjord
#

and it works

ruby pebble
#

how can i change the last line of item lore?

onyx fjord
#

until i add another enchant that triggers on block break for example

#

additionally, that plugin has the same exact enchant as mine and i know it uses blockbreakevent

#

so they must get drops internally

chrome beacon
echo basalt
#

monkey logic

ruby pebble
chrome beacon
onyx fjord
#

yeah trying that rn

#

last time i checked tho it didnt really respect fortune?

edgy hatch
remote swallow
#

tyty

echo basalt
#

it respects fortune

#

but the drops aren't always the same

#

you should really just decompile the shitty plugin and reverse-engineer it

onyx fjord
#

what about silk touch that too?

chrome beacon
#

Yeah

echo basalt
#

paid plugin?

#

doesn't prevent shit

onyx fjord
#

im doing it for someone

echo basalt
#

so?

#

you can still decompile it

onyx fjord
#

i'd have to buy it tho

echo basalt
#

ask the client for a copy, if they have one?

#

what's the plugin

chrome beacon
onyx fjord
#

some authors get mad over that you know tho

echo basalt
#

who gives a shit

onyx fjord
#

indeed

echo basalt
#

I've literally made 80$ updating an obfuscated world gen that costs 10$ a license

sacred ridge
echo basalt
#

and like 2 weeks later the author updated it

chrome beacon
ruby pebble
smoky oak
echo basalt
#

maybe because you don't have lore

ruby pebble
#

I couldn't figure out where I went wrong

echo basalt
smoky oak
#

still

echo basalt
#

I make money by providing advanced services that involve exotic techniques

#

like client-sided blocks and entities

worldly ingot
#

Also, by the way, lore.toArray().length -> lore.size() 😛

echo basalt
#

or updating obfuscated code that uses nms :)

chrome beacon
smoky oak
#

im trying to remember if i ever showed you my curernt project illusion

onyx fjord
#

for reverse engineering i'd charge 10x more tbh

ruby pebble
echo basalt
echo basalt
smoky oak
#

fair, btw, have you ever worked with particles?

chrome beacon
echo basalt
#

a bit

#

but at work we have a dedicated vfx guy

smoky oak
#

no like

#

minecraft particles

echo basalt
#

I know

smoky oak
#

not vfx stuff

echo basalt
#

we have a vfx artist

onyx fjord
#

10$ per deobfuscated clas

echo basalt
#

that does work for marvel

echo basalt
#

work on our particle engine

#

he also does our models

chrome beacon
ruby pebble
echo basalt
#

so like

#

spawning a tower that has a particle animation? all him

smoky oak
#

yea see i had a really obscure thing happen to me the other day

echo basalt
#

I'd be responsible for saving that tower's data on the db

chrome beacon
smoky oak
#

i have this code that projects a david's star made from particles into the world, but if im using the fabulously optimized client it prints out a hexagon

#

any idea why

echo basalt
#

um

smoky oak
#

thats my reaction too

echo basalt
#

isn't the middle of the star of david, a hexagon?

smoky oak
#

yea but it was the size of the outer ring

echo basalt
#

it might be culling particles outside of a range

smoky oak
#

and the wrong color to boot

echo basalt
#

so on the vanilla client it's all fine

#

but on a modded client it's fucked?

#

sounds like a client issue :p

smoky oak
#

no like the confusing thing is, that hexagon has no right to exist

echo basalt
#

still client issue

#

might be messing with particles

smoky oak
#

hm

#

i remember that particle distance is hardcoded and particle count is a packet limitation

echo basalt
#

if it works on vanilla & optifine, that's not on you

#

particle count is hardcoded to 65k

#

or 16k below 1.9

#

particle distance is hardcoded to idk

smoky oak
#

sphere of 32 blocks around ur camera

echo basalt
#

ye something like that

ruby pebble
echo basalt
#

goofy thing about particles is that they render in the void

smoky oak
#

can u bundle particles btw?

#

like

echo basalt
#

no

#

each one is an individual packet

smoky oak
#

of course they are

remote swallow
#

jetbrains discord is dead so im just gonna reinstall intellij

smoky oak
#

urgh

echo basalt
#

it'd be a big ass packet if you could bundle 15k particles in a single packet

#

RIP packet queue

onyx fjord
#

even async doesnt save 1k x 1k particle box spawning particle per block per 2 ticks

smoky oak
#

i need what feels like 20k packets to spit out a smooth symbol

echo basalt
#

this is when you should consider workload distribution

#

?workload

#

I never remember the command

#

?wd-s

#

ok fuck it

smoky oak
#

the issue is that particles dont have a 'delay' for spawning

#

so it would transmit the particle in chunks

echo basalt
#

but they have a delay for vanishing

#

you can use that delay

#

and some particle culling code

smoky oak
#

i dont think they do?

echo basalt
#

do achieve smoother, more performant goals

smoky oak
#

like

echo basalt
smoky oak
#

ah thats what you mean

echo basalt
#

bubbles are like 1 tick

#

lava-drip is longer etc

#

redstone is 40 ticks iirc

#

or 35

smoky oak
#

im using the ColorDustTransition particle which is roughly that

echo basalt
#

yeah

smoky oak
#

might be an idea to check if spliting the workload over a few chunks would help

echo basalt
#

fuck got no class, gtg home

smoky oak
#

*frames

echo basalt
#

at work we do that

#

but I also implemented a culling system to not DDOS the client

smoky oak
#

ye that might be the issue

echo basalt
#

each xyz pos has a long hash

smoky oak
#

the hell now it works

#

why was it broken yesterday then

echo basalt
#

this

#

so we have like a Map<UUID, Set<Long>> hashes

#

the set evicts after like 10 ticks

#

and if the particle is in the set, it's not sent

ruby pebble
#

Lore part or all?

chrome beacon
#

Lore

bronze eagle
#

complete noob here, Nag author(s): '[(redacted)]' of '(redacted)' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger)., just following a yt intro tutorial, what should be used instead of System.out.println()?

chrome beacon
#

Please use your plugin's logger instead (JavaPlugin#getLogger)

bronze eagle
#

(i have no idea what that means)

chrome beacon
#

You need to learn Java before starting with Spigot

#

?learnjava

undone axleBOT
bronze eagle
#

ok, thanks

ruby pebble
#
 code in other file
 List<String> lore = new ArrayList<String>();
 lore.add(".");
meta.setLore(lore);
code that changes lore (not changes)

List<String> lore = new ArrayList<String>();
lore.set(lore.size(), "Durability:"+(customdurability-Integer.parseInt(durabilty)));
meta.setLore(lore);
chrome beacon
#

That lore list will always be empty

#

Since you're making a new one

ruby pebble
#

what lore list?

chrome beacon
#

The list you named lore

onyx fjord
#

olivo and imillusion thx for help

ruby pebble
chrome beacon
#

both will always be empty when you create them

#

That's how lists work

subtle folio
remote swallow
#

do you have the repo?

subtle folio
#

No, Im unsure of the github pkg repo to use

tardy delta
#

why dont people use Arrays.asList or Collections.singletonList for lore

subtle folio
smoky oak
subtle folio
rotund ravine
#

Probably jitpack or smth

subtle folio
#

Im not using Jitpack,

smoky oak
#

try the url u posted, or maybe that url without the numbers at the end

subtle folio
#

That is the settings.xml

#

Im working with a pom.

smoky oak
#

should work the same

#

copy the repository thingy into ur pom.xml

subtle folio
#

Well that's embarrassing. Thanks 👍

smoky oak
#

np

smoky oak
remote swallow
#

the player death event getKiller method can only return a player

kind hatch
remote swallow
#

you want the EntityDamageEvent, check if the players health is 0 then send the death message by default set the death message to null

smoky oak
#

probs checking last damage source

#

like

#

wait

#

wouldnt that just be the fall

shell trench
#

How can I get an item by it's key(eg: minecraft:dirt)

kind hatch
#

Material#getKey()

#

Alternatively if you want to lookup by name. Material#matchMaterial()

ruby pebble
remote swallow
#

what are you trying to do?

quaint mantle
#

how can I check players ping with api

remote swallow
# ruby pebble .

so you have 2 files, with 2 different lore lists that you want to add to an item?

quaint mantle
#

I tried it once it was p.spigot().ping or something

undone axleBOT
quaint mantle
#

so no spigot()

#

thx

remote swallow
# ruby pebble yes

does the first lore list you add to the item actually serve a purpose? or is it just meant to be blank

ruby pebble
#

serves a purpose

remote swallow
#

what does it do?

ruby pebble
#

which?

remote swallow
#

both

ruby pebble
#

edited durability of the item is shown in the description

remote swallow
#

couldnt you just add the durability and lore in the first one and then change it on the second one?

#

setting to a new list

ruby pebble
chrome beacon
tardy delta
#

tip for the people: dont look into the CraftMetaItem#addLore method

rotund ravine
ruby pebble
tardy delta
#

that

remote swallow
ruby pebble
#

or i didn't understand ;-;

remote swallow
#

you fucking what

tardy delta
#

i mean wtf is safelyAdd

remote swallow
#

if (lore == null) this.lore = null

#

the fuck

#

why

#

what the fuck

#

i absolutely hate that

tardy delta
#

welcome to the impl

remote swallow
#
    @Overridden
    boolean equalsCommon(CraftMetaItem that) {
        return ((this.hasDisplayName() ? that.hasDisplayName() && this.displayName.equals(that.displayName) : !that.hasDisplayName()))
                && (this.hasLocalizedName()? that.hasLocalizedName()&& this.locName.equals(that.locName) : !that.hasLocalizedName())
                && (this.hasEnchants() ? that.hasEnchants() && this.enchantments.equals(that.enchantments) : !that.hasEnchants())
                && (this.hasLore() ? that.hasLore() && this.lore.equals(that.lore) : !that.hasLore())
                && (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost())
                && (this.unhandledTags.equals(that.unhandledTags))
                && (this.hideFlag == that.hideFlag)
                && (this.isUnbreakable() == that.isUnbreakable())
                && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage());
    }
tardy delta
#

wondering what @Overridden is

tardy delta
#

laugh at it

#

some people are being offended now ig

remote swallow
#

im gong to murder someone

tardy delta
#

have fun

smoky oak
#

i have so many questions

orchid gazelle
#
Velocity packets sent their X, Y and Z as a short which have a maximum value of 32767. Minecraft then divides this by 8000.0 to get a double value of velocity, which results in just under 4.1, giving a maximum visible velocity of 4.1. This means that any velocity over 4.1 gives incorrect positions and it will mess up the client.
``` Does anybody know a way to outplay this issue?
smoky oak
#

cant

#

mess around with teleports to get correct locations

eternal oxide
#

Its not an issue, it's minecrafts maximum velocity (without teleporting)

quaint mantle
#

how to make a double jump ? like player velocity ?

orchid gazelle
#

how do I do that?

#

do I just spam teleport packets to all players?

smoky oak
smoky oak
quaint mantle
#

wym cancel entering flight mode

smoky oak
#

way i detect is is using the enterFlightMode event or whatever its called

#

so u need to cancel it or theyll start floating

#

only way to find a pressed spacebar in the air afaik

smoky oak
#

on join of player

orchid gazelle
#

and 2. will this be laggy?

quaint mantle
smoky oak
quaint mantle
#

Like just adding like force from bootom to top

orchid gazelle
smoky oak
#

ah well

quaint mantle
#

Like in unity

smoky oak
#

MAKING them jump is easy

#

the issue is getting the input for the jump

#

like mentioned above, double jump is just setting the y velocity positive to whatever u start a jump with

smoky oak
#

and give a particle trail where they moved

orchid gazelle
#

I planned to give it a particle trail anyways

smoky oak
#

well if what youre planning on doing is a bullet, you can 'raytrace' - drawing a line into the direction the player is looking from their head - to determine the bullet path and checking for the first intersection with hitbox or terrain, then use particles and that direction vector to draw the particles for the path

orchid gazelle
#

what if a player places a block in the path when it has already calculated the path

smoky oak
#

cant

orchid gazelle
#

the bullet should not just teleport lol

smoky oak
#

minecraft is single threaded

#

if the block is placed the bullet hits it

orchid gazelle
#

yeah but the bullet is flying

smoky oak
#

very very fast

#

thats why i suggested doing an instantaneous check instead of messing with teleports

orchid gazelle
#

yeah but it takes like 2 seconds max on very high range

#

and in this 2 seconds, something can happen

#

(sniping from skyscrapers for example)

#

and also, there would be no bullet texture with the raytracing

smoky oak
#

ah i see. My suggestion then would be to create a task with a repeat rate of once per tick moving the bullet forwards with teleports, and a maximum repeat count so that u dont calculate it into the great void.
Keep in mind that since it isnt actually moving you still need to check the crossed distance for blocks or entities hit.
You need to do it this way or otherwise the bullet would not get rendered correctly by the clients.

quaint mantle
#

Does anyone know where in the Spigot.jar (server jar) where it handles player authentication with mojang? I want to implement my own custom authentication for it to be more secure

chrome beacon
#

Sounds like offline mode with extra steps

orchid gazelle
smoky oak
#

cuz you said you wanted a projectile

quaint mantle
#

Do you know where exactly it authenticates?

smoky oak
#

but i was like 'a bullet moves with 1km/s anyways so just raytrace it'

orchid gazelle
#

nah not that fast

#

it should still be a realistic gun lol

smoky oak
#

thats what a sniper rifle fires its bullets at

#

roughly

orchid gazelle
#

well but what if I just send projectile teleport packets every tick that do not change the position noticably at all?

#

while still using velocity

#

a normal sniper is having a speed of 800m/s btw

smoky oak
#

if ur velocity is higher than 4.1 - which i assume is per tick - its so fast it will noticeably change location. If its slower, just give the normal particle

#

err

orchid gazelle
#

oops

smoky oak
#

i mean just make it a normal projectile

orchid gazelle
#

that was the wrong table lol

smoky oak
#

brain no work brain no do that. Anyways, teleport if the velocity is too high and just make it a projectile otherwise

orchid gazelle
#

so your approach would be to make a normal arrow or teleports for normal bullets and for my snipers use raytraces

smoky oak
#

essentially yes, but not for the reason you might think. I like minimizing code, and the raytrace can be done in a single line, while the teleporting bullet entity to accurately get position is not only more complicated, but also more prone to errors

orchid gazelle
#

the 4.1 velocity would be 60 m/s

#

which would be half of the speed of a normal gun

smoky oak
#

how about this

#

make a raytrace and check if the distance is < 20m

#

*over 20m

#

and check if it hit anything

#

if not

#

spawn the projectile

#

for normal guns i mean

#

no one reacts that fast

orchid gazelle
#

hmm I don't know about that one

smoky oak
#

well youll need a raytrace anyways either way

orchid gazelle
#

not for normal bullets

smoky oak
#

thats cuz a teleporting entity doesnt cross the space in between

#

so you need to trace from the old to the new location to check if it hit anything

orchid gazelle
#

how do I let it look like a bullet then?

#

it would be just particles

smoky oak
#

the entity youre teleporting can still have a texture you know

#

also

orchid gazelle
#

I mean with raytraces

smoky oak
#

you dont

#

remember that particles and entities have a maximal render distance

#

which is very low for particles

#

like

#

31 blocks

#

its hardcoded btw

orchid gazelle
#

yeah so you will not see the raytraces

smoky oak
#

theyre internal geometry

#

you could spawn in a bullet entity but that would defeat the point of doing the raytrace in the first place

#

like the long one

orchid gazelle
#

hmmm

#

well you think using the normal terminal velocity sucks too?

#

that would be unrealistic asf wouldn't it

#

normal guns are 800m/s

smoky oak
#

well as said, I'd use raytraces for fast bullets and raytraces + particles for slow ones
mainly cuz u cant really react to something that fast so the overhead would be pointless

orchid gazelle
#

this would be a tenth of that

orchid gazelle
#

as a third party player

smoky oak
#

then go with the scheduler teleport short raytrace thing

#

you cannot see particles over range even using zoom

#

ur only option is to spawn in either a projection or an bullet entity

orchid gazelle
#

hmmm

#

well now im thinking, is it better for my gun system to actually see bullets going "slowly" or them being instant and realistic

smoky oak
#

bullet trails still give a lot of information

#

do you know how to do a projection?

orchid gazelle
smoky oak
#

its fairly easy actually

orchid gazelle
#

I did not even know that was a thing for bullets

smoky oak
#

eh its a visual thing

#

heres what you do

orchid gazelle
#

well like, the gun system is for a rp server aiming to be as realistic as possible, but I clearly do not know if it would be more fitting and cooler to have "slow" projectiles or realistic(the raytracing part would be here) and instant shots

#

like would it be a better experience?

smoky oak
#

I'd suggest fast particles and doing the projection, since it actually gives the feel of a real weapon, but its hard to tell without playtesting.
Here's how you'd do the projection to make bullet trails visible:

Then, for each player watching you calculate the vector from their camera position to each sample location.
Normalize those vectors, multiply by 16 (particle weirdness reasons)
Add those vectors to the watching player's location, and keep track of the results. Keep in mind that doing math on vectors changes them, so you just need the original list of normalized vectors.
spawn in a small but bright (maybe a silver) particle at each of those locations.
Bullet trails visible regardless of distance.```
orchid gazelle
#

the problem is, this is a big thing to try out lol

orchid gazelle
#

that does not work with projection

smoky oak
orchid gazelle
#

because they do not use textures

#

those are particle trails

smoky oak
#
public Set<Location> projectionPoints(Player observer, Location bulletTrailStart, double trailLength){
     //constant, sampling count, maybe change this depending on player distance. Dont change beyond this point.
    final int STEPS = 10;

    Location playerLocation = observer.getLocation();
        
    //Vector for stepping along the trail
    Vector direction = bulletTrailStart.getDirection().multiply(trailLength/STEPS);
    //Does not exceed Steps+1 in size, therefore 1 as load factor.
    HashSet<Location> projectionLocations = new HashSet<>(STEPS+1,1.0f);

    //Do not modify input
    Location currentTrail = bulletTrailStart.clone();

    for(int i=0;i<STEPS+1;i++){
        projectionLocations.add(playerLocation.clone().add(currentTrail.toVector().clone().subtract(playerLocation.toVector()).normalize().multiply(16)));
        currentTrail.add(direction);
    }
        
    //Project at the locations of the return set
    return projectionLocations;
}

@orchid gazelle

#

untested but i dont think theres issues with it

#

if theres any its probably in the vector math

orchid gazelle
#

so this just returns all points where I need to spawn particles for the selected player right?

#

why can't I just spawn the particles at the general trail?

smoky oak
#

well i mentioned above

#

particles do not get rendered beyond 31 blocks distance

#

32 actually but its better to say 31

#

so you need to project the bullet trail into that area around the player to make it visible

orchid gazelle
#

and how does this bypass it?

smoky oak
#

well the returned locations are within that area

#

thats what the normalize part does

orchid gazelle
#

well then the players cannot see the trail if it is more than 31 blocks away

#

smh where is the limit hardcoded?

#

maybe can do something with reflections or something

#

if it is done serverside

remote swallow
#

you what

smoky oak
#

trail pretend close
particle be rendered

#

math do that

remote swallow
#

you said return false so i found it really weird

orchid gazelle
smoky oak
#

correct

#

thats how video games work

orchid gazelle
#

well

smoky oak
#

everything in games pretends to be exactly x distance from the camera

orchid gazelle
#

what if for example a glass block is in the way of for example vector 1

#

on your sketch

remote swallow
#

jnak

smoky oak
#

u could add a check if the vector intersects a non transparent block but i aint writing all your code

orchid gazelle
#

yeah thats for sure

#

just wanted to ask

#

how it would work

#

but I understand now

smoky oak
#

ray trace from either player to trail or trail to player, check if block is there

remote swallow
smoky oak
#

keep in mind to tell the raytrace what blocks you consider transparent

#

by default its only air

#

and its variants

remote swallow
#

cave air best

orchid gazelle
#

and this is not gonna be lagging when 50 players look at that trail and it calculates the vectors every tick?

#

and 50 players shooting

smoky oak
#

math is really really fast

#

i can render 20k particles at once without issue

#

youre projecting a few hundred at most

#

ur fine

orchid gazelle
smoky oak
orchid gazelle
smoky oak
#

like at around 30k

smoky oak
#

each ray trace equals one particle, unless you draw the full line

#

which actually would make the math a lot simpler im dumb

#

that aside even with this inefficient method ur rendering like 20 particles max per player so being generous and saying theres 50 players you have like 1000 partikles

#

if everyone shoots a sniper rifle at once

#

(Here's the easier way: Project start and end point of the trail, draw a line between them, spawn particles on it)

orchid gazelle
#

well then you got 50k particles being calculated

smoky oak
#

no TOTAL

orchid gazelle
#

if you take the 1000 particles and calculate them for every player

smoky oak
#

uh

#

20 traces per player on average

#

50 players

#

so like even with this

#

1k particles MAX

orchid gazelle
#

50 shooters, 50 receivers, 20 particles

smoky oak
#

do u really recon you will have

  1. 50 players in the same area
  2. all shooting a long-range weapon
  3. in the same tick
#

this is an edge case you dont need to cover cuz its so exceedingly rare

orchid gazelle
#

exceedingly rare?

#

its not that unrealistic

#

for example take gangwars

#

25 against 25 players

remote swallow
#

almost a 0.01% chance that will happen

#

you do realise there are 20 ticks in 1 second

orchid gazelle
smoky oak
remote swallow
#

there is no chance all 50 of them will be able to time that so perfectly

remote swallow
orchid gazelle
#

also, I think I should calculate the values async actually

#

so if things are getting laggy, the server will not get hammered

smoky oak
#

eh as said theres a much simpler way

#

1sec

remote swallow
#

the only way you would be able to have 50 people all shoot there bow at exactly the same time is have them all in the same room, with another person timing it to a T

#

and i somehow dont think that will happen