#help-development
1 messages · Page 262 of 1
To create a unique implementation of rayTraceBlocks that returns all the results it hits on the way to maxDistance, you can use the following approach:
- Create a List object to store the results of the block hits.
- Set the current position to the starting position, and set the current distance traveled to 0.
- Calculate the step increment for each axis based on the direction vector.
- Iterate through the blocks between the starting position and the maxDistance. In each iteration:
- Calculate the next block to check based on the direction vector and the step increment.
- Check if the block at the calculated position is solid. If it is, add it to the list of results and continue to the next iteration.
- If the block is not solid, increment the distance traveled by the step increment and continue to the next iteration.
- When the loop finishes, return the list of results.
Here's an example implementation in Java (probably won't work):
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
public class RayTracer {
public static List<Block> rayTraceBlocks(Vector start, Vector direction, double maxDistance) {
List<Block> hits = new ArrayList<>();
// Calculate the step increment for each axis
double xStep = direction.getX();
double yStep = direction.getY();
double zStep = direction.getZ();
// Normalize the direction vector
double length = Math.sqrt(xStep * xStep + yStep * yStep + zStep * zStep);
xStep /= length;
yStep /= length;
zStep /= length;
// Set the current position and distance traveled
Vector pos = start.clone();
double distance = 0;
// Iterate through the blocks between the start and maxDistance
while (distance < maxDistance) {
// Calculate the next block to check
int x = (int) Math.floor(pos.getX());
int y = (int) Math.floor(pos.getY());
int z = (int) Math.floor(pos.getZ());
Block block = pos.getWorld().getBlockAt(x, y, z);
// Check if the block is solid
if (block.getType().isSolid()) {
// Add the block to the list of hits and continue to the next iteration
hits.add(block);
}
// Increment the distance traveled and the current position
distance += Math.sqrt(xStep * xStep + yStep * yStep + zStep * zStep);
pos.add(new Vector(xStep, yStep, zStep));
}
return hits;
}
}
This implementation will return a list of all the solid blocks that the ray trace hits on the way to maxDistance.
you must be right
add (-3) around 3?
gei-oogle
thanks ill see if i can make that work
lua be like: return +1
because both 4*4 and -4*-4 return 16
it sucks
it with interest
it will be fine then i get back on track
Christmas was so expensive
oh graph

