Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//file:noinspection All

plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -37,6 +37,10 @@ java {
withSourcesJar()
}

loom {
accessWidenerPath = file("src/main/resources/biginv.accesswidener")
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.jvmargs = -Xmx1G

biginv_version = 0.1.3

minecraft_version=1.18.2
mappings_version=1.18.2+build.3
loader_version=0.14.4
minecraft_version=1.19.4
mappings_version=1.19.4+build.2
loader_version=0.14.19

fapi_version=0.51.1+1.18.2
fapi_version=0.78.0+1.19.4
54 changes: 42 additions & 12 deletions src/main/java/com/sollyw/biginv/BigInvScreenHandlerHelper.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.sollyw.biginv;

import com.mojang.datafixers.util.Pair;
import com.sollyw.biginv.mixin.SlotAccessor;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.Identifier;

public class BigInvScreenHandlerHelper {
public static final EquipmentSlot[] EQUIPMENT_SLOT_ORDER = {
Expand Down Expand Up @@ -36,28 +43,51 @@ public static Slot[] createSlots(ScreenHandler handler, PlayerInventory playerIn
-9999));
}

slots[112] = handlerX.biginv$addSlot(SlotConstructors.OFFHAND.init(
playerInventory,
112,
-9999,
-9999));

slots[112] = handlerX.biginv$addSlot(new Slot(playerInventory, 112, -9999, -9999) {
public void setStack(ItemStack stack) {
PlayerScreenHandler.onEquipStack(playerInventory.player, EquipmentSlot.OFFHAND, stack, this.getStack()); // I need to use PlayerEntity owner, not null
super.setStack(stack);
}
public Pair<Identifier, Identifier> getBackgroundSprite() {
return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT);
}
});

for(int i = 0; i < 4; ++i) {
int index = 111 - i;
slots[index] = handlerX.biginv$addSlot(SlotConstructors.ARMOUR.init(
playerInventory,
index,
-9999,
-9999,
EQUIPMENT_SLOT_ORDER[i]
));
final EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_ORDER[i];
slots[index] = handlerX.biginv$addSlot(new Slot(playerInventory, index, -9999, -9999) {
public void setStack(ItemStack stack) {
PlayerScreenHandler.onEquipStack(playerInventory.player, equipmentSlot, stack, this.getStack());
super.setStack(stack);
}

public int getMaxItemCount() {
return 1;
}

public boolean canInsert(ItemStack stack) {
return equipmentSlot == MobEntity.getPreferredEquipmentSlot(stack);
}

public boolean canTakeItems(PlayerEntity playerEntity) {
ItemStack itemStack = this.getStack();
return (itemStack.isEmpty() || playerEntity.isCreative() || !EnchantmentHelper.hasBindingCurse(itemStack)) && super.canTakeItems(playerEntity);
}

public Pair<Identifier, Identifier> getBackgroundSprite() {
return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_ARMOR_SLOT_TEXTURES[equipmentSlot.getEntitySlotId()]);
}
});
}

handlerX.biginv$setModStage(BigInvModStage.FINISHED);
return slots;
}

