Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
CumHax authored Aug 5, 2021
1 parent 51909f6 commit 658fab2
Show file tree
Hide file tree
Showing 12 changed files with 495 additions and 0 deletions.
118 changes: 118 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/ColourHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package me.cumhax.chipshack.util;

import org.lwjgl.opengl.GL11;

import java.awt.*;

/**
* Created by Gebruiker on 18/04/2017.
*/
public class ColourHolder {

int r;
int g;
int b;
int a;

public ColourHolder(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
this.a = 255;
}

public ColourHolder(int r, int g, int b, int a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}

public ColourHolder brighter(){
return new ColourHolder(Math.min(r + 10, 255), Math.min(g + 10, 255), Math.min(b + 10, 255), getA());
}

public ColourHolder darker(){
return new ColourHolder(Math.max(r - 10, 0), Math.max(g - 10, 0), Math.max(b - 10, 0), getA());
}

public void setGLColour(){
setGLColour(-1,-1,-1,-1);
}

public void setGLColour(int dr, int dg, int db, int da){
GL11.glColor4f((float) (dr == -1 ? r : dr) / 255,(float) (dg == -1 ? g : dg) / 255,(float) (db == -1 ? b : db) / 255,(float) (da == -1 ? a : da) / 255);
}

public void becomeGLColour(){
// FloatBuffer buffer = FloatBuffer.allocate(16);
// GL11.glGetFloat(GL11.GL_CURRENT_COLOR, buffer);
// becomeHex((int) buffer.get());
}

public void becomeHex(int hex){
setR((hex & 0xFF0000) >> 16);
setG((hex & 0xFF00) >> 8);
setB((hex & 0xFF));
setA(255);
}

public static ColourHolder fromHex(int hex){
ColourHolder n = new ColourHolder(0,0,0);
n.becomeHex(hex);
return n;
}

public static int toHex(int r, int g, int b){
return (0xff << 24) | ((r&0xff) << 16) | ((g&0xff) << 8) | (b&0xff);
}

public int toHex(){
return toHex(r, g, b);
}

public int getB() {
return b;
}

public int getG() {
return g;
}

public int getR() {
return r;
}

public int getA() {
return a;
}

public ColourHolder setR(int r) {
this.r = r;
return this;
}

public ColourHolder setB(int b) {
this.b = b;
return this;
}

public ColourHolder setG(int g) {
this.g = g;
return this;
}

public ColourHolder setA(int a) {
this.a = a;
return this;
}

@Override
public ColourHolder clone() {
return new ColourHolder(r, g, b, a);
}

public Color toJavaColour() {
return new Color(r, g, b, a);
}
}
31 changes: 31 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/EventCancellable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.cumhax.chipshack.util;

/**
* Author Seth
* 4/6/2019 @ 1:27 AM.
*/

public class EventCancellable extends EventStageable {

private boolean canceled;

public EventCancellable() {
}

public EventCancellable(EventStage stage) {
super(stage);
}

public EventCancellable(EventStage stage, boolean canceled) {
super(stage);
this.canceled = canceled;
}

public boolean isCanceled() {
return canceled;
}

public void setCanceled(boolean canceled) {
this.canceled = canceled;
}
}
31 changes: 31 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/EventStageable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.cumhax.chipshack.util;

/**
* Author Seth
* 4/5/2019 @ 6:37 PM.
*/
public class EventStageable {

private EventStage stage;

public EventStageable() {

}

public EventStageable(EventStage stage) {
this.stage = stage;
}

public EventStage getStage() {
return stage;
}

public void setStage(EventStage stage) {
this.stage = stage;
}

public enum EventStage {
PRE, POST
}

}
16 changes: 16 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/ICPacketPlayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.cumhax.chipshack.util;

public interface ICPacketPlayer {

void setOnGround(boolean onGround);

void setX(double x);

void setY(double y);

void setZ(double z);

void setYaw(float yaw);

void setPitch(float pitch);
}
10 changes: 10 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/IMinecraft.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package me.cumhax.chipshack.util;

import net.minecraft.util.Timer;

public interface IMinecraft
{
Timer getTimer();

void setRightClickDelayTimer(final int p0);
}
10 changes: 10 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/IRenderManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package me.cumhax.chipshack.util;

public interface IRenderManager
{
double getRenderPosX();

double getRenderPosY();

double getRenderPosZ();
}
73 changes: 73 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/InventoryUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package me.cumhax.chipshack.util;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

/**
* @author Ace________/Ace_#1233
*/

