Added MultitaskModule, Update CrystalAura, new patches, new events

This commit is contained in:
noil 2020-12-06 23:04:36 -05:00
parent 27a6787b0f
commit d3119e9819
11 changed files with 144 additions and 22 deletions

View File

@ -1,4 +1,4 @@
package me.rigamortis.seppuku.api.event.entity;
package me.rigamortis.seppuku.api.event.player;
import me.rigamortis.seppuku.api.event.EventCancellable;

View File

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

View File

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

View File

@ -7,6 +7,7 @@ import me.rigamortis.seppuku.Seppuku;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/**
* @author noil
@ -22,7 +23,7 @@ public class FileUtil {
try {
return new FileReader(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Error creating reader: File not found exception");
}
}
return null;
@ -35,7 +36,7 @@ public class FileUtil {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Error closing reader: IO exception");
}
}
@ -98,7 +99,6 @@ public class FileUtil {
}
}
} catch (IOException e) {
e.printStackTrace();
file.delete();
}
}
@ -130,6 +130,7 @@ public class FileUtil {
fileReader.close();
}
} catch (IOException e) {
System.err.println("IOException thrown, can't close the file reader.");
}
}
@ -163,7 +164,7 @@ public class FileUtil {
fileWriter.close();
}
} catch (IOException e) {
message = "IOException thrown while attemping to close the writer.";
message = "IOException thrown while attempting to close the file writer.";
}
}

View File

@ -157,6 +157,7 @@ public final class ModuleManager {
add(new AutoFarmModule());
add(new NoEffectsModule());
add(new NoEntityTraceModule());
add(new MultitaskModule());
// p2w experience
if (Seppuku.INSTANCE.getCapeManager().hasCape())

View File

@ -42,14 +42,15 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
public final class CrystalAuraModule extends Module {
public final Value<Float> range = new Value("Range", new String[]{"Dist"}, "The minimum range to attack crystals.", 4.5f, 0.0f, 5.0f, 0.1f);
public final Value<Float> attackDelay = new Value("Attack_Delay", new String[]{"AttackDelay", "AttackDel", "Del"}, "The delay to attack in milliseconds.", 50.0f, 0.0f, 1000.0f, 1.0f);
public final Value<Boolean> place = new Value("Place", new String[]{"AutoPlace"}, "Automatically place crystals.", true);
public final Value<Float> placeDelay = new Value("Place_Delay", new String[]{"PlaceDelay", "PlaceDel"}, "The delay to place crystals.", 50.0f, 0.0f, 1000.0f, 1.0f);
public final Value<Float> minDamage = new Value("Min_Damage", new String[]{"MinDamage", "Min", "MinDmg"}, "The minimum explosion damage calculated to place down a crystal.", 1.0f, 0.0f, 20.0f, 0.5f);
public final Value<Boolean> ignore = new Value("Ignore", new String[]{"Ig"}, "Ignore self damage checks.", false);
public final Value<Boolean> render = new Value("Render", new String[]{"R"}, "Draws information about recently placed crystals from your player.", true);
public final Value<Boolean> renderDamage = new Value("Render_Damage", new String[]{"RD", "RenderDamage", "ShowDamage"}, "Draws calculated explosion damage on recently placed crystals from your player.", true);
public final Value<Float> range = new Value<Float>("Range", new String[]{"Dist"}, "The minimum range to attack crystals.", 4.0f, 0.0f, 7.0f, 0.1f);
public final Value<Float> attackDelay = new Value<Float>("Attack_Delay", new String[]{"AttackDelay", "AttackDel", "Del"}, "The delay to attack in milliseconds.", 50.0f, 0.0f, 1000.0f, 1.0f);
public final Value<Boolean> place = new Value<Boolean>("Place", new String[]{"AutoPlace"}, "Automatically place crystals.", true);
public final Value<Float> placeDelay = new Value<Float>("Place_Delay", new String[]{"PlaceDelay", "PlaceDel"}, "The delay to place crystals.", 50.0f, 0.0f, 1000.0f, 1.0f);
public final Value<Float> minDamage = new Value<Float>("Min_Damage", new String[]{"MinDamage", "Min", "MinDmg"}, "The minimum explosion damage calculated to place down a crystal.", 1.5f, 0.0f, 20.0f, 0.5f);
public final Value<Boolean> ignore = new Value<Boolean>("Ignore", new String[]{"Ig"}, "Ignore self damage checks.", false);
public final Value<Boolean> render = new Value<Boolean>("Render", new String[]{"R"}, "Draws information about recently placed crystals from your player.", true);
public final Value<Boolean> renderDamage = new Value<Boolean>("Render_Damage", new String[]{"RD", "RenderDamage", "ShowDamage"}, "Draws calculated explosion damage on recently placed crystals from your player.", true);
public final Value<Boolean> offHand = new Value<Boolean>("Offhand", new String[]{"Hand", "otherhand", "off"}, "Use crystals in the off-hand instead of holding them with the main-hand.", false);
private final Timer attackTimer = new Timer();
private final Timer placeTimer = new Timer();
@ -64,10 +65,11 @@ public final class CrystalAuraModule extends Module {
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.player.inventory.getCurrentItem().getItem() != Items.END_CRYSTAL) {
if (mc.player == null || mc.world == null)
return;
if (mc.player.getHeldItem(this.offHand.getValue() ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND).getItem() != Items.END_CRYSTAL)
return;
}
if (this.place.getValue()) {
if (this.placeTimer.passed(this.placeDelay.getValue())) {
@ -120,7 +122,7 @@ public final class CrystalAuraModule extends Module {
if (pos != null && damage > 0) {
final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), new Vec3d(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f));
Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]);
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(pos, EnumFacing.UP, EnumHand.MAIN_HAND, 0, 0, 0));
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(pos, EnumFacing.UP, this.offHand.getValue() ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND, 0, 0, 0));
this.placeLocations.add(new PlaceLocation(pos.getX(), pos.getY(), pos.getZ(), damage));
}
@ -145,7 +147,7 @@ public final class CrystalAuraModule extends Module {
final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), entity.getPositionVector());
Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]);
if (this.attackTimer.passed(this.attackDelay.getValue())) {
mc.player.swingArm(EnumHand.MAIN_HAND);
mc.player.swingArm(this.offHand.getValue() ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND);
mc.playerController.attackEntity(mc.player, entity);
this.attackTimer.reset();
}
@ -181,6 +183,7 @@ public final class CrystalAuraModule extends Module {
final Minecraft mc = Minecraft.getMinecraft();
RenderUtil.begin3D();
for (PlaceLocation placeLocation : this.placeLocations) {
if (placeLocation.alpha <= 0) {
this.placeLocations.remove(placeLocation);
@ -213,6 +216,7 @@ public final class CrystalAuraModule extends Module {
}
}
}
RenderUtil.end3D();
}
private boolean isLocalImmune() {

View File

@ -0,0 +1,32 @@
package me.rigamortis.seppuku.impl.module.combat;
import me.rigamortis.seppuku.api.event.player.EventHandActive;
import me.rigamortis.seppuku.api.event.player.EventHittingBlock;
import me.rigamortis.seppuku.api.event.player.EventResetBlockRemoving;
import me.rigamortis.seppuku.api.module.Module;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
/**
* @author noil
*/
public final class MultitaskModule extends Module {
public MultitaskModule() {
super("Multitask", new String[]{"multi", "task"}, "Allows the player to perform multiple actions at once. (eating, placing, attacking)", "NONE", -1, ModuleType.COMBAT);
}
@Listener
public void onActiveHand(EventHandActive event) {
event.setCanceled(true);
}
@Listener
public void onHittingBlock(EventHittingBlock event) {
event.setCanceled(true);
}
@Listener
public void onResetBlockRemoving(EventResetBlockRemoving event) {
event.setCanceled(true);
}
}

