Add partial implementation of a custom chat suffix and use internal math functions for calculations, add partially working idlefall (needs to be calculated based on pitch)

This commit is contained in:
Alex 2020-05-02 16:08:38 +02:00
parent dcc843d59a
commit 49ba14fc46
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
3 changed files with 44 additions and 153 deletions

View File

@ -4,6 +4,7 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.player.EventSendChatMessage;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.impl.module.hidden.CommandsModule;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.client.CPacketChatMessage;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -13,7 +14,7 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class ChatSuffixModule extends Module {
private final String prefix = "\u23D0 \uA731\u1D07\u1D18\u1D18\u1D1C\u1D0B\u1D1C";
public final Value<String> suffix = new Value("Suffix", new String[]{"suffix","s"}, "Suffix to append.", "\u23D0 \uA731\u1D07\u1D18\u1D18\u1D1C\u1D0B\u1D1C");
public ChatSuffixModule() {
super("ChatSuffix", new String[]{"Suffix", "Chat_Suffix", "CustomChat", "Custom_Chat"}, "Add a custom suffix to your chat messages.", "NONE", -1, ModuleType.MISC);
@ -25,10 +26,10 @@ public final class ChatSuffixModule extends Module {
if (cmds == null)
return;
if (event.getMessage().startsWith("/") || event.getMessage().startsWith(cmds.prefix.getValue()))
if (event.getMessage().startsWith("#") || event.getMessage().startsWith("/") || event.getMessage().startsWith(cmds.prefix.getValue()))
return;
event.setCanceled(true);
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketChatMessage(event.getMessage() + " " + prefix));
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketChatMessage(event.getMessage() + " " + this.suffix.getValue()));
}
}

View File

