Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some bug and add new Feature. #103

Open
wants to merge 3 commits into
base: forge-1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,26 @@ mixin {
config 'atianxray.mixins.json'
}

repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}

// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// flatDir {
// dir 'libs'
// }
}

dependencies {
minecraft 'net.minecraftforge:forge:1.20-46.0.13'
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
compileOnly fg.deobf("curse.maven:rubidium-574856:4952685")
}

// Example for how to get properties into the manifest for reading by the runtime..
Expand Down
50 changes: 29 additions & 21 deletions src/main/java/fr/atesab/xray/XrayMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,21 @@
import java.util.stream.Collector;
import java.util.stream.Collectors;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;

import net.minecraft.client.OptionInstance;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.client.event.*;
import net.minecraftforge.eventbus.api.IEventBus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joml.Vector3f;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;

import fr.atesab.xray.color.ColorSupplier;
import fr.atesab.xray.color.IColorObject;
import fr.atesab.xray.color.TextHudBuffer;
Expand All @@ -51,23 +41,39 @@
import net.minecraft.client.Camera;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.client.event.RenderLevelStageEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
Expand Down Expand Up @@ -454,7 +460,8 @@ public void onRenderWorld(RenderLevelStageEvent ev) {
blockPos.getX() + 1, blockPos.getY() + 1, blockPos.getZ() + 1
);

LevelRenderer.renderLineBox(stack, buffer, aabb, r, g, b, a);
RenderUtils.renderLineBoxVanillaStyle(stack, buffer, aabb, r, g, b, a);
//LevelRenderer.renderLineBox(stack, buffer, aabb, r, g, b, a);

