use of net.minecraft.util.hit.BlockHitResult in project meteor-crash-addon by AntiCope.
the class ContainerCrash method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
toggle();
mc.player.closeHandledScreen();
}
BlockIterator.register(4, 4, ((blockPos, blockState) -> {
Block block = blockState.getBlock();
if (block instanceof AbstractChestBlock || block instanceof ShulkerBoxBlock) {
BlockHitResult bhr = new BlockHitResult(new Vec3d(blockPos.getX(), blockPos.getY(), blockPos.getZ()), Direction.DOWN, blockPos, false);
PlayerInteractBlockC2SPacket openPacket = new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, bhr);
for (int i = 0; i < amount.get(); i++) {
mc.getNetworkHandler().sendPacket(openPacket);
}
}
}));
}
use of net.minecraft.util.hit.BlockHitResult in project meteor-crash-addon by AntiCope.
the class TryUseCrash method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
BlockHitResult bhr = new BlockHitResult(new Vec3d(.5, .5, .5), Direction.DOWN, mc.player.getBlockPos(), false);
net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket packet = new PlayerInteractItemC2SPacket(Hand.MAIN_HAND);
PlayerInteractBlockC2SPacket packet1 = new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, bhr);
if (mc.getNetworkHandler() == null)
return;
for (int i = 0; i < packets.get(); i++) {
mc.getNetworkHandler().sendPacket(packet);
mc.getNetworkHandler().sendPacket(packet1);
}
}
use of net.minecraft.util.hit.BlockHitResult in project meteor-client by MeteorDevelopment.
the class GhostHand method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (!mc.options.useKey.isPressed() || mc.player.isSneaking())
return;
for (BlockEntity blockEntity : Utils.blockEntities()) {
if (new BlockPos(mc.player.raycast(mc.interactionManager.getReachDistance(), mc.getTickDelta(), false).getPos()).equals(blockEntity.getPos()))
return;
}
Vec3d nextPos = new Vec3d(0, 0, 0.1).rotateX(-(float) Math.toRadians(mc.player.getPitch())).rotateY(-(float) Math.toRadians(mc.player.getYaw()));
for (int i = 1; i < mc.interactionManager.getReachDistance() * 10; i++) {
BlockPos curPos = new BlockPos(mc.player.getCameraPosVec(mc.getTickDelta()).add(nextPos.multiply(i)));
if (posList.contains(curPos))
continue;
posList.add(curPos);
for (BlockEntity blockEntity : Utils.blockEntities()) {
if (blockEntity.getPos().equals(curPos)) {
mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(mc.player.getPos(), Direction.UP, curPos, true));
return;
}
}
}
posList.clear();
}
use of net.minecraft.util.hit.BlockHitResult in project meteor-client by MeteorDevelopment.
the class BlockUtils method place.
public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rotate, int rotationPriority, boolean swingHand, boolean checkEntities, boolean swapBack) {
if (slot < 0 || slot > 8)
return false;
if (!canPlace(blockPos, checkEntities))
return false;
((IVec3d) hitPos).set(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5);
BlockPos neighbour;
Direction side = getPlaceSide(blockPos);
if (side == null) {
side = Direction.UP;
neighbour = blockPos;
} else {
neighbour = blockPos.offset(side.getOpposite());
hitPos.add(side.getOffsetX() * 0.5, side.getOffsetY() * 0.5, side.getOffsetZ() * 0.5);
}
Direction s = side;
if (rotate) {
Rotations.rotate(Rotations.getYaw(hitPos), Rotations.getPitch(hitPos), rotationPriority, () -> {
InvUtils.swap(slot, swapBack);
place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand);
if (swapBack)
InvUtils.swapBack();
});
} else {
InvUtils.swap(slot, swapBack);
place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand);
if (swapBack)
InvUtils.swapBack();
}
return true;
}
use of net.minecraft.util.hit.BlockHitResult in project meteor-client by MeteorDevelopment.
the class LookingAtHud method getRight.
@Override
protected String getRight() {
if (isInEditor())
return position.get() ? "Obsidian (0, 0, 0)" : "Obsidian";
if (mc.crosshairTarget.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
String result = Names.get(mc.world.getBlockState(pos).getBlock());
if (position.get()) {
result += String.format(" (%d, %d, %d)", pos.getX(), pos.getY(), pos.getZ());
}
if (waterLogged.get() && mc.world.getFluidState(pos).isIn(FluidTags.WATER)) {
result += " (water logged)";
}
return result;
} else if (mc.crosshairTarget.getType() == HitResult.Type.ENTITY) {
Entity target = ((EntityHitResult) mc.crosshairTarget).getEntity();
String result;
if (target instanceof PlayerEntity)
result = ((PlayerEntity) target).getGameProfile().getName();
else
result = target.getName().getString();
if (position.get()) {
result += String.format(" (%d, %d, %d)", target.getBlockX(), target.getBlockY(), target.getBlockZ());
}
if (waterLogged.get() && target.isTouchingWater()) {
result += " (in water)";
}
return result;
}
return "";
}
Aggregations