#TargetBlock location & look direction
1 messages · Page 1 of 1 (latest)
push 😄
.
this is like
a pretty simple question and nobody has answered you in 3 days
and i feel horrible
declaration: package: org.bukkit.entity, interface: LivingEntity
try this
@dark coral
so like now i've got the position as location and want to append it the direction. where do i get it out of the raytrace and how do i append it to a location object?
RayTraceResult rayTraceResult = ((Player) sender).rayTraceBlocks((double) 5);
Block block = rayTraceResult.getHitBlock();
BlockFace blockFace = rayTraceResult.getHitBlockFace();
assert block != null;
block.setType(Material.AIR);
Location location = block.getLocation();
location.setDirection() // TODO:
World world = ((Player) sender).getWorld();
placeItemFrame(world, location, ids);
and how do i insert it to location after i've got it?
here's what place itemframe does: (just that you have an overview of what i wanna do)
private ItemStack modifyMap(int i, int[] ids) {
ItemStack map = new ItemStack(Material.FILLED_MAP);
MapMeta mapMeta = (MapMeta) map.getItemMeta();
mapMeta.setMapId(ids[i]);
map.setItemMeta(mapMeta);
return map;
}
private void placeItemFrame(World world, Location location, int[] ids) {
ItemFrame itemFrame = (ItemFrame) world.spawnEntity(location, EntityType.ITEM_FRAME);
itemFrame.setFixed(true);
itemFrame.setVisible(false);
itemFrame.setItem(modifyMap(0, ids));
}
get rid of the world parameter
extract the world from location
RayTraceResult rtResult = ((Player) sender).rayTraceBlocks(5d);
if (rtResult == null) {
return;
}
Block block = rtResult.getHitBlock();
if (block == null) {
return;
}
Block toFrame = block.getRelative(rtResult.getHitBlockFace());
placeItemFrame(toFrame.getLocation(), ids);
perfect thy, i'll test it 😄
whats the problem?!? why does it prefer this block direction?
a poster maker... so like map art out of image url
have to go to school now, but i'll be back in like 45 mins
how to set it? it isn't stored in the location object?
i took exactly this code and made some small changes, but nothing with hit face or location
itemFrame.setFacingDirection(blockFace)
okee thy so much for all your support ❤️