Skip to content

Commit

Permalink
Update glowing_entities_mixin.java
Browse files Browse the repository at this point in the history
  • Loading branch information
I-No-oNe authored Dec 16, 2023
1 parent 815cc3c commit 0d271bb
Showing 1 changed file with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.i_no_am.glowing_entities.mixin;

import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.util.math.BlockPos;
Expand All @@ -10,33 +9,10 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(EntityRenderer.class)
public abstract class GlowingEntitiesMixin {

private static boolean glowingEnabled = true; // Default to true
private static int customLightLevel = 15; // Default light level
public abstract class glowing_entities_mixin {

@Inject(method = "getBlockLight", at = @At("RETURN"), cancellable = true)
public <T extends Entity> void getLight(T entity, BlockPos pos, CallbackInfoReturnable<Integer> cir) {
if (glowingEnabled) {
cir.setReturnValue(customLightLevel);
}
}

// Command to toggle glowing state
public static void toggleGlowing() {
glowingEnabled = !glowingEnabled;
MinecraftClient.getInstance().player.sendMessage(
glowingEnabled ? "Glowing is now enabled." : "Glowing is now disabled."
);
}

// Command to set custom light level
public static void setCustomLightLevel(String level) {
try {
customLightLevel = Integer.parseInt(level);
MinecraftClient.getInstance().player.sendMessage("Custom light level set to " + customLightLevel);
} catch (NumberFormatException e) {
MinecraftClient.getInstance().player.sendMessage("Invalid light level. Please provide a valid integer.");
}
cir.setReturnValue(15);
}
}

0 comments on commit 0d271bb

Please sign in to comment.