#Dafeist's thread because chat is spammy
1 messages · Page 1 of 1 (latest)
k
that should work perfectly fine
no it doesn't
that means you made a mistake somewhere else
Ugh
so you're telling me, all this time that ive been using this, it was wrong?
didn't @deep kite rant something about circular LoS?
it always worked perfectly fine
yeah i think i know what the problem might be
Location eye = player.getEyeLocation();
Vector direction = eye.getDirection().normalize();
double distance = (selection.depth + selection.width) / 4D;
Location distBlock = eye.clone().add(direction.clone().multiply(5 + distance));
let's break down some variables
could u please send the entire function?
are you braindead
me?
guess i am
but you can see the problem right?
I mean
I see what you're trying to do
and this approach is "good enough", you're just snapping a block to the client's LOS
thats not good enough as im literally tilting away all the time when im seeing this
Just for some general info, what's the depth and width you're using?
its the width and depth of my schematic
and are you rounding stuff or just calling getBlock().setType
but it's irrelevant here, as the same problem occurs when just using 5
im directly calling player.sendBlockChange on it
Okay
perhaps it might be a better approach to just test this code by spawning a particle at the given location?
If that works then it is the position -> block logic that is a bit unfortunate
instead of sending a block change sending a particle?
by not rounding we can assure it's not an issue with your math :p
player#spawnParticle(location, ParticleType.something, 1, 0, 0, 0, 0)
does not exist
are you working on 1.8 or something
flip the particle and location args
should be this one
by adding all those 0's you ensure there's no random velocity
which looks awful
Could you show a video so we could have an idea what is going on?
show code you're rounding shit
wait imma spawn the particle directly
BRO NAH
it spawns directly at my fucking crosshair
u trolling right?
@EventHandler
public void e(PlayerInteractEvent e){
if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Player p = e.getPlayer();
if(p.getInventory().getItemInMainHand().getType() != Material.DIAMOND_HORSE_ARMOR) return;
Location l = p.getEyeLocation().add(p.getEyeLocation().getDirection().multiply(5));
Bukkit.broadcastMessage(Utils.locationToString(l, 1));
p.spawnParticle(Particle.FLAME, l, 1, 0, 0, 0, 0);
ew 1 letter variables
^
it would be cool if you showed us more than 4 lines of code
it does
it does
yeah im on it
bad habits
still bad habits
ill use full letter variables next time
one day you'll try smoking because you're just trying
Location distBlock = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(5 + (selection.depth + selection.width)/4D));
System.out.println("distBlock=" + distBlock.getX() + ";" + distBlock.getY() + ";" + distBlock.getZ());
if(latest == null) {
latest = selection.show(player, distBlock, player.getFacing(), true);
return;
}
for(SchematicBlock block : latest) player.sendBlockChange(new Location(player.getWorld(), block.getX(), block.getY(), block.getZ()), Material.AIR.createBlockData());
latest = selection.show(player, distBlock, player.getFacing(), true);
it might not end well
why make new location?
when u calculate it already??
separate that into multiple variables
or am i stupid
SchematicBlock doesn't store world
ah
^
also the code for vectors i provided spawns particle pin point on crosshair >:(
public ArrayList<SchematicBlock> show(Player player, Location center, BlockFace direction, boolean replaceAir) {
ArrayList<SchematicBlock> blocks = render(center, direction, replaceAir);
if(blocks == null) return null;
for(SchematicBlock block : blocks) {
player.sendBlockChange(new Location(player.getWorld(), block.getX(), block.getY(), block.getZ()), block.getBlockdata());
}
return blocks;
}
let's see if by I remaking it, it worky
u need render too?
bro you know I already know the particle is on crosshair and im rounding?
why u constantly telling us that?
Location eye = player.getEyeLocation();
Vector direction = eye.getDirection().normalize();
double distance = (selection.depth + selection.width) / 4D;
Location distBlock = eye.clone().add(direction.clone().multiply(5 + distance));
// debug
player.spawnParticle(Particle.FLAME, distBlock, 1, 0, 0, 0, 0);
if(latest != null) {
BlockData airData = Material.AIR.createBlockData();
for(SchematicBlock block : latest) {
Location blockLocation = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ());
player.sendBlockChange(blockLocation, airData);
}
}
latest = selection.show(player, distBlock, player.getFacing(), true);
uhmmm what??
try that instead of whatever this is
should make it a bit cleaner
that draws the latest schematic position not the new one
imma just try out
does not work now
and you copypasted my code block exactly?
yes
because that's very odd
then the issue seems to be in render()
since it gets the center passed and returns the blocks
wait method too big lol
Literally gonna throw bricks against the window rn. Already tying to fix this simple issue the whole damn afternoon
o.o
is this where selection comes from?
also could explain why you divide selection by 4? o.O
Just a constant
Yes
that isn't very informative
or explain why you divide it by 4
and I assume
that when you were showing the block in the vide
that what you are trying to make like showing the player it will get placed before they place it?
Yes
then...
the entire math is wrong
jk, not all of it lol
but selection is not even important for anything
it shouldn't even be part of the math except to express magnitude
that is the bigger it is, the further away it is so player can see it
because that is what you wanted
sqrt(selection.depth*selection.depth + selection.width*selection.width)
this gives you the magnitude of the selection
Idk and care right now tho bc I gotta fix the issue first lol
Im gonna look at that later, first gotta get it working at all
double mag = sqrt(selection.depth*selection.depth + selection.width*selection.width);
Vector awayDistance = player.getEyeLocation.getDirection().multiply(mag);
Location blockLocationAway = awayDistance.toLocation();
this will give you a location relative to the size of the schematic
bro
from this location, you can center your schematic