-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/fureniku/metropolis/client/screens/MetroScreenContainerBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.fureniku.metropolis.client.screens; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
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.minecraft.world.inventory.AbstractContainerMenu; | ||
|
||
public abstract class MetroScreenContainerBase<T extends AbstractContainerMenu> extends AbstractContainerScreen<T> { | ||
|
||
private final ScreenImage _background; | ||
|
||
public MetroScreenContainerBase(T menu, Inventory inventory, Component component, ScreenImage background) { | ||
super(menu, inventory, component); | ||
_background = background; | ||
this.imageWidth = background.getWidth(); | ||
this.imageHeight = background.getHeight(); | ||
} | ||
|
||
protected abstract ResourceLocation getBackground(); | ||
|
||
@Override | ||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) { | ||
this.renderBackground(graphics); | ||
super.render(graphics, mouseX, mouseY, partialTick); | ||
this.renderTooltip(graphics, mouseX, mouseY); | ||
} | ||
|
||
@Override | ||
protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) { | ||
RenderSystem.setShaderTexture(0, getBackground()); | ||
graphics.blit(_background.getResourceLocation(), this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); | ||
} | ||
|
||
@Override | ||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { | ||
super.renderLabels(graphics, mouseX, mouseY); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/fureniku/metropolis/client/screens/ScreenImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.fureniku.metropolis.client.screens; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public class ScreenImage { | ||
|
||
private ResourceLocation _resourceLocation; | ||
private int _startLeft; | ||
private int _startTop; | ||
private int _width; | ||
private int _height; | ||
|
||
public ScreenImage(ResourceLocation loc, int startLeft, int startTop, int width, int height) { | ||
_resourceLocation = loc; | ||
_startLeft = startLeft; | ||
_startTop = startTop; | ||
_width = width; | ||
_height = height; | ||
} | ||
|
||
public ResourceLocation getResourceLocation() { | ||
return _resourceLocation; | ||
} | ||
|
||
public int getStartLeft() { | ||
return _startLeft; | ||
} | ||
|
||
public int getStartTop() { | ||
return _startTop; | ||
} | ||
|
||
public int getWidth() { | ||
return _width; | ||
} | ||
|
||
public int getHeight() { | ||
return _height; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters