-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from kevinthegreat1/debug
Update Debug Mode
- Loading branch information
Showing
7 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
package de.hysky.skyblocker.debug; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import de.hysky.skyblocker.SkyblockerMod; | ||
import de.hysky.skyblocker.utils.ItemUtils; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.minecraft.text.Text; | ||
|
||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; | ||
|
||
public class Debug { | ||
private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); | ||
|
||
public static boolean debugEnabled() { | ||
return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment(); | ||
} | ||
|
||
public static void init() { | ||
if (DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment()) { | ||
ClientCommandRegistrationCallback.EVENT.register(DumpPlayersCommand::register); | ||
if (debugEnabled()) { | ||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug") | ||
.then(dumpPlayersCommand()) | ||
.then(ItemUtils.dumpHeldItemNbtCommand()) | ||
))); | ||
} | ||
} | ||
|
||
private static LiteralArgumentBuilder<FabricClientCommandSource> dumpPlayersCommand() { | ||
return literal("dumpPlayers") | ||
.executes(context -> { | ||
context.getSource().getWorld().getPlayers().forEach(player -> context.getSource().sendFeedback(Text.of("'" + player.getName().getString() + "'"))); | ||
return Command.SINGLE_SUCCESS; | ||
}); | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.hysky.skyblocker.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import de.hysky.skyblocker.debug.Debug; | ||
import de.hysky.skyblocker.utils.Utils; | ||
import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.decoration.ArmorStandEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(EntityRenderDispatcher.class) | ||
public class EntityRenderDispatcherMixin { | ||
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isInvisible()Z", ordinal = 1)) | ||
private <E extends Entity> boolean skyblocker$armorStandHitboxVisible(boolean invisible, E entity) { | ||
return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled()) && invisible; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.hysky.skyblocker.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import de.hysky.skyblocker.debug.Debug; | ||
import de.hysky.skyblocker.utils.Utils; | ||
import net.minecraft.client.render.entity.LivingEntityRenderer; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.decoration.ArmorStandEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(LivingEntityRenderer.class) | ||
public class LivingEntityRendererMixin { | ||
@ModifyExpressionValue(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;isVisible(Lnet/minecraft/entity/LivingEntity;)Z")) | ||
private <T extends LivingEntity> boolean skyblocker$armorStandVisible(boolean visible, T entity) { | ||
return entity instanceof ArmorStandEntity && Utils.isOnHypixel() && Debug.debugEnabled() || visible; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters