Skip to content

Commit

Permalink
Initial commit v5: Popchams and FakePlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Snoworange420 committed Feb 25, 2023
1 parent 16f0d88 commit c817a6b
Show file tree
Hide file tree
Showing 16 changed files with 543 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/main/java/nl/snoworange/cranberry/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Main {
//Refrences
public static final String MOD_ID = "cranberry";
public static final String NAME = "Cranberry";
public static final String VERSION = "v0.6.4";
public static final String VERSION = "v0.7.0";
public static final String ACCEPTED_MINECRAFT_VERSIONS = "[1.12.2]";
public static final Logger LOGGER = LogManager.getLogger("Cranberry");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,51 @@ public int getHeight() { //ev+= 16 += 2 = 18
}

private void setSettingFromX(int mouseX) {

float percent = ((float) mouseX - this.x) / ((float) this.width + 7.4f);

if (this.setting.getValue() instanceof Double) {
double result = (Double) this.setting.getMin() + (double) ((float) this.difference * percent);
this.setting.setValue((double) Math.round(10.0 * result) / 10.0);

double value = (double) Math.round(10.0 * result) / 10.0;

if (value > (double) max) {
value = (double) max;
}

if (value < (double) min) {
value = (double) min;
}

this.setting.setValue(value);
} else if (this.setting.getValue() instanceof Float) {

float result = ((Float) this.setting.getMin()).floatValue() + (float) this.difference * percent;
this.setting.setValue(Float.valueOf((float) Math.round(10.0f * result) / 10.0f));

float value = Float.valueOf((float) Math.round(10.0f * result) / 10.0f);

if (value > (float) max) {
value = (float) max;
}

if (value < (float) min) {
value = (float) min;
}

this.setting.setValue(value);
} else if (this.setting.getValue() instanceof Integer) {
this.setting.setValue((Integer) this.setting.getMin() + (int) ((float) this.difference * percent));

int value = (Integer) this.setting.getMin() + (int) ((float) this.difference * percent);

if (value > (int) max) {
value = (int) max;
}

if (value < (int) min) {
value = (int) min;
}

this.setting.setValue(value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import nl.snoworange.cranberry.features.module.modules.hud.Watermark;
import nl.snoworange.cranberry.features.module.modules.misc.BetterConnectingGUI;
import nl.snoworange.cranberry.features.module.modules.misc.DiscordRPC;
import nl.snoworange.cranberry.features.module.modules.misc.FakePlayer;
import nl.snoworange.cranberry.features.module.modules.movement.AutoSprint;
import nl.snoworange.cranberry.features.module.modules.movement.ElytraFly;
import nl.snoworange.cranberry.features.module.modules.movement.LiquidSpeed;
import nl.snoworange.cranberry.features.module.modules.player.FastXP;
import nl.snoworange.cranberry.features.module.modules.render.*;
import nl.snoworange.cranberry.features.module.modules.render.popchams.PopChams;
import nl.snoworange.cranberry.features.module.modules.stronkswordmeta.*;
import org.lwjgl.input.Keyboard;

Expand Down Expand Up @@ -52,9 +54,11 @@ public ModuleManager() {
modules.add(new DVDIcon());
modules.add(new FullBright());
modules.add(new SelectionHighlight());
modules.add(new PopChams());

modules.add(new BetterConnectingGUI());
modules.add(new DiscordRPC());
modules.add(new FakePlayer());

modules.add(new AutoSprint());
modules.add(new ElytraFly());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ public PistonElevator() {
public BlockPos holePos;
public BlockPos redstonePos;
public EnumFacing pistonDirection;
public int tickTimer = 0;
public boolean placedPiston = false;


public final Setting<Boolean> targetFriends = register(new Setting<>("TargetFriends", false));
public final Setting<Boolean> rotate = register(new Setting<>("Rotate", true));
public final Setting<Boolean> swingArm = register(new Setting<>("SwingArm", true));
public final Setting<Boolean> silent = register(new Setting<>("Silent", false));
public final Setting<Integer> placeDelayTicks = register(new Setting<>("PlaceDelayTicks", 5, 0, 20));
public final Setting<Boolean> autoDisable = register(new Setting<>("AutoDisable", true));
public final Setting<Double> maxRange = register(new Setting<>("MaxTargetRange", 5.5, 0.1, 7.0));
public final Setting<Double> maxPlaceRange = register(new Setting<>("MaxPlaceRange", 6.0, 0.1, 7.0));
Expand All @@ -60,13 +64,17 @@ public void reset() {
basePos = null;
holePos = null;
redstonePos = null;
tickTimer = 0;
placedPiston = false;
}

@Override
public void onTick() {

if (n()) return;

if (placedPiston) tickTimer++;

int pistonIndex = InventoryUtils.findHotbarPiston();
int redstoneIndex = InventoryUtils.findHotbarItem(Item.getItemFromBlock(Blocks.REDSTONE_BLOCK));

Expand Down Expand Up @@ -119,23 +127,27 @@ public void onTick() {
placeBlock(basePos);
update(mc.player.inventory.currentItem, silent.getValue());

placedPiston = true;

phase = 2;
}

if (phase == 2) {

if (redstonePos == null) return;

update(redstoneIndex, silent.getValue());
placeBlock(redstonePos);
if (tickTimer >= placeDelayTicks.getValue()) {
update(redstoneIndex, silent.getValue());
placeBlock(redstonePos);

mc.player.connection.sendPacket(new CPacketHeldItemChange(mc.player.inventory.currentItem));
mc.player.connection.sendPacket(new CPacketHeldItemChange(mc.player.inventory.currentItem));

if (autoDisable.getValue()) {
disable();
phase = 3;
} else {
reset();
if (autoDisable.getValue()) {
disable();
phase = 3;
} else {
reset();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package nl.snoworange.cranberry.features.module.modules.misc;

import com.mojang.authlib.GameProfile;
import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.network.play.client.CPacketUseEntity;
import net.minecraft.network.play.server.SPacketEntityStatus;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import nl.snoworange.cranberry.event.events.PacketEvent;
import nl.snoworange.cranberry.event.events.TotemPopEvent;
import nl.snoworange.cranberry.features.module.Category;
import nl.snoworange.cranberry.features.module.Module;
import nl.snoworange.cranberry.util.minecraft.ChatUtils;

import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public class FakePlayer extends Module {

public int randomID = -420;
public EntityOtherPlayerMP fakeplayer;

//TODO: fix damage
public FakePlayer() {
super("FakePlayer",
"summons a fake client-side player",
Category.MISC
);
}

@Override
public void onEnable() {
super.onEnable();

GameProfile profile = new GameProfile(UUID.randomUUID(), "FakePlayer");

randomID = ThreadLocalRandom.current().nextInt(-69420, -69);

EntityOtherPlayerMP fakePlayer = new EntityOtherPlayerMP(mc.world, profile);

fakePlayer.setPrimaryHand(mc.player.getPrimaryHand());
fakePlayer.inventory = mc.player.inventory;
fakePlayer.inventoryContainer = mc.player.inventoryContainer;
fakePlayer.setPositionAndRotation(mc.player.posX, mc.player.getEntityBoundingBox().minY, mc.player.posZ, mc.player.rotationYaw, mc.player.rotationPitch);
fakePlayer.rotationYawHead = mc.player.rotationYawHead;
fakePlayer.onGround = mc.player.onGround;
fakePlayer.setSneaking(mc.player.isSneaking());
fakePlayer.setHealth(mc.player.getHealth());
fakePlayer.setAbsorptionAmount(mc.player.getAbsorptionAmount());

mc.player.getActivePotionEffects().forEach(fakePlayer::addPotionEffect);

mc.world.addEntityToWorld(randomID, fakePlayer);

fakeplayer = fakePlayer;
}

@Override
public void onDisable() {
super.onDisable();

mc.world.removeEntityFromWorld(randomID);
}

@SubscribeEvent
public void onPacketSend(PacketEvent.Send event) {
if (this.isEnabled() && fakeplayer != null) {
if (event.getPacket() instanceof CPacketUseEntity) {

CPacketUseEntity packet = (CPacketUseEntity) event.getPacket();

if (packet.getAction().equals(CPacketUseEntity.Action.ATTACK)) {
Entity entity = packet.getEntityFromWorld(mc.world);

if (entity != null) {
if (entity.equals(fakeplayer)) {
event.setCanceled(true);

if (mc.player.getCooledAttackStrength(0.5f) > 0.9) {

mc.world.playSound(
mc.player,
mc.player.posX,
mc.player.posY,
mc.player.posZ,
SoundEvents.ENTITY_PLAYER_ATTACK_STRONG,
mc.player.getSoundCategory(),
1.0f, 1.0f
);

attackFakePlayer();

} else {

mc.world.playSound(
mc.player,
mc.player.posX,
mc.player.posY,
mc.player.posZ,
SoundEvents.ENTITY_PLAYER_ATTACK_WEAK,
mc.player.getSoundCategory(),
1.0f, 1.0f
);

attackFakePlayer();
}
}
}
}
}
}
}

public void popPlayer(EntityOtherPlayerMP playerMP) {;

MinecraftForge.EVENT_BUS.post(new PacketEvent.Receive(new SPacketEntityStatus(playerMP, (byte) 35)));

mc.effectRenderer.emitParticleAtEntity(playerMP, EnumParticleTypes.TOTEM, 30);
mc.world.playSound(playerMP.posX,
playerMP.posY,
playerMP.posZ,
SoundEvents.ITEM_TOTEM_USE,
playerMP.getSoundCategory(),
1.0F, 1.0F, false
);

playerMP.setHealth(1.0f);
playerMP.setAbsorptionAmount(8.0f);
playerMP.clearActivePotions();
playerMP.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
playerMP.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
}

public void attackFakePlayer() {

double damage = 0.1f;

if (mc.player.inventory.getCurrentItem().getItem() instanceof ItemSword) {
damage = ((ItemSword) mc.player.inventory.getCurrentItem().getItem()).getAttackDamage() + (double) EnchantmentHelper.getModifierForCreature(mc.player.inventory.getCurrentItem(), EnumCreatureAttribute.UNDEFINED);
}

fakeplayer.setHealth(fakeplayer.getHealth() - (float) damage);

if (fakeplayer.getHealth() <= 0.0f) popPlayer(fakeplayer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public class FastXP extends Module {

public FastXP() {
super("FastXP",
Category.PLAYER);
"Modifies right click delay timer when you hold xp",
Category.PLAYER
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class CleanGUI extends Module {
public CleanGUI() {
super("CleanGUI",
"Removes tint in guis",
Category.RENDER);
Category.RENDER
);

instance = this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import java.awt.*;
import java.util.Random;

/**
* @author Snoworange
*/

public class DVDIcon extends Module {

private static DVDIcon instance;
Expand Down Expand Up @@ -69,7 +73,7 @@ public void onDisable() {
super.onDisable();

x = 69;
y = 42;
y = 69;
}

public Color dvdColor = new Color(212, 61, 89);
Expand Down Expand Up @@ -98,7 +102,7 @@ public void drawDVDIcon() {
GlStateManager.color( (float) dvdColor.getRed() / 255,
(float) dvdColor.getBlue() / 255,
(float) dvdColor.getGreen() / 255,
1F
1f
);


Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package nl.snoworange.cranberry.features.module.modules.render;

import com.mojang.authlib.GameProfile;
import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.client.model.ModelPlayer;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.GameType;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import nl.snoworange.cranberry.features.module.Category;
import nl.snoworange.cranberry.features.module.Module;
import nl.snoworange.cranberry.features.setting.Setting;

import java.util.UUID;

public class DeathEffects extends Module {

public DeathEffects() {
Expand Down Expand Up @@ -41,6 +47,8 @@ public void onLiving() {
if (player.deathTime == 1) {
if (effect.getValue().equals(Effects.LIGHTNING)) {
summonLightning(player.posX, player.posY, player.posZ);
} else if (effect.getValue().equals(Effects.TEST)) {

}
}
}
Expand Down
Loading

0 comments on commit c817a6b

Please sign in to comment.