Refactored feature / module system #55
This commit is contained in:
+4
-5
@@ -1,16 +1,15 @@
|
||||
package org.saturnclient.impl.modules.entity;
|
||||
|
||||
import org.saturnclient.common.feature.EntityFeature;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import org.saturnclient.common.module.EntityModule;
|
||||
|
||||
|
||||
/**
|
||||
* Fabric implementation of {@link EntityModule}.
|
||||
* Fabric implementation of {@link EntityFeature}.
|
||||
*
|
||||
* Crosshair targeting is resolved via {@link MinecraftClient#crosshairTarget}.
|
||||
* Entity state for nametag rendering is supplied at render time by
|
||||
@@ -18,7 +17,7 @@ import org.saturnclient.common.module.EntityModule;
|
||||
* writes into the render state; {@link NametagsMixin} then constructs
|
||||
* a {@link RenderStateEntityState} from the already-extracted snapshot.
|
||||
*/
|
||||
public class EntityModuleFabric implements EntityModule {
|
||||
public class EntityModuleFabric implements EntityFeature {
|
||||
|
||||
private final MinecraftClient mc;
|
||||
|
||||
|
||||
+10
-6
@@ -1,9 +1,10 @@
|
||||
package org.saturnclient.impl.modules.entity;
|
||||
|
||||
import org.saturnclient.common.module.EntityModule;
|
||||
import org.saturnclient.common.feature.EntityFeature;
|
||||
|
||||
/**
|
||||
* Injected interface on {@link net.minecraft.client.render.entity.state.LivingEntityRenderState}.
|
||||
* Injected interface on
|
||||
* {@link net.minecraft.client.render.entity.state.LivingEntityRenderState}.
|
||||
*
|
||||
* Carries the entity's health snapshot and classification into the render
|
||||
* pipeline so that {@link NametagsMixin} can read them without touching
|
||||
@@ -12,9 +13,12 @@ import org.saturnclient.common.module.EntityModule;
|
||||
public interface HealthRenderState {
|
||||
|
||||
float saturn$getHealth();
|
||||
float saturn$getMaxHealth();
|
||||
void saturn$setHealth(float health, float maxHealth);
|
||||
|
||||
EntityModule.EntityType saturn$getEntityType();
|
||||
void saturn$setEntityType(EntityModule.EntityType type);
|
||||
float saturn$getMaxHealth();
|
||||
|
||||
void saturn$setHealth(float health, float maxHealth);
|
||||
|
||||
EntityFeature.EntityType saturn$getEntityType();
|
||||
|
||||
void saturn$setEntityType(EntityFeature.EntityType type);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package org.saturnclient.impl.modules.mixins.entity;
|
||||
|
||||
import org.saturnclient.feature.features.FreelookFeature;
|
||||
import org.saturnclient.impl.modules.entity.CameraOverriddenEntity;
|
||||
import org.saturnclient.mod.mods.FreelookMod;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -26,7 +26,7 @@ public abstract class CameraMixin {
|
||||
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setRotation(FF)V", ordinal = 1, shift = At.Shift.AFTER))
|
||||
public void lockRotation(BlockView focusedBlock, Entity cameraEntity, boolean isThirdPerson, boolean isFrontFacing,
|
||||
float tickDelta, CallbackInfo ci) {
|
||||
if (FreelookFeature.isFreeLooking && cameraEntity instanceof ClientPlayerEntity) {
|
||||
if (FreelookMod.isFreeLooking && cameraEntity instanceof ClientPlayerEntity) {
|
||||
CameraOverriddenEntity cameraOverriddenEntity = (CameraOverriddenEntity) cameraEntity;
|
||||
|
||||
if (firstTime && SaturnClient.client.player != null) {
|
||||
@@ -38,7 +38,7 @@ public abstract class CameraMixin {
|
||||
cameraOverriddenEntity.freelook$getCameraPitch());
|
||||
|
||||
}
|
||||
if (!FreelookFeature.isFreeLooking && cameraEntity instanceof ClientPlayerEntity) {
|
||||
if (!FreelookMod.isFreeLooking && cameraEntity instanceof ClientPlayerEntity) {
|
||||
firstTime = true;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package org.saturnclient.impl.modules.mixins.entity;
|
||||
|
||||
import org.saturnclient.feature.features.FreelookFeature;
|
||||
import org.saturnclient.impl.modules.entity.CameraOverriddenEntity;
|
||||
import org.saturnclient.mod.mods.FreelookMod;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -24,7 +24,7 @@ public class EntityMixin implements CameraOverriddenEntity {
|
||||
public void changeCameraLookDirection(double xDelta, double yDelta, CallbackInfo ci) {
|
||||
// noinspection ConstantValue// IntelliJ is incorrect here, this code block is
|
||||
// reachable
|
||||
if (FreelookFeature.isFreeLooking && (Object) this instanceof ClientPlayerEntity) {
|
||||
if (FreelookMod.isFreeLooking && (Object) this instanceof ClientPlayerEntity) {
|
||||
double pitchDelta = (yDelta * 0.15);
|
||||
double yawDelta = (xDelta * 0.15);
|
||||
|
||||
|
||||
+5
-5
@@ -7,10 +7,10 @@ import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import org.saturnclient.feature.features.NametagsFeature;
|
||||
import org.saturnclient.impl.modules.entity.EntityModuleFabric;
|
||||
import org.saturnclient.impl.modules.entity.HealthRenderState;
|
||||
import org.saturnclient.impl.modules.mixins.render.LivingEntityRenderStateMixin;
|
||||
import org.saturnclient.mod.mods.NametagsMod;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Intercepts nametag rendering and replaces the displayed text with
|
||||
* the string produced by {@link NametagsFeature#getNametagString}.
|
||||
* the string produced by {@link NametagsMod#getNametagString}.
|
||||
*
|
||||
* Key changes from the original:
|
||||
*
|
||||
@@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* which wraps the {@link HealthRenderState} already injected into
|
||||
* the render state by {@link LivingEntityRenderStateMixin}.</li>
|
||||
* <li>The feature import changes from {@code Nametags} to
|
||||
* {@link NametagsFeature}; the two static methods
|
||||
* {@link NametagsMod}; the two static methods
|
||||
* ({@code shouldReplaceName} / {@code getNametagString}) are
|
||||
* unchanged in signature.</li>
|
||||
* <li>The entity's display name is extracted from the render state's
|
||||
@@ -64,7 +64,7 @@ public abstract class NametagsMixin {
|
||||
if (saturn$rendering.get())
|
||||
return;
|
||||
|
||||
if (!NametagsFeature.shouldReplaceName())
|
||||
if (!NametagsMod.shouldReplaceName())
|
||||
return;
|
||||
|
||||
// Only living entities carry health data
|
||||
@@ -80,7 +80,7 @@ public abstract class NametagsMixin {
|
||||
customName, hrs);
|
||||
|
||||
// Ask the feature for the replacement string
|
||||
String replacement = NametagsFeature.getNametagString(entityState);
|
||||
String replacement = NametagsMod.getNametagString(entityState);
|
||||
if (replacement == null)
|
||||
return; // feature decided not to replace this entity
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.saturnclient.impl.modules.mixins.render;
|
||||
|
||||
import net.minecraft.client.render.BackgroundRenderer;
|
||||
|
||||
import org.saturnclient.feature.features.NoFogFeature;
|
||||
import org.saturnclient.mod.mods.NoFogMod;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
@@ -12,7 +12,7 @@ public class BackgroundRendererMixin {
|
||||
// fog
|
||||
@ModifyVariable(method = "applyFog", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private static float modifyFogStart(float viewDistance) {
|
||||
if (NoFogFeature.isActive()) {
|
||||
if (NoFogMod.isActive()) {
|
||||
return viewDistance * 2.0f;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -2,21 +2,21 @@ package org.saturnclient.impl.modules.mixins.render;
|
||||
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
|
||||
import org.saturnclient.feature.features.ZoomFeature;
|
||||
import org.saturnclient.mod.mods.ZoomMod;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Overrides the game's field-of-view when {@link ZoomFeature} is active.
|
||||
* Overrides the game's field-of-view when {@link ZoomMod} is active.
|
||||
*
|
||||
* The old code checked both {@code Zoom.isZooming} and
|
||||
* {@code Zoom.shouldZoom()} separately. The refactored
|
||||
* {@link ZoomFeature#shouldZoom()} already ORs both conditions
|
||||
* {@link ZoomMod#shouldZoom()} already ORs both conditions
|
||||
* ({@code enabled.value && isZooming}), so only one check is needed.
|
||||
*
|
||||
* No {@link org.saturnclient.common.module.ModuleProvider} is required
|
||||
* No {@link org.saturnclient.common.module.ModProvider} is required
|
||||
* here because zooming is a pure render-time override with no per-tick
|
||||
* engine queries.
|
||||
*/
|
||||
@@ -29,8 +29,8 @@ public class GameRendererMixin {
|
||||
*/
|
||||
@Inject(method = "getFov", at = @At("RETURN"), cancellable = true)
|
||||
private void onGetFov(CallbackInfoReturnable<Float> cir) {
|
||||
if (ZoomFeature.shouldZoom()) {
|
||||
float zoomedFov = cir.getReturnValue() / ZoomFeature.getZoomLevel();
|
||||
if (ZoomMod.shouldZoom()) {
|
||||
float zoomedFov = cir.getReturnValue() / ZoomMod.getZoomLevel();
|
||||
cir.setReturnValue(zoomedFov);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -5,17 +5,17 @@ package org.saturnclient.impl.modules.mixins.render;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
|
||||
import org.saturnclient.feature.features.FullbrightFeature;
|
||||
import org.saturnclient.mod.mods.FullbrightMod;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
/**
|
||||
* Overrides the lightmap's gamma computation when
|
||||
* {@link FullbrightFeature} is active, replacing the vanilla
|
||||
* {@link FullbrightMod} is active, replacing the vanilla
|
||||
* brightness with a user-configured value.
|
||||
*
|
||||
* The old import was {@code org.saturnclient.feature.features.Fullbright};
|
||||
* it is now {@link FullbrightFeature}. The injection target and
|
||||
* it is now {@link FullbrightMod}. The injection target and
|
||||
* strategy are unchanged.
|
||||
*/
|
||||
@Mixin(LightmapTextureManager.class)
|
||||
@@ -27,8 +27,8 @@ public class LightmapTextureManagerMixin {
|
||||
*/
|
||||
@ModifyExpressionValue(method = "update", at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(FF)F", ordinal = 0))
|
||||
private float modifyGamma(float original) {
|
||||
if (FullbrightFeature.shouldOverrideBrightness()) {
|
||||
return FullbrightFeature.getBrightnessValue();
|
||||
if (FullbrightMod.shouldOverrideBrightness()) {
|
||||
return FullbrightMod.getBrightnessValue();
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
+5
-5
@@ -2,7 +2,7 @@ package org.saturnclient.impl.modules.mixins.render;
|
||||
|
||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
|
||||
import org.saturnclient.common.module.EntityModule;
|
||||
import org.saturnclient.common.feature.EntityFeature;
|
||||
import org.saturnclient.impl.modules.entity.HealthRenderState;
|
||||
import org.saturnclient.impl.modules.mixins.misc.NametagsMixin;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
* storage into every living entity's render-state snapshot.
|
||||
*
|
||||
* Previously imported {@code NametagsInterface.EntityType}; the enum
|
||||
* now lives in {@link EntityModule.EntityType} which is the single
|
||||
* now lives in {@link EntityFeature.EntityType} which is the single
|
||||
* canonical definition shared by the mixin layer and the feature layer.
|
||||
*
|
||||
* The stored values are written by
|
||||
@@ -30,7 +30,7 @@ public class LivingEntityRenderStateMixin implements HealthRenderState {
|
||||
@Unique
|
||||
private float saturn$maxHealth = 1f;
|
||||
@Unique
|
||||
private EntityModule.EntityType saturn$entityType = EntityModule.EntityType.OTHER;
|
||||
private EntityFeature.EntityType saturn$entityType = EntityFeature.EntityType.OTHER;
|
||||
|
||||
@Override
|
||||
public float saturn$getHealth() {
|
||||
@@ -49,12 +49,12 @@ public class LivingEntityRenderStateMixin implements HealthRenderState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityModule.EntityType saturn$getEntityType() {
|
||||
public EntityFeature.EntityType saturn$getEntityType() {
|
||||
return saturn$entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saturn$setEntityType(EntityModule.EntityType type) {
|
||||
public void saturn$setEntityType(EntityFeature.EntityType type) {
|
||||
saturn$entityType = type;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -7,7 +7,7 @@ import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.entity.passive.PassiveEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import org.saturnclient.common.module.EntityModule;
|
||||
import org.saturnclient.common.feature.EntityFeature;
|
||||
import org.saturnclient.impl.modules.entity.HealthRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* them without touching the live entity again.
|
||||
*
|
||||
* Previously imported {@code NametagsInterface.EntityType}; now uses
|
||||
* {@link EntityModule.EntityType} — the canonical enum shared across
|
||||
* {@link EntityFeature.EntityType} — the canonical enum shared across
|
||||
* the whole module system.
|
||||
*
|
||||
* The injection target and strategy are unchanged from the original.
|
||||
@@ -36,15 +36,15 @@ public abstract class LivingEntityRendererMixin<T extends LivingEntity, S extend
|
||||
hrs.saturn$setHealth(entity.getHealth(), entity.getMaxHealth());
|
||||
|
||||
// Classify entity type for the nametag feature's filtering logic
|
||||
EntityModule.EntityType type;
|
||||
EntityFeature.EntityType type;
|
||||
if (entity instanceof PlayerEntity)
|
||||
type = EntityModule.EntityType.PLAYER;
|
||||
type = EntityFeature.EntityType.PLAYER;
|
||||
else if (entity instanceof HostileEntity)
|
||||
type = EntityModule.EntityType.HOSTILE;
|
||||
type = EntityFeature.EntityType.HOSTILE;
|
||||
else if (entity instanceof PassiveEntity)
|
||||
type = EntityModule.EntityType.PASSIVE;
|
||||
type = EntityFeature.EntityType.PASSIVE;
|
||||
else
|
||||
type = EntityModule.EntityType.OTHER;
|
||||
type = EntityFeature.EntityType.OTHER;
|
||||
|
||||
hrs.saturn$setEntityType(type);
|
||||
}
|
||||
|
||||
+10
-10
@@ -5,12 +5,12 @@ import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
||||
import org.saturnclient.feature.Feature;
|
||||
import org.saturnclient.feature.FeatureLayout;
|
||||
import org.saturnclient.feature.FeatureManager;
|
||||
import org.saturnclient.feature.HudFeature;
|
||||
import org.saturnclient.impl.ui.RenderScopeImpl;
|
||||
import org.saturnclient.impl.ui.SaturnScreenFabric;
|
||||
import org.saturnclient.mod.HudMod;
|
||||
import org.saturnclient.mod.Mod;
|
||||
import org.saturnclient.mod.ModLayout;
|
||||
import org.saturnclient.mod.ModManager;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.mixin.DrawContextAccessor;
|
||||
import org.saturnclient.ui.RenderScope;
|
||||
@@ -24,9 +24,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* Drives per-frame rendering for all registered features.
|
||||
*
|
||||
* This mixin is intentionally kept thin: it creates a {@link RenderScope},
|
||||
* iterates the enabled feature list from {@link FeatureManager}, and
|
||||
* dispatches either {@link HudFeature#renderHud} (for HUD elements) or
|
||||
* {@link Feature#render} (for world-overlay features like Crosshair).
|
||||
* iterates the enabled feature list from {@link ModManager}, and
|
||||
* dispatches either {@link HudMod#renderHud} (for HUD elements) or
|
||||
* {@link Mod#render} (for world-overlay features like Crosshair).
|
||||
*
|
||||
* No feature-specific logic lives here — all decisions about what to
|
||||
* draw are made inside each feature class.
|
||||
@@ -57,12 +57,12 @@ public class RenderMixin {
|
||||
context.getMatrices(),
|
||||
((DrawContextAccessor) context).getVertexConsumers());
|
||||
|
||||
for (Feature feature : FeatureManager.ENABLED_MODS) {
|
||||
for (Mod feature : ModManager.ENABLED_MODS) {
|
||||
if (!feature.isEnabled())
|
||||
continue;
|
||||
|
||||
if (feature instanceof HudFeature hud) {
|
||||
FeatureLayout dim = hud.getDimensions();
|
||||
if (feature instanceof HudMod hud) {
|
||||
ModLayout dim = hud.getDimensions();
|
||||
|
||||
scope.getMatrixStack().push();
|
||||
scope.getMatrixStack().translate(dim.x.value, (float) dim.y.value, 0f);
|
||||
|
||||
+6
-6
@@ -3,28 +3,28 @@ package org.saturnclient.impl.modules.mixins.world;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket;
|
||||
|
||||
import org.saturnclient.feature.features.TpsFeature;
|
||||
import org.saturnclient.mod.mods.TpsMod;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Feeds world-time packets into {@link TpsFeature}'s TPS estimator.
|
||||
* Feeds world-time packets into {@link TpsMod}'s TPS estimator.
|
||||
*
|
||||
* This is the only place in the entire codebase that reads a network
|
||||
* packet and passes data to a feature. The feature's
|
||||
* {@link TpsFeature#onTimePacket(long)} method handles all averaging
|
||||
* packet and passes data to a feature. The feature's
|
||||
* {@link TpsMod#onTimePacket(long)} method handles all averaging
|
||||
* logic; the mixin is intentionally reduced to a single forwarding call.
|
||||
*
|
||||
* The only change from the original is renaming the import from
|
||||
* {@code feature.features.Tps} to {@link TpsFeature}.
|
||||
* {@code feature.features.Tps} to {@link TpsMod}.
|
||||
*/
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public class TpsMixin {
|
||||
|
||||
@Inject(method = "onWorldTimeUpdate", at = @At("HEAD"))
|
||||
private void onWorldTimeUpdate(WorldTimeUpdateS2CPacket packet, CallbackInfo ci) {
|
||||
TpsFeature.onTimePacket(packet.time());
|
||||
TpsMod.onTimePacket(packet.time());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,18 +1,18 @@
|
||||
package org.saturnclient.impl.modules.network;
|
||||
|
||||
import org.saturnclient.common.feature.NetworkFeature;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
|
||||
import org.saturnclient.common.module.NetworkModule;
|
||||
|
||||
/**
|
||||
* Fabric implementation of {@link NetworkModule}.
|
||||
* Fabric implementation of {@link NetworkFeature}.
|
||||
*
|
||||
* Connection presence is checked via the network handler.
|
||||
* Ping is read from the player's {@link PlayerListEntry} which the
|
||||
* server populates; returns {@code -1} when unavailable.
|
||||
*/
|
||||
public class NetworkModuleFabric implements NetworkModule {
|
||||
public class NetworkModuleFabric implements NetworkFeature {
|
||||
|
||||
private final MinecraftClient mc;
|
||||
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
|
||||
import org.saturnclient.common.module.PlayerModule;
|
||||
import org.saturnclient.common.feature.PlayerFeature;
|
||||
import org.saturnclient.common.ref.game.EffectRef;
|
||||
import org.saturnclient.common.ref.game.ItemStackRef;
|
||||
|
||||
@@ -18,16 +18,16 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Fabric implementation of {@link PlayerModule}.
|
||||
* Fabric implementation of {@link PlayerFeature}.
|
||||
*
|
||||
* All access to {@link MinecraftClient} and {@link ClientPlayerEntity}
|
||||
* is encapsulated here. Features only ever see the {@link PlayerModule}
|
||||
* is encapsulated here. Features only ever see the {@link PlayerFeature}
|
||||
* interface; they never import Minecraft classes directly.
|
||||
*
|
||||
* Every method guards against a missing player and returns a safe
|
||||
* default so features are free of null checks.
|
||||
*/
|
||||
public class PlayerModuleFabric implements PlayerModule {
|
||||
public class PlayerModuleFabric implements PlayerFeature {
|
||||
|
||||
private final MinecraftClient mc;
|
||||
|
||||
|
||||
+5
-5
@@ -1,18 +1,18 @@
|
||||
package org.saturnclient.impl.modules.render;
|
||||
|
||||
import org.saturnclient.common.feature.RenderFeature;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.option.Perspective;
|
||||
|
||||
import org.saturnclient.common.module.RenderModule;
|
||||
|
||||
/**
|
||||
* Fabric implementation of {@link RenderModule}.
|
||||
* Fabric implementation of {@link RenderFeature}.
|
||||
*
|
||||
* Window dimensions and FPS are read directly from
|
||||
* {@link MinecraftClient}. Camera perspective control delegates to
|
||||
* {@link MinecraftClient}. Camera perspective control delegates to
|
||||
* {@link net.minecraft.client.option.GameOptions}.
|
||||
*/
|
||||
public class RenderModuleFabric implements RenderModule {
|
||||
public class RenderModuleFabric implements RenderFeature {
|
||||
|
||||
private final MinecraftClient mc;
|
||||
|
||||
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
package org.saturnclient.impl.modules.world;
|
||||
|
||||
import org.saturnclient.common.feature.WorldFeature;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
import org.saturnclient.common.module.WorldModule;
|
||||
|
||||
/**
|
||||
* Fabric implementation of {@link WorldModule}.
|
||||
* Fabric implementation of {@link WorldFeature}.
|
||||
*
|
||||
* Reads the client world's time directly from {@link MinecraftClient}.
|
||||
* Returns safe defaults when no world is loaded.
|
||||
*/
|
||||
public class WorldModuleFabric implements WorldModule {
|
||||
public class WorldModuleFabric implements WorldFeature {
|
||||
|
||||
private final MinecraftClient mc;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class WorldModuleFabric implements WorldModule {
|
||||
|
||||
/**
|
||||
* Returns the total world age in ticks, or {@code 0} when no world
|
||||
* is loaded. Used by {@link TpsFeature#onTimePacket} (which is
|
||||
* is loaded. Used by {@link TpsFeature#onTimePacket} (which is
|
||||
* called from the mixin and stores its own copy) and by
|
||||
* {@link DayCounterFeature} for the day count.
|
||||
*/
|
||||
|
||||
+14
-14
@@ -2,16 +2,16 @@ package org.saturnclient.impl.provider;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
import org.saturnclient.common.provider.ModuleProvider;
|
||||
import org.saturnclient.common.feature.*;
|
||||
import org.saturnclient.common.provider.FeatureProvider;
|
||||
import org.saturnclient.impl.modules.entity.EntityModuleFabric;
|
||||
import org.saturnclient.impl.modules.network.NetworkModuleFabric;
|
||||
import org.saturnclient.impl.modules.player.PlayerModuleFabric;
|
||||
import org.saturnclient.impl.modules.render.RenderModuleFabric;
|
||||
import org.saturnclient.impl.modules.world.WorldModuleFabric;
|
||||
import org.saturnclient.common.module.*;
|
||||
|
||||
/**
|
||||
* Fabric implementation of {@link ModuleProvider}.
|
||||
* Fabric implementation of {@link FeatureProvider}.
|
||||
*
|
||||
* Instantiated once during client startup (e.g. in the mod initialiser)
|
||||
* and passed to every feature constructor. All five sub-modules share
|
||||
@@ -25,13 +25,13 @@ import org.saturnclient.common.module.*;
|
||||
* // …
|
||||
* }</pre>
|
||||
*/
|
||||
public class ModuleProviderFabric implements ModuleProvider {
|
||||
public class ModuleProviderFabric implements FeatureProvider {
|
||||
|
||||
private final PlayerModule player;
|
||||
private final WorldModule world;
|
||||
private final EntityModule entity;
|
||||
private final RenderModule render;
|
||||
private final NetworkModule network;
|
||||
private final PlayerFeature player;
|
||||
private final WorldFeature world;
|
||||
private final EntityFeature entity;
|
||||
private final RenderFeature render;
|
||||
private final NetworkFeature network;
|
||||
|
||||
public ModuleProviderFabric(MinecraftClient mc) {
|
||||
this.player = new PlayerModuleFabric(mc);
|
||||
@@ -42,27 +42,27 @@ public class ModuleProviderFabric implements ModuleProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerModule player() {
|
||||
public PlayerFeature player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldModule world() {
|
||||
public WorldFeature world() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityModule entity() {
|
||||
public EntityFeature entity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderModule render() {
|
||||
public RenderFeature render() {
|
||||
return render;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkModule network() {
|
||||
public NetworkFeature network() {
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.client.MinecraftClient;
|
||||
import org.saturnclient.client.ServiceClient;
|
||||
import org.saturnclient.cosmetics.Emotes;
|
||||
import org.saturnclient.cosmetics.Hats;
|
||||
import org.saturnclient.feature.FeatureManager;
|
||||
import org.saturnclient.cosmetics.Cloaks;
|
||||
import org.saturnclient.common.provider.Providers;
|
||||
import org.saturnclient.impl.provider.GLFWProviderImpl;
|
||||
@@ -17,6 +16,7 @@ import org.saturnclient.impl.provider.RefConstructorImpl;
|
||||
import org.saturnclient.impl.provider.SaturnProviderImpl;
|
||||
import org.saturnclient.impl.ui.EntityDrawerImpl;
|
||||
import org.saturnclient.impl.ui.SaturnScreenFabric;
|
||||
import org.saturnclient.mod.ModManager;
|
||||
import org.saturnclient.saturnclient.event.KeyInputHandler;
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.config.ConfigManager;
|
||||
@@ -45,7 +45,7 @@ public class SaturnClient implements ModInitializer {
|
||||
SkinPreview.DRAWER = new EntityDrawerImpl();
|
||||
|
||||
Config.init();
|
||||
FeatureManager.init();
|
||||
ModManager.init();
|
||||
|
||||
client.execute(() -> {
|
||||
SaturnScreenFabric.preload(client);
|
||||
@@ -54,7 +54,7 @@ public class SaturnClient implements ModInitializer {
|
||||
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> ConfigManager.save());
|
||||
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
for (org.saturnclient.feature.Feature m : FeatureManager.ENABLED_MODS) {
|
||||
for (org.saturnclient.mod.Mod m : ModManager.ENABLED_MODS) {
|
||||
m.tick();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user