View File

@ -1,6 +1,6 @@
package me.rigamortis.seppuku.impl.module.combat;
import me.rigamortis.seppuku.api.event.entity.EventGetMouseOver;
import me.rigamortis.seppuku.api.event.player.EventGetMouseOver;
import me.rigamortis.seppuku.api.module.Module;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;

View File

@ -382,5 +382,39 @@ public final class EntityPlayerSPPatch extends ClassPatch {
methodNode.instructions.insert(insnList);
}
@MethodPatch(
mcpName = "isHandActive",
notchName = "cG",
mcpDesc = "()Z")
public void isHandActive(MethodNode methodNode, PatchManager.Environment env) {
//create a list of instructions
final InsnList insnList = new InsnList();
//call our hook function
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "isHandActiveHook", "()Z", false));
//create a label to jump to
final LabelNode jmp = new LabelNode();
//add "if equals"
insnList.add(new JumpInsnNode(IFEQ, jmp));
//add 0 or false
insnList.add(new InsnNode(ICONST_0));
//return so the rest of the function doesnt get called
insnList.add(new InsnNode(IRETURN));
//add our label
insnList.add(jmp);
//insert the list of instructs at the top of the function
methodNode.instructions.insert(insnList);
}
/**
* Our isHandActive hook used to override hand activity
*
* @return
*/
public static boolean isHandActiveHook() {
//dispatch our event
final EventHandActive event = new EventHandActive();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
return event.isCanceled();
}
}

View File

@ -1,7 +1,7 @@
package me.rigamortis.seppuku.impl.patch;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.entity.EventGetMouseOver;
import me.rigamortis.seppuku.api.event.player.EventGetMouseOver;
import me.rigamortis.seppuku.api.event.player.EventFovModifier;
import me.rigamortis.seppuku.api.event.render.EventHurtCamEffect;
import me.rigamortis.seppuku.api.event.render.EventOrientCamera;
@ -13,13 +13,11 @@ 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 org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
import team.stiff.pomelo.EventManager;
import java.util.ArrayList;
import java.util.List;
import static org.objectweb.asm.Opcodes.*;

View File

@ -358,4 +358,38 @@ public final class PlayerControllerMPPatch extends ClassPatch {
return event.isCanceled();
}
@MethodPatch(
mcpName = "getIsHittingBlock",
notchName = "m",
mcpDesc = "()Z")
public void getIsHittingBlock(MethodNode methodNode, PatchManager.Environment env) {
//create a list of instructions
final InsnList insnList = new InsnList();
//call our hook function
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "getIsHittingBlockHook", "()Z", false));
//create a label to jump to
final LabelNode jmp = new LabelNode();
//add "if equals"
insnList.add(new JumpInsnNode(IFEQ, jmp));
//add 0 or false
insnList.add(new InsnNode(ICONST_0));
//return so the rest of the function doesnt get called
insnList.add(new InsnNode(IRETURN));
//add our label
insnList.add(jmp);
//insert the list of instructs at the top of the function
methodNode.instructions.insert(insnList);
}
/**
* Our getIsHittingBlockHook hook used to override block-hitting hand activity
*
* @return true if the event is cancelled
*/
public static boolean getIsHittingBlockHook() {
//dispatch our event
final EventHittingBlock event = new EventHittingBlock();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
return event.isCanceled();
}
}