public class InventoryUtil {
private static final Minecraft mc = Minecraft.getMinecraft();

public static int findBlockInHotbar(Block blockToFind) {

// search blocks in hotbar
int slot = -1;
for (int i = 0; i < 9; i++) {

// filter out non-block items
ItemStack stack = mc.player.inventory.getStackInSlot(i);

if (stack == ItemStack.EMPTY || !(stack.getItem() instanceof ItemBlock)) {
continue;
}

Block block = ((ItemBlock) stack.getItem()).getBlock();
if (block.equals(blockToFind)) {
slot = i;
break;
}

}

return slot;

}

public static int findItemInHotbar(Item itemToFind) {

// search blocks in hotbar
int slot = -1;
for (int i = 0; i < 9; i++) {

ItemStack stack = mc.player.inventory.getStackInSlot(i);

if (stack == ItemStack.EMPTY || !(stack.getItem() instanceof Item)) {
continue;
}

Item item = (stack.getItem());
if (item.equals(itemToFind)) {
slot = i;
break;
}

}

return slot;

}
public static int getItems(Item i) {
return mc.player.inventory.mainInventory.stream().filter(itemStack -> itemStack.getItem() == i).mapToInt(ItemStack::getCount).sum() + mc.player.inventory.offHandInventory.stream().filter(itemStack -> itemStack.getItem() == i).mapToInt(ItemStack::getCount).sum();
}

public static int getBlocks(Block block) {
return getItems(Item.getItemFromBlock(block));
}
}


53 changes: 53 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/Mapping.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Decompiled by Procyon v0.5.36
//

package me.cumhax.chipshack.util;

import net.minecraft.client.Minecraft;

public class Mapping
{
public static final String tickLength;
public static final String timer;
public static final String placedBlockDirection;
public static final String playerPosLookYaw;
public static final String playerPosLookPitch;
public static final String isInWeb;
public static final String cPacketPlayerYaw;
public static final String cPacketPlayerPitch;
public static final String renderManagerRenderPosX;
public static final String renderManagerRenderPosY;
public static final String renderManagerRenderPosZ;
public static final String rightClickDelayTimer;
public static final String sPacketEntityVelocityMotionX;
public static final String sPacketEntityVelocityMotionY;
public static final String sPacketEntityVelocityMotionZ;

public static boolean isObfuscated() {
try {
return Minecraft.class.getDeclaredField("instance") == null;
}
catch (Exception e) {
return true;
}
}

static {
tickLength = (isObfuscated() ? "field_194149_e" : "tickLength");
timer = (isObfuscated() ? "field_71428_T" : "timer");
placedBlockDirection = (isObfuscated() ? "field_149579_d" : "placedBlockDirection");
playerPosLookYaw = (isObfuscated() ? "field_148936_d" : "yaw");
playerPosLookPitch = (isObfuscated() ? "field_148937_e" : "pitch");
isInWeb = (isObfuscated() ? "field_70134_J" : "isInWeb");
cPacketPlayerYaw = (isObfuscated() ? "field_149476_e" : "yaw");
cPacketPlayerPitch = (isObfuscated() ? "field_149473_f" : "pitch");
renderManagerRenderPosX = (isObfuscated() ? "field_78725_b" : "renderPosX");
renderManagerRenderPosY = (isObfuscated() ? "field_78726_c" : "renderPosY");
renderManagerRenderPosZ = (isObfuscated() ? "field_78723_d" : "renderPosZ");
rightClickDelayTimer = (isObfuscated() ? "field_71467_ac" : "rightClickDelayTimer");
sPacketEntityVelocityMotionX = (isObfuscated() ? "field_70159_w" : "motionX");
sPacketEntityVelocityMotionY = (isObfuscated() ? "field_70181_x" : "motionY");
sPacketEntityVelocityMotionZ = (isObfuscated() ? "field_70179_y" : "motionZ");
}
}
28 changes: 28 additions & 0 deletions src/main/java/me/cumhax/chipshack/util/PacketEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.cumhax.chipshack.util;

import net.minecraft.network.Packet;

public class PacketEvent extends EventCancellable {

private final Packet packet;

public PacketEvent(Packet packet) {
this.packet = packet;
}

public Packet getPacket() {
return packet;
}

public static class Receive extends PacketEvent {
public Receive(Packet packet) {
super(packet);
}
}

public static class Send extends PacketEvent {
public Send(Packet packet) {
super(packet);
}
}
}
Loading

0 comments on commit 658fab2

Please sign in to comment.