if i just knew about investing
It's pretty much a gamble short term
stoink
I think I'm down 25% all time, but it's just the way the market is heading rn
damn I had over 10 million in september
Aye not bad
Oof fall off sad
awh
I should have taken a short position in tsla a while back they were over valued
tsla?
Hinesite is 20 20 tho
Tesla
ah ok
Crazy Twitter mans company
I took a short on tsla for my stock sim last year but for some reason I didn't with my real money should have been more confident with my play
Atleast should have done options
I once had a client who always went for stocks. I was like "how the fuck can you play with your money like that" and he answered "well sometimes you win, sometimes you lose, that's how it works" lol
oh alex, do you know if i can change the boot option list in grub, to change windows as my main boot not mint
ofc you can do that
install "grub-pc" then you get a fancy GUI where you can change it
on windows or mint
Isn't it default on mint?
idk
It is on Ubuntu
then it probably is on mint too
But the delay is set to 0 upon install you need to config it
I have a 5 second delay prior to boot
WHERE IS MY BF
mines like 10 seconds before auto boot to linux
in basement
There Is hockey's you can press between the boot of bios being over and os startup to get into grub
ah yes, the hockeys
it auto boots to grub, whats the point of that
Oh I thought you were saying it didn't
give him back
it does i just want to make my auto boot windows not mint
Then there really isn't a point it's super trivial to switch just press down arrow an enter once
but what if i want to press the power button and walk downstairs
Grub is better than windows boot system hands down
Could I have any assistance? My code errors out and spits:
Cannot resolve method 'getRelative' in 'BlockFace'
In the lines of:
if (block.getType() == Material.RED_BED) {
Bed bedData = (Bed) block.getBlockData();
Block head = bedData.getFacing().getOppositeFace().getRelative(block);
no you are zacken
what MC version
Re: 1.8????
are you using maven?
yes
does that mean you only s...xly attacted to hyper people? 😏
which version do you have for spigot-api in your pom.xml?
this is just joke ofc
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
so the loops
that I was doing it perfercly works it generates tihs code:
World pW = ((Player) p).getWorld();
pW.getBlockAt(((Player) p).getLocation().add(-2, 2, -1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 2, 0)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 2, 1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 2, 2)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 3, -1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 3, 0)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 3, 1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-2, 3, 2)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-1, 0, 0)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-1, 0, 1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-1, 1, 0)).setType(Material.COBBLESTONE_SLAB);
pW.getBlockAt(((Player) p).getLocation().add(-1, 1, 1)).setType(Material.COBBLESTONE_SLAB);
pW.getBlockAt(((Player) p).getLocation().add(-1, 2, -1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-1, 2, 2)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-1, 3, -1)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(-1, 3, 2)).setType(Material.STONE);
pW.getBlockAt(((Player) p).getLocation().add(0, 0, 0)).setType(Material.STONE);```
ok tell that to person then
this is the code I was talking about it generates
?notworking
"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.
just put it in the code and it generates a structure
Code before loops existed be like
in game you specifi pos1 pos2 and it generates code
it copies the object it game and converts it into this code
Not on my watch time machine time mother fucker
Why aren't you using a loop

no the loop creates this code
What kinda loop creates more code
why does it create code
you can create ur own structure in mc
there is simple ways to do this
okay
just copy it in game with command and it creates a code with that you paste it into ur plugin code and voala ur structure is there
^^
^^!
why
@quaint mantle Why not iterate through a set of coordinates? That would save so many lines
Because that is just god awful. Why not use config files and have more abstract code? Only reason I can think of is not understanding basic abstraction concepts
this are the coordinates
He is generating code the user has to copy paste the methodology makes no sense
for example
Use config files hell I'd reccomend you use .schematic files
how would you create a house with code ?
Iirc there are apis for doing that like fawe iirc
no without apis
So you hate yourself
Ic
Make your own .schematic file
Good luck
That's the best solution
What you are doing now is not scalable in any sense
You need to make your own file type and make it parseable by your plugin simply no way round that any other method just wouldn't make sense.
tf just make a class with name of structure and ur done
Myes you expect too much from people and have a horrible user experience being constructed
so line per block?
seems like a great moment to tell you to learn java
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
definitely better to have files
copy and pasting like 10,000 times is bad programming
yo chill out
🪞
i asked to show noobs
fava
not mirror emoji
jree fava lesons?
yes

that
pointing at the noob rn
maybe
and at you
well that means you point to yourself too
it is not :)
@fluid river In case you haven’t got the gist, he is saying your a noob
&data ?
at all of us
I'm not perpendicular to my monitor
who
i c no pointers
you
🚪
I love joe
mama
@fluid river ImIllusion
no you
cyrei
who is that
in case you didn't notice
carefall
but useless
WH1Z
that
yus
-_-
someone better make that fava language real
gaga??
i'm too lazy
if GC worked real good, @fluid river wouldn't be here
like a turtle
🐢
Yeah, i would have been rewarded for developing it


probably 'd have left this channel
guys my code is broken, how to fix
p.sendTurtle();
heap moment
all my homies like stack
is the turle even real
my code broken how do I fix
method = p.send_turtle;
method()
that must be the problem
malloc(deeznuts**)
python moment
hey guys how do i code scdehuler which scdehules after server restart + 5 nanosex. I had been wanting to store player's inventory lore and history to hashmap of primitive ints. So when scdehuler scdehules i run -Xmx128M and pass lore as args
also where is a way to increase tickrate to 21
omg i just attended to i'm using 1.4.6. Can anybody provide me MNS guide(ya know NBT)
also why do i keep getting Unsupported class file version(52.0) error when running need for speed mine crafted
umm and in the end why doesn't it work
nigAss().get().put(1, 228);
HashMap<Integer> mep = new HashSet<String>();
player.sendMessage().mep.get(4), 4);```
it's underlined with red and i have chinese intellij from my father and i forgot how to read it
@OverrideDeez
nigAss
I use java unsafe 
relfector
nah
sorry i use binary
int* bruhWhat = (int*) malloc(1488*sizeof(int));```
1488

is that when your mom was born
nig
LOL
nah
damm time traveler i see
imagine not compiling with brain
How do I force people to use this texture pack? because people can just choose to not use this texture pack in game
you never tasted StackOverflow in brain
imagine tryna flex something you don't know how to do, ending up looking like a monkey and still thinking you're right
he?
hehe
nvm
ResourcePackSomethingEvent
Check out this
if player didn't accept then kick him
don’t do that
@fluid river
How can a server detect this? textures are client side
client sends a response
dont trust client
sure hacked clients can send whatever response they want
but you can't control that
*sends fake response
wouldn't it be problematic for my plugin?
Is there a reason we can't cancel ChunkUnloadEvent in higher versions?
lol
I'm trying to keep the chunk my entities are in loaded but I fear if I use Chunk#setForceLoaded those chunks will never unload and there'll just be a trace of chunks forever loaded
🩸 👁️
Wait, Fava? (Always has been jree
iirc use a plugin ticket
beyond server itself you have no control
@quaint mantle get in here or ill make alex call you a jerk'
glad we all agree
bad pratices
@round finch
imposter @round finch
:)
Why can maven find my package that is clearly on github packages? this is my pom ```xml
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/tazpvp/NR-Core</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>world.ntdi</groupId>
<artifactId>nrcore</artifactId>
<version>1.0.8</version>
<scope>provided</scope>
</dependency>
</dependencies>```
dont you need a / at the end of urls
Do you know if it's possible to add a plugin ticket in the ChunkUnloadEvent or would it have no effect?
after modifying it seems to work but somehow server crashes after about 10 seconds of plugin running lol
most want a /
no idea
Didn't do anything :/
so i guess its correct then lol
no idea then sorry
dont know how it works but whatever, as long as my parser does it correctly
Might wanna use schedulers instead of a loop
im using scheduler
ill open thread
what is it then
Custom raytracer crashing server
servers are probably down
i'm using imgur
imgur's or spigot's?
spigots servers
so should i just wait?
pretty much
Does anyone know why I get this error, Im shading nrcore into my plugin and all that. https://paste.md-5.net/ecozigemev.md
are you sure the library gets exported in the jar file?
check your ide and make it export it otherwise class won't exist in the final product
this is my pom: https://paste.md-5.net/ihogobawal.xml
provided 
if you are trying to shade it in dont you need compile scope
hmm let me test
is that jar actually a plugin?
yes
does it get loaded correctly?
yes
then idk xD
yeah no, compile breaks everything

causes errors that don't occur in other plugins that use provided
idk why it's breaking in this one
its another plugin
then you don't want to shade
that's what i was saying ;-;
why is there a shade plugin 
so then why am I getting a class not found exception?
for buildingg
you are depending on the other plugin ?
yes
in your plugin.yml
and world.ntdi.nrcore.utils.command.CommandFunction actually exists 
a weird package name
I ought to say
in a bukkit runnable, how can I check if a player is currently mining a certain block?
nrcore?
no the world prefix
ah
also in the jar on the server ?
let me jdgui qr
in a bukkit runnable, how can I check if a player is currently mining a certain block?
pls I needa do this I couldnt find it anywhere 😭
y up
bruh
i just restarted my server
and it fixed itself
You should always restart smh
best way to fix anything lol
💀
💀
😅
rd /S /Q server
sudo rm -rf /
only know the cmd commands
unicks >
public List<Location> getProjectionPoints(Location bulletStart, Vector direction) {
List<Location> projectionLocations = new ArrayList<Location>();
double distance = 0;
RayTraceResult RTres = bulletStart.getWorld().rayTraceBlocks(bulletStart, direction, 1000);
distance = RTres.getHitPosition().length();
Location targetLocation = bulletStart.add(RTres.getHitPosition());
Location l = bulletStart;
Vector vector = targetLocation.toVector().clone().subtract(bulletStart.toVector()).normalize().multiply(2);
double length = 0;
while(length < distance) {
l.add(vector);
projectionLocations.add(l.clone());
length += 2;
}
return projectionLocations;
}
Somehow it is not giving me any locations, any ideas?
The RTres variable may be null\
Replace the l.clone() call with l so that the modified value of l is added to the projectionLocations list.
I debugged, it isn't null
maybe try to printing stuff liike print out the values of l, vector, and length at the beginning of each iteration of the while loop, and verify that they are being updated correctly
any way to check if a player is in a lush cave?
lush cave is a standalone biome?
oh nice. thanks
didnt know that
Does anyone know a way to save player's potion effects to the potion bottle and drop it to the floor on death?
is there a way to increase the amount of ore a mined block drops
yes
how
you want to change the amount a block drops?
yeah like a coal ore block drops 5 coal instead of otherwise
block drop item event
To double the amount of ores that an ore block drops in a Spigot plugin, you can use the setDrops method of the BlockBreakEvent class. Here's an example of how you could do this:
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (block.getType().name().contains("_ORE")) {
List<ItemStack> drops = event.getDrops();
drops.add(new ItemStack(block.getType(), 1));
event.setDrops(drops);
}
}
This code will listen for block break events and check if the broken block is an ore block by checking if the block's type name contains the string "_ORE". If it is an ore block, it will get the current drops for the event and add another ore item to the list. Finally, it will set the modified list of drops back to the event.
This will cause the ore block to drop two ore items instead of one when it is broken. The code will work for any type of ore block, as it checks for any block type with a name that contains "_ORE".
Or for a single ore you can do this.
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.IRON_ORE) {
List<ItemStack> drops = new ArrayList<>();
drops.add(new ItemStack(Material.IRON_ORE, 2));
event.setDrops(drops);
}
}
This code will listen for block break events and check if the broken block is an iron ore block. If it is, it will create a list of drops containing two iron ore items and set that list as the drops for the event. This will cause the iron ore block to drop two iron ore items instead of one when it is broken.
Note that this code will only work for iron ore blocks. If you want to double the drops for other types of ore blocks, you will need to add additional conditions to check for those block types and add the appropriate item to the drops list.
very nice. thanks so much for including example code

BlockDropItemEvent ...
can anyone please tell me how to set a multiple lined mob name? thanks (1.19.3). Should I use packets? I tried with passenger but not work
Is there a way to not make the server hang when we create a new world ? Actually when i create a new world the whole server is just frozen like if it was reloading 🤔
It does it sync, not sure if you can do it async. Probably nto
Hmm 🤔
can potion effects be negative? For example strength -2?
What you can do though is.
"
Have 2 servers, connect them via a bridge.
When server 1 (main) wants a world created it can request Server 2 to create it.
Then Server 1 copies it over async afterwards, and loads it sync.
"
Should cut down on the lag @covert yacht
Yeah why not 🤔 , and is a folder copy gonna make the server hang ? Like if i use pre generated world and copy the folder whenever i need it so i don't need to use too much ressources to generate a world 🤔
@covert yacht the loading should make it hang a bit depending on ur hdd/ssd speed. The transfer of the world can be done async.
Okay, yeah i see, thanks for the infos 😁
Otherwise, i can just create the worlds on server 2 and then tp the player to server 2
well
forget that
that will make people on server 2 lag too
yeah
depends actually
paper can load chunks async iirc
and SWM should allow async worlds
Hello guys. I was wondering when player click to text then how can we send directly message to player.
answer_1.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, //player.sendMessage("test")));
make it run a command that your plugin has registered
We can't do that without register command?
You can
I guess there is something like multi threads ? so thread 1 is the server and thread 2 will generate worlds for the server ? (bad explanation ik but yeah)
@covert yacht Fairly certain generating new worlds still fall on sync. So it would still hang it a bit
yep, i understand, creating a world i an heavy task
I get it. Thanks both of you guys @last temple @rotund ravine
well in theory
you can make it run a command with a uuid
and associate a task with a uuid
but it can very easily cause a memory leak unless you use premade tasks :)
them running the command is already a uuid (the player), but yeah using a unique descriptor to define what they click like /answerthing 1 (1 being answer 1) etc.
like
how do i drop an item at a specific location
@atomic swift world.dropitem method
private final Cache<String, Runnable> cache = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).build();
public String makeCommand(Runnable runnable) {
UUID uuid = UUID.randomUUID(); // is this the method? I don't remember.
tasks.put(uuid.toString(), runnable); // we're using strings instead of the UUID object itself because parsing the UUID when reading commands takes longer
return "/" + uuid;
}
@EventHandler
public void onCommand(PlayerCommandPreProcessEvent event) {
Player player = event.getPlayer();
String command = event.getMessage();
if(command.startsWith("/")) {
command = command.substring(1); // I don't remember if the message starts with "/", but it might
}
Runnable task = cache.asMap().get(command);
if(task == null) {
return;
}
cache.invalidate(command);
task.run();
}
type deal
so like
I mean sure, but you can do it easier.
Player player = ...;
String command = makeCommand(() -> {
player.sendMessage("You are a gangster.");
});
setClickAction(RUN_COMMAND, command)
type deal
Shouldn't leak that bad as tasks are only kept for like 5 minutes
we can do one better and invalidate after the client receives 250 chat packets
or quits :)
how can i fix this?
PlayerTasks.put(player.getUniqueId(), runnable.getTaskId());```
on the second line console says that it have not been scheduled yet
how can i fix that?
PreLogin -> before login
declaration: package: org.bukkit.scheduler, class: BukkitRunnable
yes
this link tells me nothing
task was already scheduled
i scheduled it above that line
That's more or less how you would do it.
yeah pretty much
How do I give github actions build tools !?
?docs
?eventlist
?javadocs
any event for a player joining the server the first time
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.
"THATS JUST SPOONFEEDING!!!!!!!!1111111"
Hello any idea on why my cursor goes in the bottom center when i'm clicking button in my custom GUI
ok 2min
i'll try whitout
oh...
I need that because i want to change the title
Can i update inventory title ?? whitout reopening
i'll try whitout closing so
if your opening a new menu thats default behavior
Yeah it works, but I have to remove my removePlayerInventory from my onInventoryClose event
theres nothing you can do to fix that without using packets
or ig without closing works maybe
does player.sendBlockDamage only send it for one tick or smthin?
cus im trying to use it for a custom block breaking system and it is rly glitchy and disappearing and reappearing when I mine
you can
with packets :)
very simple but basically you reopen the container with the same id
client-sided predictions n all
they time out after like 5 seconds?
you need to re-use the same id for each block and give fatigue so the client can't predict it
it like flickers kinda lol
for the id thing, just use the block location's hashcode
someone? :(
Hey Guys, i've tried switching to 1.19.2, so i downloaded spigot 1.19.2 and added it to my referenced library but i still can't import import org.bukkit.plugin.java.JavaPlugin;
Do you know why ?
how are you adding spigot to your project?
Are you using a version control system like Gradle or Maven?
i've never used packets. Hard to do that ??
Nope, i'm not
It's the most basic nms thing
this is what it does
oh god
i'm just right clicking referenced libraries, and i add my spigot.jar
its ok it just kinda flickers
that's the client doing stupid shit
ah dang
add a negative mining fatigue effect
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
and send the packet with the player's entity id
use gradle or maven
to make the client not predict
i absolutely have to use maven or graven if i want it to work ??
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
that tells you what jar to depend on if you dont want to
i would highly recommend using maven or gradle though
Oh tysm i didn't understand it was for me :)
all my homies coding in bytecode
xD
i code in brainfuck
paypal seriously using base64 strings on their URL
question md_5
why is spigot fork of the old bukkit api
it is 2022
7 months of development
it's time you start
what does that question even mean
yo md
the one problem i have, i havent touched nms, packets or like half of spigot api yet
I heard you use the logi mx master 3
and i dont know all of java
that's fine, you're starting out
yes
I only started touching nms after 3 years
nms is so weird
theyre nice mice, though they only last 2-3 years on average :\
why isn't just it own stand alone thing? just wondering
what do you mean?
uh I dont think so, might get an mx keys for laptop though
so excuse me if i sound kinda dumb
are you asking why is spigot a fork not a standalone thing
mx keys automatic backlight so nice
yes exactly
for bitches like me who just walk out of their pc and let it go on standby by itself
because its helpful to have old plugins work and not just make a new API for no reason?
than you EpicEbic
i wonder if i can make my computer auto hibernate if my pc is not doing stuff for an hour
backwards compatibility yes
keyboard uses proximity sensors to turn on the backlight when my hands are on it
and turns itself off once I'm not using
it's taking FOREVER to download wtf
is it normal if it has been downloading for 10Mins ?
buildtools?
yes
yes that is normal
do u have an idea of the size of it ?
no idea on teh size
is this sentence english btw ?
yeah
kk
normally it takes 20min for me but can take longer depending on your hardware
how can I uninstall it ? Cause i'm only installing it for a test
hello, how do I get the EXACT Direction(As a Vector) a player is looking at with their crosshair
since player.getEyeLocation().getDirection()gives me weird outputs
what is weird about it
well then my vector is just wrong lol
the direction is just wrong
hmmm wait maybe something else is wrong
I just get wrong outputs for my particles:
public List<Location> getProjectionPoints(Location bulletStart, Vector direction) {
List<Location> projectionLocations = new ArrayList<Location>();
double distance = 0;
RayTraceResult RTres = bulletStart.getWorld().rayTraceBlocks(bulletStart, direction, 1000);
distance = RTres.getHitBlock().getLocation().distance(bulletStart);
Location targetLocation = bulletStart.clone().add(RTres.getHitPosition());
Location l = bulletStart;
Vector vector = targetLocation.toVector().clone().subtract(bulletStart.toVector()).normalize().multiply(1.2);
double length = 0;
while(length < distance) {
l.add(vector);
Bukkit.getLogger().info("vecLoop: " + l.clone().getX() + ";" + l.clone().getY() + ";" + l.clone().getZ() + " | length=" + length + " | distance=" + distance + " | Vec=" + vector.getX() + ";" + vector.getY() + ";" + vector.getZ());
projectionLocations.add(l.clone());
length += 1.2;
}
return projectionLocations;
}
when targetting the Block 19 -59 50, im getting the output 21 -62 50
in which case you just want scalar multiplication, not vector addition
taking math notes
lol
?iamlazy
ok so
I noticed that I it is wrong to do the multiply(1.2)
but I still have some offset, and the offset is not there when I look in a specific direction
somehow the vector is wrong
In 1.19, putting the .jar plugin in the plugins folder isn't working ?
Wait, which jar are you putting in the plugins folder?
i'm exporting to jar from my java project and then i'm putting it into the plugins folder
And? Do you get any errors when trying to start the server?
Nope !
?paste the full startup log, an what's the plugin called
What java version are you using
it completely goes in the wrong direction
Your compiler is using a newer java than your server is running.
I downloaded the latest
Latest is not a number
Did you ask for a number ? :p
I've downloaded java 19
Java SE Development Kit 19.0.1 downloads
Downgrade to Java 17
Do i just have to dl it and to open it ?
Remove Java 19, Then download and install Java 17, and convert your plugin to use Java 17 and re-build it
It still tells me that i'm using a more recent version ...
What does the output of java --version show
C:\Users\loual>java -version
java version "17.0.5" 2022-10-18 LTS
Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)
I'm running 1.12.2
With spigot 1.12.2 as it seemed logic
You should be able to run it on 17. Just that you don't really want to unless it's only a plugin for you and not some pub plugin
Ok i've tried with a lot of versions on another server and it's 1.17
Why ?
Because when people DL it and run it with the recommended version of java it won't run because it was compiled with a newer version
So what version do you think is the best ?
Whatever version is recommended
Assuming it's a public plugin. If it's private it doesn't matter. If it's public you'll want to enable the largest group of people to be able to use it.
jearn lava
lree fava jessons
fun algorithm to make
replacing first letter
with next in line's first letter
Does anyone know is it possible to get the variant of the axolotl while it's in the bucket?
declaration: package: org.bukkit.inventory.meta, interface: AxolotlBucketMeta
thx
Axolotl bucket meta but no goat horns 😩
How do I getVariant because when I run if (new AxolotlBucketMeta().hasVariant()){ it returns an error
an error
well
im pretty new to it
you get an itemmeta object from an itemstack, then check if the itemmeta is an instance of axolotlbucketmeta. afterwards you cast and voila, you have your axolotlbucketmeta
anyone know off the top of their heads if there's a way to conditionally have one css style or a different css style based on some kind of if statement without tying it in with JS?
Hey all, what JDK version do you all use for Spigot dev nowadays? I remember I ran into some issues coding plugins for the public when I was using a too-new JDK earlier
if you're going to want something dynamic like that I assume you'll be needing JS
I have java 18 oracle or something.
ah there is another java update.
17 is pretty standard
You mean like different css classes applied to a specific element? Or like css variables?
it's fine I caved in an am just doing it via js
I think I might've maybe been able to do it via media queries but those don't look dynamic
there's maybe some other math trickery I could've done in css but nothing as easy as just adding a window resize listener
defender.addPotionEffect((new PotionEffect(PotionEffectType.BLINDNESS, 60, 0, false, false, true)));
why does this result in blindness 2
aw heck yeah my webapp is now ultra responsive
idk why i get this error but when i tryed to compare type with string to know if item is Pickaxe or other the game return false everytime :/
public Boolean isType(ItemStack item, Tool type)
{
String it = item.getType().toString();
System.out.println("Item: "+item.getType()+" Tool: "+type);
switch(type)
{
case ARMOR:
System.out.println(it.contains("Helmet"));
return (it.contains("Helmet") || it.contains("Chestplate") || it.contains("Boot") || it.contains("Legging"));
case ALL:
return (item.getType() == Material.BOW || it.contains("Sword") || it.contains("Axe") || it.contains("hoe") || it.contains("shovel"));
case SWORD:
return (it.contains("Sword"));
case TOOLS:
return (it.contains("Axe") || it.contains("Hoe") || it.contains("Shovel"));
case PICKAXE:
return (item.getType().toString().contains("Pickaxe") || (item.hasItemMeta() && item.getItemMeta().getDisplayName().contains("Hammer")));
case HOE:
return (item.getType().toString().contains("Hoe"));
default:
return false;
}
}```
contains() is case sensitive
I know but now i changed the code to add lower case on it variable but the problem still :/
public Boolean isType(ItemStack item, Tool type)
{
String it = item.getType().toString().toLowerCase();
switch(type)
{
case ARMOR:
return (it.contains("Helmet") || it.contains("Chestplate") || it.contains("Boot") || it.contains("Legging"));
case ALL:
return (item.getType() == Material.BOW || it.contains("Sword") || it.contains("Axe") || it.contains("hoe") || it.contains("shovel"));
case SWORD:
return (it.contains("Sword"));
case TOOLS:
return (it.contains("Axe") || it.contains("Hoe") || it.contains("Shovel"));
case PICKAXE:
return (item.getType().toString().contains("Pickaxe") || (item.hasItemMeta() && item.getItemMeta().getDisplayName().contains("Hammer")));
case HOE:
return (item.getType().toString().contains("Hoe"));
default:
return false;
}
}```
again, it's case sensitive
you're making it lowercase but checking if it contains with a capital letter
diamond_helmet does not contain "Helmet"
change them to lowercase
Ow my bad thnx for ur help bro
I'm having another error with checking Material
System.out.println(mat+" "+it.getType());
System.out.println(it.getType().equals(mat));
if(!(it.getType().equals(mat) && mat.equals(Material.AIR))) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.RED+"Cannot store that item !"));
return;
}```
why not avoid this whole mess and use pdc
???
Im not on the same problem
Now im storing item into an Inventory but i want to have only the same item (except when menu is empty)
its not really an inventory so i cant check if the slot is empty
Im storing them in my db when player click on the block
the screen return the two item material and the check if they are similar
interesting
https://commandgeek.boomer.international/4R1kRCWT
is it possible to set it invis before i spawn it its very noticeable you see giant slime for a couple ticks
you can create an entity before you spawn it
PlayerTasks.put(player.getUniqueId(), runnable.getTaskId());``` It says that task have not been scheduled yet (errors on second line) but it's scheduled on the first line as you see
how can i fix it?
If runnable is a bukkitrunnable you should be calling runnable.schedule
There should even be a deprecation warning you
@Override
public HashMap<Location, Integer> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// Create a new HashMap
HashMap<Location, Integer> map = new HashMap<>();
// Cast the JsonElement to a JsonObject
JsonObject object = json.getAsJsonObject();
// Loop through the JsonObject and add the values to the HashMap
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
map.put(Location.deserialize(entry.getKey()), entry.getValue().getAsInt());
}
// Return the HashMap
return map;
}``` this is giving me Required type: Map<java.lang.String, java.lang.Object> Provided: String (as expected) but i cant think of any other way to do it
full class https://paste.md-5.net/isofehihez.cpp
yea there is
uhh. where is it?
?
what am i doing wrong?
can i have a example? i quite cant understand what u are trying to tell
Whichever is applicable for your situation
ok
it has deprecation warning again
uh
i get it
nvm
md_5
am i the only one with that one problem where ProtocolLib never worked for me on maven
at least never without it being on a system scope
it just shows it's working on Intellij there is no errors but it's not even in my .m2 folder
if there's anybody else with that problem just lmk that I'm not lonely 😭
show your pom
//push
Make it a runnable not a bukkitrunnable
So what you mean is that IJ's maven integration finds Protolib? So what is the issue there? That it isn't in the .m2 folder is to be expected with some things
Yeah, dump it into a FileOutputStream, then load the file
Unless you want to do some truely dark magic java needs an URL somewhere at the very least
yeah but i need to have a "temp" folder, the thing is i want to do the whole process on memory
I guess you could do in-memory URLs but I recall that being not super fun
in memory urls? whats that
https://github.com/Starloader-project/slbrachyura/tree/master/brachyura/src/main/java/io/github/coolcrabs/brachyura/memurl something with this. Super hacky to be honest and I do not know if URLClassloader would like that
How to find nearest block witch is not air under the sertain location?
For older versions of spigot it might even be easier to instantiate a https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java (through reflection hackery) with a dummy URL as it's path and doing the actual classloading through the parent classloader (which you c an easily do by overriding Classloader#findClass to return a bytearray defined in a map)
It could be possible for newer versions too, but I am not aware how well it would work
I need it to calculate collision for npc
If you want to keep your temporary jar as small as possible you could use my UnsafeValues hack in order to inflate the 0-length entries within the jar to their proper size
BFS (Breadth-first-search)
How that is actually done in a 3D world I cannot tell unless you want your plugin to be GPL
hmm, my idea was to just modify SimplePluginManager#loadPlugin(File file) to be working with inputstream, but... will that even work?
The issue is that JavaPlugin#getProvidingPlugin would break no matter what you do
huh, why?
It expects the classloader of the class to be a PluginClassLoader
hmm, will i even need that?
no idea, but protolib might
ah
no need lol
Can I squash 2 git commits if one of them came from a merged branch? I've been working on a feature branch and I was forced to merge another branch into it, and now I cannot squash my commits... (I use gitkraken)
The bottom commit is from dependabot:
Are those two commits the last two commits?
bukkitrunnable is deprecated
oh wait isnt it -
lol
no but i need it to invert the bits
~i?
lol
me thinking that constructor call was the overhead but no
love it how the results are not equal \🤔
why does this one flag include like 70% of the lore
they had 32 bits to work with
It shouldnt be
in that method it is
It’s not deprecated yeah. Cause he just needs to call it differently.
exactly
and i can't use a single class
because there's no jat file to use
Then it doesn't find ProtoLib
Flush caches, hit the IDE with a hammer and so on
i tried both
i even restarted my pc
nothing really helpful
as if ProtocolLib is just my inner conscious being mad at me for the people i killed in Valorant and Minecraft
i haven't killed a single person in these games in a while
there was a grace period. i want more of that.
I am a complete IJ noob, but could you show the screen that looks roughly equivalent to this (with the protocollib jar extanded)?
Do note that this is eclipse, IJ will look vastly different
yes
look in external libs
it shows all libraries and you can look inside of them
the funny thing is if i misspell ProtocolLib it shows an error
so it's sure it's ProtocolLib
and sure
1s
chances are either the scope is wrong or the classifier or type is the wrong one or you have set it in the dependency management block by accident
Is there a way to set inventory title to text componet?
hi , what does this error mean : ?
co.aikar.commands.UnresolvedDependencyException: Could not find a registered instance
Playing the human mavenresolver that should work: https://repo.dmulloy2.net/repository/public/com/comphenix/protocol/ProtocolLib/4.8.0/ProtocolLib-4.8.0.jar
ok i figured it out thanks
I guess you'd need to try force a refresh of the maven build (perhaps a full reload)
But again, I have no experience with IJ maven, so I cannot tell
using @Dependency or smth?
yeb i fixed it thanks
how do i make the player damage an entity
i tried player#attack but it seems that the entity needs to be in range for that to work
hey, i want the use the vault api in my plugin to hook chat/economy. but both do not work. in the server the plugins (pex and craftconomy) are there and get recognized by vault, but my plugin does not hook into them
Here is my Vault method
public void hookVault() {
Plugin vault = this.getServer().getPluginManager().getPlugin("Vault");
if (vault != null) {
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
economySystem = economyProvider.getProvider();
System.out.println("[Hook] Vault: Hooked with economy system");
}
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(Chat.class);
if(chatProvider != null) {
chatSystem = chatProvider.getProvider();
System.out.println("[Hook] Vault: Hooked with chat system");
}
}
}
Here is the console output:
[13:43:51] [Server thread/INFO]: [Vault] [Permission] PermissionsEx found: Waiting
[13:43:51] [Server thread/INFO]: [Vault] [Permission] SuperPermissions loaded as backup permission system.
[13:43:51] [Server thread/INFO]: [Vault] [Chat] PermissionsEx found: Waiting
[13:43:51] [Server thread/INFO]: [Vault] Enabled Version 1.7.3-b131
[13:43:51] [Server thread/INFO]: [PermissionsEx] Enabling PermissionsEx v1.23.4
[13:43:51] [Server thread/INFO]: [PermissionsEx] Initializing file backend
[13:43:51] [Server thread/INFO]: [PermissionsEx] Permissions file successfully reloaded
[13:43:51] [Server thread/INFO]: [Vault][Permission] PermissionsEx hooked.
[13:43:51] [Server thread/INFO]: [Vault] [Vault][Chat] PermissionsEx_Chat hooked.
[13:43:51] [Server thread/INFO]: [Craftconomy3] Enabling Craftconomy3 v3.3.1-d99cf63-trv200
[13:43:51] [Server thread/INFO]: [Craftconomy3] Starting up!
[13:43:51] [Server thread/INFO]: [Craftconomy3] Loading the Configuration
[13:43:51] [Thread-83/WARN]: [PermissionsEx] The updater could not find any files for the project id 31279
[13:43:51] [Server thread/INFO]: [Craftconomy3] Loading listeners.
[13:43:51] [Server thread/INFO]: [Craftconomy3] Loading commands
[13:43:51] [Server thread/WARN]: [Craftconomy3] Loading Craftconomy in setup mode. Please type /ccsetup to start the setup.
[13:43:51] [Server thread/INFO]: [Vault] [Economy] Craftconomy3 hooked.
I got vault api with maven. here is the repo:
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>spigot-vault-api</id>
<url>https://ci.ender.zone/plugin/repository/everything/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
</dependency>
</dependencies>
Means the vault is perhaps somehow null?
Try doing some debug printing on nullability of
Plugin vault = this.getServer().getPluginManager().getPlugin("Vault");
depending or softdepending on vault?
bruh why am i getting this stupid cryptic ahh error
* What went wrong:
A problem occurred evaluating script.
> No signature of method: module_1tvwuz28hz5f7m96ddjq2c1al.tasks() is applicable for argument types: (module_1tvwuz28hz5f7m96ddjq2c1al$_run_closure4) values: [module_1tvwuz28hz5f7m96ddjq2c1al$_run_closure4@25bc18b4]
Possible solutions: hasMc(), tap(groovy.lang.Closure), wait(), any(), wait(long), files([Ljava.lang.Object;)
tasks { /* <- it says error is here */
assemble {
dependsOn(shadowJar) }
if (hasMc()) {
assemble { dependsOn(shadowJar, reobfJar) }
}
compileJava {
options.encoding = 'UTF-8'
options.release.set(17) }
javadoc {
options.encoding = 'UTF-8' }
processResources {
filteringCharset = 'UTF-8' }
reobfJar {
String mcS = hasMc() ? "+" + project.versionMC : "";
String fn = project.name + "-" + project.version + mcS + ".jar";
outputFile(new File("../builds/", fn));
}
}
Ah right - the reason I ditched gradle
is there anything outside the tasks thing?
i feel the same pain as when i get a c++ linking error
I am pretty sure that everything would work if you ditch tasks and put it's contents a layer down
aight
At least I never recall configuring such an object
ok so I know this is a really weird question and more like gameplay-experience orientated. With the following code, I am shooting at a block from a player-perspective. The bulletStart is the location of the right hand. This means that the target is getting hit like too much down-right, which means if you shoot a player you may miss even if you aim correctly(See example screenshot):```java
public List<Location> getProjectionPoints(Location bulletStart, Vector direction) {
List<Location> projectionLocations = new ArrayList<Location>();
double distance = 0;
RayTraceResult RTres = bulletStart.getWorld().rayTraceBlocks(bulletStart, direction, 1000);
if(RTres == null || RTres.getHitBlock() == null && RTres.getHitEntity() == null) {
distance = 1000;
} else {
distance = RTres.getHitPosition().distance(bulletStart.toVector());
}
Location l = bulletStart;
Vector vector = direction.clone();
double length = 0;
while(length < distance) {
l.add(vector);
projectionLocations.add(l.clone());
length += 1.05;
}
return projectionLocations;
}
**_Now my Question is, how do I make it so that the bullet hits the EXACT location on the target?_**
Or whatever this cursery is called
getHitPosition provides the exact point of where it's hit
Likely similar issues:
- https://github.com/MilkBowl/VaultAPI/issues/150 (Problems with Vault)
- https://github.com/MilkBowl/Vault/issues/906 (Economy provider issue)
- https://github.com/MilkBowl/Vault/issues/905 (Economy Provider issue)
yeah I see but it still does not hit it as you can see lol
How can i use debug without being disconnect with intelij ? If I'm too long my server is disconnected :
Disconnected from the target VM, address: '127.0.0.1:51389', transport: 'socket'
it is possible that you are experiencing rounding issues?
uhm im not rounding anywhere
Uh, floating-point issues
just use raytrace, if the result is null, render a line with the range of like 60
if not, render a line between start and end pos
you gotta start splitting methods a bit
That rendering process does not seem to work correctly
Raytrace -> renderPoints(result) -> do shit with the same result
instead of calculating a result in the renderPoints method itself
They do not use that though
I dont get why it does not work :(
because I have other functions than you?
@fair zealot What the name of ur plugin, show us your main class.
Your plugin.yml
I don't see where it does not work though
and your guns do not include the thing I am doing here
Here is my main class
package de.ahmet.knockbackffa;
import de.ahmet.knockbackffa.commands.setup.SetupCommand;
import de.ahmet.knockbackffa.configuration.LocationConfiguration;
import de.ahmet.knockbackffa.configuration.MessageConfiguration;
import de.ahmet.knockbackffa.configuration.PluginConfiguration;
import de.ahmet.knockbackffa.database.MySQL;
import de.ahmet.knockbackffa.listener.ServerDefaultListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
public final class KnockbackFFA extends JavaPlugin {
public static String pluginVersion;
// configuration
public PluginConfiguration config;
public MessageConfiguration messages;
public LocationConfiguration locations;
// database
// api
private Economy economySystem;
private Chat chatSystem;
@Override
public void onEnable() {
pluginVersion = getDescription().getVersion();
loadConfig();
loadSetupCommands();
if(isReady()) {
loadDatabase();
loadCommands();
hookVault();
loadListener();
getServer().getConsoleSender().sendMessage(config.getPrefix() + "§cThe game is ready");
} else {
getServer().getConsoleSender().sendMessage(config.getPrefix() + "§cThe game is not ready yet§8. §7Use §e/setup §7to set everything up");
}
}
// loader section
public void loadSetupCommands() {
getCommand("setup").setExecutor(new SetupCommand(this));
getCommand("setup").setTabCompleter(new SetupCommand(this));
}
public void loadCommands() {
}
public void loadListener() {
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new ServerDefaultListener(this), this);
}
public void loadConfig() {
this.config = new PluginConfiguration(this);
this.messages = new MessageConfiguration(this);
this.locations = new LocationConfiguration();
}
public void loadDatabase() {
if(config.isSqlEnabled()) {
MySQL mySQL = new MySQL(this, config.getSQLHostname(), config.getSqlPort(), config.getSqlDatabase(), config.getSqlUser(), config.getSqlPassword());
if(mySQL.getConnection() == null) {
System.out.println("[KnockbackFFA] Disable MySQL and reload.");
}
}
}
public void hookVault() {
Plugin vault = this.getServer().getPluginManager().getPlugin("Vault");
if (vault != null) {
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
economySystem = economyProvider.getProvider();
System.out.println("[KnockbackFFA] Vault: Hooked with economy system");
}
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(Chat.class);
if(chatProvider != null) {
chatSystem = chatProvider.getProvider();
System.out.println("[KnockbackFFA] Vault: Hooked with chat system");
}
}
}
// method section
public boolean isReady() {
return locations.ready();
}
public void reload() {
getServer().reload();
}
// getter section
public Economy getEconomySystem() {
return economySystem;
}
public Chat getChatSystem() {
return chatSystem;
}
}
It's 100% the issue that I gave them before as 100% of all vault issues are that
raytrace blocks instead of blocks & entities?
It's very very frustrating that that is the case -.-
the isReady() method is true btw.
Your @fair zealot plugin.yml?
name: KnockbackFFA
version: '${project.version}'
main: de.ahmet.knockbackffa.KnockbackFFA
api-version: 1.13
prefix: KnockbackFFA
softdepend: [ Vault ]
authors: [ ahmet ]
description: a knockback ffa remaster
commands:
setup:
description: A KnockbackFFA provided command
stats:
description: A KnockbackFFA provided command
you are shooting your bullet from the player directly, I am shooting it from about the right hand coordinates
okay, just change the eyeLocation variable to the right hand location
I almost want to write a bot that replies "Yo, stop using the Bukkit registry" whenever it encounters RegisteredServiceProvider<Economy>
xD
I did
Because that - whether you know it or not - is a bug waiting to happen
what can i use instead
rest works
@fair zealot I am guessing like geol said, whilst vault is indeed loaded. Your economy provider has not provided itself yet, and you can't hook into it yet.
declaration: package: org.bukkit.event.server, class: ServiceRegisterEvent
The most simple and dirty solution is just to register a taskscheduler that runs the code.
ooooh now i start to understand
tbh I did not use your code, just informed about some raytracing this and that, bukkit forums and then wrote the method myself
thank you very much ill try it now
so rest works is obvious
while usually working, it is dangerous when a plugin gets unloaded
You're doing some weird wacky stuff with your code like doing raycasts on the render method
I did say dirty haha
Make a method that:
- Does the raycasting
- Renders the particles, based on the raycasting
- uses the hit position to do damage / whatever
basically a shoot() method
I have, you can see it in my question
so in the event i just ask the name of the service, right?
... to determine the end point
im passing java handLoc, player.getEyeLocation().getDirection()btw.
That method should only be used to render the particles themselves
whatever
AH I see
You need to shoot from the eyes, not hand
no I want it to shoot from the hand lol
shooting from eyes looks ugly imo
what weird gun is that
flamethrower
Then gl aligning the crosshair
thats the issue basicly
ah its a flamethrower
The hand direction vector
I tried, it is scuffed
it always has about the same angle, no matter where I look
Really?
Well I basically mean computing the vector between hand and the target
do I pass the yaw/pitch to the handLoc?
public void onServiceRegister(ServiceRegisterEvent event) {
if(event.getProvider().getService().equals(Chat.class)) {
chatSystem =
}
I have no idea from now on xD, chatSystem is RegisteredServiceProvider<Chat>
not truely
yes I do, you can see it in the method of the question I sent
event.getProvider().getService() instanceof Chat
You don't do that
The IDE says Inconvertible types; cannot cast 'java.lang.Class<capture<?>>' to 'net.milkbowl.vault.chat.Chat
You just continuously add the vector of your hand onto it
in the method, bulletStart is the location of the hand
huh
?jd-s
the direction is my eye-vector where im looking
public void shoot(Player player, Location handLocation) {
Vector direction = handLocation.getDirection();
World world = player.getWorld();
double range = 100;
RaytraceResult result = ...
if(result == null) {
renderLine(handLocation, handLocation.clone().add(direction.clone().normalize().multiply(range)));
return;
}
Vector hitPosition = result.getHitPosition();
renderLine(handLocation, hitPosition.toLocation(world));
// do damage
}
public void renderLine(Location start, Location finish) {
Vector offset = finish.toVector().subtract(start.toVector());
double density = 0.3;
double distance = start.distance(finish);
offset = offset.normalize().multiply(density);
Location current = start.clone();
List<Location> positions = new ArrayList<>();
for(double position = 0; position <= distance; position += distance) {
current.add(offset);
positions.add(current.clone());
}
// pass positions to your renderer / queue
}
Oh yeah, then your code was correct. I mixed up #getService with #getProvider()
which is the wrong vector as I said
I would like to get the tps of all plots, query whether they have reached a limit and, if a plot has reached the limit, the redstone should be deactivated or the RandomTickSpeed should be lowered. (Only for the respective plot)
Vector offset = finish.toVector().subtract(start.toVector());
double density = 0.3;
double distance = start.distance(finish);
offset = offset.normalize().multiply(density);
would be the vector you need according to @echo basalt ' code
And that calculates the vector between the two pos, no?
ye
and then this, right: chatSystem = getServer().getServicesManager().getRegistration(Chat.class).getProvider();
to set the provicer
Yep
thanks!
the vector that you need to add to start, 1/density*start times to get to finish
Perhaps do it once too in the onEnable block, but outside of that, no
when I replace the vector of the direction with the full vector of start to end, wouldn't my whole code after break?
or does it not because I normalize it?
Yep.
you clone and normalize it
I've used raytracing so many times fml
even made my own algorithm
and for raytracing, I still use the direction of the eye?
nope
and then render the line with the vector between these 2
you use the direction of the hand
which is scuffed as hell isn't it
"a bit" for me was literally the opposite direction not mattering on any positions or rotations at all
ye
double yawRightHandDirection = Math.toRadians(-1 * player.getEyeLocation().getYaw() - 45);
double x = 0.5 * Math.sin(yawRightHandDirection) + player.getLocation().getX();
double y = player.getLocation().getY() + 1.45;
double z = 0.5 * Math.cos(yawRightHandDirection) + player.getLocation().getZ();
Location handLoc = new Location(player.getWorld(), x, y, z);
yeah so thats why it is scuffed
imo it should just be like
Vector offset = new Vector(0.2, -0.35, 0).rotateAroundY(Math.toRadians(yaw - 45);
Location handLocation = eyeLocation.clone().add(offset);
// correct yaw and pitch
float yawOffset = 5f; // mess with these nums
float pitchOffset = -3f;
handLocation.setYaw(handLocation.getYaw() - yawOffset);
handLocation.setPitch(handLocation.getPitch() - pitchOffset);
then you just mess with the numbers a bit
guys how does the durability of items work, iam trying to make it run something when a tool or armor reaches 10 points but it triggers it when the durability is like still full anyways
@EventHandler
public void onItemDamage(PlayerItemDamageEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (item.getDurability() > 10) {
return;
}```
well as geol said, it does not include rotation then?
public void hookVault() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onServiceRegister(ServiceRegisterEvent event) {
if(!config.isVaultEnabled()) {
return;
}
Plugin vault = this.getServer().getPluginManager().getPlugin("Vault");
if (vault == null) {
return;
}
if(event.getProvider().getService().equals(Chat.class)) {
chatSystem = getServer().getServicesManager().getRegistration(Chat.class).getProvider();
System.out.println("[KnockbackFFA] VaultHook: Hooked with chat system");
}
if(event.getProvider().getService().equals(Economy.class)) {
economySystem = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
System.out.println("[KnockbackFFA] VaultHook: Hooked with economy system");
}
}```
I have done it like this now, but it does not register the events.
The event is not even run
the setYaw and setPitch handle it
add a bit of Z as well
like 0.2
because the hand is a bit ahead
you might need to permutate X and Z
can you explain what the "offset" is in your code pls?
just mess with the values a bit and you'll get there
🥺
basically this
ye
ok imma try

