ElytraFly: new mode "Look", Optimized notification icons, Added firework sounds to NoLag

This commit is contained in:
noil 2021-04-12 15:34:03 -04:00
parent 61ddfa54e6
commit e1146eec99
5 changed files with 113 additions and 65 deletions

View File

@ -1,7 +1,6 @@
package me.rigamortis.seppuku.api.notification;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.texture.Texture;
import me.rigamortis.seppuku.api.util.MathUtil;
import me.rigamortis.seppuku.api.util.Timer;
import me.rigamortis.seppuku.impl.gui.hud.component.NotificationsComponent;
@ -135,28 +134,28 @@ public final class Notification {
}
public enum Type {
INFO(0xFF909090, new Texture("info.png")),
SUCCESS(0xFF10FF10, new Texture("success.png")),
WARNING(0xFFFFFF10, new Texture("warning.png")),
ERROR(0xFFFF1010, new Texture("error.png")),
QUESTION(0xFF10FFFF, new Texture("question.png")),
MISC(0xFFFFFFFF, new Texture("module-misc.png"));
INFO(0xFF909090, 0),
SUCCESS(0xFF10FF10, 1),
WARNING(0xFFFFFF10, 2),
ERROR(0xFFFF1010, 3),
QUESTION(0xFF10FFFF, 4),
MISC(0xFFFFFFFF, 5);
private final int color;
private final Texture texture;
private final int textureID;
Type(int color, Texture texture) {
Type(int color, int textureID) {
this.color = color;
this.texture = texture;
this.textureID = textureID;
}
public int getColor() {
return color;
}
public Texture getTexture() {
return texture;
public int getTextureID() {
return textureID;
}
}
}

View File

@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.gui.hud.component;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import me.rigamortis.seppuku.api.notification.Notification;
import me.rigamortis.seppuku.api.texture.Texture;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import me.rigamortis.seppuku.impl.gui.hud.anchor.AnchorPoint;
@ -12,15 +13,28 @@ import me.rigamortis.seppuku.impl.gui.hud.anchor.AnchorPoint;
*/
public final class NotificationsComponent extends DraggableHudComponent {
private final Texture[] textures = new Texture[6];
public NotificationsComponent(AnchorPoint anchorPoint) {
super("Notifications");
this.setAnchorPoint(anchorPoint); // by default anchors in the top center
this.setVisible(true);
this.init();
}
public NotificationsComponent() {
super("Notifications");
this.setVisible(true);
this.init();
}
private void init() {
this.textures[0] = new Texture("info.png");
this.textures[1] = new Texture("success.png");
this.textures[2] = new Texture("warning.png");
this.textures[3] = new Texture("error.png");
this.textures[4] = new Texture("question.png");
this.textures[5] = new Texture("module-misc.png");
}
@Override
@ -61,7 +75,7 @@ public final class NotificationsComponent extends DraggableHudComponent {
//rect bar
RenderUtil.drawRect(notification.getTransitionX() + 16 - 1, notification.getTransitionY(), notification.getTransitionX() + notification.getWidth() + 1, (notification.getTransitionY() + 1), notification.getType().getColor());
//icon
notification.getType().getTexture().render(notification.getTransitionX() - 1, notification.getTransitionY() - 1, 16, 16);
this.textures[notification.getType().getTextureID()].render(notification.getTransitionX() - 1, notification.getTransitionY() - 1, 16, 16);
//text
mc.fontRenderer.drawStringWithShadow(notification.getText(), notification.getTransitionX() + 16, notification.getTransitionY() + 4.0F, 0xFFFFFFFF);

View File

@ -5,9 +5,11 @@ import com.mojang.realmsclient.gui.ChatFormatting;
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.world.EventLoadWorld;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.notification.Notification;
import me.rigamortis.seppuku.api.util.FileUtil;
import me.rigamortis.seppuku.api.util.Timer;
import me.rigamortis.seppuku.api.value.Value;
import me.rigamortis.seppuku.impl.module.hidden.CommandsModule;
import net.minecraft.client.Minecraft;
@ -45,6 +47,7 @@ public final class StorageAlertModule extends Module {
public final Value<Boolean> dispensers = new Value<Boolean>("Dispensers", new String[]{"Dispensers", "disp"}, "Count dispensers.", false);
public final Value<Boolean> stands = new Value<Boolean>("BrewingStands", new String[]{"BrewingStands", "brew"}, "Count brewing stands.", false);
private final Timer loadWorldTimer = new Timer();
private final File locationsFile;
private CommandsModule commandsModule;
@ -65,57 +68,66 @@ public final class StorageAlertModule extends Module {
}
@Listener
public void recievePacket(EventReceivePacket event) {
public void onLoadWorld(EventLoadWorld event) {
if (event.getWorld() != null) {
this.loadWorldTimer.reset();
}
}
@Listener
public void onReceivePacket(EventReceivePacket event) {
if (event.getStage() == EventStageable.EventStage.POST) {
if (event.getPacket() instanceof SPacketChunkData) {
final SPacketChunkData packet = (SPacketChunkData) event.getPacket();
final Vec2f position = new Vec2f(packet.getChunkX() * 16, packet.getChunkZ() * 16);
final Map<String, Vec2f> foundStorage = Maps.newLinkedHashMap();
if (this.loadWorldTimer.passed(2000)) { // wait 2000 ms on world load
if (event.getPacket() instanceof SPacketChunkData) {
final SPacketChunkData packet = (SPacketChunkData) event.getPacket();
final Vec2f position = new Vec2f(packet.getChunkX() * 16, packet.getChunkZ() * 16);
final Map<String, Vec2f> foundStorage = Maps.newLinkedHashMap();
for (NBTTagCompound tag : packet.getTileEntityTags()) {
final String id = tag.getString("id");
if (
(this.chests.getValue() && (id.equals("minecraft:chest") || id.equals("minecraft:trapped_chest"))) ||
(this.echests.getValue() && id.equals("minecraft:ender_chest")) ||
(this.shulkers.getValue() && id.equals("minecraft:shulker_box")) ||
(this.hoppers.getValue() && id.equals("minecraft:hopper")) ||
(this.droppers.getValue() && id.equals("minecraft:dropper")) ||
(this.dispensers.getValue() && id.equals("minecraft:dispenser")) ||
(this.stands.getValue() && id.equals("minecraft:brewing_stand"))
) {
foundStorage.put(id, position);
}
}
if (foundStorage.size() > 0) {
String id = "storage block" + (foundStorage.size() == 1 ? "" : "s");
for (String type : foundStorage.keySet()) {
final Vec2f otherPosition = foundStorage.get(type);
if (position.equals(otherPosition)) {
id = type.replaceAll("minecraft:", "");
for (NBTTagCompound tag : packet.getTileEntityTags()) {
final String id = tag.getString("id");
if (
(this.chests.getValue() && (id.equals("minecraft:chest") || id.equals("minecraft:trapped_chest"))) ||
(this.echests.getValue() && id.equals("minecraft:ender_chest")) ||
(this.shulkers.getValue() && id.equals("minecraft:shulker_box")) ||
(this.hoppers.getValue() && id.equals("minecraft:hopper")) ||
(this.droppers.getValue() && id.equals("minecraft:dropper")) ||
(this.dispensers.getValue() && id.equals("minecraft:dispenser")) ||
(this.stands.getValue() && id.equals("minecraft:brewing_stand"))
) {
foundStorage.put(id, position);
}
}
final String message = foundStorage.size() + " " + id + " located";
if (this.mode.getValue() == Mode.CHAT || this.mode.getValue() == Mode.BOTH) {
if (this.commandsModule == null) {
this.commandsModule = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class);
} else {
final TextComponentString textComponent = new TextComponentString(ChatFormatting.YELLOW + message);
textComponent.appendSibling(new TextComponentString("(*)")
.setStyle(new Style()
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\2476" + "Create a waypoint for this position" + "\n" + ChatFormatting.WHITE + "X: " + position.x + ", Z: " + position.y)))
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, commandsModule.getPrefix().getValue() + "waypoint add " + String.format("x%s_z%s", position.x, position.y) + " " + position.x + " 120 " + position.y))));
Seppuku.INSTANCE.logcChat(textComponent);
}
}
if (this.mode.getValue() == Mode.NOTIFICATION || this.mode.getValue() == Mode.BOTH) {
Seppuku.INSTANCE.getNotificationManager().addNotification("", message, Notification.Type.INFO, 3000);
}
if (foundStorage.size() > 0) {
String id = "storage block" + (foundStorage.size() == 1 ? "" : "s");
if (this.saveToFile.getValue()) {
this.saveStorageToFile(foundStorage);
for (String type : foundStorage.keySet()) {
final Vec2f otherPosition = foundStorage.get(type);
if (position.equals(otherPosition)) {
id = type.replaceAll("minecraft:", "");
}
}
final String message = foundStorage.size() + " " + id + " located";
if (this.mode.getValue() == Mode.CHAT || this.mode.getValue() == Mode.BOTH) {
if (this.commandsModule == null) {
this.commandsModule = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class);
} else {
final TextComponentString textComponent = new TextComponentString(ChatFormatting.YELLOW + message);
textComponent.appendSibling(new TextComponentString("(*)")
.setStyle(new Style()
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\2476" + "Create a waypoint for this position" + "\n" + ChatFormatting.WHITE + "X: " + position.x + ", Z: " + position.y)))
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, commandsModule.getPrefix().getValue() + "waypoint add " + String.format("x%s_z%s", position.x, position.y) + " " + position.x + " 120 " + position.y))));
Seppuku.INSTANCE.logcChat(textComponent);
}
}
if (this.mode.getValue() == Mode.NOTIFICATION || this.mode.getValue() == Mode.BOTH) {
Seppuku.INSTANCE.getNotificationManager().addNotification("", message, Notification.Type.INFO, 3000);
}
if (this.saveToFile.getValue()) {
this.saveStorageToFile(foundStorage);
}
}
}
}

View File

@ -31,10 +31,10 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class ElytraFlyModule extends Module {
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Mode to use for elytra flight.", Mode.VANILLA);
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Mode to use for elytra flight.", Mode.LOOK);
private enum Mode {
VANILLA, PACKET, CONTROL
VANILLA, PACKET, CONTROL, LOOK
}
public final Value<Float> speed = new Value<Float>("Speed", new String[]{"Spd", "amount", "s"}, "Speed multiplier for elytra flight, higher values equals more speed.", 1.0f, 0.0f, 5.0f, 0.1f);
@ -44,7 +44,7 @@ public final class ElytraFlyModule extends Module {
public final Value<Float> speedZ = new Value<Float>("SpeedZ", new String[]{"SpdZ", "amountZ", "sZ"}, "The Z speed factor (speed * this).", 1.0f, 0.1f, 5.0f, 0.1f);
public final Value<Boolean> autoStart = new Value<Boolean>("AutoStart", new String[]{"AutoStart", "Auto-Start", "start", "autojump", "as"}, "Hold down the jump key to have an easy automated lift off.", true);
public final Value<Float> autoStartDelay = new Value<Float>("StartDelay", new String[]{"AutoStartDelay", "startdelay", "autojumpdelay", "asd"}, "Delay(ms) between auto-start attempts.", 10.0f, 0.0f, 300.0f, 10.0f);
public final Value<Float> autoStartDelay = new Value<Float>("StartDelay", new String[]{"AutoStartDelay", "startdelay", "autojumpdelay", "asd"}, "Delay(ms) between auto-start attempts.", 150.0f, 0.0f, 300.0f, 10.0f);
public final Value<Boolean> autoEquip = new Value<Boolean>("AutoEquip", new String[]{"AutoEquipt", "AutoElytra", "Equip", "Equipt", "ae"}, "Automatically equips a durable elytra before or during flight. (inventory only, not hotbar!)", false);
public final Value<Float> autoEquipDelay = new Value<Float>("EquipDelay", new String[]{"AutoEquipDelay", "AutoEquiptDelay", "equipdelay", "aed"}, "Delay(ms) between elytra equip swap attempts.", 200.0f, 0.0f, 1000.0f, 10.0f);
public final Value<Boolean> stayAirborne = new Value<Boolean>("StayAirborne", new String[]{"Airborne", "StayInAir", "Stay-Airborne", "air", "sa"}, "Attempts to always keep the player airborne (only use when AutoEquip is enabled).", false);
@ -239,22 +239,42 @@ public final class ElytraFlyModule extends Module {
Minecraft mc = Minecraft.getMinecraft();
if (mc.player.isElytraFlying()) {
final double[] directionSpeed = MathUtil.directionSpeed(this.speed.getValue());
if (this.mode.getValue() == Mode.CONTROL) {
mc.player.motionY = 0; // Prevent the player from slowly falling down
final double[] directionSpeedControl = MathUtil.directionSpeed(this.speed.getValue());
mc.player.motionX = 0;
mc.player.motionZ = 0;
if (mc.player.movementInput.jump) {
mc.player.motionY = (this.speed.getValue() / 2) * this.speedYUp.getValue();
} else if (mc.player.movementInput.sneak) {
mc.player.motionY = -(this.speed.getValue() / 2) * this.speedYDown.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeedControl[0] * this.speedX.getValue();
mc.player.motionZ = directionSpeedControl[1] * this.speedZ.getValue();
mc.player.motionX = directionSpeed[0] * this.speedX.getValue();
mc.player.motionZ = directionSpeed[1] * this.speedZ.getValue();
}
event.setX(mc.player.motionX);
event.setY(mc.player.motionY);
event.setZ(mc.player.motionZ);
} else if (this.mode.getValue() == Mode.LOOK) {
mc.player.motionX = 0;
mc.player.motionY = 0;
mc.player.motionZ = 0;
if (mc.gameSettings.keyBindForward.isKeyDown() || mc.gameSettings.keyBindBack.isKeyDown()) {
mc.player.motionY = (this.speed.getValue() * (-MathUtil.degToRad(mc.player.rotationPitch))) * mc.player.movementInput.moveForward;
}
if (mc.player.movementInput.jump) {
mc.player.motionY = (this.speed.getValue() / 2) * this.speedYUp.getValue();
} else if (mc.player.movementInput.sneak) {
mc.player.motionY = -(this.speed.getValue() / 2) * this.speedYDown.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeed[0] * this.speedX.getValue();
mc.player.motionZ = directionSpeed[1] * this.speedZ.getValue();
}
event.setX(mc.player.motionX);
event.setY(mc.player.motionY);
event.setZ(mc.player.motionZ);

View File

@ -93,6 +93,9 @@ public final class NoLagModule extends Module {
if (packet.getCategory() == SoundCategory.PLAYERS && packet.getSound() == SoundEvents.ITEM_ARMOR_EQUIP_GENERIC) {
event.setCanceled(true);
}
if (packet.getSound() == SoundEvents.ENTITY_FIREWORK_LAUNCH) {
event.setCanceled(true);
}
}
}
}