Large update, will be in change log. Moved ver# to 3.1.6

This commit is contained in:
noil 2021-02-06 20:07:49 -05:00
parent 36ea526f65
commit 43d7419df9
32 changed files with 866 additions and 409 deletions

View File

@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: "com.github.johnrengelman.shadow"
version = "3.1.5"
version = "3.1.6"
group = "me.rigamortis"
archivesBaseName = "seppuku"
def buildmode = "IDE"

View File

@ -1,13 +1,19 @@
package me.rigamortis.seppuku.api.camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.culling.ICamera;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.ForgeHooksClient;
import org.lwjgl.util.glu.Project;
import static org.lwjgl.opengl.GL11.GL_QUADS;
@ -19,6 +25,8 @@ public class Camera {
private Vec3d pos;
private Vec3d prevPos;
private float yaw;
private float pitch;
@ -31,17 +39,22 @@ public class Camera {
private boolean firstUpdate;
private float farPlaneDistance;
private Framebuffer frameBuffer;
private final int WIDTH_RESOLUTION = 800;
private final int HEIGHT_RESOLUTION = 600;
private final int WIDTH_RESOLUTION = 420;
private final int HEIGHT_RESOLUTION = 420;
private int frameCount;
private final Minecraft mc = Minecraft.getMinecraft();
public Camera() {
this.pos = new Vec3d(0, 0, 0);
this.yaw = 0;
this.pitch = 0;
this.frameBuffer = new Framebuffer(WIDTH_RESOLUTION, HEIGHT_RESOLUTION, true);
this.frameBuffer.createFramebuffer(WIDTH_RESOLUTION, HEIGHT_RESOLUTION);
}
public void render(float x, float y, float w, float h) {
@ -71,17 +84,148 @@ public class Camera {
}
}
public void renderWorld(float partialTicks, long nano) {
//mc.entityRenderer.updateLightMap(partialTicks);
if (mc.getRenderViewEntity() == null) {
mc.setRenderViewEntity(mc.player);
}
GlStateManager.enableDepth();
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.5F);
renderWorldPass(2, partialTicks, nano);
}
public void setupCameraTransform(float partialTicks) {
this.farPlaneDistance = (float) (mc.gameSettings.renderDistanceChunks * 16);
GlStateManager.matrixMode(5889);
GlStateManager.loadIdentity();
Project.gluPerspective(90.0f, (float) this.mc.displayWidth / (float) this.mc.displayHeight, 0.05F, this.farPlaneDistance * MathHelper.SQRT_2);
GlStateManager.matrixMode(5888);
GlStateManager.loadIdentity();
mc.entityRenderer.orientCamera(partialTicks);
}
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano) {
if (mc.getRenderViewEntity() == null)
return;
RenderGlobal renderglobal = mc.renderGlobal;
GlStateManager.enableCull();
GlStateManager.viewport(0, 0, mc.displayWidth, mc.displayHeight);
//this.updateFogColor(partialTicks);
GlStateManager.clear(16640);
setupCameraTransform(partialTicks);
ActiveRenderInfo.updateRenderInfo(mc.getRenderViewEntity(), mc.gameSettings.thirdPersonView == 2);
ClippingHelperImpl.getInstance();
ICamera icamera = new Frustum();
Entity entity = mc.getRenderViewEntity();
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
icamera.setPosition(d0, d1, d2);
GlStateManager.shadeModel(7425);
this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
RenderHelper.disableStandardItemLighting();
renderglobal.setupTerrain(entity, partialTicks, icamera, this.frameCount++, this.mc.player.isSpectator());
if (pass == 0 || pass == 2) {
mc.renderGlobal.updateChunks(finishTimeNano);
}
GlStateManager.matrixMode(5888);
GlStateManager.pushMatrix();
GlStateManager.disableAlpha();
renderglobal.renderBlockLayer(BlockRenderLayer.SOLID, partialTicks, pass, entity);
GlStateManager.enableAlpha();
mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, mc.gameSettings.mipmapLevels > 0);
renderglobal.renderBlockLayer(BlockRenderLayer.CUTOUT_MIPPED, partialTicks, pass, entity);
mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
renderglobal.renderBlockLayer(BlockRenderLayer.CUTOUT, partialTicks, pass, entity);
mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
GlStateManager.shadeModel(7424);
GlStateManager.alphaFunc(516, 0.1F);
//entities
GlStateManager.matrixMode(5888);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
RenderHelper.enableStandardItemLighting();
ForgeHooksClient.setRenderPass(0);
renderglobal.renderEntities(entity, icamera, partialTicks);
ForgeHooksClient.setRenderPass(0);
RenderHelper.disableStandardItemLighting();
mc.entityRenderer.disableLightmap();
GlStateManager.matrixMode(5888);
GlStateManager.popMatrix();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
this.mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
renderglobal.drawBlockDamageTexture(Tessellator.getInstance(), Tessellator.getInstance().getBuffer(), entity, partialTicks);
this.mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
GlStateManager.disableBlend();
//particles
// mc.entityRenderer.enableLightmap();
// mc.effectRenderer.renderLitParticles(entity, partialTicks);
// RenderHelper.disableStandardItemLighting();
// mc.effectRenderer.renderParticles(entity, partialTicks);
// mc.entityRenderer.disableLightmap();
GlStateManager.depthMask(false);
GlStateManager.enableCull();
//this.renderRainSnow(partialTicks);
GlStateManager.depthMask(true);
//renderglobal.renderWorldBorder(entity, partialTicks);
GlStateManager.disableBlend();
GlStateManager.enableCull();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.enableBlend();
GlStateManager.depthMask(false);
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.shadeModel(7425);
renderglobal.renderBlockLayer(BlockRenderLayer.TRANSLUCENT, partialTicks, pass, entity);
//entities
RenderHelper.enableStandardItemLighting();
ForgeHooksClient.setRenderPass(1);
renderglobal.renderEntities(entity, icamera, partialTicks);
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
ForgeHooksClient.setRenderPass(-1);
RenderHelper.disableStandardItemLighting();
GlStateManager.shadeModel(7424);
GlStateManager.depthMask(true);
GlStateManager.enableCull();
GlStateManager.disableBlend();
GlStateManager.disableFog();
//Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventRender3D(mc.getRenderPartialTicks()));
//Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventCameraRender3D(mc.getRenderPartialTicks()));
}
public void updateFbo() {
final Minecraft mc = Minecraft.getMinecraft();
if (!this.firstUpdate) {
mc.renderGlobal.loadRenderers();
mc.renderGlobal.markBlockRangeForRenderUpdate(
(int) mc.player.posX - 256,
(int) mc.player.posY - 256,
(int) mc.player.posZ - 256,
(int) mc.player.posX + 256,
(int) mc.player.posY + 256,
(int) mc.player.posZ + 256);
this.firstUpdate = true;
}
if (mc.player != null) {
double posX = mc.player.posX;
double posY = mc.player.posY;
double posZ = mc.player.posZ;
this.setPrevPos(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ));
double prevPosX = mc.player.prevPosX;
double prevPosY = mc.player.prevPosY;
double prevPosZ = mc.player.prevPosZ;
@ -103,28 +247,18 @@ public class Camera {
boolean viewBobbing = mc.gameSettings.viewBobbing;
int particles = mc.gameSettings.particleSetting;
boolean shadows = mc.gameSettings.entityShadows;
int displayWidth = mc.displayWidth;
int displayHeight = mc.displayHeight;
int frameLimit = mc.gameSettings.limitFramerate;
float fovSetting = mc.gameSettings.fovSetting;
mc.player.posX = this.getPos().x;
mc.player.posY = this.getPos().y;
mc.player.posZ = this.getPos().z;
int width = mc.displayWidth;
int height = mc.displayHeight;
mc.player.prevPosX = this.getPos().x;
mc.player.prevPosY = this.getPos().y;
mc.player.prevPosZ = this.getPos().z;
mc.displayWidth = WIDTH_RESOLUTION;
mc.displayHeight = HEIGHT_RESOLUTION;
mc.player.lastTickPosX = this.getPos().x;
mc.player.lastTickPosY = this.getPos().y;
mc.player.lastTickPosZ = this.getPos().z;
this.setCameraPos(this.getPos());
this.setCameraAngle(this.yaw, this.pitch);
mc.player.rotationYaw = this.yaw;
mc.player.prevRotationYaw = this.yaw;
mc.player.rotationPitch = this.pitch;
mc.player.prevRotationPitch = this.pitch;
mc.player.setSprinting(false);
mc.gameSettings.hideGUI = true;
@ -135,24 +269,25 @@ public class Camera {
mc.gameSettings.viewBobbing = false;
mc.gameSettings.particleSetting = 0;
mc.gameSettings.entityShadows = false;
mc.displayWidth = WIDTH_RESOLUTION;
mc.displayHeight = HEIGHT_RESOLUTION;
mc.gameSettings.limitFramerate = 10;
mc.gameSettings.fovSetting = 110;
mc.gameSettings.fovSetting = 90;
this.setRecording(true);
frameBuffer.bindFramebuffer(true);
mc.entityRenderer.renderWorld(mc.timer.renderPartialTicks, System.nanoTime());
renderWorld(mc.timer.renderPartialTicks, System.nanoTime());
//TODO force gui scale here?
mc.entityRenderer.setupOverlayRendering();
//final ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());
//Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventRender2D(mc.getRenderPartialTicks(), res));
frameBuffer.unbindFramebuffer();
this.setRecording(false);
mc.player.posX = posX;
mc.player.posY = posY;
mc.player.posZ = posZ;
mc.player.posX = getPrevPos().x;
mc.player.posY = getPrevPos().y;
mc.player.posZ = getPrevPos().z;
mc.player.prevPosX = prevPosX;
mc.player.prevPosY = prevPosY;
@ -166,6 +301,7 @@ public class Camera {
mc.player.prevRotationYaw = prevRotationYaw;
mc.player.rotationPitch = rotationPitch;
mc.player.prevRotationPitch = prevRotationPitch;
mc.player.setSprinting(sprinting);
mc.gameSettings.hideGUI = hideGUI;
@ -176,11 +312,12 @@ public class Camera {
mc.gameSettings.viewBobbing = viewBobbing;
mc.gameSettings.particleSetting = particles;
mc.gameSettings.entityShadows = shadows;
mc.displayWidth = displayWidth;
mc.displayHeight = displayHeight;
mc.gameSettings.limitFramerate = frameLimit;
mc.gameSettings.fovSetting = fovSetting;
mc.displayWidth = width;
mc.displayHeight = height;
this.setValid(true);
this.setRendering(false);
}
@ -194,6 +331,35 @@ public class Camera {
}
}
public void setCameraPos(Vec3d pos) {
mc.player.posX = pos.x;
mc.player.posY = pos.y;
mc.player.posZ = pos.z;
mc.player.prevPosX = pos.x;
mc.player.prevPosY = pos.y;
mc.player.prevPosZ = pos.z;
mc.player.lastTickPosX = pos.x;
mc.player.lastTickPosY = pos.y;
mc.player.lastTickPosZ = pos.z;
}
public void setCameraAngle(float yaw, float pitch) {
mc.player.rotationYaw = yaw;
mc.player.prevRotationYaw = yaw;
mc.player.rotationPitch = pitch;
mc.player.prevRotationPitch = pitch;
}
public Framebuffer getFrameBuffer() {
return frameBuffer;
}
public void setFrameBuffer(Framebuffer frameBuffer) {
this.frameBuffer = frameBuffer;
}
public Vec3d getPos() {
return pos;
}
@ -202,6 +368,14 @@ public class Camera {
this.pos = pos;
}
public Vec3d getPrevPos() {
return prevPos;
}
public void setPrevPos(Vec3d prevPos) {
this.prevPos = prevPos;
}
public float getYaw() {
return yaw;
}

View File

@ -1,7 +1,23 @@
package me.rigamortis.seppuku.api.event.gui.hud;
import me.rigamortis.seppuku.api.value.Value;
/**
* @author noil
*/
public class EventUIValueChanged {
private Value value;
public EventUIValueChanged(Value value) {
this.value = value;
}
public Value getValue() {
return value;
}
public void setValue(Value value) {
this.value = value;
}
}

View File

@ -1,9 +1,14 @@
package me.rigamortis.seppuku.api.event.gui.hud.modulelist;
import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged;
import me.rigamortis.seppuku.api.value.Value;
/**
* @author noil
*/
public class EventUIListValueChanged extends EventUIValueChanged {
public EventUIListValueChanged(Value value) {
super(value);
}
}

View File

@ -0,0 +1,9 @@
package me.rigamortis.seppuku.api.event.player;
import me.rigamortis.seppuku.api.event.EventCancellable;
/**
* @author Seth
*/
public class EventExtendPlayerReach extends EventCancellable {
}

View File

@ -1,25 +0,0 @@
package me.rigamortis.seppuku.api.event.player;
/**
* Author Seth
* 4/6/2019 @ 6:35 PM.
*/
public class EventGetBlockReachDistance {
private float distance;
public EventGetBlockReachDistance() {
}
public EventGetBlockReachDistance(float distance) {
this.distance = distance;
}
public float getDistance() {
return distance;
}
public void setDistance(float distance) {
this.distance = distance;
}
}

View File

@ -0,0 +1,19 @@
package me.rigamortis.seppuku.api.event.player;
import me.rigamortis.seppuku.api.event.EventCancellable;
/**
* @author Seth
*/
public class EventPlayerReach extends EventCancellable {
private float reach;
public float getReach() {
return reach;
}
public void setReach(float reach) {
this.reach = reach;
}
}

View File

@ -0,0 +1,19 @@
package me.rigamortis.seppuku.api.event.render;
import net.minecraft.util.math.BlockPos;
/**
* @author noil
*/
public class EventRenderBlock {
private final BlockPos pos;
public EventRenderBlock(BlockPos pos) {
this.pos = pos;
}
public BlockPos getPos() {
return pos;
}
}

View File

@ -2,6 +2,7 @@ package me.rigamortis.seppuku.api.event.render;
import me.rigamortis.seppuku.api.event.EventCancellable;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
/**
* Author Seth
@ -10,10 +11,12 @@ import net.minecraft.block.Block;
public class EventRenderBlockSide extends EventCancellable {
private Block block;
private BlockPos pos;
private boolean renderable;
public EventRenderBlockSide(Block block) {
public EventRenderBlockSide(Block block, BlockPos pos) {
this.block = block;
this.pos = pos;
}
public Block getBlock() {
@ -24,6 +27,14 @@ public class EventRenderBlockSide extends EventCancellable {
this.block = block;
}
public BlockPos getPos() {
return pos;
}
public void setPos(BlockPos pos) {
this.pos = pos;
}
public boolean isRenderable() {
return renderable;
}

View File

@ -146,7 +146,7 @@ public final class BlocksComponent extends HudComponent {
else
this.value.getValue().add(block);
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIListValueChanged());
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIListValueChanged(this.value));
}
}

View File

@ -148,7 +148,7 @@ public final class ItemsComponent extends HudComponent {
else
this.value.getValue().add(item);
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIListValueChanged());
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIListValueChanged(this.value));
}
}

View File

@ -2,6 +2,7 @@ package me.rigamortis.seppuku.api.gui.hud.component;
import com.mojang.realmsclient.gui.ChatFormatting;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged;
import me.rigamortis.seppuku.api.util.ColorUtil;
import me.rigamortis.seppuku.api.util.MathUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
@ -190,6 +191,9 @@ public final class SliderComponent extends HudComponent {
break;
}
// dispatch event
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(this.value));
this.sliding = false;
}

View File

@ -1,6 +1,7 @@
package me.rigamortis.seppuku.api.gui.hud.component;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged;
import me.rigamortis.seppuku.api.texture.Texture;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.util.Timer;

View File

@ -133,7 +133,13 @@ public final class MathUtil {
final double deltaX = pos.x - x;
final double deltaY = pos.y - y;
final double deltaZ = pos.z - z;
return (double) MathHelper.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
return MathHelper.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
}
public static double getDistance(double x1, double z1, double x2, double z2) {
double d0 = x1 - x2;
double d1 = z1 - z2;
return MathHelper.sqrt(d0 * d0 + d1 * d1);
}
public static double[] calcIntersection(double[] line, double[] line2) {

View File

@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
@Mod(modid = "seppukumod", name = "Seppuku", version = SeppukuMod.VERSION, certificateFingerprint = "7979b1d0446af2675fcb5e888851a7f32637fdb9")
public final class SeppukuMod {
public static final String VERSION = "3.1.5";
public static final String VERSION = "3.1.6";
/**
* Our mods entry point

View File

@ -3,10 +3,13 @@ package me.rigamortis.seppuku.impl.gui.hud.component;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.camera.Camera;
import me.rigamortis.seppuku.api.gui.hud.component.ResizableHudComponent;
import me.rigamortis.seppuku.api.gui.hud.component.SliderComponent;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.value.Value;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.input.Mouse;
/**
* Author Seth
@ -16,15 +19,19 @@ public final class OverViewComponent extends ResizableHudComponent {
private final Camera overviewCamera = new Camera();
private float scroll;
private float lastScroll;
private float distance = 35.0f;
private final Value<Float> zoom = new Value<>("Zoom", new String[]{"Z"}, "The zoom distance", 50.0f, 0.0f, 100.0f, 1.0f);
private final SliderComponent zoomSlider;
public OverViewComponent() {
super("OverView", 120, 120, 400, 400);
Seppuku.INSTANCE.getCameraManager().addCamera(overviewCamera);
this.setW(120);
this.setH(120);
zoomSlider = new SliderComponent("Zoom", zoom);
zoomSlider.setX(this.getX());
zoomSlider.setY(this.getY() + this.getH() - 10);
zoomSlider.setW(this.getW());
zoomSlider.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT);
}
@Override
@ -43,29 +50,58 @@ public final class OverViewComponent extends ResizableHudComponent {
final Vec3d ground = this.getGround(partialTicks);
if (ground != null) {
/*
"isometric" view
final Vec3d forward = MathUtil.direction(mc.player.rotationYaw);
final float factor = 30.0f;
this.overviewCamera.setPos(ground.add(0, this.getDist(partialTicks), 0).subtract(forward.x * factor, forward.y * factor, forward.z * factor));
this.overviewCamera.setYaw(mc.player.rotationYaw);
this.overviewCamera.setPitch(65.0f);
this.overviewCamera.render(this.getX() + 2, this.getY() + 12, this.getX() + this.getW() - 2, this.getY() + this.getH() - 2);
*/
//final Vec3d forward = MathUtil.direction(mc.player.rotationYaw);
//final float factor = 30.0f;
//this.overviewCamera.setPos(ground.add(0, this.getDist(partialTicks), 0).subtract(forward.x * factor, forward.y * factor, forward.z * factor));
this.overviewCamera.setPos(ground.add(0, this.getDist(partialTicks), 0));
this.overviewCamera.setYaw(mc.player.rotationYaw);
this.overviewCamera.setPitch(90.0f);
this.overviewCamera.render(this.getX() + 2, this.getY() + 12, this.getX() + this.getW() - 2, this.getY() + this.getH() - 2);
this.overviewCamera.render(this.getX() + 2, this.getY() + 12, this.getX() + this.getW() - 2, this.getY() + (mc.currentScreen instanceof GuiHudEditor ? this.getH() - 12 : this.getH() - 2));
//todo camera fbo size = width * frac
if (mc.currentScreen instanceof GuiHudEditor) {
this.zoomSlider.setX(this.getX());
this.zoomSlider.setY(this.getY() + this.getH() - 10);
this.zoomSlider.setW(this.getW());
this.zoomSlider.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT);
this.zoomSlider.render(mouseX, mouseY, partialTicks);
}
}
}
}
if (this.isMouseInside(mouseX, mouseY)) {
this.handleScrolling(mouseX, mouseY);
mc.fontRenderer.drawStringWithShadow("Zoom: " + this.distance, this.getX() + 4, this.getY() + this.getH() - mc.fontRenderer.FONT_HEIGHT - 2, 0xFFFFFFFF);
RenderUtil.drawTriangle(this.getX() + this.getW() / 2, this.getY() + this.getH() / 2 + 5, 4, 0, 0x70101010);
RenderUtil.drawTriangle(this.getX() + this.getW() / 2, this.getY() + this.getH() / 2 + 5 + 0.5f, 2.5f, 0, 0xAAFFFFFF);
}
@Override
public void mouseClick(int mouseX, int mouseY, int button) {
final boolean insideDragZone = mouseY <= this.getY() + mc.fontRenderer.FONT_HEIGHT + 3 || mouseY >= ((this.getY() + this.getH()) - CLICK_ZONE);
if (insideDragZone) {
super.mouseClick(mouseX, mouseY, button);
}
this.zoomSlider.mouseClick(mouseX, mouseY, button);
}
@Override
public void mouseClickMove(int mouseX, int mouseY, int button) {
super.mouseClickMove(mouseX, mouseY, button);
this.zoomSlider.mouseClickMove(mouseX, mouseY, button);
}
@Override
public void mouseRelease(int mouseX, int mouseY, int button) {
super.mouseRelease(mouseX, mouseY, button);
this.zoomSlider.mouseRelease(mouseX, mouseY, button);
}
@Override
public void keyTyped(char typedChar, int keyCode) {
super.keyTyped(typedChar, keyCode);
this.zoomSlider.keyTyped(typedChar, keyCode);
}
private Vec3d getGround(float partialTicks) {
@ -81,33 +117,12 @@ public final class OverViewComponent extends ResizableHudComponent {
private double getDist(float partialTicks) {
final Vec3d eyes = mc.player.getPositionEyes(partialTicks);
final RayTraceResult ray = mc.world.rayTraceBlocks(eyes, eyes.add(0, this.distance, 0), false);
final RayTraceResult ray = mc.world.rayTraceBlocks(eyes, eyes.add(0, this.zoom.getValue(), 0), false);
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) {
return mc.player.getDistance(ray.hitVec.x, ray.hitVec.y, ray.hitVec.z) - 4;
}
return this.distance;
return this.zoom.getValue();
}
private void handleScrolling(int mouseX, int mouseY) {
if (this.isMouseInside(mouseX, mouseY) && Mouse.hasWheel()) {
this.scroll += -(Mouse.getDWheel() / 100.0f);
if (this.scroll <= 0) {
this.scroll = 0;
}
if (this.scroll >= 10) {
this.scroll = 10;
}
if (this.lastScroll != this.scroll) {
this.lastScroll = this.scroll;
this.distance = this.scroll * 10;
//TODO update fbo
}
}
}
}
}