if (esp.hasTracer()) {
Vec3 center = aabb.getCenter();
Expand Down Expand Up @@ -500,7 +507,8 @@ public void onRenderWorld(RenderLevelStageEvent ev) {

AABB aabb = type.getAABB(x, y, z);

LevelRenderer.renderLineBox(stack, buffer, aabb, r, g, b, a);
RenderUtils.renderLineBoxVanillaStyle(stack, buffer, aabb, r, g, b, a);
//LevelRenderer.renderLineBox(stack, buffer, aabb, r, g, b, a);

if (esp.hasTracer()) {
Vec3 center = aabb.getCenter();
Expand Down
69 changes: 67 additions & 2 deletions src/main/java/fr/atesab/xray/config/LocationFormatTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;
Expand All @@ -52,6 +52,8 @@ public class LocationFormatTool implements EnumElement {
public static long currentHours;
public static long currentMinutes;
public static long currentSeconds;
public static int currentNutrition;
public static float currentSaturation;

public static final ToolFunction EMPTY_FUNCTION = (mc, player, world) -> "";
public static final LocationFormatTool PLAYER_LOCATION_X = register("x13.mod.location.opt.x", Items.BOOK, "x",
Expand Down Expand Up @@ -104,7 +106,59 @@ public class LocationFormatTool implements EnumElement {
(mc, player, world) -> LocationUtils.getTwoDigitNumberFormat().format(currentSeconds));
public static final LocationFormatTool IS_SLIME = register("x13.mod.location.opt.isSlime", Items.SLIME_BALL, "slime",
(mc, player, world) -> String.valueOf(LocationUtils.isSlimeChunk(mc, player.chunkPosition())));
public static final LocationFormatTool NEW_LINE = register("x13.mod.location.opt.lineFeed",Items.WRITABLE_BOOK, "lf",
public static final LocationFormatTool NUTRITION = register("x13.mod.location.opt.nutrition", Items.BEEF, "nutrition",
(mc, player, world) -> String.valueOf(currentNutrition));
public static final LocationFormatTool SATURATION = register("x13.mod.location.opt.saturation", Items.COOKED_BEEF, "saturation",
(mc, player, world) -> String.format("%.1f",currentSaturation));
public static final LocationFormatTool MAINHAND_NAME = register("x13.mod.location.opt.mainhandName", Items.DIAMOND_SWORD, "mainhandName",
(mc, player, world) -> ForgeRegistries.ITEMS.getKey(player.getMainHandItem().getItem()).getPath());
public static final LocationFormatTool MAINHAND_NAME_TRANSLATE = register("x13.mod.location.opt.mainhandTranslate", Items.DIAMOND_SWORD, "mainhandTranslate",
(mc, player, world) -> I18n.get(player.getMainHandItem().getDescriptionId()).toString());
public static final LocationFormatTool MAINHAND_DURABILITY = register("x13.mod.location.opt.mainhandDurability", Items.DIAMOND_SWORD, "mainhandDurability",
(mc, player, world) -> LocationUtils.getDurabilityOrFoodData(player.getMainHandItem()));
public static final LocationFormatTool MAINHAND_MAXDURABILITY = register("x13.mod.location.opt.mainhandMaxDurability", Items.DIAMOND_SWORD, "mainhandMaxDurability",
(mc, player, world) -> LocationUtils.getMaxDurabilityOrAfterFoodData(player.getMainHandItem(),currentNutrition,currentSaturation));
public static final LocationFormatTool OFFHAND_NAME = register("x13.mod.location.opt.offhandName", Items.SHIELD, "offhandName",
(mc, player, world) -> ForgeRegistries.ITEMS.getKey(player.getOffhandItem().getItem()).getPath());
public static final LocationFormatTool OFFHAND_NAME_TRANSLATE = register("x13.mod.location.opt.offhandTranslate", Items.SHIELD, "offhandTranslate",
(mc, player, world) -> I18n.get(player.getOffhandItem().getDescriptionId()).toString());
public static final LocationFormatTool OFFHAND_DURABILITY = register("x13.mod.location.opt.offhandDurability", Items.SHIELD, "offhandDurability",
(mc, player, world) -> LocationUtils.getDurabilityOrFoodData(player.getOffhandItem()));
public static final LocationFormatTool OFFHAND_MAXDURABILITY = register("x13.mod.location.opt.mainhandMaxDurability", Items.SHIELD, "offhandMaxDurability",
(mc, player, world) -> LocationUtils.getMaxDurabilityOrAfterFoodData(player.getOffhandItem(),currentNutrition,currentSaturation));
public static final LocationFormatTool HELMET_NAME = register("x13.mod.location.opt.helmetName", Items.DIAMOND_HELMET, "helmetName",
(mc, player, world) -> ForgeRegistries.ITEMS.getKey(player.getItemBySlot(EquipmentSlot.HEAD).getItem()).getPath());
public static final LocationFormatTool HELMET_NAME_TRANSLATE = register("x13.mod.location.opt.helmetTranslate", Items.DIAMOND_HELMET, "helmetTranslate",
(mc, player, world) -> I18n.get(player.getItemBySlot(EquipmentSlot.HEAD).getDescriptionId()).toString());
public static final LocationFormatTool HELMET_DURABILITY = register("x13.mod.location.opt.helmetDurability", Items.DIAMOND_HELMET, "helmetDurability",
(mc, player, world) -> String.valueOf(LocationUtils.getRemainDurability(player.getItemBySlot(EquipmentSlot.HEAD))));
public static final LocationFormatTool HELMET_MAXDURABILITY = register("x13.mod.location.opt.helmetMaxDurability", Items.DIAMOND_HELMET, "helmetMaxDurability",
(mc, player, world) -> String.valueOf(player.getItemBySlot(EquipmentSlot.HEAD).getMaxDamage()));
public static final LocationFormatTool CHESTPLATE_NAME = register("x13.mod.location.opt.chestplateName", Items.DIAMOND_CHESTPLATE, "chestplateName",
(mc, player, world) -> ForgeRegistries.ITEMS.getKey(player.getItemBySlot(EquipmentSlot.CHEST).getItem()).getPath());
public static final LocationFormatTool CHESTPLATE_NAME_TRANSLATE = register("x13.mod.location.opt.chestplateTranslate", Items.DIAMOND_CHESTPLATE, "chestplateTranslate",
(mc, player, world) -> I18n.get(player.getItemBySlot(EquipmentSlot.CHEST).getDescriptionId()).toString());
public static final LocationFormatTool CHESTPLATE_DURABILITY = register("x13.mod.location.opt.chestplateDurability", Items.DIAMOND_CHESTPLATE, "chestplateDurability",
(mc, player, world) -> String.valueOf(LocationUtils.getRemainDurability(player.getItemBySlot(EquipmentSlot.CHEST))));
public static final LocationFormatTool CHESTPLATE_MAXDURABILITY = register("x13.mod.location.opt.chestplateMaxDurability", Items.DIAMOND_CHESTPLATE, "chestplateMaxDurability",
(mc, player, world) -> String.valueOf(player.getItemBySlot(EquipmentSlot.CHEST).getMaxDamage()));
public static final LocationFormatTool LEGGINGS_NAME = register("x13.mod.location.opt.leggingsName", Items.DIAMOND_LEGGINGS, "leggingsName",
(mc, player, world) -> ForgeRegistries.ITEMS.getKey(player.getItemBySlot(EquipmentSlot.LEGS).getItem()).getPath());
public static final LocationFormatTool LEGGINGS_NAME_TRANSLATE = register("x13.mod.location.opt.leggingsTranslate", Items.DIAMOND_LEGGINGS, "leggingsTranslate",
(mc, player, world) -> I18n.get(player.getItemBySlot(EquipmentSlot.LEGS).getDescriptionId()).toString());
public static final LocationFormatTool LEGGINGS_DURABILITY = register("x13.mod.location.opt.leggingsDurability", Items.DIAMOND_LEGGINGS, "leggingsDurability",
(mc, player, world) -> String.valueOf(LocationUtils.getRemainDurability(player.getItemBySlot(EquipmentSlot.LEGS))));
public static final LocationFormatTool LEGGINGS_MAXDURABILITY = register("x13.mod.location.opt.leggingsMaxDurability", Items.DIAMOND_LEGGINGS, "leggingsMaxDurability",
(mc, player, world) -> String.valueOf(player.getItemBySlot(EquipmentSlot.LEGS).getMaxDamage()));
public static final LocationFormatTool BOOTS_NAME = register("x13.mod.location.opt.bootsName", Items.DIAMOND_BOOTS, "bootsName",
(mc, player, world) -> ForgeRegistries.ITEMS.getKey(player.getItemBySlot(EquipmentSlot.FEET).getItem()).getPath());
public static final LocationFormatTool BOOTS_NAME_TRANSLATE = register("x13.mod.location.opt.bootsTranslate", Items.DIAMOND_BOOTS, "bootsTranslate",
(mc, player, world) -> I18n.get(player.getItemBySlot(EquipmentSlot.FEET).getDescriptionId()).toString());
public static final LocationFormatTool BOOTS_DURABILITY = register("x13.mod.location.opt.bootsDurability", Items.DIAMOND_BOOTS, "bootsDurability",
(mc, player, world) -> String.valueOf(LocationUtils.getRemainDurability(player.getItemBySlot(EquipmentSlot.FEET))));
public static final LocationFormatTool BOOTS_MAXDURABILITY = register("x13.mod.location.opt.bootsMaxDurability", Items.DIAMOND_BOOTS, "bootsMaxDurability",
(mc, player, world) -> String.valueOf(player.getItemBySlot(EquipmentSlot.FEET).getMaxDamage()));
public static final LocationFormatTool NEW_LINE = register("x13.mod.location.opt.lineFeed",Items.WRITABLE_BOOK, "lf",
(mc, player, world) -> "\n");
public static final LocationFormatTool ALL = register("debug",Items.WRITABLE_BOOK, "debug",
(mc, player, world) -> "DEBUG\n" + TOOLS.entrySet().stream()
Expand Down Expand Up @@ -393,6 +447,8 @@ public ListToolFunction() {
public String apply(Minecraft client, LocalPlayer player, ClientLevel world) {
StringBuilder bld = new StringBuilder();
updateTimeField(client, player, world);
updateFoodDataField(client, player, world);
updateHandDataField(client, player, world);

for (ToolFunction func : functions) {
bld.append(func.apply(client, player, world));
Expand Down Expand Up @@ -430,4 +486,13 @@ private static void updateTimeField(Minecraft client, LocalPlayer player, Client
long fixedSeconds = Math.floorMod(fixedMinutes * 60, 1000);
currentSeconds = Math.floorDiv(fixedSeconds * 60, 1000);
}

private static void updateFoodDataField(Minecraft client, LocalPlayer player, ClientLevel world) {
currentNutrition = player.getFoodData().getFoodLevel();
currentSaturation = player.getFoodData().getSaturationLevel();
}

private static void updateHandDataField(Minecraft client, LocalPlayer player, ClientLevel world) {

}
}
31 changes: 31 additions & 0 deletions src/main/java/fr/atesab/xray/mixins/MixinBlock_rubidium.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fr.atesab.xray.mixins;

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.CallbackInfoReturnable;

import fr.atesab.xray.XrayMain;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockOcclusionCache;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;

@Mixin(value = BlockOcclusionCache.class)
public class MixinBlock_rubidium {
@Inject(at = @At("RETURN"), method = "shouldDrawSide(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z",cancellable = true,remap=false)
public void shouldDrawSideMixin(BlockState selfState, BlockGetter view, BlockPos pos, Direction facing, CallbackInfoReturnable<Boolean> ci) {
XrayMain.getMod().shouldSideBeRendered(selfState, view, pos, facing, ci);
}

@Redirect(at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockOcclusionCache;calculate(Lnet/minecraft/world/phys/shapes/VoxelShape;Lnet/minecraft/world/phys/shapes/VoxelShape;)Z"), method = "shouldDrawSide(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z",remap=false)
private boolean ignoreCache(BlockOcclusionCache cache, VoxelShape selfShape, VoxelShape adjShape) {
return true;
}

private MixinBlock_rubidium() {
}
}
5 changes: 1 addition & 4 deletions src/main/java/fr/atesab/xray/screen/BlockSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import java.util.ArrayList;
import java.util.List;

import com.mojang.blaze3d.vertex.PoseStack;

import fr.atesab.xray.utils.GuiUtils;
import fr.atesab.xray.widget.XrayButton;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -116,7 +113,7 @@ public void updateSearch() {
visible.clear();
blocks.stream().filter(block -> I18n.get(block.getDescriptionId()).toLowerCase().contains(query))
.forEach(visible::add);
page = Math.min(visible.size(), page);
page = Math.min(visible.size() / elementByPage, page);
updateArrows();
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/fr/atesab/xray/screen/XrayBlockMenu.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package fr.atesab.xray.screen;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import fr.atesab.xray.config.BlockConfig;
import fr.atesab.xray.utils.GuiUtils;
import fr.atesab.xray.widget.XrayButton;
Expand All @@ -12,10 +16,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class XrayBlockMenu extends XrayScreen {
private static final Component ADD = Component.literal("+").withStyle(ChatFormatting.GREEN);
private static final Component REPLACE = Component.translatable("x13.mod.menu.replace")
Expand Down Expand Up @@ -130,7 +130,7 @@ public void updateSearch() {
visible.clear();
config.stream().filter(block -> I18n.get(block.getDescriptionId()).toLowerCase().contains(query))
.forEach(visible::add);
page = Math.min(visible.size(), page);
page = Math.min(visible.size() / elementByPage, page);
updateArrows();
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/fr/atesab/xray/screen/XrayEntityMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;
import java.util.Objects;

import com.mojang.blaze3d.vertex.PoseStack;
import fr.atesab.xray.color.BlockEntityTypeIcon;
import fr.atesab.xray.color.EntityTypeIcon;
import fr.atesab.xray.color.EnumElement;
Expand Down Expand Up @@ -174,7 +173,7 @@ public void updateSearch() {
visible.clear();
config.stream().filter(block -> I18n.get(block.text()).toLowerCase().contains(query))
.forEach(visible::add);
page = Math.min(visible.size(), page);
page = Math.min(visible.size() / elementByPage, page);
updateArrows();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void init() {
}));

format = new EditBox(font, width / 2 - 98, height / 2 + 2, 196, 16, Component.literal(""));
format.setMaxLength(256);
format.setMaxLength(1024);
format.setValue(mod.getConfig().getLocationConfig().getFormat());
format.setResponder(mod.getConfig().getLocationConfig()::setFormat);
format.setFocused(true);
Expand Down
Loading
Loading