small steps forward

This commit is contained in:
2020-08-21 22:19:13 +02:00
parent f4550898a2
commit 737c4bd31a
3 changed files with 27 additions and 5 deletions

View File

@ -48,7 +48,7 @@ public class BackpackInventory implements Inventory {
public DefaultedList<ItemStack> getList() {
return stacks;
}
@Override
public void clear() {
stacks.clear();

View File

@ -1,5 +1,8 @@
package de.jottyfan.minecraft.quickiefabric.container;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.mojang.blaze3d.platform.GlStateManager;
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
@ -14,9 +17,15 @@ import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
/**
*
* @author jotty
*
*/
@Environment(EnvType.CLIENT)
public class BackpackScreen extends HandledScreen<BackpackScreenHandler>
implements ScreenHandlerProvider<BackpackScreenHandler> {
private final static Logger LOGGER = LogManager.getLogger(BackpackScreen.class);
private final static Identifier TEXTURE = new Identifier(RegistryManager.QUICKIEFABRIC,
"textures/gui/backpack.png");
private final static Identifier SLOT_TEXTURE = new Identifier(RegistryManager.QUICKIEFABRIC,
@ -33,7 +42,7 @@ public class BackpackScreen extends HandledScreen<BackpackScreenHandler>
super.init();
this.x = (this.width - this.containerWidth) / 2;
}
private void drawSlots(MatrixStack matrices, int guiX, int guiY) {
this.client.getTextureManager().bindTexture(SLOT_TEXTURE);
for (int y = 0; y < (ItemBackpack.SLOTSIZE / 9); y++)

View File

@ -1,8 +1,11 @@
package de.jottyfan.minecraft.quickiefabric.container;
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ScreenHandler;
@ -43,6 +46,10 @@ public class BackpackScreenHandler extends ScreenHandler {
public PlayerEntity getPlayer() {
return this.player;
}
public Inventory getInventory() {
return backpackInventory;
}
@Override
public boolean canUse(PlayerEntity playerEntity) {
@ -57,13 +64,13 @@ public class BackpackScreenHandler extends ScreenHandler {
}
@Override
public ItemStack transferSlot(PlayerEntity player, int slotNum) {
public ItemStack transferSlot(PlayerEntity player, int slotIndex) {
ItemStack copy = ItemStack.EMPTY;
Slot chosenSlot = this.slots.get(slotNum);
Slot chosenSlot = this.slots.get(slotIndex);
if (chosenSlot != null && chosenSlot.hasStack()) {
ItemStack chosenStack = chosenSlot.getStack();
copy = chosenStack.copy();
if (slotNum < backpackInventory.size()) {
if (slotIndex < backpackInventory.size()) {
if (!this.insertItem(chosenStack, backpackInventory.size(), this.slots.size(), true)) {
return ItemStack.EMPTY;
}
@ -78,4 +85,10 @@ public class BackpackScreenHandler extends ScreenHandler {
}
return copy;
}
@Environment(EnvType.CLIENT)
public int getRows() {
return 6;
}
}