View File

@ -2,6 +2,7 @@ package me.rigamortis.seppuku.impl.gui.hud.component.module;
import com.mojang.realmsclient.gui.ChatFormatting;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged;
import me.rigamortis.seppuku.api.gui.hud.component.TextComponent;
import me.rigamortis.seppuku.api.gui.hud.component.*;
import me.rigamortis.seppuku.api.module.Module;
@ -517,6 +518,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
@Override
public void onComponentEvent() {
value.setValue(valueButton.enabled);
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));
}
};
components.add(valueButton);
@ -569,6 +571,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
if (value.getEnum(valueText.displayValue) != -1) {
value.setEnumValue(valueText.displayValue);
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save configs
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));
} else {
Seppuku.INSTANCE.logfChat("%s - %s: Invalid entry.", module.getDisplayName(), value.getName());
}
@ -590,6 +593,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
if (valueText.displayValue.length() > 0) {
value.setValue(valueText.displayValue);
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save configs
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));
} else {
Seppuku.INSTANCE.logfChat("%s - %s: Not enough input.", module.getDisplayName(), value.getName());
}
@ -605,6 +609,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
public void onComponentEvent() {
value.setValue(valueColor.getCurrentColor());
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class);
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));
}
};
components.add(valueColor);

View File

@ -4,8 +4,9 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.camera.Camera;
import me.rigamortis.seppuku.api.event.minecraft.EventUpdateFramebufferSize;
import me.rigamortis.seppuku.api.event.player.EventFovModifier;
import me.rigamortis.seppuku.api.event.render.*;
import net.minecraft.client.Minecraft;
import me.rigamortis.seppuku.api.event.render.EventHurtCamEffect;
import me.rigamortis.seppuku.api.event.render.EventRenderOverlay;
import me.rigamortis.seppuku.api.event.render.EventRenderSky;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.util.ArrayList;
@ -24,11 +25,9 @@ public final class CameraManager {
}
public void update() {
if (Minecraft.getMinecraft().inGameHasFocus && Minecraft.getMinecraft().currentScreen == null) {
for (Camera cam : this.cameraList) {
if (cam != null && !cam.isRecording() && cam.isRendering()) {
cam.updateFbo();
}
for (Camera cam : this.cameraList) {
if (cam != null && !cam.isRecording() && cam.isRendering()) {
cam.updateFbo();
}
}
}
@ -57,13 +56,6 @@ public final class CameraManager {
}
}
@Listener
public void renderOutlines(EventRenderEntityOutlines event) {
if (this.isCameraRecording()) {
event.setCanceled(true);
}
}
@Listener
public void hurtCamEffect(EventHurtCamEffect event) {
if (this.isCameraRecording()) {
@ -78,13 +70,6 @@ public final class CameraManager {
}
}
@Listener
public void renderBlockDamage(EventRenderBlockDamage event) {
if (this.isCameraRecording()) {
event.setCanceled(true);
}
}
public void addCamera(Camera cam) {
this.cameraList.add(cam);
}
@ -95,11 +80,9 @@ public final class CameraManager {
}
public boolean isCameraRecording() {
if (Minecraft.getMinecraft().inGameHasFocus && Minecraft.getMinecraft().currentScreen == null) {
for (Camera cam : this.cameraList) {
if (cam != null && cam.isRecording()) {
return true;
}
for (Camera cam : this.cameraList) {
if (cam != null && cam.isRecording()) {
return true;
}
}
return false;
@ -112,4 +95,4 @@ public final class CameraManager {
public void setCameraList(List<Camera> cameraList) {
this.cameraList = cameraList;
}
}
}

View File

@ -41,11 +41,12 @@ public final class PatchManager {
this.patchList.add(new EntityPigPatch());
this.patchList.add(new EntityLlamaPatch());
this.patchList.add(new AbstractHorsePatch());
this.patchList.add(new BlockRendererDispatcherPatch());
//this.patchList.add(new BlockPatch());
this.patchList.add(new BlockSoulSandPatch());
this.patchList.add(new KeyBindingPatch());
this.patchList.add(new BlockModelRendererPatch());
this.patchList.add(new BlockFluidRendererPatch());
//this.patchList.add(new BlockModelRendererPatch());
//this.patchList.add(new BlockFluidRendererPatch());
this.patchList.add(new ActiveRenderInfoPatch());
this.patchList.add(new BlockSlimePatch());
this.patchList.add(new BlockLiquidPatch());

View File

@ -1,5 +1,6 @@
package me.rigamortis.seppuku.impl.module.combat;
import me.rigamortis.seppuku.api.event.mouse.EventMouseRightClick;
import me.rigamortis.seppuku.api.event.player.EventHandActive;
import me.rigamortis.seppuku.api.event.player.EventHittingBlock;
import me.rigamortis.seppuku.api.event.player.EventResetBlockRemoving;
@ -7,6 +8,7 @@ import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
/**
@ -15,6 +17,7 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
public final class MultitaskModule extends Module {
private final Value<Boolean> bowDisable = new Value<Boolean>("BowDisable", new String[]{"disableonbow", "bd"}, "Disables multi-tasking when holding a bow.", true);
private final Value<Boolean> shieldDisable = new Value<Boolean>("ShielDisable", new String[]{"disablewithshield", "sd"}, "Disables multi-tasking when holding a shield.", true);
public MultitaskModule() {
super("Multitask", new String[]{"multi", "task"}, "Allows the player to perform multiple actions at once. (eating, placing, attacking)", "NONE", -1, ModuleType.COMBAT);
@ -22,9 +25,15 @@ public final class MultitaskModule extends Module {
@Listener
public void onActiveHand(EventHandActive event) {
if (this.bowDisable.getValue()) {
if (Minecraft.getMinecraft().player != null) {
if (Minecraft.getMinecraft().player.getHeldItemMainhand().getItem().equals(Items.BOW)) {
if (Minecraft.getMinecraft().player != null) {
final Item heldItem = Minecraft.getMinecraft().player.getHeldItemMainhand().getItem();
if (this.bowDisable.getValue()) {
if (heldItem.equals(Items.BOW)) {
return;
}
}
if (this.shieldDisable.getValue()) {
if (heldItem.equals(Items.SHIELD)) {
return;
}
}
@ -41,4 +50,9 @@ public final class MultitaskModule extends Module {
public void onResetBlockRemoving(EventResetBlockRemoving event) {
event.setCanceled(true);
}
}
@Listener
public void onRightClick(EventMouseRightClick event) {
Minecraft.getMinecraft().player.rowingBoat = false;
}
}

View File

@ -1,43 +1,30 @@
package me.rigamortis.seppuku.impl.module.player;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
import me.rigamortis.seppuku.api.event.player.EventClickBlock;
import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate;
import me.rigamortis.seppuku.api.event.player.EventExtendPlayerReach;
import me.rigamortis.seppuku.api.event.player.EventPlayerReach;
import me.rigamortis.seppuku.api.event.player.EventRightClickBlock;
import me.rigamortis.seppuku.api.event.render.EventRender3D;
import me.rigamortis.seppuku.api.event.world.EventLoadWorld;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import me.rigamortis.seppuku.impl.module.render.BlockHighlightModule;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.network.play.client.CPacketPlayerDigging;
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
import net.minecraft.util.EnumActionResult;
import net.minecraft.network.play.client.CPacketUseEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
/**
* @author noil
* @author Seth
*/
public final class ReachModule extends Module {
public enum Mode {
BYPASS, VANILLA
}
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Type", "T", "M"}, "Change between reach modes.", Mode.BYPASS);
public final Value<Float> distance = new Value<Float>("Distance", new String[]{"Dist", "D"}, "The distance (in blocks) to reach.", 5.5f, 0.0f, 10.0f, 0.5f);
public final Value<Boolean> highlight = new Value<Boolean>("Highlight", new String[]{"Hover", "H"}, "Enables rendering the BlockHighlight for the extended reach.", true);
public final Value<Boolean> blocks = new Value<Boolean>("Blocks", new String[]{"Block", "B"}, "Enables reaching for breaking & building blocks.", true);
//public final Value<Boolean> entities = new Value<Boolean>("Entities", new String[]{"Entity", "Entitie", "E"}, "Enables reaching for attacking and interacting with entities.", false);
private BlockHighlightModule blockHighlightModule = null;
private RayTraceResult currentBlockTrace = null;
//private RayTraceResult currentEntityTrace = null;
public final Value<Boolean> teleport = new Value<Boolean>("Teleport", new String[]{"Tp", "Tele"}, "Allows you to reach further on vanilla servers.", false);
private final Minecraft mc = Minecraft.getMinecraft();
@ -45,127 +32,55 @@ public final class ReachModule extends Module {
super("Reach", new String[]{"Rch"}, "Extends the player's reach.", "NONE", -1, ModuleType.PLAYER);
}
@Listener
public void onLoadWorld(EventLoadWorld event) {
if (event.getWorld() == null)
return;
this.blockHighlightModule = (BlockHighlightModule) Seppuku.INSTANCE.getModuleManager().find(BlockHighlightModule.class);
private float getVanillaReach() {
float attrib = (float) this.mc.player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue();
return mc.player.isCreative() ? attrib : attrib - 0.5F;
}
@Listener
public void onRender3D(EventRender3D event) {
if (mc.player == null)
return;
public void onPlayerReach(EventPlayerReach event) {
event.setReach(this.distance.getValue());
event.setCanceled(true);
}
if (mc.objectMouseOver == null)
return;
if (!mc.objectMouseOver.typeOfHit.equals(RayTraceResult.Type.MISS)) {
this.currentBlockTrace = null;
return;
}
if (this.blocks.getValue()) {
this.currentBlockTrace = mc.player.rayTrace(this.distance.getValue(), event.getPartialTicks());
if (this.highlight.getValue()) {
if (this.blockHighlightModule != null && this.currentBlockTrace != null) {
if (this.blockHighlightModule.isEnabled()) {
this.blockHighlightModule.drawHighlight(this.currentBlockTrace, mc);
}
}
}
}
/*
if (this.entities.getValue()) {
Vec3d positionEyes = mc.player.getPositionEyes(event.getPartialTicks());
Vec3d look = mc.player.getLook(event.getPartialTicks());
Vec3d end = positionEyes.add(look.x * this.distance.getValue(), look.y * this.distance.getValue(), look.z * this.distance.getValue());
mc.world.
final RayTraceResult result = mc.world.rayTraceBlocks(positionEyes, end, false, true, false);
assert result != null;
System.out.println(result.entityHit);
//this.currentEntityTrace = mc.world.rayTraceBlocks()
}
*/
@Listener
public void onExtendReach(EventExtendPlayerReach event) {
event.setCanceled(true);
}
@Listener
public void onClickBlock(EventClickBlock event) {
if (!this.mode.getValue().equals(Mode.VANILLA))
return;
if (event.getPos() != null) {
mc.player.connection.sendPacket(new CPacketPlayer.Position(event.getPos().getX(), event.getPos().getY() + 2, event.getPos().getZ(), mc.player.onGround));
if (event.getPos() != null && mc.player.getDistance(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ()) > getVanillaReach() && this.teleport.getValue()) {
mc.player.connection.sendPacket(new CPacketPlayer.Position(event.getPos().getX(), event.getPos().getY() + 2, event.getPos().getZ(), true));
mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, event.getPos(), event.getFace()));
mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, event.getPos(), event.getFace()));
mc.player.swingArm(EnumHand.MAIN_HAND);
mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY, mc.player.posZ, mc.player.onGround));
mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY, mc.player.posZ, true));
event.setCanceled(true);
}
}
@Listener
public void onRightClickBlock(EventRightClickBlock event) {
if (!this.mode.getValue().equals(Mode.VANILLA))
return;
if (event.getPos() != null) {
mc.player.connection.sendPacket(new CPacketPlayer.Position(event.getPos().getX(), event.getPos().getY() + 2, event.getPos().getZ(), mc.player.onGround));
if (event.getPos() != null && mc.player.getDistance(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ()) > getVanillaReach() && this.teleport.getValue()) {
mc.player.connection.sendPacket(new CPacketPlayer.Position(event.getPos().getX(), event.getPos().getY() + 2, event.getPos().getZ(), true));
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(event.getPos(), event.getFacing(), EnumHand.MAIN_HAND, 0.5F, 0.5F, 0.5F));
mc.player.swingArm(EnumHand.MAIN_HAND);
mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY, mc.player.posZ, mc.player.onGround));
mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY, mc.player.posZ, true));
event.setCanceled(true);
}
}
@Listener
public void onUpdate(EventPlayerUpdate event) {
if (event.getStage() != EventStageable.EventStage.PRE)
return;
//if (!this.mode.getValue().equals(Mode.BYPASS))
// return;
if (mc.player == null || mc.world == null)
return;
if (this.blocks.getValue()) {
if (this.currentBlockTrace == null)
return;
if (this.currentBlockTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
if (mc.gameSettings.keyBindAttack.pressed) {
if (!mc.world.isAirBlock(this.currentBlockTrace.getBlockPos())) {
if (mc.player.capabilities.isCreativeMode) {
mc.playerController.onPlayerDestroyBlock(this.currentBlockTrace.getBlockPos());
} else {
mc.playerController.onPlayerDamageBlock(this.currentBlockTrace.getBlockPos(), this.currentBlockTrace.sideHit);
}
mc.player.swingArm(EnumHand.MAIN_HAND);
}
} else if (mc.gameSettings.keyBindUseItem.pressed) {
final EnumActionResult actionResult = mc.playerController.processRightClickBlock(mc.player, mc.world, this.currentBlockTrace.getBlockPos(), this.currentBlockTrace.sideHit, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND);
if (actionResult.equals(EnumActionResult.SUCCESS)) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
public void sendPacket(EventSendPacket event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if (event.getPacket() instanceof CPacketUseEntity) {
final CPacketUseEntity packet = (CPacketUseEntity) event.getPacket();
final Entity entity = mc.world.getEntityByID(packet.entityId);
if (entity != null && mc.player.getDistance(entity.posX, entity.posY, entity.posZ) > getVanillaReach() && this.teleport.getValue()) {
mc.player.connection.sendPacket(new CPacketPlayer.Position(entity.posX, entity.posY + 2, entity.posZ, true));
}
}
}
/*
if (this.entities.getValue()) {
if (entityTraceResult == null) {
if (mc.gameSettings.keyBindAttack.pressed) {
System.out.println("ATTACJ");
mc.playerController.attackEntity(mc.player, entityTraceResult.entityHit);
} else if (mc.gameSettings.keyBindUseItem.pressed) {
mc.playerController.interactWithEntity(mc.player, entityTraceResult.entityHit, EnumHand.MAIN_HAND);
}
}
}
*/
}
}

View File

@ -18,6 +18,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@ -28,12 +29,13 @@ import static org.lwjgl.opengl.GL11.glLineWidth;
*/
public final class HolesModule extends Module {
public final Value<Color> color = new Value<Color>("Color", new String[]{"col", "c"}, "Change the color of holes.", new Color(153, 0, 238));
public final Value<Integer> radius = new Value<Integer>("Radius", new String[]{"Radius", "Range", "Distance"}, "Radius in blocks to scan for holes.", 8, 0, 32, 1);
public final Value<Boolean> fade = new Value<Boolean>("Fade", new String[]{"f"}, "Fades the opacity of the hole the closer your player is to it when enabled.", true);
public final List<Hole> holes = new ArrayList<>();
private ICamera camera = new Frustum();
private final ICamera camera = new Frustum();
public HolesModule() {
super("Holes", new String[]{"Hole", "HoleESP"}, "Shows areas the player could fall into, holes.", "NONE", -1, ModuleType.RENDER);
@ -99,8 +101,8 @@ public final class HolesModule extends Module {
glLineWidth(1.5f);
final double dist = mc.player.getDistance(hole.getX() + 0.5f, hole.getY() + 0.5f, hole.getZ() + 0.5f) * 0.75f;
float alpha = MathUtil.clamp((float) (dist * 255.0f / (this.radius.getValue()) / 255.0f), 0.0f, 0.3f);
RenderGlobal.renderFilledBox(bb, 0, 1, 0, this.fade.getValue() ? alpha : 0.25f);
RenderGlobal.drawBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ, 0, 1, 0, this.fade.getValue() ? alpha : 0.25f);
RenderGlobal.renderFilledBox(bb, this.color.getValue().getRed() / 255.0f, this.color.getValue().getGreen() / 255.0f, this.color.getValue().getRed() / 255.0f, this.fade.getValue() ? alpha : this.color.getValue().getAlpha() / 255.0f);
RenderGlobal.drawBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ, this.color.getValue().getRed() / 255.0f, this.color.getValue().getGreen() / 255.0f, this.color.getValue().getRed() / 255.0f, this.fade.getValue() ? alpha : this.color.getValue().getAlpha() / 255.0f);
GlStateManager.popMatrix();
}
}
@ -108,8 +110,10 @@ public final class HolesModule extends Module {
}
private boolean isBlockValid(IBlockState blockState, BlockPos blockPos) {
if (this.holes.contains(blockPos))
return false;
for (Hole hole : this.holes) {
if (hole.getX() == blockPos.getX() && hole.getY() == blockPos.getY() && hole.getZ() == blockPos.getZ())
return false;
}
if (blockState.getBlock() != Blocks.AIR)
return false;

View File

@ -8,8 +8,10 @@ import me.rigamortis.seppuku.api.event.world.EventSpawnParticle;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockPistonExtension;
import net.minecraft.block.BlockPistonMoving;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityEnderCrystal;
@ -22,6 +24,8 @@ import net.minecraft.network.play.server.SPacketSpawnMob;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -85,16 +89,16 @@ public final class NoLagModule extends Module {
}*/
}
@Listener
public void renderBlockModel(EventRenderBlockModel event) {
if (this.pistons.getValue()) {
final Block block = event.getBlockState().getBlock();
if (block instanceof BlockPistonMoving || block instanceof BlockPistonExtension) {
event.setRenderable(false);
event.setCanceled(true);
}
}
}
// @Listener
// public void renderBlockModel(EventRenderBlockModel event) {
// if (this.pistons.getValue()) {
// final Block block = event.getBlockState().getBlock();
// if (block instanceof BlockPistonMoving || block instanceof BlockPistonExtension) {
// event.setRenderable(false);
// event.setCanceled(true);
// }
// }
// }
@Listener
public void renderWorld(EventRender3D event) {
@ -116,6 +120,14 @@ public final class NoLagModule extends Module {
}
}
// @Listener
// public void onRenderBlock(EventRenderBlock event) {
// final IBlockState blockState = Minecraft.getMinecraft().world.getBlockState(event.getPos());
// if (blockState.getBlock() instanceof BlockLiquid) {
// event.setCanceled(true);
// }
// }
@Listener
public void onRenderFluid(EventRenderFluid event) {
if (this.fluids.getValue()) {

View File

@ -1,14 +1,19 @@
package me.rigamortis.seppuku.impl.module.render;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged;
import me.rigamortis.seppuku.api.event.gui.hud.modulelist.EventUIListValueChanged;
import me.rigamortis.seppuku.api.event.player.EventDestroyBlock;
import me.rigamortis.seppuku.api.event.render.EventRender3D;
import me.rigamortis.seppuku.api.event.render.EventRenderBlockModel;
import me.rigamortis.seppuku.api.event.render.EventRenderBlock;
import me.rigamortis.seppuku.api.event.world.EventChunk;
import me.rigamortis.seppuku.api.event.world.EventLoadWorld;
import me.rigamortis.seppuku.api.event.world.EventSetOpaqueCube;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.ColorUtil;
import me.rigamortis.seppuku.api.util.MathUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.util.Timer;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
@ -21,10 +26,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.chunk.Chunk;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* @author noil
@ -39,6 +47,7 @@ public final class SearchModule extends Module {
public final Value<Integer> limit = new Value<Integer>("Limit", new String[]{"max"}, "The maximum amount of blocks that can be rendered.", 3000, 1, 9000, 1);
public final Value<Integer> alpha = new Value<Integer>("Alpha", new String[]{"opacity"}, "Alpha value for the search bounding box.", 127, 1, 255, 1);
public final Value<Float> width = new Value<Float>("Width", new String[]{"size"}, "Line width of the search bounding box.", 1.0f, 0.1f, 5.0f, 0.1f);
public final Value<Float> renderTime = new Value<Float>("RenderDelay", new String[]{"rendelay", "delay", "rd"}, "Delay(ms) between render updates if chunks are queued.", 4000.0f, 500f, 8000f, 100f);
public final Value<Boolean> tracer = new Value<Boolean>("Tracer", new String[]{"trace", "line"}, "Draw a tracer line to each search result.", false);
public enum Mode {
@ -46,7 +55,9 @@ public final class SearchModule extends Module {
}
private final Value<List<Block>> blockIds = new Value<>("Ids", new String[]{"id", "i", "blocks"}, "Blocks to search for.");
private final List<Vec3d> blocks = new ArrayList<>(512);
private final List<Vec3i> blocks = new CopyOnWriteArrayList<>();
private final List<Chunk> renderQueue = new CopyOnWriteArrayList<>();
private final Timer renderTimer = new Timer();
private final ICamera frustum = new Frustum();
public SearchModule() {
@ -89,25 +100,32 @@ public final class SearchModule extends Module {
@Listener
public void onDrawWorld(EventRender3D event) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.getRenderViewEntity() == null)
if (mc.getRenderViewEntity() == null || mc.world == null || mc.player == null)
return;
RenderUtil.begin3D();
for (int i = this.blocks.size() - 1; i >= 0; i--) {
final Vec3d searchBlock = this.blocks.get(i);
if (searchBlock == null)
continue;
this.frustum.setPosition(mc.getRenderViewEntity().posX, mc.getRenderViewEntity().posY, mc.getRenderViewEntity().posZ);
final BlockPos blockPos = new BlockPos(searchBlock.x, searchBlock.y, searchBlock.z);
if (!this.renderQueue.isEmpty() && this.renderTimer.passed(this.renderTime.getValue())) {
this.updateRenders();
this.renderQueue.clear();
this.renderTimer.reset();
}
RenderUtil.begin3D();
for (Vec3i searchBlock : this.blocks) {
final BlockPos blockPos = new BlockPos(searchBlock);
final Block block = mc.world.getBlockState(blockPos).getBlock();
if (block instanceof BlockAir)
continue;
if (mc.player.getDistance(searchBlock.x, searchBlock.y, searchBlock.z) < this.range.getValue()) {
final AxisAlignedBB bb = this.boundingBoxForBlock(blockPos);
if (MathUtil.getDistance(mc.player.posX, mc.player.posZ, searchBlock.getX(), searchBlock.getZ()) > this.range.getValue() || !this.contains(block)) {
this.blocks.remove(searchBlock);
continue;
}
this.frustum.setPosition(mc.getRenderViewEntity().posX, mc.getRenderViewEntity().posY, mc.getRenderViewEntity().posZ);
if (this.contains(block)) {
final AxisAlignedBB bb = this.boundingBoxForBlock(blockPos);
if (this.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(bb.minX + mc.getRenderManager().viewerPosX,
bb.minY + mc.getRenderManager().viewerPosY,
@ -118,20 +136,20 @@ public final class SearchModule extends Module {
final int color = ColorUtil.changeAlpha(this.getColor(blockPos, block), this.alpha.getValue());
switch (this.mode.getValue()) {
case BOX:
RenderUtil.drawFilledBox(bb, ColorUtil.changeAlpha(color, this.alpha.getValue()));
RenderUtil.drawFilledBox(bb, color);
break;
case OUTLINE:
RenderUtil.drawBoundingBox(bb, this.width.getValue(), color);
break;
case OUTLINE_BOX:
RenderUtil.drawFilledBox(bb, ColorUtil.changeAlpha(color, this.alpha.getValue()));
RenderUtil.drawFilledBox(bb, color);
RenderUtil.drawBoundingBox(bb, this.width.getValue(), color);
break;
case PLANE:
RenderUtil.drawPlane(
searchBlock.x - mc.getRenderManager().viewerPosX,
searchBlock.y - mc.getRenderManager().viewerPosY,
searchBlock.z - mc.getRenderManager().viewerPosZ,
searchBlock.getX() - mc.getRenderManager().viewerPosX,
searchBlock.getY() - mc.getRenderManager().viewerPosY,
searchBlock.getZ() - mc.getRenderManager().viewerPosZ,
new AxisAlignedBB(0, 0, 0, 1, 1, 1),
this.width.getValue(),
color);
@ -139,7 +157,7 @@ public final class SearchModule extends Module {
}
if (this.tracer.getValue()) {
final Vec3d pos = new Vec3d(searchBlock.x, searchBlock.y, searchBlock.z).subtract(mc.getRenderManager().renderPosX, mc.getRenderManager().renderPosY, mc.getRenderManager().renderPosZ);
final Vec3d pos = new Vec3d(searchBlock.getX(), searchBlock.getY(), searchBlock.getZ()).subtract(mc.getRenderManager().renderPosX, mc.getRenderManager().renderPosY, mc.getRenderManager().renderPosZ);
final boolean bobbing = mc.gameSettings.viewBobbing;
mc.gameSettings.viewBobbing = false;
mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
@ -149,36 +167,60 @@ public final class SearchModule extends Module {
mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
}
}
} else {
this.blocks.remove(searchBlock);
}
}
RenderUtil.end3D();
}
@Listener
public void onRenderBlock(EventRenderBlockModel event) {
final BlockPos pos = event.getBlockPos();
final IBlockState blockState = event.getBlockState();
if (this.contains(blockState.getBlock()) && !this.isPosCached(pos.getX(), pos.getY(), pos.getZ()) && this.blocks.size() < this.limit.getValue()) {
this.blocks.add(new Vec3d(pos));
} else if (!this.contains(blockState.getBlock()) && this.isPosCached(pos.getX(), pos.getY(), pos.getZ())) {
this.blocks.remove(new Vec3d(pos));
public void onRenderBlock(EventRenderBlock event) {
final BlockPos pos = event.getPos();
final IBlockState blockState = Minecraft.getMinecraft().world.getBlockState(pos);
if (this.contains(blockState.getBlock())) {
final Vec3i vec3i = new Vec3i(pos.getX(), pos.getY(), pos.getZ());
final double dist = MathUtil.getDistance(Minecraft.getMinecraft().player.posX, Minecraft.getMinecraft().player.posZ, pos.getX(), pos.getZ());
final boolean inRange = dist < this.range.getValue();
if (inRange && !this.isPosCached(pos.getX(), pos.getY(), pos.getZ()) && this.blocks.size() < this.limit.getValue()) {
this.blocks.add(vec3i);
} else if (this.isPosCached(pos) && !inRange) {
this.blocks.remove(vec3i);
}
}
}
@Listener
public void setOpaqueCube(EventSetOpaqueCube event) {
event.setCanceled(true);
}
@Listener
public void onChunk(EventChunk event) {
if (event.getType().equals(EventChunk.ChunkType.LOAD)) {
if (this.renderQueue.size() > 32) {
this.renderQueue.clear();
}
this.renderQueue.add(event.getChunk());
}
}
@Listener
public void onUIListValueChanged(EventUIListValueChanged event) {
this.updateRenders();
if (event.getValue().getName().equals(this.blockIds.getName())) {
this.updateRenders();
}
}
@Listener
public void onUIValueChanged(EventUIValueChanged event) {
for (Value value : this.getValueList()) {
if (value.getName().equals(event.getValue().getName())) {
this.updateRenders();
}
}
}
private void removeBlock(BlockPos pos) {
for (int i = this.blocks.size() - 1; i >= 0; i--) {
final Vec3d searchBlock = this.blocks.get(i);
if (searchBlock.x == pos.getX() && searchBlock.y == pos.getY() && searchBlock.z == pos.getZ()) {
this.blocks.remove(i);
}
}
this.blocks.removeIf(vec3i -> vec3i.getX() == pos.getX() && vec3i.getY() == pos.getY() && vec3i.getZ() == pos.getZ());
}
public void clearBlocks() {
@ -186,13 +228,12 @@ public final class SearchModule extends Module {
}
private boolean isPosCached(int x, int y, int z) {
boolean temp = false;
for (int i = this.blocks.size() - 1; i >= 0; i--) {
Vec3d searchBlock = this.blocks.get(i);
if (searchBlock.x == x && searchBlock.y == y && searchBlock.z == z)
temp = true;
for (Vec3i vector : this.blocks) {
if (vector.getX() == x && vector.getY() == y && vector.getZ() == z) {
return true;
}
}
return temp;
return false;
}
private boolean isPosCached(BlockPos pos) {
@ -215,12 +256,25 @@ public final class SearchModule extends Module {
//mc.renderGlobal.loadRenderers();
final Minecraft mc = Minecraft.getMinecraft();
mc.renderGlobal.markBlockRangeForRenderUpdate(
(int) mc.player.posX - 256,
(int) mc.player.posY - 256,
(int) mc.player.posZ - 256,
(int) mc.player.posX + 256,
(int) mc.player.posY + 256,
(int) mc.player.posZ + 256);
(int) mc.player.posX - this.range.getValue(),
0,
(int) mc.player.posZ - this.range.getValue(),
(int) mc.player.posX + this.range.getValue(),
256,
(int) mc.player.posZ + this.range.getValue());
}
public void updateRenders(Chunk chunk) {
//mc.renderGlobal.loadRenderers();
final Minecraft mc = Minecraft.getMinecraft();
System.out.println(chunk.x * 16);
mc.renderGlobal.markBlockRangeForRenderUpdate(
chunk.x * 16,
0,
chunk.z * 16,
(chunk.x * 16) + 16,
256,
(chunk.z * 16) + 16);
}
public boolean contains(Block block) {
@ -270,27 +324,45 @@ public final class SearchModule extends Module {
private int getColor(final BlockPos pos, final Block block) {
if (block instanceof BlockEnderChest)
return 0xFF624FFF;
return 0x624FFF;
else if (block == Blocks.CRAFTING_TABLE)
return 0xFFFFC853;
return 0xFFC853;
else if (block == Blocks.FURNACE || block == Blocks.LIT_FURNACE)
return 0xFF76A7B4;
return 0x76A7B4;
else if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA)
return 0xFFFF8639;
return 0xFF8639;
else if (block == Blocks.WATER || block == Blocks.FLOWING_WATER)
return 0xFF4CD1FF;
return 0x4CD1FF;
else if (block == Blocks.ANVIL)
return 0xFFB6BA9E;
return 0xB6BA9E;
else if (block == Blocks.DISPENSER || block == Blocks.DROPPER)
return 0xFFD3E2CA;
return 0xD3E2CA;
else if (block == Blocks.CAULDRON || block == Blocks.PORTAL)
return 0xFF9E97BF;
return 0x9E97BF;
else if (block == Blocks.DIAMOND_ORE || block == Blocks.DIAMOND_BLOCK)
return 0x27E6FF;
else if (block == Blocks.EMERALD_ORE || block == Blocks.EMERALD_BLOCK)
return 0x40FF33;
else if (block == Blocks.COAL_ORE || block == Blocks.COAL_BLOCK)
return 0x817B6F;
else if (block == Blocks.IRON_ORE || block == Blocks.IRON_BLOCK)
return 0xF6F6F6;
else if (block == Blocks.GOLD_ORE || block == Blocks.GOLD_BLOCK)
return 0xFFFD33;
else if (block == Blocks.LAPIS_ORE || block == Blocks.LAPIS_BLOCK)
return 0x2A4DFF;
else if (block == Blocks.LIT_REDSTONE_ORE || block == Blocks.REDSTONE_BLOCK)
return 0xFF0816;
else if (block == Blocks.REDSTONE_ORE)
return 0xCB0713;
else if (block == Blocks.QUARTZ_ORE || block == Blocks.QUARTZ_BLOCK)
return 0xFFF2B7;
final int mapColor = Minecraft.getMinecraft().world.getBlockState(pos).getMaterial().getMaterialMapColor().colorValue;
if (mapColor > 0)
return mapColor;
return 0xFFFFFFFF;
return 0xFFFFFF;
}
public Value<List<Block>> getBlockIds() {

View File

@ -75,16 +75,16 @@ public final class XrayModule extends Module {
*/
}
@Listener
public void renderBlockModel(EventRenderBlockModel event) {
final Block block = event.getBlockState().getBlock();
if (this.contains(block)) {
if (Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelFlat(event.getBlockAccess(), event.getBakedModel(), event.getBlockState(), event.getBlockPos(), event.getBufferBuilder(), event.isCheckSides(), event.getRand())) {
event.setRenderable(true);
}
}
event.setCanceled(true);
}
// @Listener
// public void renderBlockModel(EventRenderBlockModel event) {
// final Block block = event.getBlockState().getBlock();
// if (this.contains(block)) {
// if (Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelFlat(event.getBlockAccess(), event.getBakedModel(), event.getBlockState(), event.getBlockPos(), event.getBufferBuilder(), event.isCheckSides(), event.getRand())) {
// event.setRenderable(true);
// }
// }
// event.setCanceled(true);
// }
@Listener
public void setOpaqueCube(EventSetOpaqueCube event) {

View File

@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.module.world;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate;
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
import me.rigamortis.seppuku.api.event.render.EventRender3D;
import me.rigamortis.seppuku.api.event.world.EventLoadWorld;
@ -41,8 +42,8 @@ public final class NoteBotModule extends Module {
private final Value<BotState> state = new Value<BotState>("State", new String[]{"State", "s"}, "Current state of the note-bot.", BotState.IDLE);
private final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"mod", "m"}, "Current mode of the note-bot.", Mode.NORMAL);
private final Value<Boolean> rotate = new Value<Boolean>("Rotate", new String[]{"rot", "r"}, "Rotate the player's head & body for each note-bot function.", true);
private final Value<Boolean> swing = new Value<Boolean>("Swing", new String[]{"swingarm", "armswing", "sa"}, "Swing the player's hand for each note-bot function.", true);
private final Value<Boolean> rotate = new Value<Boolean>("Rotate", new String[]{"rot", "r"}, "Rotate the player's head & body for each note-bot function.", false);
private final Value<Boolean> swing = new Value<Boolean>("Swing", new String[]{"swingarm", "armswing", "sa"}, "Swing the player's hand for each note-bot function.", false);
private final Value<Float> discoverDelay = new Value<Float>("DiscoverDelay", new String[]{"Discover Delay", "discover-delay", "ddelay", "ddel", "dd", "d"}, "Delay(ms) to wait between left clicks.", 50.0f, 0.0f, 1000.0f, 1.0f);
private final Value<Float> tuneDelay = new Value<Float>("TuneDelay", new String[]{"Tune Delay", "tune-delay", "tdelay", "tdel", "td"}, "Delay(ms) to wait between right clicks.", 200.0f, 0.0f, 1000.0f, 1.0f);
@ -147,7 +148,7 @@ public final class NoteBotModule extends Module {
}
@Listener
public void onMotionUpdate(EventUpdateWalkingPlayer event) {
public void onUpdate(EventPlayerUpdate event) {
if (mc.world == null || mc.player == null)
return;

View File

@ -75,52 +75,52 @@ public final class BlockLiquidPatch extends ClassPatch {
methodNode.instructions.insert(insnList);
}
@MethodPatch(
mcpName = "shouldSideBeRendered",
notchName = "a",
mcpDesc = "(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z",
notchDesc = "(Lawt;Lamy;Let;Lfa;)Z")
public void shouldSideBeRendered(MethodNode methodNode, PatchManager.Environment env) {
//create a list of instructions
final InsnList insnList = new InsnList();
//create a new instance of "EventRenderBlockSide" and dupe the top value on the stack
insnList.add(new TypeInsnNode(NEW, Type.getInternalName(EventRenderBlockSide.class)));
insnList.add(new InsnNode(DUP));
//add ALOAD 0 to pass "this" into the event
insnList.add(new VarInsnNode(ALOAD, 0));
//call "EventRenderBlockSide" constructor
insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(EventRenderBlockSide.class), "<init>", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/block/Block;)V" : "(Laow;)V", false));
//store our event in the local vars
insnList.add(new VarInsnNode(ASTORE, 5));
//Seppuku.INSTANCE
insnList.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(Seppuku.class), "INSTANCE", "Lme/rigamortis/seppuku/Seppuku;"));
//getEventManager
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(Seppuku.class), "getEventManager", "()Lteam/stiff/pomelo/EventManager;", false));
//add ALOAD to access our event
insnList.add(new VarInsnNode(ALOAD, 5));
//call EventManager.dispatchEvent and pass our event in
insnList.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(EventManager.class), "dispatchEvent", "(Ljava/lang/Object;)Ljava/lang/Object;", true));
//remove the top value on the stack
insnList.add(new InsnNode(POP));
//add ALOAD to access our event
insnList.add(new VarInsnNode(ALOAD, 5));
//call EventRenderBlockSide.isCanceled
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventRenderBlockSide.class), "isCanceled", "()Z", false));
//create a label to jump to
final LabelNode jmp = new LabelNode();
//add "if equals"
insnList.add(new JumpInsnNode(IFEQ, jmp));
//add ALOAD to access our event
insnList.add(new VarInsnNode(ALOAD, 5));
//call EventRenderBlockSide.isRenderable
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventRenderBlockSide.class), "isRenderable", "()Z", false));
//return the value of isRenderable
insnList.add(new InsnNode(IRETURN));
//add our label
insnList.add(jmp);
//add our instructions at the top of the function
methodNode.instructions.insert(insnList);
}
// @MethodPatch(
// mcpName = "shouldSideBeRendered",
// notchName = "a",
// mcpDesc = "(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z",
// notchDesc = "(Lawt;Lamy;Let;Lfa;)Z")
// public void shouldSideBeRendered(MethodNode methodNode, PatchManager.Environment env) {
////create a list of instructions
// final InsnList insnList = new InsnList();
// //create a new instance of "EventRenderBlockSide" and dupe the top value on the stack
// insnList.add(new TypeInsnNode(NEW, Type.getInternalName(EventRenderBlockSide.class)));
// insnList.add(new InsnNode(DUP));
// //add ALOAD 0 to pass "this" into the event
// insnList.add(new VarInsnNode(ALOAD, 0));
// //call "EventRenderBlockSide" constructor
// insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(EventRenderBlockSide.class), "<init>", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/block/Block;)V" : "(Laow;)V", false));
// //store our event in the local vars
// insnList.add(new VarInsnNode(ASTORE, 5));
// //Seppuku.INSTANCE
// insnList.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(Seppuku.class), "INSTANCE", "Lme/rigamortis/seppuku/Seppuku;"));
// //getEventManager
// insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(Seppuku.class), "getEventManager", "()Lteam/stiff/pomelo/EventManager;", false));
// //add ALOAD to access our event
// insnList.add(new VarInsnNode(ALOAD, 5));
// //call EventManager.dispatchEvent and pass our event in
// insnList.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(EventManager.class), "dispatchEvent", "(Ljava/lang/Object;)Ljava/lang/Object;", true));
// //remove the top value on the stack
// insnList.add(new InsnNode(POP));
// //add ALOAD to access our event
// insnList.add(new VarInsnNode(ALOAD, 5));
// //call EventRenderBlockSide.isCanceled
// insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventRenderBlockSide.class), "isCanceled", "()Z", false));
// //create a label to jump to
// final LabelNode jmp = new LabelNode();
// //add "if equals"
// insnList.add(new JumpInsnNode(IFEQ, jmp));
// //add ALOAD to access our event
// insnList.add(new VarInsnNode(ALOAD, 5));
// //call EventRenderBlockSide.isRenderable
// insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventRenderBlockSide.class), "isRenderable", "()Z", false));
// //return the value of isRenderable
// insnList.add(new InsnNode(IRETURN));
// //add our label
// insnList.add(jmp);
// //add our instructions at the top of the function
// methodNode.instructions.insert(insnList);
// }
@MethodPatch(
mcpName = "canCollideCheck",

View File

@ -45,8 +45,10 @@ public final class BlockPatch extends ClassPatch {
insnList.add(new InsnNode(DUP));
//add ALOAD 0 to pass "this" into the event
insnList.add(new VarInsnNode(ALOAD, 0));
//add ALOAD 3 to pass "BlockPos" into the event
insnList.add(new VarInsnNode(ALOAD, 3));
//call "EventRenderBlockSide" constructor
insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(EventRenderBlockSide.class), "<init>", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/block/Block;)V" : "(Laow;)V", false));
insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(EventRenderBlockSide.class), "<init>", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/block/Block;Lnet/minecraft/util/math/BlockPos;)V" : "(Laow;Let;)V", false));
//store our event in the local vars
insnList.add(new VarInsnNode(ASTORE, 6));
//Seppuku.INSTANCE
@ -79,6 +81,7 @@ public final class BlockPatch extends ClassPatch {
methodNode.instructions.insert(insnList);
}
@MethodPatch(
mcpName = "getBlockLayer",
notchName = "f",

View File

@ -0,0 +1,49 @@
package me.rigamortis.seppuku.impl.patch;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.render.EventRenderBlock;
import me.rigamortis.seppuku.api.patch.ClassPatch;
import me.rigamortis.seppuku.api.patch.MethodPatch;
import me.rigamortis.seppuku.impl.management.PatchManager;
import net.minecraft.util.math.BlockPos;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
/**
* @author noil
*/
public final class BlockRendererDispatcherPatch extends ClassPatch {
public BlockRendererDispatcherPatch() {
super("net.minecraft.client.renderer.BlockRendererDispatcher", "bvm");
}
//public boolean renderBlock(IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder bufferBuilderIn)Z
//public boolean a(awt , et et1, amy amy1, buk buk1)Z {
@MethodPatch(
mcpName = "renderBlock",
notchName = "a",
mcpDesc = "(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/client/renderer/BufferBuilder;)Z",
notchDesc = "(Lawt;Let;Lamy;Lbuk;)Z")
public void renderBlock(MethodNode methodNode, PatchManager.Environment env) {
//create a list of instructions
final InsnList insnList = new InsnList();
//aload the BlockPos
insnList.add(new VarInsnNode(ALOAD, 2));
//call our hook function
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "renderBlockHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/util/math/BlockPos;)V" : "(Let;)V", false));
//insert instructions
methodNode.instructions.insert(insnList);
}
public static void renderBlockHook(BlockPos pos) {
final EventRenderBlock event = new EventRenderBlock(pos);
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
}
}

View File

@ -1,8 +1,11 @@
package me.rigamortis.seppuku.impl.patch;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.player.EventFovModifier;
import me.rigamortis.seppuku.api.event.player.EventGetMouseOver;
import me.rigamortis.seppuku.api.event.player.EventPlayerReach;
import me.rigamortis.seppuku.api.event.render.EventHurtCamEffect;
import me.rigamortis.seppuku.api.event.render.EventOrientCamera;
import me.rigamortis.seppuku.api.event.render.EventRender2D;
@ -13,11 +16,21 @@ import me.rigamortis.seppuku.api.util.ASMUtil;
import me.rigamortis.seppuku.impl.management.PatchManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.util.EntitySelectors;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
import team.stiff.pomelo.EventManager;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import static org.objectweb.asm.Opcodes.*;
@ -212,25 +225,104 @@ public final class EntityRendererPatch extends ClassPatch {
notchName = "a",
mcpDesc = "(F)V")
public void getMouseOver(MethodNode methodNode, PatchManager.Environment env) {
final AbstractInsnNode target = ASMUtil.findMethodInsn(methodNode, INVOKEVIRTUAL, env == PatchManager.Environment.IDE ? "net/minecraft/client/multiplayer/WorldClient" : "bsb", env == PatchManager.Environment.IDE ? "getEntitiesInAABBexcluding" : "a", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/AxisAlignedBB;Lcom/google/common/base/Predicate;)Ljava/util/List;" : "(Lvg;Lbhb;Lcom/google/common/base/Predicate;)Ljava/util/List;");
if (target != null) {
final InsnList insnList = new InsnList();
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "getMouseOverHook", "()Z", false));
final LabelNode jmp = new LabelNode();
insnList.add(new JumpInsnNode(IFEQ, jmp));
insnList.add(new TypeInsnNode(NEW, Type.getInternalName(ArrayList.class)));
insnList.add(new InsnNode(DUP));
insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(ArrayList.class), "<init>", "()V", false));
insnList.add(new VarInsnNode(ASTORE, 14));
insnList.add(jmp);
methodNode.instructions.insert(target.getNext(), insnList);
}
final InsnList insnList = new InsnList();
insnList.add(new VarInsnNode(FLOAD, 1));
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "getMouseOverHook", "(F)V", false));
insnList.add(new InsnNode(RETURN));
methodNode.instructions.insert(insnList);
}
public static boolean getMouseOverHook() {
final EventGetMouseOver event = new EventGetMouseOver();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
return event.isCanceled();
/**
* getMouseOver (original game function with modified event handling)
*
* @param partialTicks
*/
public static void getMouseOverHook(float partialTicks) {
final Minecraft mc = Minecraft.getMinecraft();
final Entity entity = mc.getRenderViewEntity();
if (entity != null && mc.world != null) {
mc.profiler.startSection("pick");
mc.pointedEntity = null;
double d0 = mc.playerController.getBlockReachDistance();
mc.objectMouseOver = entity.rayTrace(d0, partialTicks);
Vec3d vec3d = entity.getPositionEyes(partialTicks);
boolean flag = false;
double d1 = d0;
if (mc.playerController.extendedReach()) {
final EventPlayerReach event = new EventPlayerReach();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
d1 = event.isCanceled() ? event.getReach() : 6.0d;
d0 = d1;
} else if (d0 > 3.0D) {
flag = true;
}
if (mc.objectMouseOver != null) {
d1 = mc.objectMouseOver.hitVec.distanceTo(vec3d);
}
Vec3d vec3d1 = entity.getLook(1.0F);
Vec3d vec3d2 = vec3d.add(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0);
mc.entityRenderer.pointedEntity = null;
Vec3d vec3d3 = null;
float f = 1.0F;
List<Entity> list = mc.world.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().expand(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0).grow(1.0D, 1.0D, 1.0D), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>() {
public boolean apply(@Nullable Entity p_apply_1_) {
return p_apply_1_ != null && p_apply_1_.canBeCollidedWith();
}
}));
final EventGetMouseOver event = new EventGetMouseOver();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
if (event.isCanceled()) {
list = new ArrayList<>();
}
double d2 = d1;
for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j);
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow((double) entity1.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.contains(vec3d)) {
if (d2 >= 0.0D) {
mc.entityRenderer.pointedEntity = entity1;
vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec;
d2 = 0.0D;
}
} else if (raytraceresult != null) {
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < d2 || d2 == 0.0D) {
if (entity1.getLowestRidingEntity() == entity.getLowestRidingEntity() && !entity1.canRiderInteract()) {
if (d2 == 0.0D) {
mc.entityRenderer.pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
}
} else {
mc.entityRenderer.pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
d2 = d3;
}
}
}
}
if (mc.entityRenderer.pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > 3.0D) {
mc.entityRenderer.pointedEntity = null;
mc.objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, null, new BlockPos(vec3d3));
}
if (mc.entityRenderer.pointedEntity != null && (d2 < d1 || mc.objectMouseOver == null)) {
mc.objectMouseOver = new RayTraceResult(mc.entityRenderer.pointedEntity, vec3d3);
if (mc.entityRenderer.pointedEntity instanceof EntityLivingBase || mc.entityRenderer.pointedEntity instanceof EntityItemFrame) {
mc.pointedEntity = mc.entityRenderer.pointedEntity;
}
}
mc.profiler.endSection();
}
}
}

