2016-08-02 16:32:13 +02:00
/ *
* This file ( " GuiBag.java " ) is part of the Actually Additions mod for Minecraft .
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http : //ellpeck.de/actaddlicense
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015 - 2017 Ellpeck
2016-08-02 16:32:13 +02:00
* /
package de.ellpeck.actuallyadditions.mod.inventory.gui ;
2021-02-27 21:24:26 +01:00
import com.mojang.blaze3d.matrix.MatrixStack ;
2021-11-14 00:20:29 +01:00
import com.mojang.blaze3d.systems.RenderSystem ;
2023-12-20 22:02:25 +01:00
import de.ellpeck.actuallyadditions.mod.inventory.SackContainer ;
2016-08-02 16:32:13 +02:00
import de.ellpeck.actuallyadditions.mod.util.AssetUtil ;
2021-02-27 21:24:26 +01:00
import net.minecraft.client.gui.widget.button.Button ;
import net.minecraft.entity.player.PlayerInventory ;
2016-08-02 16:32:13 +02:00
import net.minecraft.util.ResourceLocation ;
2021-02-27 21:24:26 +01:00
import net.minecraft.util.text.ITextComponent ;
2016-08-02 16:32:13 +02:00
2021-12-29 03:36:23 +01:00
import javax.annotation.Nonnull ;
2023-12-20 22:02:25 +01:00
public class SackGui extends AAScreen < SackContainer > {
2016-11-19 23:12:22 +01:00
private static final ResourceLocation RES_LOC = AssetUtil . getGuiLocation ( " gui_bag " ) ;
private static final ResourceLocation RES_LOC_VOID = AssetUtil . getGuiLocation ( " gui_void_bag " ) ;
2016-08-02 16:32:13 +02:00
2023-12-20 22:02:25 +01:00
private final SackContainer container ;
2016-08-02 16:32:13 +02:00
private final boolean isVoid ;
2016-09-12 20:45:29 +02:00
private FilterSettingsGui filter ;
2021-02-27 21:24:26 +01:00
private Button buttonAutoInsert ;
2016-08-02 16:32:13 +02:00
2023-12-20 22:02:25 +01:00
public SackGui ( SackContainer container , PlayerInventory inventory , ITextComponent title ) {
2021-12-29 03:36:23 +01:00
super ( container , inventory , title ) ;
2021-08-22 17:09:06 +02:00
this . imageWidth = 176 ;
this . imageHeight = 90 + 86 ;
2023-03-16 00:17:57 +01:00
this . isVoid = false ; //TODO fix later
2016-08-02 16:32:13 +02:00
this . container = container ;
}
@Override
2021-03-01 20:14:50 +01:00
public void init ( ) {
super . init ( ) ;
2016-08-02 16:32:13 +02:00
2023-03-16 00:17:57 +01:00
this . filter = new FilterSettingsGui ( this . container . filter , this . leftPos + 138 , this . topPos + 10 , this . buttons ) ;
2021-11-21 17:31:57 +01:00
//
// this.buttonAutoInsert = new Button(0, this.leftPos - 21, this.topPos + 8, 20, 20, (this.container.autoInsert
// ? TextFormatting.DARK_GREEN
// : TextFormatting.RED) + "I");
2023-03-16 00:17:57 +01:00
//this.addButton(this.buttonAutoInsert);
2016-08-02 16:32:13 +02:00
}
2021-11-21 17:31:57 +01:00
// @Override
// protected void actionPerformed(Button button) throws IOException {
// CompoundNBT data = new CompoundNBT();
// data.putInt("ButtonID", button.id);
// data.putInt("PlayerID", Minecraft.getInstance().player.getId());
// data.putInt("WorldID", Minecraft.getInstance().level.provider.getDimension());
// PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER));
// }
2016-08-02 16:32:13 +02:00
@Override
2021-11-14 00:20:29 +01:00
public void tick ( ) {
super . tick ( ) ;
2021-03-01 20:55:50 +01:00
this . filter . tick ( ) ;
2016-08-02 16:32:13 +02:00
2021-11-14 00:20:29 +01:00
//this.buttonAutoInsert.displayString = (this.container.autoInsert
// ? TextFormatting.DARK_GREEN
// : TextFormatting.RED) + "I";
2016-08-02 16:32:13 +02:00
}
2021-11-21 17:31:57 +01:00
/ * @Override
2019-05-02 09:10:29 +02:00
public void drawGuiContainerForegroundLayer ( int x , int y ) {
2021-08-22 17:09:06 +02:00
AssetUtil . displayNameString ( this . font , this . imageWidth , - 10 , StringUtil . localize ( " container. " + ActuallyAdditions . MODID + " . " + ( this . isVoid
2021-02-26 22:15:48 +01:00
? " voidBag "
: " bag " ) + " .name " ) ) ;
2021-11-21 17:31:57 +01:00
} * /
2016-08-02 16:32:13 +02:00
@Override
2021-12-29 03:36:23 +01:00
public void render ( @Nonnull MatrixStack stack , int mouseX , int mouseY , float partialTicks ) {
2021-02-27 21:24:26 +01:00
super . render ( stack , mouseX , mouseY , partialTicks ) ;
2023-03-16 00:17:57 +01:00
this . filter . drawHover ( stack , mouseX , mouseY ) ;
2016-08-02 16:32:13 +02:00
2021-11-21 17:31:57 +01:00
/ * if ( this . buttonAutoInsert . isMouseOver ( ) ) {
2019-02-27 19:53:05 +01:00
List < String > text = new ArrayList < > ( ) ;
2021-02-26 22:15:48 +01:00
text . add ( TextFormatting . BOLD + " Auto-Insert " + ( this . container . autoInsert
? " On "
: " Off " ) ) ;
2021-02-27 21:24:26 +01:00
text . addAll ( this . font . listFormattedStringToWidth ( " Turn this on to make items that get picked up automatically go into the bag. " , 200 ) ) ;
text . addAll ( this . font . listFormattedStringToWidth ( TextFormatting . GRAY + " " + TextFormatting . ITALIC + " Note that this WON'T work when you are holding the bag in your hand. " , 200 ) ) ;
2021-08-22 17:09:06 +02:00
this . renderToolTip ( stack , text , mouseX , mouseY , this . getMinecraft ( ) . font ) ;
2021-11-21 17:31:57 +01:00
} * /
2016-08-02 16:32:13 +02:00
}
2021-02-27 21:24:26 +01:00
@Override
2021-08-22 17:09:06 +02:00
protected void renderBg ( MatrixStack matrixStack , float partialTicks , int x , int y ) {
2021-03-01 20:55:50 +01:00
RenderSystem . color4f ( 1 . 0F , 1 . 0F , 1 . 0F , 1 . 0F ) ;
2021-02-27 21:24:26 +01:00
2021-08-22 17:09:06 +02:00
this . getMinecraft ( ) . getTextureManager ( ) . bind ( AssetUtil . GUI_INVENTORY_LOCATION ) ;
this . blit ( matrixStack , this . leftPos , this . topPos + 90 , 0 , 0 , 176 , 86 ) ;
2021-02-27 21:24:26 +01:00
2021-08-22 17:09:06 +02:00
this . getMinecraft ( ) . getTextureManager ( ) . bind ( this . isVoid
2021-02-27 21:24:26 +01:00
? RES_LOC_VOID
: RES_LOC ) ;
2021-08-22 17:09:06 +02:00
this . blit ( matrixStack , this . leftPos , this . topPos , 0 , 0 , 176 , 90 ) ;
2021-02-27 21:24:26 +01:00
}
2021-02-26 22:15:48 +01:00
}