Skip to content

Commit

Permalink
Converted gui code to halplibe GuiHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
kill05 committed Jun 15, 2024
1 parent be1b51a commit ea2bf5b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ loader_version=0.15.6-babric.6-bta
mod_menu_version=2.0.5

# HalpLibe
halplibe_version=4.0.6
halplibe_version=4.1.0

# Mod
mod_version=0.0.3
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/github/kill05/ArchitectGuis.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.github.kill05;

import com.github.kill05.blocks.architectstation.ArchitectTableTileEntity;
import com.github.kill05.blocks.architectstation.part.PartModeContainer;
import com.github.kill05.blocks.architectstation.part.PartModeGui;
import com.github.kill05.blocks.architectstation.tool.ToolModeContainer;
import com.github.kill05.blocks.architectstation.tool.ToolModeGui;
import net.minecraft.client.entity.player.EntityPlayerSP;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.core.player.inventory.Container;
import net.minecraft.server.entity.player.EntityPlayerMP;
import org.jetbrains.annotations.NotNull;
import turniplabs.halplibe.helper.gui.GuiHelper;
import turniplabs.halplibe.helper.gui.factory.block.TileGuiFactory;
import turniplabs.halplibe.helper.gui.registered.RegisteredGui;

public class ArchitectGuis {

public static final RegisteredGui PART_MODE = GuiHelper.registerServerGui(ArchitectTools.MOD_ID, "part_mode", new TileGuiFactory<ArchitectTableTileEntity>() {
@Override
public @NotNull GuiScreen createGui(@NotNull RegisteredGui gui, @NotNull EntityPlayerSP player, @NotNull ArchitectTableTileEntity tile) {
return new PartModeGui(tile, player);
}

@Override
public @NotNull Container createContainer(@NotNull RegisteredGui gui, @NotNull EntityPlayerMP player, @NotNull ArchitectTableTileEntity tile) {
return new PartModeContainer(tile, player);
}
});

public static final RegisteredGui TOOL_MODE = GuiHelper.registerServerGui(ArchitectTools.MOD_ID, "tool_mode", new TileGuiFactory<ArchitectTableTileEntity>() {
@Override
public @NotNull GuiScreen createGui(@NotNull RegisteredGui gui, @NotNull EntityPlayerSP player, @NotNull ArchitectTableTileEntity tile) {
return new ToolModeGui(tile, player);
}

@Override
public @NotNull Container createContainer(@NotNull RegisteredGui gui, @NotNull EntityPlayerMP player, @NotNull ArchitectTableTileEntity tile) {
return new ToolModeContainer(tile, player);
}
});

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.kill05.blocks.architectstation;

import com.github.kill05.blocks.architectstation.part.PartModeGui;
import com.github.kill05.ArchitectGuis;
import com.github.kill05.config.ArchitectConfig;
import com.github.kill05.utils.InventoryUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.block.BlockTileEntity;
import net.minecraft.core.block.entity.TileEntity;
import net.minecraft.core.block.material.Material;
Expand All @@ -24,9 +23,7 @@ protected TileEntity getNewBlockEntity() {
@Override
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer player) {
if(player.isSneaking()) return false;

ArchitectTableTileEntity tile = (ArchitectTableTileEntity) world.getBlockTileEntity(x, y, z);
Minecraft.getMinecraft(Minecraft.class).displayGuiScreen(new PartModeGui(tile, player));
ArchitectGuis.PART_MODE.open(player, x, y, z);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.github.kill05.utils.RenderUtils;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.player.inventory.IInventory;
import org.lwjgl.opengl.GL11;

public class PartModeGui extends TileContainerGui {

Expand Down Expand Up @@ -44,6 +45,8 @@ public void init() {
@Override
protected void drawGuiContainerBackgroundLayer(float f) {
RenderUtils.bindTexture("gui/part_mode.png");
GL11.glColor4f(1f, 1f, 1f, 1f);

int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class ToolModeContainer extends TileContainer {

protected ToolModeContainer(ArchitectTableTileEntity tile, EntityPlayer player) {
public ToolModeContainer(ArchitectTableTileEntity tile, EntityPlayer player) {
super(tile, tile.getToolInventory());

for(int i = 0; i < tile.getToolInventory().getSizeInventory(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.github.kill05.items.tool.ToolPartInfo;
import com.github.kill05.utils.RenderUtils;
import net.minecraft.core.entity.player.EntityPlayer;
import org.lwjgl.opengl.GL11;

public class ToolModeGui extends TileContainerGui {

Expand Down Expand Up @@ -44,6 +45,8 @@ public void init() {
@Override
protected void drawGuiContainerBackgroundLayer(float f) {
RenderUtils.bindTexture("gui/tool_mode.png");
GL11.glColor4f(1f, 1f, 1f, 1f);

int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
Expand Down

0 comments on commit ea2bf5b

Please sign in to comment.