|
1 | 1 | package com.robotgryphon.compactmachines.item; |
2 | 2 |
|
3 | 3 | import com.robotgryphon.compactmachines.CompactMachines; |
| 4 | +import com.robotgryphon.compactmachines.client.gui.PersonalShrinkingDeviceScreen; |
4 | 5 | import com.robotgryphon.compactmachines.core.Registration; |
5 | 6 | import com.robotgryphon.compactmachines.util.CompactMachineUtil; |
6 | 7 | import com.robotgryphon.compactmachines.util.PlayerUtil; |
| 8 | +import net.minecraft.client.entity.player.ClientPlayerEntity; |
7 | 9 | import net.minecraft.client.gui.screen.Screen; |
8 | 10 | import net.minecraft.client.util.ITooltipFlag; |
9 | 11 | import net.minecraft.entity.player.PlayerEntity; |
10 | 12 | import net.minecraft.entity.player.ServerPlayerEntity; |
11 | 13 | import net.minecraft.item.Item; |
12 | 14 | import net.minecraft.item.ItemStack; |
| 15 | +import net.minecraft.item.ItemUseContext; |
13 | 16 | import net.minecraft.util.ActionResult; |
| 17 | +import net.minecraft.util.ActionResultType; |
14 | 18 | import net.minecraft.util.Hand; |
15 | 19 | import net.minecraft.util.text.IFormattableTextComponent; |
16 | 20 | import net.minecraft.util.text.ITextComponent; |
17 | 21 | import net.minecraft.util.text.TextFormatting; |
18 | 22 | import net.minecraft.util.text.TranslationTextComponent; |
19 | 23 | import net.minecraft.world.World; |
20 | 24 | import net.minecraft.world.server.ServerWorld; |
| 25 | +import net.minecraftforge.fml.client.gui.GuiUtils; |
| 26 | +import net.minecraftforge.fml.network.NetworkHooks; |
21 | 27 |
|
22 | 28 | import javax.annotation.Nullable; |
23 | 29 | import java.util.List; |
@@ -58,12 +64,13 @@ public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player |
58 | 64 | return ActionResult.resultFail(stack); |
59 | 65 | } |
60 | 66 |
|
61 | | -// TODO: Machine enter/exit dimension |
62 | | -// if(world.provider.getDimension() != ConfigurationHandler.Settings.dimensionId) { |
63 | | -// // player.openGui(compactmachines.instance, GuiIds.PSD_GUIDE.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); |
64 | | -// return new ActionResult(ActionResultType.SUCCESS, stack); |
65 | | -// } |
66 | | -// |
| 67 | + // If we aren't in the compact dimension, allow PSD guide usage |
| 68 | + // Prevents misfiring if a player is trying to leave a machine or set their spawn |
| 69 | + if(world.isRemote && world.getDimensionKey() != Registration.COMPACT_DIMENSION) { |
| 70 | + PersonalShrinkingDeviceScreen.show(); |
| 71 | + return ActionResult.resultSuccess(stack); |
| 72 | + } |
| 73 | + |
67 | 74 | if (world instanceof ServerWorld && player instanceof ServerPlayerEntity) { |
68 | 75 | ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player; |
69 | 76 |
|
|
0 commit comments