Skip to content
Merged
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
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ loom {
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

include implementation("dev.xpple:clientarguments:${project.clientarguments_version}")
implementation "fi.dy.masa.malilib:malilib-fabric-26.2:${project.malilib_version}"
implementation "fi.dy.masa.malilib:malilib-fabric-26.3:${project.malilib_version}"
}

processResources {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ org.gradle.configuration-cache=false

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=26.2
loader_version=0.19.3
minecraft_version=26.3
loader_version=0.19.5
loom_version=1.17-SNAPSHOT

# Mod Properties
mod_version=6.0.7
maven_group=ru.obabok

# Dependencies
fabric_api_version=0.155.0+26.2
clientarguments_version=1.13.1
malilib_version = 0.29.3
fabric_api_version=0.161.0+26.3
clientarguments_version=1.14.0
malilib_version = 0.30.1
10 changes: 9 additions & 1 deletion src/client/java/ru/obabok/client/AreaScannerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@ public void onInitializeClient() {
});

HudElementRegistry.addLast(Identifier.fromNamespaceAndPath(References.MOD_ID, "hud"), HudRender::render);
LevelRenderEvents.AFTER_TRANSLUCENT_TERRAIN.register(RenderUtil::render);
LevelRenderEvents.END_MAIN.register(RenderUtil::render);
ChunkScheduler.startProcessing();
ClientLifecycleEvents.CLIENT_STOPPING.register(ChunkScheduler::stopProcessing);
}
}
//need to be here because this class no load malilib classes
public static boolean shouldUpdateRealtime() {
if (AreaScannerClient.isMaliLibLoaded) {
//config class not load if isMaliLibLoaded = false and no crash occurred
return Config.Generic.REALTIME_UPDATE.getBooleanValue();
}
return false;
}
}
2 changes: 2 additions & 0 deletions src/client/java/ru/obabok/client/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static class Generic
public static final ConfigInteger LOD2 = new ConfigInteger("LOD2", 50).apply(GENERIC_KEY);
public static final ConfigInteger LOD2_HORIZON = new ConfigInteger("LOD2_horizon", 100).apply(GENERIC_KEY);
public static final ConfigBoolean LOD2_HUD = new ConfigBoolean("LOD2_hud", true).apply(GENERIC_KEY);
public static final ConfigFloat LOD2_HUD_TRANSPARENCY = new ConfigFloat("LOD2_hud_transparency", 1.0f, 0.0f, 1.0f).apply(GENERIC_KEY);
public static final ConfigBoolean GROUP_RENDER = new ConfigBoolean("group_render", false).apply(GENERIC_KEY);

public static final ConfigInteger PROCESS_COOLDOWN = new ConfigInteger("processCooldown", 10, 1, 100).apply(GENERIC_KEY);
Expand Down Expand Up @@ -72,6 +73,7 @@ public static class Generic
LOD2,
LOD2_HORIZON,
LOD2_HUD,
LOD2_HUD_TRANSPARENCY,
GROUP_RENDER,

SPLITTER,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package ru.obabok.client.gui.screens;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.StringWidget;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;

