Skip to content

Commit

Permalink
updated to mc 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Globox1997 committed Jun 22, 2024
1 parent c3da86c commit 0b5ba39
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
### Fixed:
-
### Changed:
- Updated to mc 1.20.6
- Updated to mc 1.21
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.jvmargs = -Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

# Mod Properties
mod_version = 1.2.15
maven_group = net.backslot
archives_base_name = backslot

# Dependencies
fabric_version=0.97.8+1.20.6
cloth_config_version=14.0.126
mod_menu_version=10.0.0-beta.1
fabric_version=0.100.3+1.21
cloth_config_version=15.0.127
mod_menu_version=11.0.0
amecs_version=1.5.5+mc1.20.2
6 changes: 3 additions & 3 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jdk:
- openjdk17
- openjdk21
before_install:
- sdk install java 17.0.3-tem
- sdk use java 17.0.3-tem
- sdk install java 21.0.0-tem
- sdk use java 21.0.0-tem
6 changes: 2 additions & 4 deletions src/main/java/net/backslot/BackSlotMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class BackSlotMain implements ModInitializer {

public static BackSlotConfig CONFIG = new BackSlotConfig();

public static final TagKey<Item> BACKSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, new Identifier("backslot", "backslot_items"));
public static final TagKey<Item> BELTSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, new Identifier("backslot", "beltslot_items"));
public static final TagKey<Item> BACKSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("backslot", "backslot_items"));
public static final TagKey<Item> BELTSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("backslot", "beltslot_items"));