public static void positionSlots(Slot[] slots, int offsetX, int offsetY, int armourOffsetX, int armourOffsetY) {

for(int row = 0; row < 5; ++row) {
for(int col = 0; col < 18; ++col) {
move(slots,
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/sollyw/biginv/BigInvScreenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BigInvScreenHelper {

public static void patchScreen(MatrixStack matrices, int x, int y, int backgroundWidth, int backgroundHeight,
int mouseX, int mouseY, LivingEntity entity, RightmostBehaviour rightmostBehaviour) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShaderTexture(0, MOD_BACKGROUND);

Expand Down Expand Up @@ -124,12 +124,12 @@ public static void patchScreen(MatrixStack matrices, int x, int y, int backgroun
if (entity != null) {
int x0 = x - 49;
int y0 = y + backgroundHeight - 91;
InventoryScreen.drawEntity(
InventoryScreen.drawEntity(matrices,
x0,
y0,
30,
x0 - mouseX,
y0 - 50 - mouseY,
(float)(x0 - mouseX),
(float)(y0 - 50 - mouseY),
entity);
}
}
Expand Down
39 changes: 0 additions & 39 deletions src/main/java/com/sollyw/biginv/SlotConstructors.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

@Mixin(CraftingScreenHandler.class)
public abstract class CraftingScreenHandlerMixin {
@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = @Constant(intValue = 46))
private int invEnd(int constant) {
return 118;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = @Constant(intValue = 37))
private int hotbarStart(int constant) {
return 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Mixin(ForgingScreenHandler.class)
public abstract class ForgingScreenHandlerMixin {
@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = @Constant(intValue = 39))
private int value(int constant) {
return 111;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.sollyw.biginv.BigInvModInfo;
import com.sollyw.biginv.ScreenHandlerOverrides;
import com.sollyw.biginv.ScreenHandlerExt;
import net.minecraft.registry.Registries;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.util.registry.Registry;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(GenericContainerScreenHandler.class)
Expand All @@ -13,7 +13,7 @@ public abstract class GenericContainerScreenHandlerMixin implements ScreenHandle
public BigInvModInfo biginv$getModInfo() {
if (this.biginv$getType() != null) {
return ScreenHandlerOverrides.SCREEN_HANDLER_OVERRIDES.getOrDefault(
Registry.SCREEN_HANDLER.getId(this.biginv$getType()),
Registries.SCREEN_HANDLER.getId(this.biginv$getType()),
BigInvModInfo.GENERIC_CONTAINER);
}
return BigInvModInfo.GENERIC_CONTAINER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.sollyw.biginv.BigInvModInfo;
import com.sollyw.biginv.ScreenHandlerOverrides;
import com.sollyw.biginv.ScreenHandlerExt;
import net.minecraft.registry.Registries;
import net.minecraft.screen.MerchantScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.registry.Registry;
import net.minecraft.village.MerchantInventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -30,7 +30,7 @@ private Slot addSlot(Slot par1) {
public BigInvModInfo biginv$getModInfo() {
if (this.biginv$getType() != null) {
return ScreenHandlerOverrides.SCREEN_HANDLER_OVERRIDES.getOrDefault(
Registry.SCREEN_HANDLER.getId(this.biginv$getType()),
Registries.SCREEN_HANDLER.getId(this.biginv$getType()),
BigInvModInfo.MERCHANT);
}
return BigInvModInfo.MERCHANT;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static boolean isInHotbar(int slot) {
return slot >= 108 && slot <= 126;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = {
@Constant(intValue = 9,
ordinal = 1),
Expand All @@ -41,7 +41,7 @@ private int mainInvStart(int value) {
return 5;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = {
@Constant(intValue = 36,
ordinal = 0),
Expand All @@ -55,7 +55,7 @@ private int mainInvEndHotbarStart(int value) {
return 95;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = {
@Constant(intValue = 45,
ordinal = 1),
Expand All @@ -73,7 +73,7 @@ private int hotbarEndArmourStart(int value) {
return 113;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = {
@Constant(intValue = 8,
ordinal = 0),
Expand All @@ -83,7 +83,7 @@ private int armourLast(int value) {
return 116;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = {
@Constant(intValue = 9,
ordinal = 2),
Expand All @@ -95,7 +95,7 @@ private int armourEndOffhandStart(int value) {
return 117;
}

@ModifyConstant(method = "transferSlot",
@ModifyConstant(method = "quickMove",
constant = @Constant(intValue = 46,
ordinal = 0))
private int offhandEnd(int value) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/sollyw/biginv/mixin/ScreenHandlerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.sollyw.biginv.*;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.registry.Registries;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -81,7 +81,7 @@ private void addSlot(Slot slot, CallbackInfoReturnable<Slot> cir) {
public BigInvModInfo biginv$getModInfo() {
if (this.type != null) {
return ScreenHandlerOverrides.SCREEN_HANDLER_OVERRIDES.getOrDefault(
Registry.SCREEN_HANDLER.getId(this.type),
Registries.SCREEN_HANDLER.getId(this.type),
BigInvModInfo.DEFAULT);
}

Expand All @@ -95,6 +95,7 @@ private void addSlot(Slot slot, CallbackInfoReturnable<Slot> cir) {

@Override
public void biginv$positionSlots(int offsetX, int offsetY, int armourOffsetX, int armourOffsetY) {

if (this.bigInvSlots != null) {
BigInvScreenHandlerHelper.positionSlots(this.bigInvSlots, offsetX, offsetY, armourOffsetX, armourOffsetY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public abstract class ClientPlayerInteractionManagerMixin {
public boolean hasCreativeInventory() {
return false;
}
}
}
Loading