public class NoMalilibScreen extends Screen {

public NoMalilibScreen() {
public static boolean showed = false;
private final Screen parent;
public NoMalilibScreen(Screen parent) {
super(Component.literal("No Malilib"));
this.parent = parent;
}

@Override
protected void init() {
super.init();
showed = true;
Component noMalilibText = Component.literal("Malilib mod not found, unable to load AreaScanner");
addRenderableWidget(new StringWidget(width / 2 - font.width(noMalilibText) / 2, height / 2, font.width(noMalilibText), 20, noMalilibText, font));
addRenderableWidget(Button.builder(Component.literal("Exit"), btn -> System.exit(0)).bounds(width / 2 - 40, height / 2 + 40, 80, 20).build());
addRenderableWidget(Button.builder(Component.literal("Exit"), btn -> System.exit(0)).bounds(width / 2 - 90, height / 2 + 40, 80, 20).build());
addRenderableWidget(Button.builder(Component.literal("Continue"), btn -> Minecraft.getInstance().setScreenAndShow(parent)).bounds(width / 2 + 10, height / 2 + 40, 80, 20).build());
}
}
19 changes: 12 additions & 7 deletions src/client/java/ru/obabok/client/gui/screens/ScanTaskScreen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.obabok.client.gui.screens;

import com.mojang.blaze3d.platform.InputConstants;
import fi.dy.masa.malilib.util.input.ScanCodes;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
Expand All @@ -17,7 +18,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.CommonColors;
import org.lwjgl.glfw.GLFW;
import net.minecraft.util.Util;
import org.lwjgl.sdl.SDLScancode;
import ru.obabok.client.Scan;
import ru.obabok.client.gui.widgets.ToggelableWidgedDropDownList;
import ru.obabok.common.model.BlockArea;
Expand Down Expand Up @@ -410,18 +412,21 @@ private void applyNudge(EditBox field, int direction) {
}

public static boolean hasControlDown() {
return InputConstants.isKeyDown(Minecraft.getInstance().getWindow(), GLFW.GLFW_KEY_LEFT_CONTROL)
|| InputConstants.isKeyDown(Minecraft.getInstance().getWindow(), GLFW.GLFW_KEY_RIGHT_CONTROL);
return Util.getPlatform() == Util.OS.OSX
? InputConstants.isKeyDown(SDLScancode.SDL_SCANCODE_LGUI)
|| InputConstants.isKeyDown(SDLScancode.SDL_SCANCODE_RGUI)
: InputConstants.isKeyDown(SDLScancode.SDL_SCANCODE_LCTRL)
|| InputConstants.isKeyDown(SDLScancode.SDL_SCANCODE_RCTRL);
}

public static boolean hasShiftDown() {
return InputConstants.isKeyDown(Minecraft.getInstance().getWindow(), GLFW.GLFW_KEY_LEFT_SHIFT)
|| InputConstants.isKeyDown(Minecraft.getInstance().getWindow(), GLFW.GLFW_KEY_RIGHT_SHIFT);
return InputConstants.isKeyDown(ScanCodes.SCAN_LEFT_SHIFT)
|| InputConstants.isKeyDown(ScanCodes.SCAN_RIGHT_SHIFT);
}

public static boolean hasAltDown() {
return InputConstants.isKeyDown(Minecraft.getInstance().getWindow(), GLFW.GLFW_KEY_LEFT_ALT)
|| InputConstants.isKeyDown(Minecraft.getInstance().getWindow(), GLFW.GLFW_KEY_RIGHT_ALT);
return InputConstants.isKeyDown(SDLScancode.SDL_SCANCODE_LALT)
|| InputConstants.isKeyDown(SDLScancode.SDL_SCANCODE_RALT);
}

private void updateRange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.world.level.block.Blocks;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.sdl.SDLScancode;
import ru.obabok.client.Scan;
import ru.obabok.client.gui.widgets.SuggestionListWidget;
import ru.obabok.client.gui.widgets.ToggelableWidgedDropDownList;
Expand Down Expand Up @@ -260,23 +260,23 @@ public void extractRenderState(GuiGraphicsExtractor context, int mouseX, int mou
@Override
public boolean keyPressed(@NonNull KeyEvent event) {
if (blockSuggestions != null && blockSuggestions.visible) {
if (event.key() == GLFW.GLFW_KEY_DOWN) {
if (event.key() == SDLScancode.SDL_SCANCODE_DOWN) {
blockSuggestions.selectRelative(1);
return true;
}

if (event.key() == GLFW.GLFW_KEY_UP) {
if (event.key() == SDLScancode.SDL_SCANCODE_UP) {
blockSuggestions.selectRelative(-1);
return true;
}

if (event.key() == GLFW.GLFW_KEY_ENTER || event.key() == GLFW.GLFW_KEY_KP_ENTER || event.key() == GLFW.GLFW_KEY_TAB) {
if (event.key() == SDLScancode.SDL_SCANCODE_KP_ENTER || event.key() == SDLScancode.SDL_SCANCODE_RETURN || event.key() == SDLScancode.SDL_SCANCODE_RETURN2 || event.key() == SDLScancode.SDL_SCANCODE_KP_TAB || event.key() == SDLScancode.SDL_SCANCODE_TAB) {
if (blockSuggestions.confirmSelected()) {
return true;
}
}

if (event.key() == GLFW.GLFW_KEY_ESCAPE) {
if (event.key() == SDLScancode.SDL_SCANCODE_ESCAPE) {
blockSuggestions.hide();
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/java/ru/obabok/client/mixin/TitleScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protected TitleScreenMixin(Component title) {

@Inject(method = "init", at = @At("HEAD"))
private void init(CallbackInfo ci){
if(!AreaScannerClient.isMaliLibLoaded){
minecraft.setScreenAndShow(new NoMalilibScreen());
if(!AreaScannerClient.isMaliLibLoaded && !NoMalilibScreen.showed){
minecraft.setScreenAndShow(new NoMalilibScreen((TitleScreen) (Object)this));
}
}
}
4 changes: 2 additions & 2 deletions src/client/java/ru/obabok/client/mixin/WorldChunkMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.obabok.client.AreaScannerClient;
import ru.obabok.client.Scan;
import ru.obabok.client.util.AreaScannerMalilibHelper;
import ru.obabok.client.util.ChunkScheduler;

@Environment(EnvType.CLIENT)
Expand All @@ -22,7 +22,7 @@ public class WorldChunkMixin {

@Inject(method = "setBlockState", at = @At("RETURN"))
private void setBlock(BlockPos pos, BlockState state, int i, CallbackInfoReturnable<BlockState> cir){
if(AreaScannerMalilibHelper.shouldUpdateRealtime()){
if(AreaScannerClient.shouldUpdateRealtime()){
BlockState oldState = cir.getReturnValue();
if (oldState != null && oldState != state) {
Level world = ((LevelChunk) (Object) this).getLevel();
Expand Down
2 changes: 1 addition & 1 deletion src/client/java/ru/obabok/client/render/HudRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private static void renderClusteredDots(GuiGraphicsExtractor guiGraphicsExtracto
int screenHeight = mc.getWindow().getGuiScaledHeight();

if(Config.Generic.LOD2_HUD.getBooleanValue()){
int color = Config.Generic.SELECTED_BLOCKS_COLOR.getIntegerValue();
int color = Config.Generic.SELECTED_BLOCKS_COLOR.getColor().withAlpha(Config.Generic.LOD2_HUD_TRANSPARENCY.getFloatValue()).getIntValue();
for (int i = 0; i < preparedBlockClusters.size(); i++) {
BlockPos pos = preparedBlockClusters.get(i);
renderDot(guiGraphicsExtractor, camera, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, screenWidth, screenHeight, color);
Expand Down
34 changes: 19 additions & 15 deletions src/client/java/ru/obabok/client/render/RenderUtil.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package ru.obabok.client.render;

import com.mojang.blaze3d.IndexType;
import com.mojang.blaze3d.PrimitiveTopology;
import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.buffers.GpuBufferSlice;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.systems.RenderPass;

import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.renderpearl.api.buffers.GpuBuffer;
import com.mojang.renderpearl.api.buffers.GpuBufferSlice;
import com.mojang.renderpearl.api.commands.RenderPass;
import com.mojang.renderpearl.api.pipeline.IndexType;
import com.mojang.renderpearl.api.pipeline.PrimitiveTopology;
import com.mojang.renderpearl.api.pipeline.RenderPipeline;
import com.mojang.renderpearl.api.textures.GpuTextureView;
import fi.dy.masa.malilib.util.data.Color4f;
import net.fabricmc.fabric.api.client.rendering.v1.level.LevelRenderContext;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.DynamicUniforms;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.client.renderer.StagedVertexBuffer;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.Identifier;
Expand Down Expand Up @@ -431,28 +434,29 @@ private static void draw(Minecraft client, RenderPipeline pipeline, MeshData bui
indexType = shapeIndexBuffer.type();
}

GpuBufferSlice[] transforms = RenderSystem.getDynamicUniforms().writeTransforms(
new DynamicUniforms.Transform(
GpuBufferSlice transforms = RenderSystem.getDynamicUniforms().writeTransform(
RenderSystem.getModelViewMatrixCopy(),
COLOR_MODULATOR,
MODEL_OFFSET,
TEXTURE_MATRIX
)
);
RenderTarget mainTarget = client.gameRenderer.mainRenderTarget();
GpuTextureView colorTexture = mainTarget.getColorTextureView();
assert colorTexture != null;

try (RenderPass renderPass = RenderSystem.getDevice()
.createCommandEncoder()
.createRenderPass(
() -> "mod_render_pass",
client.gameRenderer.mainRenderTarget().getColorTextureView(),
() -> References.MOD_ID + " render pipeline",
colorTexture,
Optional.empty(),
client.gameRenderer.mainRenderTarget().getDepthTextureView(),
mainTarget.getDepthTextureView(),
OptionalDouble.empty()
)) {

renderPass.setPipeline(RenderSystem.getCompiledPipeline(pipeline));
RenderSystem.bindDefaultUniforms(renderPass);
renderPass.setPipeline(pipeline);
renderPass.setUniform("DynamicTransforms", transforms[0]);
renderPass.setUniform("DynamicTransforms", transforms);

renderPass.setVertexBuffer(0, vertexBuffer.slice());
renderPass.setIndexBuffer(indices, indexType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
import fi.dy.masa.malilib.event.InitializationHandler;
import fi.dy.masa.malilib.registry.Registry;
import fi.dy.masa.malilib.util.data.ModInfo;
import ru.obabok.client.AreaScannerClient;
import ru.obabok.client.Config;
import ru.obabok.client.gui.screens.ConfigGui;
import ru.obabok.client.handlers.InitHandler;
import ru.obabok.common.References;

public class AreaScannerMalilibHelper {
public static boolean shouldUpdateRealtime() {
if (AreaScannerClient.isMaliLibLoaded) {
return Config.Generic.REALTIME_UPDATE.getBooleanValue();
}
return false;
}

public static void initMalilib(){
InitializationHandler.getInstance().registerInitializationHandler(new InitHandler());
Registry.CONFIG_SCREEN.registerConfigScreenFactory(new ModInfo(References.MOD_ID, References.MOD_NAME, ConfigGui::new));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ru/obabok/common/BlockMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ public static PistonBehavior getPistonBehavior(BlockState state, Level world, Bl
}

switch (state.getPistonPushReaction()) {
case BLOCK -> {
case IMMOVEABLE -> {
return PistonBehavior.IMMOVABLE;
}
case DESTROY -> {
case POPPED -> {
return PistonBehavior.DESTROY;
}
case PUSH_ONLY -> {
case PUSH -> {
return PistonBehavior.NORMAL;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/areascanner/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"areascanner.config.generic.name.LOD2_hud": "Display LOD2 blocks in HUD",
"areascanner.config.generic.comment.LOD2_hud": "Will never stop rendering",

"areascanner.config.generic.name.LOD2_hud_transparency": "LOD2 transparency in the HUD",
"areascanner.config.generic.comment.LOD2_hud_transparency": "",

"areascanner.config.generic.name.group_render": "Renders groups of blocks as a single object",
"areascanner.config.generic.comment.group_render": "It can be useful if there are large clusters of blocks in one place",

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/areascanner/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"areascanner.config.generic.name.LOD2_hud": "Отображать LOD2 блоки в худе",
"areascanner.config.generic.comment.LOD2_hud": "Они будут всегда рендерится",

"areascanner.config.generic.name.LOD2_hud_transparency": "Прозрачность LOD2 блоков в худе",
"areascanner.config.generic.comment.LOD2_hud_transparency": "",

"areascanner.config.generic.name.group_render": "Рендер скопления блоков как одного объекта",
"areascanner.config.generic.comment.group_render": "Может быть полезно если есть большие скопления блоков в одном месте",

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
}
],
"depends": {
"fabricloader": ">=0.19.3",
"minecraft": "~26.2",
"fabricloader": ">=0.19.5",
"minecraft": "~26.3",
"java": ">=25",
"fabric-api": "*"
},
"suggests": {
"malilib": ">=0.29.3"
"malilib": ">=0.30.1"
}
}