public static final boolean isMedievalWeaponsLoaded = FabricLoader.getInstance().isModLoaded("medievalweapons");
public static final boolean isMcdwLoaded = FabricLoader.getInstance().isModLoaded("mcdw");
Expand All @@ -30,6 +30,4 @@ public void onInitialize() {
BackSlotServerPacket.init();
}



}
4 changes: 2 additions & 2 deletions src/main/java/net/backslot/client/key/SwitchKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class SwitchKey {

public static void init() {

backSlotKeyBind = new AmecsKeyBinding(new Identifier("backslot", "switch_backslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers());
beltSlotKeyBind = new AmecsKeyBinding(new Identifier("backslot", "switch_beltslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers().setShift(true));
backSlotKeyBind = new AmecsKeyBinding(Identifier.of("backslot", "switch_backslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers());
beltSlotKeyBind = new AmecsKeyBinding(Identifier.of("backslot", "switch_beltslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers().setShift(true));
KeyBindingHelper.registerKeyBinding(backSlotKeyBind);
KeyBindingHelper.registerKeyBinding(beltSlotKeyBind);
ClientTickEvents.END_CLIENT_TICK.register(client -> {
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/net/backslot/client/sprite/BackSlotSprites.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
@Environment(EnvType.CLIENT)
public class BackSlotSprites {

public static final Identifier EMPTY_BACK_SLOT_TEXTURE = new Identifier("backslot", "gui/empty_back_slot");
public static final Identifier EMPTY_BELT_SLOT_TEXTURE = new Identifier("backslot", "gui/empty_belt_slot");
public static final Identifier EMPTY_BACK_SLOT_TEXTURE = Identifier.of("backslot", "gui/empty_back_slot");
public static final Identifier EMPTY_BELT_SLOT_TEXTURE = Identifier.of("backslot", "gui/empty_belt_slot");

public static final Identifier HOTBAR_BACK_SLOT_TEXTURE = new Identifier("backslot", "textures/gui/hotbar_back_slot.png");
public static final Identifier HOTBAR_BELT_SLOT_TEXTURE = new Identifier("backslot", "textures/gui/hotbar_back_slot.png");
public static final Identifier HOTBAR_BACK_SLOT_TEXTURE = Identifier.of("backslot", "textures/gui/hotbar_back_slot.png");
public static final Identifier HOTBAR_BELT_SLOT_TEXTURE = Identifier.of("backslot", "textures/gui/hotbar_back_slot.png");

public static void init() {
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
HudRenderCallback.EVENT.register((drawContext, tickCounter) -> {
MinecraftClient client = MinecraftClient.getInstance();
if (!client.options.hudHidden) {
PlayerEntity playerEntity = client.player;
Expand All @@ -41,14 +41,16 @@ public static void init() {
RenderSystem.enableBlend();
drawContext.drawTexture(HOTBAR_BELT_SLOT_TEXTURE, i - 90 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p - 3 + BackSlotMain.CONFIG.hudSlotY, 0, 0, 22, 22, 22, 22);

renderHotbarItem(drawContext, client, i - 87 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickDelta, playerEntity, backSlotStack, 0);
renderHotbarItem(drawContext, client, i - 87 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickCounter.getTickDelta(true), playerEntity,
backSlotStack, 0);
}
if (!beltSlotStack.isEmpty()) {
// Required
RenderSystem.enableBlend();
drawContext.drawTexture(HOTBAR_BACK_SLOT_TEXTURE, i - 112 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p - 3 + BackSlotMain.CONFIG.hudSlotY, 0, 0, 22, 22, 22, 22);

renderHotbarItem(drawContext, client, i - 109 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickDelta, playerEntity, beltSlotStack, 0);
renderHotbarItem(drawContext, client, i - 109 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickCounter.getTickDelta(true), playerEntity,
beltSlotStack, 0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.At;

import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.ExperienceOrbEntity;
Expand All @@ -21,8 +20,12 @@ public class ExperienceOrbEntityMixin {
private Map.Entry<EquipmentSlot, ItemStack> repairPlayerGearsMixin(Map.Entry<EquipmentSlot, ItemStack> original, PlayerEntity player, int amount) {
ItemStack backStack = player.getInventory().getStack(41);
ItemStack beltStack = player.getInventory().getStack(42);
boolean backSlotRepairable = !backStack.isEmpty() && backStack.isDamaged() && EnchantmentHelper.getLevel(Enchantments.MENDING, backStack) > 0;
boolean beltSlotRepairable = !beltStack.isEmpty() && beltStack.isDamaged() && EnchantmentHelper.getLevel(Enchantments.MENDING, beltStack) > 0;
boolean backSlotRepairable = !backStack.isEmpty() && backStack.isDamaged()
&& beltStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.MENDING.getRegistry()));
boolean beltSlotRepairable = !beltStack.isEmpty() && beltStack.isDamaged()
&& beltStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.MENDING.getRegistry()));

beltStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.MENDING.getRegistry()));
if (backSlotRepairable || beltSlotRepairable) {
if (original != null) {
if (backSlotRepairable && beltSlotRepairable) {
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/net/backslot/mixin/PlayerScreenHandlerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.screen.AbstractRecipeScreenHandler;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
Expand All @@ -22,10 +23,10 @@
import net.backslot.network.SwitchPacketReceiver;
import net.fabricmc.api.Environment;
import net.fabricmc.api.EnvType;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;

@Mixin(value = PlayerScreenHandler.class, priority = 999)
public abstract class PlayerScreenHandlerMixin extends AbstractRecipeScreenHandler<CraftingInventory> {
public abstract class PlayerScreenHandlerMixin extends AbstractRecipeScreenHandler<CraftingRecipeInput, CraftingRecipe> {
private static boolean changeArrangement = BackSlotMain.CONFIG.changeSlotArrangement;

public PlayerScreenHandlerMixin(ScreenHandlerType<PlayerScreenHandler> screenHandlerType, int i) {
Expand Down Expand Up @@ -62,7 +63,9 @@ public boolean canInsert(ItemStack stack) {
@Override
public boolean canTakeItems(PlayerEntity playerEntity) {
ItemStack itemStack = this.getStack();
return !itemStack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemStack) ? false : super.canTakeItems(playerEntity);
return !itemStack.isEmpty() && !playerEntity.isCreative()
&& itemStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.BINDING_CURSE.getRegistry())) ? false
: super.canTakeItems(playerEntity);
}

@Environment(EnvType.CLIENT)
Expand All @@ -87,7 +90,9 @@ public boolean canInsert(ItemStack stack) {
@Override
public boolean canTakeItems(PlayerEntity playerEntity) {
ItemStack itemStack = this.getStack();
return !itemStack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemStack) ? false : super.canTakeItems(playerEntity);
return !itemStack.isEmpty() && !playerEntity.isCreative()
&& itemStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.BINDING_CURSE.getRegistry())) ? false
: super.canTakeItems(playerEntity);
}

@Environment(EnvType.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Mixin(InventoryScreen.class)
public abstract class InventoryScreenMixin extends AbstractInventoryScreen<PlayerScreenHandler> implements RecipeBookProvider {

private static final Identifier BACK_TEXTURE = new Identifier("backslot", "textures/gui/blank.png");
private static final Identifier BACK_TEXTURE = Identifier.of("backslot", "textures/gui/blank.png");
@Shadow
@Mutable
@Final
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/backslot/network/SwitchPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public record SwitchPacket(int slotId) implements CustomPayload {

public static final CustomPayload.Id<SwitchPacket> PACKET_ID = new CustomPayload.Id<>(new Identifier("backslot", "switch_item"));
public static final CustomPayload.Id<SwitchPacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of("backslot", "switch_item"));

public static final PacketCodec<RegistryByteBuf, SwitchPacket> PACKET_CODEC = PacketCodec.of((value, buf) -> {
buf.writeInt(value.slotId);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/backslot/network/VisibilityPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public record VisibilityPacket(int entityId, int slotId, ItemStack itemStack) implements CustomPayload {

public static final CustomPayload.Id<VisibilityPacket> PACKET_ID = new CustomPayload.Id<>(new Identifier("backslot", "visibility_packet"));
public static final CustomPayload.Id<VisibilityPacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of("backslot", "visibility_packet"));

// public static final PacketCodec<RegistryByteBuf, VisibilityPacket> PACKET_CODEC = PacketCodec.of((value, buf) -> {
// buf.writeInt(value.entityId);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/backslot/sound/BackSlotSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import net.minecraft.util.Identifier;

public class BackSlotSounds {
public static final Identifier PACK_UP_ITEM = new Identifier("backslot:pack_up_item");
public static final Identifier PACK_UP_ITEM = Identifier.of("backslot:pack_up_item");
public static SoundEvent PACK_UP_ITEM_EVENT = SoundEvent.of(PACK_UP_ITEM);
public static final Identifier SHEATH_SWORD = new Identifier("backslot:sheath_sword");
public static final Identifier SHEATH_SWORD = Identifier.of("backslot:sheath_sword");
public static SoundEvent SHEATH_SWORD_EVENT = SoundEvent.of(SHEATH_SWORD);

public static void init() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"backslot.mixins.json"
],
"depends": {
"java": ">=17",
"java": ">=21",
"minecraft": ">=${minecraft_version}",
"fabric-api": ">=${fabric_version}",
"fabricloader": ">=${loader_version}",
Expand Down

0 comments on commit 0b5ba39

Please sign in to comment.