Skip to content

Commit

Permalink
Use RailcraftMenuScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Mar 15, 2024
1 parent dd40e9e commit 28f5350
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package mods.railcraft.client.gui.screen.inventory.detector;

import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.client.gui.screen.inventory.RailcraftMenuScreen;
import mods.railcraft.world.inventory.detector.AdvancedDetectorMenu;
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;

public class AdvancedDetectorScreen extends AbstractContainerScreen<AdvancedDetectorMenu> {
public class AdvancedDetectorScreen extends RailcraftMenuScreen<AdvancedDetectorMenu> {

private static final ResourceLocation BACKGROUND_TEXTURE =
RailcraftConstants.rl("textures/gui/container/advanced_detector.png");
Expand All @@ -20,10 +19,7 @@ public AdvancedDetectorScreen(AdvancedDetectorMenu menu, Inventory inventory, Co
}

@Override
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
this.renderBackground(guiGraphics);
final int x = this.leftPos;
final int y = this.topPos;
guiGraphics.blit(BACKGROUND_TEXTURE, x, y, 0, 0, this.imageWidth, this.imageHeight);
public ResourceLocation getWidgetsTexture() {
return BACKGROUND_TEXTURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.client.gui.screen.IngameWindowScreen;
import mods.railcraft.client.gui.screen.inventory.RailcraftMenuScreen;
import mods.railcraft.network.NetworkChannel;
import mods.railcraft.network.play.SetItemDetectorAttributesMessage;
import mods.railcraft.world.inventory.detector.ItemDetectorMenu;
import mods.railcraft.world.level.block.entity.detector.ItemDetectorBlockEntity;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FastColor;
import net.minecraft.world.entity.player.Inventory;

public class ItemDetectorScreen extends AbstractContainerScreen<ItemDetectorMenu> {
public class ItemDetectorScreen extends RailcraftMenuScreen<ItemDetectorMenu> {

private static final ResourceLocation BACKGROUND_TEXTURE =
RailcraftConstants.rl("textures/gui/container/item_detector.png");
Expand All @@ -26,6 +26,11 @@ public ItemDetectorScreen(ItemDetectorMenu menu, Inventory inventory, Component
this.itemDetector = menu.getItemDetector();
}

@Override
public ResourceLocation getWidgetsTexture() {
return BACKGROUND_TEXTURE;
}

@Override
protected void init() {
super.init();
Expand Down Expand Up @@ -73,21 +78,12 @@ private void sendAttributes() {

@Override
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
this.renderBackground(guiGraphics);
final int x = this.leftPos;
final int y = this.topPos;
guiGraphics.blit(BACKGROUND_TEXTURE, x, y, 0, 0, this.imageWidth, this.imageHeight);
super.renderBg(guiGraphics, partialTicks, mouseX, mouseY);
var visible = itemDetector.getPrimaryMode() == ItemDetectorBlockEntity.PrimaryMode.FILTERED;
this.filterLeft.visible = visible;
this.filterRight.visible = visible;
}

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
super.render(guiGraphics, mouseX, mouseY, partialTick);

}

@Override
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
guiGraphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import mods.railcraft.Translations;
import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.client.gui.screen.inventory.RailcraftMenuScreen;
import mods.railcraft.world.inventory.detector.LocomotiveDetectorMenu;
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;

public class LocomotiveDetectorScreen extends AbstractContainerScreen<LocomotiveDetectorMenu> {
public class LocomotiveDetectorScreen extends RailcraftMenuScreen<LocomotiveDetectorMenu> {

private static final ResourceLocation BACKGROUND_TEXTURE =
RailcraftConstants.rl("textures/gui/container/double_slot.png");
Expand All @@ -21,11 +21,8 @@ public LocomotiveDetectorScreen(LocomotiveDetectorMenu menu, Inventory inventory
}

@Override
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
this.renderBackground(guiGraphics);
final int x = this.leftPos;
final int y = this.topPos;
guiGraphics.blit(BACKGROUND_TEXTURE, x, y, 0, 0, this.imageWidth, this.imageHeight);
public ResourceLocation getWidgetsTexture() {
return BACKGROUND_TEXTURE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package mods.railcraft.client.gui.screen.inventory.detector;

import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.client.gui.screen.inventory.RailcraftMenuScreen;
import mods.railcraft.world.inventory.detector.SheepDetectorMenu;
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;

public class SheepDetectorScreen extends AbstractContainerScreen<SheepDetectorMenu> {
public class SheepDetectorScreen extends RailcraftMenuScreen<SheepDetectorMenu> {

private static final ResourceLocation BACKGROUND_TEXTURE =
RailcraftConstants.rl("textures/gui/container/single_slot.png");
Expand All @@ -20,10 +19,7 @@ public SheepDetectorScreen(SheepDetectorMenu menu, Inventory inventory, Componen
}

@Override
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
this.renderBackground(guiGraphics);
final int x = this.leftPos;
final int y = this.topPos;
guiGraphics.blit(BACKGROUND_TEXTURE, x, y, 0, 0, this.imageWidth, this.imageHeight);
public ResourceLocation getWidgetsTexture() {
return BACKGROUND_TEXTURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import mods.railcraft.Translations;
import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.client.gui.screen.inventory.RailcraftMenuScreen;
import mods.railcraft.client.gui.widget.button.ButtonTexture;
import mods.railcraft.client.gui.widget.button.MultiButton;
import mods.railcraft.network.NetworkChannel;
Expand All @@ -10,12 +11,11 @@
import mods.railcraft.world.level.block.entity.detector.TankDetectorBlockEntity;
import net.minecraft.SharedConstants;
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;

public class TankDetectorScreen extends AbstractContainerScreen<TankDetectorMenu> {
public class TankDetectorScreen extends RailcraftMenuScreen<TankDetectorMenu> {

private static final ResourceLocation BACKGROUND_TEXTURE =
RailcraftConstants.rl("textures/gui/container/tank_detector.png");
Expand All @@ -31,6 +31,11 @@ public TankDetectorScreen(TankDetectorMenu menu, Inventory inventory, Component
this.tankDetectorBlockEntity = this.menu.getTankDetectorBlockEntity();
}

@Override
public ResourceLocation getWidgetsTexture() {
return BACKGROUND_TEXTURE;
}

@Override
public void init() {
super.init();
Expand Down Expand Up @@ -61,14 +66,6 @@ public void containerTick() {
}
}

@Override
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
this.renderBackground(guiGraphics);
final int x = this.leftPos;
final int y = this.topPos;
guiGraphics.blit(BACKGROUND_TEXTURE, x, y, 0, 0, this.imageWidth, this.imageHeight);
}

@Override
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
super.renderLabels(guiGraphics, mouseX, mouseY);
Expand Down

0 comments on commit 28f5350

Please sign in to comment.