diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java new file mode 100644 index 000000000..25c4d73b4 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/FuMO25Screen.java @@ -0,0 +1,51 @@ +package com.atsuishio.superbwarfare.client.screens; + +import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.menu.FuMO25Menu; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public class FuMO25Screen extends AbstractContainerScreen { + + private static final ResourceLocation TEXTURE = ModUtils.loc("textures/gui/radar.png"); + private static final ResourceLocation SCAN = ModUtils.loc("textures/gui/radar_scan.png"); + + public FuMO25Screen(FuMO25Menu pMenu, Inventory pPlayerInventory, Component pTitle) { + super(pMenu, pPlayerInventory, pTitle); + imageWidth = 340; + imageHeight = 166; + } + + @Override + protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) { + int i = (this.width - this.imageWidth) / 2; + int j = (this.height - this.imageHeight) / 2; + pGuiGraphics.blit(TEXTURE, i, j, 0, 0, this.imageWidth, this.imageHeight, 358, 328); + } + + @Override + public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { + this.renderBackground(pGuiGraphics); + super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); + this.renderTooltip(pGuiGraphics, pMouseX, pMouseY); + } + + @Override + protected void renderLabels(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY) { + } + + @Override + protected void init() { + super.init(); + this.titleLabelX = 33; + this.titleLabelY = 5; + this.inventoryLabelX = 105; + this.inventoryLabelY = 128; + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java b/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java index 745eb7164..1e79497ab 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.init; import com.atsuishio.superbwarfare.client.screens.ChargingStationScreen; +import com.atsuishio.superbwarfare.client.screens.FuMO25Screen; import com.atsuishio.superbwarfare.client.screens.ReforgingTableScreen; import com.atsuishio.superbwarfare.client.screens.VehicleScreen; import net.minecraft.client.gui.screens.MenuScreens; @@ -18,6 +19,7 @@ public class ModScreens { MenuScreens.register(ModMenuTypes.REFORGING_TABLE_MENU.get(), ReforgingTableScreen::new); MenuScreens.register(ModMenuTypes.CHARGING_STATION_MENU.get(), ChargingStationScreen::new); MenuScreens.register(ModMenuTypes.VEHICLE_MENU.get(), VehicleScreen::new); + MenuScreens.register(ModMenuTypes.FUMO_25_MENU.get(), FuMO25Screen::new); }); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/menu/FuMO25Menu.java b/src/main/java/com/atsuishio/superbwarfare/menu/FuMO25Menu.java index ed3daee73..6372163b6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/menu/FuMO25Menu.java +++ b/src/main/java/com/atsuishio/superbwarfare/menu/FuMO25Menu.java @@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.menu; import com.atsuishio.superbwarfare.init.ModBlocks; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModMenuTypes; +import net.minecraft.core.BlockPos; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; @@ -12,13 +13,19 @@ import net.minecraft.world.inventory.ContainerLevelAccess; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; +import javax.annotation.Nullable; + public class FuMO25Menu extends AbstractContainerMenu { protected final Container container; protected final ContainerLevelAccess access; - public static final int X_OFFSET = 0; - public static final int Y_OFFSET = 11; + private int posX = Integer.MIN_VALUE; + private int posY = Integer.MIN_VALUE; + private int posZ = Integer.MIN_VALUE; + + public static final int X_OFFSET = 164; + public static final int Y_OFFSET = 0; public FuMO25Menu(int pContainerId, Inventory pPlayerInventory) { this(pContainerId, pPlayerInventory, new SimpleContainer(1), ContainerLevelAccess.NULL); @@ -36,7 +43,7 @@ public class FuMO25Menu extends AbstractContainerMenu { this.container = container; this.access = access; - this.addSlot(new ParaSlot(container, 0, 8 + X_OFFSET, 11 + Y_OFFSET)); + this.addSlot(new ParaSlot(container, 0, 278, 60)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { @@ -49,6 +56,40 @@ public class FuMO25Menu extends AbstractContainerMenu { } } + public void setPos(int x, int y, int z) { + this.posX = x; + this.posY = y; + this.posZ = z; + } + + public void resetPos() { + this.posX = Integer.MIN_VALUE; + this.posY = Integer.MIN_VALUE; + this.posZ = Integer.MIN_VALUE; + } + + public void setPosToParameters() { + if (this.posX != Integer.MIN_VALUE && this.posY != Integer.MIN_VALUE) { + ItemStack stack = this.container.getItem(0); + if (stack.isEmpty()) return; + + stack.getOrCreateTag().putInt("TargetX", this.posX); + stack.getOrCreateTag().putInt("TargetY", this.posY); + stack.getOrCreateTag().putInt("TargetZ", this.posZ); + + this.resetPos(); + this.container.setChanged(); + } + } + + @Nullable + public BlockPos getCurrentPos() { + if (this.posX != Integer.MIN_VALUE && this.posY != Integer.MIN_VALUE && this.posZ != Integer.MIN_VALUE) { + return new BlockPos(this.posX, this.posY, this.posZ); + } + return null; + } + @Override public ItemStack quickMoveStack(Player pPlayer, int pIndex) { ItemStack itemstack = ItemStack.EMPTY; @@ -100,6 +141,7 @@ public class FuMO25Menu extends AbstractContainerMenu { pPlayer.getInventory().placeItemBackInInventory(para); } this.container.removeItemNoUpdate(0); + resetPos(); }); } diff --git a/src/main/resources/assets/superbwarfare/textures/gui/rader.png b/src/main/resources/assets/superbwarfare/textures/gui/radar.png similarity index 100% rename from src/main/resources/assets/superbwarfare/textures/gui/rader.png rename to src/main/resources/assets/superbwarfare/textures/gui/radar.png diff --git a/src/main/resources/assets/superbwarfare/textures/gui/rader_scan.png b/src/main/resources/assets/superbwarfare/textures/gui/radar_scan.png similarity index 100% rename from src/main/resources/assets/superbwarfare/textures/gui/rader_scan.png rename to src/main/resources/assets/superbwarfare/textures/gui/radar_scan.png