mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-05-18 23:51:23 +02:00
87601c1e6e
Added the void sack recipe. Fixed the void sack.
89 lines
3.2 KiB
Java
89 lines
3.2 KiB
Java
/*
|
|
* This file ("GuiRangedCollector.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
|
|
*
|
|
* © 2015-2017 Ellpeck
|
|
*/
|
|
|
|
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector;
|
|
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.GuiGraphics;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.player.Inventory;
|
|
import net.neoforged.api.distmarker.Dist;
|
|
import net.neoforged.api.distmarker.OnlyIn;
|
|
import net.neoforged.neoforge.network.PacketDistributor;
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public class GuiRangedCollector extends AAScreen<ContainerRangedCollector> {
|
|
|
|
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_ranged_collector");
|
|
private final TileEntityRangedCollector collector;
|
|
|
|
private FilterSettingsGui filter;
|
|
|
|
public GuiRangedCollector(ContainerRangedCollector container, Inventory inventory, Component title) {
|
|
super(container, inventory, title);
|
|
this.collector = container.collector;
|
|
this.imageWidth = 176;
|
|
this.imageHeight = 86 + 86;
|
|
}
|
|
|
|
@Override
|
|
public void init() {
|
|
super.init();
|
|
|
|
this.filter = new FilterSettingsGui(this.collector.filter, this.leftPos + 3, this.topPos + 6, true, this::addRenderableWidget, this::buttonClicked, 0);
|
|
}
|
|
|
|
@Override
|
|
public void render(@Nonnull GuiGraphics guiGraphics, int x, int y, float f) {
|
|
super.render(guiGraphics, x, y, f);
|
|
|
|
this.filter.drawHover(guiGraphics, x, y);
|
|
}
|
|
|
|
@Override
|
|
public void containerTick() {
|
|
super.containerTick();
|
|
|
|
this.filter.tick();
|
|
}
|
|
|
|
@Override
|
|
public void renderBg(GuiGraphics guiGraphics, float f, int x, int y) {
|
|
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
|
|
|
|
guiGraphics.blit(AssetUtil.GUI_INVENTORY_LOCATION, this.leftPos, this.topPos + 86, 0, 0, 176, 86);
|
|
|
|
guiGraphics.blit(RES_LOC, this.leftPos, this.topPos, 0, 0, 176, 86);
|
|
}
|
|
|
|
public void buttonClicked(int id) {
|
|
CompoundTag data = new CompoundTag();
|
|
data.putInt("ButtonID", id);
|
|
data.putInt("PlayerID", Minecraft.getInstance().player.getId());
|
|
data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString());
|
|
data.putInt("X", this.collector.getBlockPos().getX());
|
|
data.putInt("Y", this.collector.getBlockPos().getY());
|
|
data.putInt("Z", this.collector.getBlockPos().getZ());
|
|
PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
|
}
|
|
|
|
}
|