Skip to content

Commit

Permalink
it compiles...
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Jun 28, 2024
1 parent d0541de commit aa04fd8
Show file tree
Hide file tree
Showing 33 changed files with 293 additions and 652 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/connorcode/sigmautils/commands/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private static int save(CommandContext<FabricClientCommandSource> context) {

File mapFile = getNewFile(mapId);
try {
client.gameRenderer.getMapRenderer().getMapTexture(mapId.id(), mapState).texture.getImage().writeTo(mapFile);
client.gameRenderer.getMapRenderer().getMapTexture(mapId, mapState).texture.getImage().writeTo(mapFile);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,16 @@ protected ResourceAddScreen(Screen _super, ResourceManager<K> renderer) {

@Override
protected void init() {
this.searchField =
new TextFieldWidget(SigmaUtils.client.textRenderer, 0, 10, entryWidth / 2, 20, this.searchField,
Text.empty());
focusOn(this.searchField);
this.searchField = new TextFieldWidget(SigmaUtils.client.textRenderer, 0, 10, entryWidth / 2, 20, this.searchField, Text.empty());
setFocused(this.searchField);
searchField.setX(width / 2 - searchField.getWidth() / 2);
var y = padding * 6 + 30 - (int) this.scroll;
var x = 20 + padding + startX();

var search = searchField.getText();
var res = renderer.getAllResources();
count = res.size();
for (var i : res
.stream()
.filter(r -> search.isEmpty() || search(r, search))
for (var i : res.stream().filter(r -> search.isEmpty() || search(r, search))
.toList()) {
if (y < -entryHeight - padding) {
y += entryHeight + padding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,16 @@ protected ResourceSelectScreen(Screen _super, ResourceManager<K> renderer) {

@Override
protected void init() {
this.searchField =
new TextFieldWidget(SigmaUtils.client.textRenderer, 0, 10, entryWidth / 2, 20, this.searchField,
Text.empty());
focusOn(this.searchField);
this.searchField = new TextFieldWidget(SigmaUtils.client.textRenderer, 0, 10, entryWidth / 2, 20, this.searchField, Text.empty());
setFocused(this.searchField);
searchField.setX(width / 2 - searchField.getWidth() / 2);
var y = padding * 6 + 30 - (int) this.scroll;
var x = 20 + padding + startX();

var search = searchField.getText();
var res = renderer.getAllResources();
count = res.size();
for (var i : res
.stream()
.filter(r -> search.isEmpty() || search(r, search))
for (var i : res.stream().filter(r -> search.isEmpty() || search(r, search))
.toList()) {
if (y < -entryHeight - padding) {
y += entryHeight + padding;
Expand Down
49 changes: 3 additions & 46 deletions src/main/java/com/connorcode/sigmautils/misc/Components.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.connorcode.sigmautils.misc.util.Util;
import com.connorcode.sigmautils.mixin.ScreenAccessor;
import com.connorcode.sigmautils.module.Module;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element;
Expand All @@ -15,7 +14,6 @@
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.CheckboxWidget;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
Expand Down Expand Up @@ -183,52 +181,11 @@ protected Text tooltip() {
@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
super.render(drawContext, mouseX, mouseY, delta);
if (!this.hovered)
return;
if (!this.hovered) return;
Text tooltip = this.tooltip();
if (tooltip == null)
return;

drawContext.drawOrderedTooltip(client.textRenderer, client.textRenderer.wrapLines(tooltip, 200), mouseX,
mouseY);
}
}

public static class EventCheckbox extends CheckboxWidget {
PressAction onPress;
TooltipSupplier tooltipSupplier;

public EventCheckbox(int x, int y, int width, int height, Text message, boolean checked, TextRenderer renderer, PressAction onPress, TooltipSupplier tooltipSupplier) {
super(x, y, message, renderer, checked, Callback.EMPTY);
this.width = width;
this.height = height;
this.onPress = onPress;
this.tooltipSupplier = tooltipSupplier;
}

@Override
public void onPress() {
super.onPress();
this.onPress.onPress(this);
}

public void renderTooltip(DrawContext drawContext, int mouseX, int mouseY) {
tooltipSupplier.onTooltip(this, drawContext, mouseX, mouseY);
}

@Override
public void renderWidget(DrawContext drawContext, int mouseX, int mouseY, float delta) {
super.renderWidget(drawContext, mouseX, mouseY, delta);
if (this.isSelected())
this.renderTooltip(drawContext, mouseX, mouseY);
}

public interface PressAction {
void onPress(EventCheckbox button);
}
if (tooltip == null) return;

public interface TooltipSupplier {
void onTooltip(EventCheckbox button, DrawContext drawContext, int mouseX, int mouseY);
drawContext.drawOrderedTooltip(client.textRenderer, client.textRenderer.wrapLines(tooltip, 200), mouseX, mouseY);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.MappingResolver;
import net.minecraft.network.NetworkPhase;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.packet.Packet;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;

import static com.connorcode.sigmautils.SigmaUtils.client;
Expand All @@ -26,10 +23,11 @@ public class NetworkUtils {

public static Object2IntOpenHashMap<Class<? extends Packet<?>>> getPackets(NetworkSide side) {
var packets = new Object2IntOpenHashMap<Class<? extends Packet<?>>>();
Arrays.stream(NetworkPhase.values())
.map(state -> state.packetHandlers.get(side))
.filter(Objects::nonNull)
.forEach(handler -> packets.putAll(handler.backingHandler.packetIds));
// TODO: Fix
// Arrays.stream(NetworkPhase.values())
// .map(state -> state.packetHandlers.get(side))
// .filter(Objects::nonNull)
// .forEach(handler -> packets.putAll(handler.backingHandler.packetIds));
return packets;
}

Expand Down
33 changes: 13 additions & 20 deletions src/main/java/com/connorcode/sigmautils/mixin/CameraMixin.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package com.connorcode.sigmautils.mixin;

import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.modules.misc.CameraClip;
import com.connorcode.sigmautils.modules.misc.CameraDistance;
import net.minecraft.client.render.Camera;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Camera.class)
public class CameraMixin {
@ModifyVariable(method = "clipToSpace", at = @At("HEAD"), argsOnly = true)
double clipToSpace(double desiredCameraDistance) {
if (!Config.getEnabled(CameraDistance.class))
return desiredCameraDistance;
return CameraDistance.getDistance();
}

@Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable<Double> cir) {
if (!Config.getEnabled(CameraClip.class))
return;
cir.setReturnValue(desiredCameraDistance);
}
// @ModifyVariable(method = "clipToSpace", at = @At("HEAD"), argsOnly = true)
// double clipToSpace(double desiredCameraDistance) {
// if (!Config.getEnabled(CameraDistance.class))
// return desiredCameraDistance;
// return CameraDistance.getDistance();
// }
//
// @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
// void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable<Double> cir) {
// if (!Config.getEnabled(CameraClip.class))
// return;
// cir.setReturnValue(desiredCameraDistance);
// }
}
30 changes: 11 additions & 19 deletions src/main/java/com/connorcode/sigmautils/mixin/ChatHudMixin.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
package com.connorcode.sigmautils.mixin;

import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.modules._interface.NoChatFade;
import com.connorcode.sigmautils.modules.chat.NoMessageHiding;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.network.message.MessageSignatureData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ChatHud.class)
public abstract class ChatHudMixin {
@Shadow
protected abstract boolean isChatFocused();

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
boolean isChatFocused(ChatHud instance) {
if (Config.getEnabled(NoChatFade.class))
return true;
return isChatFocused();
}

@Inject(method = "removeMessage", at = @At("HEAD"), cancellable = true)
void onHideMessage(MessageSignatureData signature, CallbackInfo ci) {
if (Config.getEnabled(NoMessageHiding.class)) ci.cancel();
}
// @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
// boolean isChatFocused(ChatHud instance) {
// if (Config.getEnabled(NoChatFade.class))
// return true;
// return isChatFocused();
// }
//
// @Inject(method = "removeMessage", at = @At("HEAD"), cancellable = true)
// void onHideMessage(MessageSignatureData signature, CallbackInfo ci) {
// if (Config.getEnabled(NoMessageHiding.class)) ci.cancel();
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientCommonNetworkHandler.class)
public class ClientCommonNetworkHandlerMixin {
@Inject(method = "onCustomPayload", at = @At("HEAD"))
void onCustomPayload(CustomPayloadS2CPacket packet) {
void onCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo ci) {
// var buf = packet.getPayload();
// var event = new UnknownPacketEvent(buf, packet.payload().getId().id());
System.out.println("CUSTOM PAYLOAD:" + packet.payload().getClass().getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public void onRequestRespawn(CallbackInfo ci) {
PrintDeathCords.lastDeath = null;
}

@Redirect(method = "updateNausea", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;closeHandledScreen()V"))
@Redirect(method = "tickNausea", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;closeHandledScreen()V"))
void onCloseHandledScreen(ClientPlayerEntity instance) {
if (!Config.getEnabled(PortalInventory.class))
instance.closeHandledScreen();
}

@Redirect(method = "updateNausea", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"))
@Redirect(method = "tickNausea", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"))
void onSetScreen(MinecraftClient instance, Screen screen) {
if (!Config.getEnabled(PortalInventory.class))
instance.setScreen(screen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;

@Mixin(CustomPayloadS2CPacket.class)
public class CustomPayloadS2CPacketMixin {
@Inject(method = "apply", at = @At("HEAD"))
void onApply() {

}
// @Inject(method = "apply", at = @At("HEAD"))
// void onApply() {
//
// }
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
package com.connorcode.sigmautils.mixin;

import com.connorcode.sigmautils.config.Config;
import com.connorcode.sigmautils.modules.rendering.Deadmau5Ears;
import com.connorcode.sigmautils.modules.rendering.Titles;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin<T extends Entity> {
@Redirect(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
private boolean isDeadmau5(String stringA, Object stringB) {
if (Config.getEnabled(Deadmau5Ears.class))
return true;
return stringA.equals(stringB);
}

@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
private void renderLabelIfPresent(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers,
int light, CallbackInfo ci) {
if (Titles.tamableOwner.value() && (entity instanceof TameableEntity || entity instanceof AbstractHorseEntity))
ci.cancel();
}
// TODO: fix
// @Redirect(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
// private boolean isDeadmau5(String stringA, Object stringB) {
// if (Config.getEnabled(Deadmau5Ears.class))
// return true;
// return stringA.equals(stringB);
// }
//
// @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
// private void renderLabelIfPresent(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers,
// int light, CallbackInfo ci) {
// if (Titles.tamableOwner.value() && (entity instanceof TameableEntity || entity instanceof AbstractHorseEntity))
// ci.cancel();
// }
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit aa04fd8

Please sign in to comment.