View File

@ -392,4 +392,55 @@ public final class PlayerControllerMPPatch extends ClassPatch {
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
return event.isCanceled();
}
@MethodPatch(
mcpName = "getBlockReachDistance",
notchName = "d",
mcpDesc = "()F")
public void getBlockReachDistance(MethodNode methodNode, PatchManager.Environment env) {
final InsnList insnList = new InsnList();
insnList.add(new TypeInsnNode(NEW, Type.getInternalName(EventPlayerReach.class)));
insnList.add(new InsnNode(DUP));
insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(EventPlayerReach.class), "<init>", "()V", false));
insnList.add(new VarInsnNode(ASTORE, 2));
insnList.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(Seppuku.class), "INSTANCE", "Lme/rigamortis/seppuku/Seppuku;"));
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(Seppuku.class), "getEventManager", "()Lteam/stiff/pomelo/EventManager;", false));
insnList.add(new VarInsnNode(ALOAD, 2));
insnList.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(EventManager.class), "dispatchEvent", "(Ljava/lang/Object;)Ljava/lang/Object;", true));
insnList.add(new InsnNode(POP));
insnList.add(new VarInsnNode(ALOAD, 2));
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventPlayerReach.class), "isCanceled", "()Z", false));
final LabelNode jmp = new LabelNode();
insnList.add(new JumpInsnNode(IFEQ, jmp));
insnList.add(new VarInsnNode(ALOAD, 2));
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventPlayerReach.class), "getReach", "()F", false));
insnList.add(new InsnNode(FRETURN));
insnList.add(jmp);
methodNode.instructions.insert(insnList);
}
@MethodPatch(
mcpName = "extendedReach",
notchName = "i",
mcpDesc = "()Z")
public void extendedReach(MethodNode methodNode, PatchManager.Environment env) {
final InsnList insnList = new InsnList();
insnList.add(new TypeInsnNode(NEW, Type.getInternalName(EventExtendPlayerReach.class)));
insnList.add(new InsnNode(DUP));
insnList.add(new MethodInsnNode(INVOKESPECIAL, Type.getInternalName(EventExtendPlayerReach.class), "<init>", "()V", false));
insnList.add(new VarInsnNode(ASTORE, 2));
insnList.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(Seppuku.class), "INSTANCE", "Lme/rigamortis/seppuku/Seppuku;"));
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(Seppuku.class), "getEventManager", "()Lteam/stiff/pomelo/EventManager;", false));
insnList.add(new VarInsnNode(ALOAD, 2));
insnList.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(EventManager.class), "dispatchEvent", "(Ljava/lang/Object;)Ljava/lang/Object;", true));
insnList.add(new InsnNode(POP));
insnList.add(new VarInsnNode(ALOAD, 2));
insnList.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(EventExtendPlayerReach.class), "isCanceled", "()Z", false));
final LabelNode jmp = new LabelNode();
insnList.add(new JumpInsnNode(IFEQ, jmp));
insnList.add(new InsnNode(ICONST_1));
insnList.add(new InsnNode(IRETURN));
insnList.add(jmp);
methodNode.instructions.insert(insnList);
}
}

View File

@ -112,10 +112,11 @@ public net.minecraft.network.play.client.CPacketCloseWindow field_149556_a
public-f net.minecraft.tileentity.TileEntitySign field_145915_a # signText
public net.minecraft.client.entity.AbstractClientPlayer func_175155_b()Lnet/minecraft/client/network/NetworkPlayerInfo; # getPlayerInfo
public-f net.minecraft.util.text.TextComponentString field_150267_b # text
#smallshield stuff
public net.minecraft.client.renderer.ItemRenderer field_187471_h # equippedProgressOffHand
public net.minecraft.client.renderer.RenderGlobal field_72738_E # damagedBlocks
public net.minecraft.network.play.server.SPacketCloseWindow field_148896_a # windowId
public net.minecraft.network.play.server.SPacketSetSlot field_149179_a # windowId
public net.minecraft.network.play.server.SPacketSetSlot field_149177_b # slot
public net.minecraft.client.gui.GuiChat field_146415_a # inputField
public net.minecraft.client.renderer.EntityRenderer field_78528_u # pointedEntity
public net.minecraft.client.entity.EntityPlayerSP field_184844_co # rowingBoat