@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.module.movement;
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.network.EventSendPacket;
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.impl.module.player.NoHungerModule;
@ -14,6 +15,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.network.play.server.SPacketPlayerPosLook;
import net.minecraft.network.play.server.SPacketChat;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -32,6 +35,9 @@ public final class ElytraFlyModule extends Module {
public final Value<Float> speed = new Value<Float>("Speed", new String[]{"Spd"}, "Speed multiplier for elytra flight, higher values equals more speed.", 1.0f, 0.0f, 5.0f, 0.01f);
public final Value<Float> delay = new Value<Float>("Delay", new String[]{"delay,dly"}, "Delay to start the elytra after the space press.", 250.0f, 0.0f, 500.0f, 1000.0f);
public final Value<Float> downspd = new Value<Float>("Down Speed", new String[]{"downspeed","dsp"}, "Y velocity on going down (control only).", 0.25f, 0.5f, 2.0f, 0.1f);
public final Value<Float> upspd = new Value<Float>("Up Speed", new String[]{"upspeed","usp"}, "Y velocity on going up (control only).", 0.5f, 0.25f, 2.0f, 0.1f);
public final Value<Float> idlefall = new Value<Float>("Idle fall speed", new String[]{"idlespeed","isp"}, "Idle Y velocity (control only).", 0.000050000002f, 0f, -1f, 1f); // Taken from KAMI-blue @ module/modules/movement/ElytraFlight.java:43
public final Value<Boolean> autoStart = new Value<Boolean>("AutoStart", new String[]{"AutoStart", "start", "autojump"}, "Hold down the jump key to have an easy automated lift off.", true);
public final Value<Boolean> disableInLiquid = new Value<Boolean>("DisableInLiquid", new String[]{"DisableInWater", "DisableInLava", "disableliquid", "liquidoff", "noliquid"}, "Disables all elytra flight when the player is in contact with liquid.", true);
@ -102,24 +108,19 @@ public final class ElytraFlyModule extends Module {
switch (this.mode.getValue()) {
case VANILLA:
final float speedScaled = this.speed.getValue() * 0.05f; // 5/100 of original value
if (mc.gameSettings.keyBindJump.isKeyDown()) {
mc.player.motionY += speedScaled;
final double[] directionSpeedVanilla = MathUtil.directionSpeed(speedScaled);
if (mc.player.movementInput.jump) {
mc.player.motionY = this.speed.getValue();
}
if (mc.gameSettings.keyBindSneak.isKeyDown()) {
mc.player.motionY -= speedScaled;
if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.speed.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX += directionSpeedVanilla[0];
mc.player.motionZ += directionSpeedVanilla[1];
}
if (mc.gameSettings.keyBindForward.isKeyDown()) {
mc.player.motionX -= Math.sin(rotationYaw) * speedScaled;
mc.player.motionZ += Math.cos(rotationYaw) * speedScaled;
}
if (mc.gameSettings.keyBindBack.isKeyDown()) {
mc.player.motionX += Math.sin(rotationYaw) * speedScaled;
mc.player.motionZ -= Math.cos(rotationYaw) * speedScaled;
}
break;
case PACKET:
this.freezePlayer(mc.player);
@ -170,43 +171,19 @@ public final class ElytraFlyModule extends Module {
}
break;
case CONTROL:
final double speedHalved = this.speed.getValue() / 2;
mc.player.motionY = 0;
if (mc.gameSettings.keyBindJump.isKeyDown()) {
mc.player.motionY = speedHalved;
} else if (mc.gameSettings.keyBindSneak.isKeyDown()) {
mc.player.motionY = -speedHalved;
final double[] directionSpeedControl = MathUtil.directionSpeed(this.speed.getValue());
mc.player.motionY = -this.idlefall.getValue();
mc.player.motionX = 0;
mc.player.motionZ = 0;
if (mc.player.movementInput.jump) {
mc.player.motionY = this.upspd.getValue();
} else if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.downspd.getValue();
}
final double sinSpeed = Math.sin(rotationYaw) * this.speed.getValue();
final double cosSpeed = Math.cos(rotationYaw) * this.speed.getValue();
double Xavg = 0;
double Zavg = 0;
boolean avgbit = false;
final boolean invBit = rotationYaw/90%2==1;
if (mc.gameSettings.keyBindForward.isKeyDown()) {
Xavg = -sinSpeed;
Zavg = cosSpeed;
avgbit = true;
} else if (mc.gameSettings.keyBindBack.isKeyDown()) {
Xavg = sinSpeed;
Zavg = -cosSpeed;
avgbit = true;
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeedControl[0];
mc.player.motionZ = directionSpeedControl[1];
}
if ((mc.gameSettings.keyBindRight.isKeyDown() && invBit) || mc.gameSettings.keyBindLeft.isKeyDown()) {
Xavg += cosSpeed;
Zavg += sinSpeed;
} else if ((mc.gameSettings.keyBindLeft.isKeyDown() && invBit) || mc.gameSettings.keyBindRight.isKeyDown()) {
Xavg += -cosSpeed;
Zavg += -sinSpeed;
}
if (avgbit) {
Xavg *= 0.5;
Zavg *= 0.5;
}
mc.player.motionX = Xavg;
mc.player.motionZ = Zavg;
break;
}
}

View File

@ -165,107 +165,20 @@ public final class ScaffoldModule extends Module {
private void placeBlock(BlockPos pos) {
final Minecraft mc = Minecraft.getMinecraft();
BlockPos[][] posit = {{pos.add(0, 0, 1), pos.add(0, 0, -1)}, {pos.add(0, 1, 0), pos.add(0, -1, 0)}, {pos.add(1, 0, 0),pos.add(-1, 0, 0)}};
EnumFacing[][] facing = {{EnumFacing.NORTH, EnumFacing.SOUTH}, {EnumFacing.DOWN, EnumFacing.UP}, {EnumFacing.WEST, EnumFacing.EAST}}; // Facing reversed as blocks are placed while facing in the opposite direction
final Block north = mc.world.getBlockState(pos.add(0, 0, -1)).getBlock();
final Block south = mc.world.getBlockState(pos.add(0, 0, 1)).getBlock();
final Block east = mc.world.getBlockState(pos.add(1, 0, 0)).getBlock();
final Block west = mc.world.getBlockState(pos.add(-1, 0, 0)).getBlock();
final Block up = mc.world.getBlockState(pos.add(0, 1, 0)).getBlock();
final Block down = mc.world.getBlockState(pos.add(0, -1, 0)).getBlock();
if (up != null && up != Blocks.AIR && !(up instanceof BlockLiquid)) {
final boolean activated = up.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.DOWN, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 1, 0), EnumFacing.DOWN, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (down != null && down != Blocks.AIR && !(down instanceof BlockLiquid)) {
final boolean activated = down.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, -1, 0), EnumFacing.UP, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (north != null && north != Blocks.AIR && !(north instanceof BlockLiquid)) {
final boolean activated = north.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 0, -1), EnumFacing.SOUTH, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (south != null && south != Blocks.AIR && !(south instanceof BlockLiquid)) {
final boolean activated = south.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 0, 1), EnumFacing.NORTH, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (east != null && east != Blocks.AIR && !(east instanceof BlockLiquid)) {
final boolean activated = east.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(1, 0, 0), EnumFacing.WEST, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
if (west != null && west != Blocks.AIR && !(west instanceof BlockLiquid)) {
final boolean activated = west.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
}
if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(-1, 0, 0), EnumFacing.EAST, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) {
mc.player.swingArm(EnumHand.MAIN_HAND);
}
if (activated) {
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
for (int i=0; i<6; i++) {
final Block block = mc.world.getBlockState(posit[i/2][i%2]).getBlock();
final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
if (block != null && block != Blocks.AIR && !(block instanceof BlockLiquid)) {
if (activated)
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
if (mc.playerController.processRightClickBlock(mc.player, mc.world, posit[i/2][i%2], facing[i/2][i%2], new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL)
mc.player.swingArm(EnumHand.MAIN_HAND);
if (activated)
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
}
}
}
@ -306,4 +219,4 @@ public final class ScaffoldModule extends Module {
return block != Blocks.AIR;
}
}
}