Skip to content

Commit cf0c624

Browse files
committed
Fix bug where pick block on unmapped machines gives ID 0
1 parent 46f2628 commit cf0c624

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) [year] [fullname]
3+
Copyright (c) 2021 Compact Mods Team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/main/java/com/robotgryphon/compactmachines/block/BlockCompactMachine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockRea
226226
nbt.putString("size", this.size.getName());
227227

228228
CompactMachineTile tileEntity = (CompactMachineTile) world.getBlockEntity(pos);
229-
if (tileEntity != null) {
229+
if (tileEntity != null && tileEntity.mapped()) {
230230
nbt.putInt("coords", tileEntity.machineId);
231231
}
232232

src/main/java/com/robotgryphon/compactmachines/compat/theoneprobe/providers/CompactMachineProvider.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.robotgryphon.compactmachines.compat.theoneprobe.providers;
22

33
import com.mojang.authlib.GameProfile;
4+
import com.robotgryphon.compactmachines.CompactMachines;
45
import com.robotgryphon.compactmachines.api.core.Tooltips;
56
import com.robotgryphon.compactmachines.block.tiles.CompactMachineTile;
67
import com.robotgryphon.compactmachines.block.tiles.TunnelWallTile;
@@ -10,11 +11,14 @@
1011
import com.robotgryphon.compactmachines.util.TranslationUtil;
1112
import mcjty.theoneprobe.api.IProbeHitData;
1213
import mcjty.theoneprobe.api.IProbeInfo;
14+
import mcjty.theoneprobe.api.ITextStyle;
1315
import mcjty.theoneprobe.api.ProbeMode;
1416
import net.minecraft.entity.player.PlayerEntity;
1517
import net.minecraft.tileentity.TileEntity;
18+
import net.minecraft.util.ResourceLocation;
1619
import net.minecraft.util.math.BlockPos;
1720
import net.minecraft.util.text.IFormattableTextComponent;
21+
import net.minecraft.util.text.ITextComponent;
1822
import net.minecraft.util.text.StringTextComponent;
1923
import net.minecraft.util.text.TextFormatting;
2024
import net.minecraft.world.World;
@@ -36,11 +40,19 @@ private static void addProbeInfo(IProbeInfo info, World world, IProbeHitData hit
3640
if (te instanceof CompactMachineTile) {
3741
CompactMachineTile machine = (CompactMachineTile) te;
3842

39-
IFormattableTextComponent id = TranslationUtil
40-
.tooltip(Tooltips.Machines.ID, machine.machineId)
41-
.withStyle(TextFormatting.GREEN);
43+
if(machine.mapped()) {
44+
IFormattableTextComponent id = TranslationUtil
45+
.tooltip(Tooltips.Machines.ID, machine.machineId)
46+
.withStyle(TextFormatting.GREEN);
4247

43-
info.text(id);
48+
info.text(id);
49+
} else {
50+
IFormattableTextComponent newMachine = TranslationUtil
51+
.message(new ResourceLocation(CompactMachines.MOD_ID, "new_machine"))
52+
.withStyle(TextFormatting.GREEN);
53+
54+
info.text(newMachine);
55+
}
4456

4557
machine.getOwnerUUID().ifPresent(ownerID -> {
4658
// Owner Name

src/main/java/com/robotgryphon/compactmachines/teleportation/DimensionalPosition.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public RegistryKey<World> getDimension() {
8383
}
8484

8585
private String getDimensionString() {
86+
if(this.dimension == null)
87+
return "";
88+
8689
return this.dimension.location().toString();
8790
}
8891

0 commit comments

Comments
 (0)