Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 36e8117

Browse files
committed
fix: allow the block editor to be opened when the mod isn't installed on the server (#85)
1 parent a744b4c commit 36e8117

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

common/src/main/java/com/github/franckyi/ibeeditor/client/logic/ClientEditorRequestLogic.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.github.franckyi.ibeeditor.client.ClientContext;
44
import com.github.franckyi.ibeeditor.client.ClientUtil;
55
import com.github.franckyi.ibeeditor.client.ModScreenHandler;
6+
import com.github.franckyi.ibeeditor.client.context.BlockEditorContext;
67
import com.github.franckyi.ibeeditor.client.context.EntityEditorContext;
78
import com.github.franckyi.ibeeditor.client.context.ItemEditorContext;
89
import com.github.franckyi.ibeeditor.common.EditorType;
@@ -16,8 +17,6 @@
1617
import net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket;
1718
import net.minecraft.world.Container;
1819
import net.minecraft.world.entity.player.Inventory;
19-
import net.minecraft.world.item.CreativeModeTab;
20-
import net.minecraft.world.item.CreativeModeTabs;
2120
import net.minecraft.world.phys.BlockHitResult;
2221
import net.minecraft.world.phys.EntityHitResult;
2322
import net.minecraft.world.phys.HitResult;
@@ -50,7 +49,11 @@ public static boolean requestBlockEditor(EditorType editorType) {
5049
if (ClientContext.isModInstalledOnServer()) {
5150
NetworkManager.sendToServer(NetworkManager.BLOCK_EDITOR_REQUEST, new BlockEditorPacket.Request(editorType, blockPos));
5251
} else {
53-
ClientUtil.showMessage(ModTexts.Messages.errorServerModRequired(ModTexts.BLOCK));
52+
var level = Minecraft.getInstance().level;
53+
var blockState = level.getBlockState(blockPos);
54+
var blockEntity = level.getBlockEntity(blockPos);
55+
var tag = blockEntity == null ? null : blockEntity.saveWithId();
56+
ModScreenHandler.openEditor(editorType, new BlockEditorContext(blockState, tag, ModTexts.errorServerModRequired(ModTexts.BLOCK), null));
5457
}
5558
return true;
5659
}

0 commit comments

Comments
 (0)