laser pointer fixed also fixed block screen gui url changing thing
This commit is contained in:
parent
b9716dd537
commit
0d0c201fba
|
|
@ -75,7 +75,7 @@ dependencies {
|
|||
minecraft 'net.minecraftforge:forge:1.19.2-43.2.6'
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||
|
||||
implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:d45957d9f6")
|
||||
implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:51cf5945f3")
|
||||
implementation fg.deobf("curse.maven:cloth_config_forge-348521:3972423")
|
||||
implementation fg.deobf("curse.maven:SU-370704:4410614")
|
||||
implementation fg.deobf("curse.maven:spark-361579:4381167")
|
||||
|
|
|
|||
|
|
@ -178,16 +178,12 @@ public class BlockScreen extends BaseEntityBlock {
|
|||
TileEntityScreen.Screen scr = te.getScreen(side);
|
||||
|
||||
if (sneaking) { //Right Click
|
||||
if ((scr.rightsFor(player) & ScreenRights.CLICK) == 0) {
|
||||
if((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0)
|
||||
Util.toast(player, "restrictions");
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
(new SetURLData(pos, scr.side, scr.url)).sendTo((ServerPlayer) player);
|
||||
|
||||
Vector2i tmp = new Vector2i();
|
||||
if (hit2pixels(side, hit.getBlockPos(), pos, scr, (float) hit.getLocation().x, (float) hit.getLocation().y, (float) hit.getLocation().z, tmp))
|
||||
te.click(side, tmp);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
} else if (heldItem != null) {
|
||||
if (!te.hasUpgrade(side, heldItem)) {
|
||||
if ((scr.rightsFor(player) & ScreenRights.MANAGE_UPGRADES) == 0) {
|
||||
|
|
|
|||
|
|
@ -605,6 +605,7 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
|||
if(mc.player != null && mc.level != null && ItemInit.itemLaserPointer.isPresent() && mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.itemLaserPointer.get())
|
||||
&& mc.options.keyUse.isDown()
|
||||
&& (mc.hitResult == null || mc.hitResult.getType() == HitResult.Type.BLOCK)) {
|
||||
laserPointerRenderer.isOn = true;
|
||||
BlockHitResult result = raycast(64.0); //TODO: Make that distance configurable
|
||||
|
||||
BlockPos bpos = result.getBlockPos();
|
||||
|
|
@ -633,6 +634,7 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
|||
}
|
||||
}
|
||||
} else {
|
||||
laserPointerRenderer.isOn = false;
|
||||
deselectScreen();
|
||||
|
||||
//Handle JS queries
|
||||
|
|
|
|||
|
|
@ -4,34 +4,35 @@
|
|||
|
||||
package net.montoyo.wd.client.renderers;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class LaserPointerRenderer implements IItemRenderer {
|
||||
|
||||
private static final float PI = (float) Math.PI;
|
||||
private final Tesselator t = Tesselator.getInstance();
|
||||
private final BufferBuilder bb = t.getBuilder();
|
||||
public boolean isOn = false;
|
||||
|
||||
public LaserPointerRenderer() {}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, ItemStack is, float handSideSign, float swingProgress, float equipProgress, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
//This whole method is a fucking hack
|
||||
float sqrtSwingProg = (float) Math.sqrt(swingProgress);
|
||||
float sinSqrtSwingProg1 = (float) Math.sin(sqrtSwingProg * PI);
|
||||
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
float PI = (float) Math.PI;
|
||||
|
||||
float sqrtSwingProg = (float) Math.sqrt(swingProgress);
|
||||
float sinSqrtSwingProg1 = (float) Math.sin(sqrtSwingProg * PI);
|
||||
|
||||
//Laser pointer
|
||||
poseStack.pushPose();
|
||||
|
|
@ -44,11 +45,10 @@ public final class LaserPointerRenderer implements IItemRenderer {
|
|||
poseStack.translate(0.0f, 0.2f, 0.0f);
|
||||
poseStack.mulPose(Vector3f.XP.rotationDegrees(10.0f));
|
||||
poseStack.scale(1.0f / 16.0f, 1.0f / 16.0f, 1.0f / 16.0f);
|
||||
|
||||
RenderSystem.setShaderColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
var matrix = poseStack.last().pose();
|
||||
|
||||
bb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
||||
|
||||
bb.vertex(matrix, 0.0f, 0.0f, 0.0f).color(0.5f, 0.5f, 0.5f, 1.0f).endVertex();
|
||||
bb.vertex(matrix, 1.0f, 0.0f, 0.0f).color(0.5f, 0.5f, 0.5f, 1.0f).endVertex();
|
||||
bb.vertex(matrix, 1.0f, 0.0f, 4.0f).color(0.5f, 0.5f, 0.5f, 1.0f).endVertex();
|
||||
|
|
@ -68,24 +68,42 @@ public final class LaserPointerRenderer implements IItemRenderer {
|
|||
bb.vertex(matrix, 1.0f, -1.0f, 4.0f).color(0.5f, 0.5f, 0.5f, 1.0f).endVertex();
|
||||
bb.vertex(matrix, 1.0f, 0.0f, 4.0f).color(0.5f, 0.5f, 0.5f, 1.0f).endVertex();
|
||||
bb.vertex(matrix, 0.0f, 0.0f, 4.0f).color(0.5f, 0.5f, 0.5f, 1.0f).endVertex();
|
||||
if(isOn) {
|
||||
drawLineBetween(bb, matrix, new Vec3(0.5f, -0.5f, 0.5f), new Vec3(-7.0f, 3.5f, -10.0f));
|
||||
}
|
||||
t.end();
|
||||
|
||||
drawLine(bb, t, matrix);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.enableTexture(); //Fix for shitty minecraft fire
|
||||
RenderSystem.enableCull();
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
public static void drawLine(BufferBuilder bb, Tesselator t, Matrix4f matrix) {
|
||||
GlStateManager._enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
RenderSystem.setShaderColor(255f, 0f,0f, 127.5f);
|
||||
RenderSystem.enableDepthTest();
|
||||
bb.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR);
|
||||
private static void drawLineBetween(BufferBuilder bb, Matrix4f matrix, Vec3 local, Vec3 target)
|
||||
{
|
||||
//Calculate distance between points -> length of the line
|
||||
float distance = (float) local.distanceTo(target);
|
||||
float quarterWidth = 0.25f;
|
||||
|
||||
bb.vertex(matrix, 0, 0, 0).color(255f, 0f,0f, 127.5f).endVertex();
|
||||
bb.vertex(matrix, 20, 0, 20).color(255f, 0f,0f, 127.5f).endVertex();
|
||||
t.end();
|
||||
GlStateManager._disableBlend();
|
||||
bb.vertex(matrix, 0.25f, -0.25f, 0.5f).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, quarterWidth + 0.25f, -0.25f, 0.5f).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, quarterWidth - 6f, 3f, - distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, -6f, 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
|
||||
bb.vertex(matrix, 0.25f, -0.25f, 0.5f).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, 0.25f, -quarterWidth - 0.25f, 0.5f).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, -6f, -quarterWidth + 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, -6f, 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
|
||||
bb.vertex(matrix,quarterWidth + 0.25f, -0.25f, 0.5f).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix,quarterWidth + 0.25f, -quarterWidth - 0.25f, 0.5f).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix,quarterWidth - 6f, -quarterWidth + 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix,quarterWidth - 6f, 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
|
||||
bb.vertex(matrix, -6f, -quarterWidth + 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, quarterWidth - 6f, -quarterWidth + 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, quarterWidth - 6f, 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
bb.vertex(matrix, -6f, 3f, -distance).color((float) 0.5, (float) 0.0, (float) 0.0, (float) 1.0).endVertex();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,11 +528,11 @@ public class TileEntityScreen extends BlockEntity {
|
|||
|
||||
if (scr.browser != null) {
|
||||
if (event == CMessageScreenUpdate.MOUSE_CLICK) {
|
||||
if(InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_LEFT_CONTROL)
|
||||
|| InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_RIGHT_CONTROL)) {
|
||||
scr.browser.injectMouseMove(vec.x, vec.y, InputEvent.BUTTON3_DOWN_MASK, false); //Move to target
|
||||
scr.browser.injectMouseButton(vec.x, vec.y, InputEvent.BUTTON3_DOWN_MASK, 3, true, 1); //Press
|
||||
scr.browser.injectMouseButton(vec.x, vec.y, InputEvent.BUTTON3_DOWN_MASK, 3, false, 1); //Release
|
||||
if(InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_LEFT_ALT)
|
||||
|| InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_RIGHT_ALT)) {
|
||||
scr.browser.injectMouseMove(vec.x, vec.y, 0, false); //Move to target
|
||||
scr.browser.injectMouseButton(vec.x, vec.y, 0, 3, true, 1); //Press
|
||||
scr.browser.injectMouseButton(vec.x, vec.y, 0, 3, false, 1); //Release
|
||||
} else {
|
||||
scr.browser.injectMouseMove(vec.x, vec.y, 0, false); //Move to target
|
||||
scr.browser.injectMouseButton(vec.x, vec.y, 0, 1, true, 1); //Press
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user