Skip to content

Commit 60dbe9e

Browse files
chore: mostly ported
1 parent 4424a89 commit 60dbe9e

File tree

16 files changed

+61
-58
lines changed

16 files changed

+61
-58
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
22
id 'java-library'
3-
id 'fabric-loom' version '1.12.0-alpha.48' apply(false)
3+
id 'fabric-loom' version '1.13.3' apply(false)
44
id 'net.neoforged.moddev' version '2.0.112' apply(false)
5-
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
5+
id "me.modmuss50.mod-publish-plugin" version "1.1.0"
66
}
77

88
tasks.named('wrapper', Wrapper).configure {

common/src/main/java/pro/mikey/xray/XRay.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import net.minecraft.client.KeyMapping;
44
import net.minecraft.client.Minecraft;
55
import net.minecraft.client.resources.language.I18n;
6-
import net.minecraft.resources.ResourceLocation;
6+
import net.minecraft.resources.Identifier;
77
import org.apache.logging.log4j.LogManager;
88
import org.apache.logging.log4j.Logger;
99
import org.lwjgl.glfw.GLFW;
@@ -57,12 +57,12 @@ private boolean minecraftNotReady() {
5757
return mc.player == null || Minecraft.getInstance().screen != null || Minecraft.getInstance().level == null;
5858
}
5959

60-
public static ResourceLocation id(String path) {
61-
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
60+
public static Identifier id(String path) {
61+
return Identifier.fromNamespaceAndPath(MOD_ID, path);
6262
}
6363

64-
public static ResourceLocation assetLocation(String path) {
65-
return ResourceLocation.fromNamespaceAndPath(MOD_ID, "textures/" + path);
64+
public static Identifier assetLocation(String path) {
65+
return Identifier.fromNamespaceAndPath(MOD_ID, "textures/" + path);
6666
}
6767

6868
public static Configuration config() {

common/src/main/java/pro/mikey/xray/core/scanner/BlockScanType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.google.gson.JsonObject;
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.core.registries.BuiltInRegistries;
6-
import net.minecraft.resources.ResourceLocation;
6+
import net.minecraft.resources.Identifier;
77
import net.minecraft.world.level.Level;
88
import net.minecraft.world.level.block.Block;
99
import net.minecraft.world.level.block.state.BlockState;
@@ -25,7 +25,7 @@ public BlockScanType(Block block, String name, String color, int order) {
2525
public BlockScanType(Type type, JsonObject obj) {
2626
super(type, obj);
2727
this.blockName = obj.get("block_name").getAsString();
28-
this.block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.tryParse(this.blockName));
28+
this.block = BuiltInRegistries.BLOCK.getValue(Identifier.tryParse(this.blockName));
2929
}
3030

3131
@Override

common/src/main/java/pro/mikey/xray/core/scanner/ScanStore.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.google.gson.JsonObject;
77
import com.mojang.serialization.JsonOps;
88
import net.minecraft.core.registries.BuiltInRegistries;
9-
import net.minecraft.resources.ResourceLocation;
9+
import net.minecraft.resources.Identifier;
1010
import net.minecraft.world.item.ItemStack;
1111
import net.minecraft.world.level.block.Block;
1212
import net.minecraft.world.level.block.Blocks;
@@ -25,8 +25,8 @@ public class ScanStore {
2525
private static final Logger LOGGER = LoggerFactory.getLogger(ScanStore.class);
2626
private static final String STORE_FILE = "scan-store.json";
2727

28-
private static final LazyValue<Map<ResourceLocation, String>> BLOCK_TO_COLOR_DEFAULTS = LazyValue.of(() -> {
29-
Map<ResourceLocation, String> defaults = new HashMap<>();
28+
private static final LazyValue<Map<Identifier, String>> BLOCK_TO_COLOR_DEFAULTS = LazyValue.of(() -> {
29+
Map<Identifier, String> defaults = new HashMap<>();
3030
defaults.put(fromBlock(Blocks.DIAMOND_ORE), "rgb(0, 255, 0)"); // Green
3131
defaults.put(fromBlock(Blocks.DEEPSLATE_DIAMOND_ORE), "rgb(0, 255, 0)"); // Green (Deepslate Diamond)
3232
defaults.put(fromBlock(Blocks.GOLD_ORE), "rgb(255, 215, 0)"); // Gold
@@ -67,7 +67,7 @@ public void createDefaultCategories() {
6767
BuiltInRegistries.BLOCK
6868
.stream()
6969
.filter(e -> e.defaultBlockState().is(oresTag))
70-
.map(e -> new BlockScanType(e, e.getName().getString(), blockColorDefaults.getOrDefault(e.builtInRegistryHolder().key().location(), ScanType.randomRgbColor()), 0))
70+
.map(e -> new BlockScanType(e, e.getName().getString(), blockColorDefaults.getOrDefault(e.builtInRegistryHolder().key().identifier(), ScanType.randomRgbColor()), 0))
7171
.forEach(entries::add);
7272

7373
this.categories.add(createDefaultCategory(entries));
@@ -236,7 +236,7 @@ public static Category load(JsonObject obj) {
236236
for (var entry : entriesArray) {
237237
var entryObj = entry.getAsJsonObject();
238238
try {
239-
var type = ScanType.Type.fromId(ResourceLocation.tryParse(entryObj.get("type").getAsString()));
239+
var type = ScanType.Type.fromId(Identifier.tryParse(entryObj.get("type").getAsString()));
240240
var creator = SCAN_TYPE_CREATORS.get(type);
241241
if (creator == null) {
242242
LOGGER.warn("No creator found for scan type: {}", type);
@@ -268,7 +268,7 @@ public static Category load(JsonObject obj) {
268268
}
269269
}
270270

271-
private static ResourceLocation fromBlock(Block block) {
271+
private static Identifier fromBlock(Block block) {
272272
if (block == null) {
273273
return null;
274274
}

common/src/main/java/pro/mikey/xray/core/scanner/ScanType.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.google.gson.JsonObject;
44
import net.minecraft.core.BlockPos;
5-
import net.minecraft.resources.ResourceLocation;
5+
import net.minecraft.resources.Identifier;
66
import net.minecraft.world.level.Level;
77
import net.minecraft.world.level.block.state.BlockState;
88
import net.minecraft.world.level.material.FluidState;
@@ -229,13 +229,13 @@ public enum Type {
229229

230230
private static final Set<Type> values = Set.of(values());
231231

232-
private final ResourceLocation id;
232+
private final Identifier id;
233233

234-
Type(ResourceLocation id) {
234+
Type(Identifier id) {
235235
this.id = id;
236236
}
237237

238-
public static Type fromId(ResourceLocation id) {
238+
public static Type fromId(Identifier id) {
239239
for (Type type : values) {
240240
if (type.id.equals(id)) {
241241
return type;
@@ -244,7 +244,7 @@ public static Type fromId(ResourceLocation id) {
244244
throw new IllegalArgumentException("Unknown ScanType ID: " + id);
245245
}
246246

247-
public ResourceLocation getId() {
247+
public Identifier getId() {
248248
return id;
249249
}
250250
}

common/src/main/java/pro/mikey/xray/screens/HelpScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import net.minecraft.client.gui.components.Button;
66
import net.minecraft.client.resources.language.I18n;
77
import net.minecraft.network.chat.Component;
8-
import net.minecraft.resources.ResourceLocation;
8+
import net.minecraft.resources.Identifier;
99
import pro.mikey.xray.screens.helpers.GuiBase;
1010

1111
import java.awt.*;
@@ -53,7 +53,7 @@ public boolean hasTitle() {
5353
}
5454

5555
@Override
56-
public ResourceLocation getBackground() {
56+
public Identifier getBackground() {
5757
return BG_LARGE;
5858
}
5959

common/src/main/java/pro/mikey/xray/screens/HudOverlay.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import net.minecraft.client.gui.GuiGraphics;
77
import net.minecraft.client.renderer.RenderPipelines;
88
import net.minecraft.client.resources.language.I18n;
9-
import net.minecraft.resources.ResourceLocation;
9+
import net.minecraft.resources.Identifier;
1010
import pro.mikey.xray.XRay;
1111
import pro.mikey.xray.core.ScanController;
1212

1313
public class HudOverlay {
14-
private static final ResourceLocation CIRCLE = XRay.assetLocation("gui/circle.png");
14+
private static final Identifier CIRCLE = XRay.assetLocation("gui/circle.png");
1515

1616
public static void renderGameOverlayEvent(GuiGraphics graphics) {
1717
// Draw Indicator

common/src/main/java/pro/mikey/xray/screens/ScanConfigureScreen.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
import net.minecraft.client.gui.GuiGraphics;
55
import net.minecraft.client.gui.components.Button;
66
import net.minecraft.client.gui.components.EditBox;
7-
import net.minecraft.client.gui.components.SpriteIconButton;
87
import net.minecraft.client.gui.layouts.GridLayout;
9-
import net.minecraft.client.gui.layouts.Layout;
108
import net.minecraft.client.input.MouseButtonEvent;
119
import net.minecraft.client.renderer.RenderPipelines;
1210
import net.minecraft.client.resources.language.I18n;
1311
import net.minecraft.network.chat.Component;
14-
import net.minecraft.resources.ResourceLocation;
12+
import net.minecraft.resources.Identifier;
1513
import net.minecraft.world.item.ItemStack;
1614
import net.minecraft.world.level.block.Block;
1715
import org.jetbrains.annotations.Nullable;
@@ -28,8 +26,8 @@
2826
import java.util.function.Supplier;
2927

3028
public class ScanConfigureScreen extends GuiBase {
31-
private static final ResourceLocation TRASH_ICON = XRay.assetLocation("gui/trash.png");
32-
private static final ResourceLocation TRANSPARENT_BACKGROUND = XRay.assetLocation("gui/transparent_background.png");
29+
private static final Identifier TRASH_ICON = XRay.assetLocation("gui/trash.png");
30+
private static final Identifier TRANSPARENT_BACKGROUND = XRay.assetLocation("gui/transparent_background.png");
3331

3432
private EditBox oreName;
3533

common/src/main/java/pro/mikey/xray/screens/ScanManageScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import net.minecraft.client.renderer.entity.ItemRenderer;
1313
import net.minecraft.client.resources.language.I18n;
1414
import net.minecraft.network.chat.Component;
15-
import net.minecraft.resources.ResourceLocation;
15+
import net.minecraft.resources.Identifier;
1616
import net.minecraft.world.InteractionHand;
1717
import net.minecraft.world.entity.player.Player;
1818
import net.minecraft.world.item.BlockItem;
@@ -40,7 +40,7 @@
4040
import java.util.List;
4141

4242
public class ScanManageScreen extends GuiBase {
43-
private static final ResourceLocation CIRCLE = XRay.assetLocation("gui/circle.png");
43+
private static final Identifier CIRCLE = XRay.assetLocation("gui/circle.png");
4444

4545
private Button distButtons;
4646
private EditBox search;

common/src/main/java/pro/mikey/xray/screens/helpers/GuiBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import net.minecraft.client.renderer.RenderPipelines;
1111
import net.minecraft.locale.Language;
1212
import net.minecraft.network.chat.Component;
13-
import net.minecraft.resources.ResourceLocation;
13+
import net.minecraft.resources.Identifier;
1414
import net.minecraft.util.FormattedCharSequence;
1515
import pro.mikey.xray.XRay;
1616

1717
import java.util.ArrayList;
1818
import java.util.List;
1919

2020
public abstract class GuiBase extends Screen {
21-
public static final ResourceLocation BG_NORMAL = XRay.assetLocation("gui/bg.png");
22-
public static final ResourceLocation BG_LARGE = XRay.assetLocation("gui/bg-help.png");
21+
public static final Identifier BG_NORMAL = XRay.assetLocation("gui/bg.png");
22+
public static final Identifier BG_LARGE = XRay.assetLocation("gui/bg-help.png");
2323

2424
private boolean hasSide;
2525
private String sideTitle = "";
@@ -88,7 +88,7 @@ public void render(GuiGraphics guiGraphics, int x, int y, float partialTicks) {
8888
}
8989
}
9090

91-
public ResourceLocation getBackground() {
91+
public Identifier getBackground() {
9292
return BG_NORMAL;
9393
}
9494

0 commit comments

Comments
 (0)