Small cleanups #5
19 changed files with 52 additions and 156 deletions
src/main
java/land/chipmunk/chipmunkmod
listeners
mixin
ClientConnectionAccessor.javaClientConnectionInvoker.javaClientConnectionMixin.javaClientPlayNetworkHandlerAccessor.javaClientPlayerEntityMixin.javaElderGuardianAppearanceParticleMixin.javaIdentifierMixin.javaPlayerListEntryAccessor.javaSoundSystemMixin.javaStringHelperMixin.java
modules
resources
|
@ -3,14 +3,14 @@ package land.chipmunk.chipmunkmod.listeners;
|
|||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class Listener {
|
||||
public void chatMessageReceived (Text message) {}
|
||||
public interface Listener {
|
||||
default void chatMessageReceived (Text message) {}
|
||||
|
||||
public void packetReceived (Packet<?> packet) {}
|
||||
default void packetReceived (Packet<?> packet) {}
|
||||
|
||||
public void packetSent (Packet<?> packet) {}
|
||||
default void packetSent (Packet<?> packet) {}
|
||||
|
||||
public void coreReady () {}
|
||||
default void coreReady () {}
|
||||
|
||||
public void coreMoved () {}
|
||||
default void coreMoved () {}
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public interface ClientConnectionAccessor {
|
||||
@Accessor("packetListener")
|
||||
PacketListener packetListener ();
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public interface ClientConnectionInvoker {
|
||||
@Invoker("handlePacket")
|
||||
static <T extends PacketListener> void handlePacket (Packet<T> packet, PacketListener listener) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -12,7 +11,6 @@ import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
|
|||
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
@ -25,6 +23,8 @@ import java.util.regex.Pattern;
|
|||
|
||||
@Mixin(net.minecraft.network.ClientConnection.class)
|
||||
public class ClientConnectionMixin {
|
||||
@Unique
|
||||
private static final double MAX_PARTICLES_PER_PACKET = 1000;
|
||||
@Unique
|
||||
private static final Pattern CUSTOM_PITCH_PATTERN = Pattern.compile(".*\\.pitch\\.(.*)");
|
||||
|
||||
|
@ -45,9 +45,7 @@ public class ClientConnectionMixin {
|
|||
// please don't skid this.,.
|
||||
// mabe mabe mabe
|
||||
if (packet instanceof ParticleS2CPacket t_packet) {
|
||||
final double max = 1000;
|
||||
|
||||
if (t_packet.getCount() > max) {
|
||||
if (t_packet.getCount() > MAX_PARTICLES_PER_PACKET) {
|
||||
ci.cancel();
|
||||
}
|
||||
} else if (packet instanceof PlaySoundS2CPacket t_packet) {
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(net.minecraft.client.network.ClientPlayNetworkHandler.class)
|
||||
public interface ClientPlayNetworkHandlerAccessor {
|
||||
@Accessor("playerListEntries")
|
||||
Map<UUID, PlayerListEntry> playerListEntries();
|
||||
|
||||
@Accessor("listedPlayerListEntries")
|
||||
Set<PlayerListEntry> listedPlayerListEntries();
|
||||
}
|
|
@ -1,38 +1,42 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.modules.CommandCore;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import land.chipmunk.chipmunkmod.modules.CommandCore;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class ClientPlayerEntityMixin {
|
||||
@Unique private static MinecraftClient CLIENT = MinecraftClient.getInstance();
|
||||
public abstract class ClientPlayerEntityMixin extends Entity {
|
||||
@Shadow @Final public ClientPlayNetworkHandler networkHandler;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "move")
|
||||
public void move (MovementType type, Vec3d relPos, CallbackInfo ci) {
|
||||
if ((ClientPlayerEntity) (Object) this != CLIENT.player) return;
|
||||
|
||||
final Vec3d position = ((ClientPlayerEntity) (Object) this).getPos().add(relPos);
|
||||
|
||||
final ClientWorld world = CLIENT.getNetworkHandler().getWorld();
|
||||
|
||||
final BlockPos origin = CommandCore.INSTANCE.origin;
|
||||
if (origin == null) { CommandCore.INSTANCE.move(position); return; }
|
||||
final int distance = (int) Math.sqrt(new Vec2f(origin.getX() / 16, origin.getZ() / 16).distanceSquared(new Vec2f((int) position.getX() / 16, (int) position.getZ() / 16)));
|
||||
if (distance > world.getSimulationDistance()) {
|
||||
CommandCore.INSTANCE.clientPlayerEntityFilled = true;
|
||||
CommandCore.INSTANCE.move(position);
|
||||
public ClientPlayerEntityMixin(final EntityType<?> type, final World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "move")
|
||||
public void move(CallbackInfo ci) {
|
||||
final BlockPos origin = CommandCore.INSTANCE.origin;
|
||||
if (origin == null) {
|
||||
CommandCore.INSTANCE.move(this.getPos());
|
||||
return;
|
||||
}
|
||||
|
||||
final int distanceSquared = this.getChunkPos().getSquaredDistance(new ChunkPos(origin));
|
||||
final int distance = (int) Math.sqrt(distanceSquared);
|
||||
|
||||
if (distance > networkHandler.getWorld().getSimulationDistance()) {
|
||||
CommandCore.INSTANCE.clientPlayerEntityFilled = true;
|
||||
CommandCore.INSTANCE.move(this.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
|
||||
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -11,10 +9,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
|
||||
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
|
||||
public class ElderGuardianAppearanceParticleMixin {
|
||||
@Inject(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"))
|
||||
private void createParticle (SimpleParticleType simpleParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
||||
if (cir.isCancelled() || !cir.isCancellable()) return;
|
||||
|
||||
cir.cancel();
|
||||
@Inject(
|
||||
method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void createParticle(final CallbackInfoReturnable<Particle> cir) {
|
||||
cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Identifier.class)
|
||||
public class IdentifierMixin {
|
||||
@Inject(method = "isNamespaceCharacterValid", at = @At("HEAD"), cancellable = true)
|
||||
private static void isNamespaceCharacterValid (char character, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(true);
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "isNamespaceValid", at = @At("HEAD"), cancellable = true)
|
||||
private static void isNamespaceValid (String namespace, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(true);
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "validateNamespace", at = @At("HEAD"), cancellable = true)
|
||||
private static void validateNamespace(String namespace, String path, CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue(namespace);
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.world.GameMode;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(PlayerListEntry.class)
|
||||
public interface PlayerListEntryAccessor {
|
||||
@Accessor("gameMode")
|
||||
void setGameMode (GameMode gameMode);
|
||||
|
||||
@Accessor("latency")
|
||||
void setLatency (int latency);
|
||||
}
|
|
@ -12,6 +12,5 @@ public class SoundSystemMixin {
|
|||
@Inject(method = "getAdjustedPitch", at = @At("HEAD"), cancellable = true)
|
||||
private void getAdjustedPitch (SoundInstance sound, CallbackInfoReturnable<Float> cir) {
|
||||
cir.setReturnValue(sound.getPitch());
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,18 +11,15 @@ public class StringHelperMixin {
|
|||
@Inject(method = "truncateChat", at = @At("HEAD"), cancellable = true)
|
||||
private static void truncateChat (String text, CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue(text);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "stripTextFormat", at = @At("HEAD"), cancellable = true)
|
||||
private static void stripTextFormat(String text, CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue(text);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.text.TextContent;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
public class ChomeNSAuth extends Listener {
|
||||
public class ChomeNSAuth implements Listener {
|
||||
public static final ChomeNSAuth INSTANCE = new ChomeNSAuth();
|
||||
|
||||
public final String id = "chomens_bot_verify";
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.text.Text;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChomeNSBotCommandSuggestions extends Listener {
|
||||
public class ChomeNSBotCommandSuggestions implements Listener {
|
||||
public static final String ID = "chomens_bot_request_command_suggestion";
|
||||
|
||||
public static ChomeNSBotCommandSuggestions INSTANCE = new ChomeNSBotCommandSuggestions(MinecraftClient.getInstance());
|
||||
|
|
|
@ -4,8 +4,6 @@ import com.google.common.hash.Hashing;
|
|||
import com.google.gson.JsonElement;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -13,13 +11,10 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class CustomChat {
|
||||
private final MinecraftClient client;
|
||||
|
@ -127,6 +122,7 @@ public class CustomChat {
|
|||
// .replace("\"PREFIX\"", prefix)
|
||||
// .replace("\"DISPLAYNAME\"", displayName)
|
||||
.replace("USERNAME", username)
|
||||
.replace("UUID", player.getUuidAsString())
|
||||
.replace("HASH", hash)
|
||||
.replace("{\"text\":\"MESSAGE\"}", messageWithColor)
|
||||
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":")
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Timer;
|
|||
import java.util.TimerTask;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class KaboomCheck extends Listener {
|
||||
public class KaboomCheck implements Listener {
|
||||
public boolean isKaboom = false;
|
||||
|
||||
private Timer timer = null;
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.TimerTask;
|
|||
|
||||
import static land.chipmunk.chipmunkmod.util.ServerUtilities.serverHasCommand;
|
||||
|
||||
public class SelfCare extends Listener {
|
||||
public class SelfCare implements Listener {
|
||||
private final MinecraftClient client;
|
||||
public final long interval;
|
||||
public final long chatInterval;
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class TabComplete extends Listener {
|
||||
public class TabComplete implements Listener {
|
||||
private final MinecraftClient client;
|
||||
|
||||
private final Map<Integer, CompletableFuture<CommandSuggestionsS2CPacket>> transactions = new HashMap<>();
|
||||
|
|
|
@ -8,16 +8,11 @@
|
|||
"ChatScreenMixin",
|
||||
"ClientConnectionMixin",
|
||||
"ClientPlayerEntityMixin",
|
||||
"ClientPlayNetworkHandlerAccessor",
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"MinecraftClientAccessor",
|
||||
"StringHelperMixin",
|
||||
"ElderGuardianAppearanceParticleMixin",
|
||||
"IdentifierMixin",
|
||||
"TextMixin",
|
||||
"ClientConnectionInvoker",
|
||||
"ClientConnectionAccessor",
|
||||
"PlayerListEntryAccessor",
|
||||
"TextSerializerMixin",
|
||||
"CommandDispatcherMixin",
|
||||
"SoundSystemMixin",
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"translate": "chat.type.text",
|
||||
"with": [
|
||||
{
|
||||
"selector": "USERNAME"
|
||||
"selector": "UUID"
|
||||
},
|
||||
{
|
||||
"text": "MESSAGE"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue