Skip to content

Commit

Permalink
updated to mc 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Globox1997 committed May 9, 2024
1 parent ed510de commit 9a2ac88
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
17
21
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 17
- name: set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'adopt-hotspot'
java-version: 17
java-version: 21
cache: 'gradle'

- name: make gradle wrapper executable
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Added:
-
### Fixed:
- Fixed slot arrangement config
-
### Changed:
-
- Updated to mc 1.20.6
34 changes: 21 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -8,14 +8,15 @@ version = project.mod_version
group = project.maven_group

repositories {
maven { url 'https://jitpack.io' }
maven { url "https://maven.jamieswhiteshirt.com/libs-release/" }
// maven { url 'https://jitpack.io' }
// maven { url "https://maven.jamieswhiteshirt.com/libs-release/" }
maven { url "https://maven.siphalor.de/" }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
maven { url "https://www.cursemaven.com" }
maven { url = uri("https://storage.googleapis.com/devan-maven/") }
maven { url = uri("https://ueaj.dev/maven") }
maven { url "https://api.modrinth.com/maven" }
// maven { url "https://www.cursemaven.com" }
// maven { url = uri("https://storage.googleapis.com/devan-maven/") }
// maven { url = uri("https://ueaj.dev/maven") }
}

dependencies {
Expand All @@ -37,16 +38,22 @@ dependencies {
exclude(group: "net.fabricmc.fabric-api")
}
// Medieval Weapons
modCompileOnly ('maven.modrinth:medievalweapons:1.4.8+1.20.1'){
exclude(group: "net.fabricmc.fabric-api")
}
// modCompileOnly ('com.github.Globox1997:MedievalWeapons:1.19-SNAPSHOT') {
// exclude(group: "net.fabricmc.fabric-api")
// }
modCompileOnly("curse.maven:medievalweapons-411400:4427110") {
exclude(group: "net.fabricmc.fabric-api")
}
// modCompileOnly("curse.maven:medievalweapons-411400:4427110") {
// exclude(group: "net.fabricmc.fabric-api")
// }
// Dungeon Weapons
modCompileOnly("curse.maven:mcdw-407311:3918562") {
modCompileOnly ('maven.modrinth:mcdw:9.0.4'){
exclude(group: "net.fabricmc.fabric-api")
}
// modCompileOnly("curse.maven:mcdw-407311:3918562") {
// exclude(group: "net.fabricmc.fabric-api")
// }
//modCompileOnly "curse.maven:enchanthelper-434579:3347061"
//modCompileOnly "wraith.EnchantGiver:wraith-enchant_giver-1.3.0"
// Charm
Expand All @@ -66,14 +73,14 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand All @@ -85,6 +92,7 @@ jar {
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
14 changes: 7 additions & 7 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.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10

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

# Dependencies
fabric_version=0.86.0+1.20.1
cloth_config_version=11.0.99
mod_menu_version=7.0.0
amecs_version=1.5.0+mc1.20-pre1
fabric_version=0.97.8+1.20.6
cloth_config_version=14.0.126
mod_menu_version=10.0.0-beta.1
amecs_version=1.5.5+mc1.20.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 3 additions & 7 deletions src/main/java/net/backslot/client/key/SwitchKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import org.lwjgl.glfw.GLFW;

import io.netty.buffer.Unpooled;
import net.backslot.network.BackSlotServerPacket;
import net.backslot.network.SwitchPacket;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
import net.minecraft.util.Identifier;
import de.siphalor.amecs.api.AmecsKeyBinding;
import de.siphalor.amecs.api.KeyModifiers;
Expand Down Expand Up @@ -39,9 +37,7 @@ public static void init() {
}

public static void syncSlotSwitchItem(MinecraftClient client, int slot) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(slot);
client.getNetworkHandler().sendPacket(new CustomPayloadC2SPacket(BackSlotServerPacket.SWITCH_PACKET, buf));
ClientPlayNetworking.send(new SwitchPacket(slot));
}

}
34 changes: 16 additions & 18 deletions src/main/java/net/backslot/client/sprite/BackSlotSprites.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
@Environment(EnvType.CLIENT)
public class BackSlotSprites {

// assets/minecraft/atlases/blocks.json
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");

private static final Identifier WIDGETS_TEXTURE = new Identifier("textures/gui/widgets.png");
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 void init() {
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
Expand All @@ -32,25 +32,23 @@ public static void init() {
ItemStack backSlotStack = playerEntity.getInventory().getStack(41);
ItemStack beltSlotStack = playerEntity.getInventory().getStack(42);

if (!backSlotStack.isEmpty() || !beltSlotStack.isEmpty()) {
int i = drawContext.getScaledWindowWidth() / 2;
int p = drawContext.getScaledWindowHeight() - 19;
int leftHandX = playerEntity.getMainArm().getOpposite() == Arm.LEFT ? -52 : -30;

int i = drawContext.getScaledWindowWidth() / 2;
int p = drawContext.getScaledWindowHeight() - 16 - 3;
Arm arm = playerEntity.getMainArm().getOpposite();

// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
if (!backSlotStack.isEmpty()) {
// Required
RenderSystem.enableBlend();
// RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
drawContext.drawTexture(WIDGETS_TEXTURE, i - 91 + (arm == Arm.LEFT ? -29 : 0) + BackSlotMain.CONFIG.hudSlotX,
drawContext.getScaledWindowHeight() - 23 + BackSlotMain.CONFIG.hudSlotY, 24, 22, 29, 24);
renderHotbarItem(drawContext, client, i - 91 + (arm == Arm.LEFT ? -26 : 0) + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickDelta, playerEntity,
backSlotStack, 0);
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);
}
if (!beltSlotStack.isEmpty()) {
// Required
RenderSystem.enableBlend();
// RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
drawContext.drawTexture(WIDGETS_TEXTURE, i - 112 + (arm == Arm.LEFT ? -29 : 0) + BackSlotMain.CONFIG.hudSlotX,
drawContext.getScaledWindowHeight() - 23 + BackSlotMain.CONFIG.hudSlotY, 24, 22, 29, 24);
renderHotbarItem(drawContext, client, i - 112 + (arm == Arm.LEFT ? -26 : 0) + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickDelta, playerEntity,
beltSlotStack, 0);
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);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/backslot/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
public class EntityMixin {

@Inject(method = "getItemsEquipped", at = @At("RETURN"), cancellable = true)
public void getItemsEquippedWithBackSlotItems(CallbackInfoReturnable<Iterable<ItemStack>> info) {
Entity entity = (Entity) (Object) this;
if (entity instanceof PlayerEntity) {
PlayerEntity playerEntity = (PlayerEntity) entity;
private void getItemsEquippedMixin(CallbackInfoReturnable<Iterable<ItemStack>> info) {
if ((Entity) (Object) this instanceof PlayerEntity playerEntity) {
ItemStack backSlotStack = playerEntity.getInventory().getStack(41);
ItemStack beltSlotStack = playerEntity.getInventory().getStack(42);
Iterable<ItemStack> equippedItems = info.getReturnValue();
Expand Down
34 changes: 14 additions & 20 deletions src/main/java/net/backslot/mixin/EntityTrackerEntryMixin.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
package net.backslot.mixin;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import io.netty.buffer.Unpooled;

import org.spongepowered.asm.mixin.injection.At;

import net.backslot.network.BackSlotServerPacket;
import net.backslot.network.VisibilityPacket;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.EntityTrackerEntry;
import net.minecraft.server.network.ServerPlayerEntity;

@Mixin(EntityTrackerEntry.class)
public class EntityTrackerEntryMixin {
public abstract class EntityTrackerEntryMixin {

@Shadow
private final Entity entity;
@Mutable
@Final
private Entity entity;

public EntityTrackerEntryMixin(Entity entity) {
this.entity = entity;
public EntityTrackerEntryMixin() {
}

@Inject(method = "startTracking", at = @At(value = "TAIL"))
public void startTrackingMixin(ServerPlayerEntity serverPlayer, CallbackInfo info) {
if (entity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) entity;
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
for (int i = 41; i < 43; i++) {
if (!serverPlayer.getInventory().getStack(i).isEmpty()) {
PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
data.writeIntArray(new int[] { serverPlayer.getId(), i });
data.writeItemStack(serverPlayer.getInventory().getStack(i));
ServerPlayNetworking.send((ServerPlayerEntity) player, BackSlotServerPacket.VISIBILITY_UPDATE_PACKET, data);
ServerPlayNetworking.send(serverPlayerEntity, new VisibilityPacket(serverPlayer.getId(), i, serverPlayer.getInventory().getStack(i)));

}
if (!player.getInventory().getStack(i).isEmpty()) {
PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
data.writeIntArray(new int[] { player.getId(), i });
data.writeItemStack(player.getInventory().getStack(i));
ServerPlayNetworking.send(serverPlayer, BackSlotServerPacket.VISIBILITY_UPDATE_PACKET, data);
if (!serverPlayerEntity.getInventory().getStack(i).isEmpty()) {
ServerPlayNetworking.send((ServerPlayerEntity) serverPlayer, new VisibilityPacket(serverPlayerEntity.getId(), i, serverPlayerEntity.getInventory().getStack(i)));
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/net/backslot/mixin/PlayerInventoryMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ public abstract class PlayerInventoryMixin implements Inventory {
private List<DefaultedList<ItemStack>> combinedInventory;
@Shadow
@Final
@Mutable
public DefaultedList<ItemStack> main;
@Shadow
@Final
@Mutable
public DefaultedList<ItemStack> armor;
@Shadow
@Final
@Mutable
public DefaultedList<ItemStack> offHand;
@Shadow
@Mutable
@Final
public PlayerEntity player;

private DefaultedList<ItemStack> backSlot;
private DefaultedList<ItemStack> beltSlot;
Expand All @@ -59,14 +66,12 @@ public void serializeMixin(NbtList tag, CallbackInfoReturnable<NbtList> info) {
if (!this.backSlot.get(0).isEmpty()) {
NbtCompound compoundTag = new NbtCompound();
compoundTag.putByte("Slot", (byte) (110));
this.backSlot.get(0).writeNbt(compoundTag);
tag.add(compoundTag);
tag.add(this.backSlot.get(0).encode(this.player.getRegistryManager(), compoundTag));
}
if (!this.beltSlot.get(0).isEmpty()) {
NbtCompound compoundTag = new NbtCompound();
compoundTag.putByte("Slot", (byte) (111));
this.beltSlot.get(0).writeNbt(compoundTag);
tag.add(compoundTag);
tag.add(this.beltSlot.get(0).encode(this.player.getRegistryManager(), compoundTag));
}

}
Expand All @@ -78,7 +83,7 @@ public void deserializeMixin(NbtList tag, CallbackInfo info) {
for (int i = 0; i < tag.size(); ++i) {
NbtCompound compoundTag = tag.getCompound(i);
int slot = compoundTag.getByte("Slot") & 255;
ItemStack itemStack = ItemStack.fromNbt(compoundTag);
ItemStack itemStack = ItemStack.fromNbt(this.player.getRegistryManager(), compoundTag).orElse(ItemStack.EMPTY);
if (!itemStack.isEmpty()) {
if (slot >= 110 && slot < this.backSlot.size() + 110) {
this.backSlot.set(slot - 110, itemStack);
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/net/backslot/mixin/ServerPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import io.netty.buffer.Unpooled;

import org.spongepowered.asm.mixin.injection.At;

import net.backslot.network.BackSlotServerPacket;
import net.backslot.network.VisibilityPacket;
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.world.World;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
Expand Down Expand Up @@ -53,10 +50,8 @@ private void tickMixin(CallbackInfo info) {

private void sendPacket(int slot) {
Collection<ServerPlayerEntity> players = PlayerLookup.tracking((ServerWorld) this.getWorld(), this.getBlockPos());
PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
data.writeIntArray(new int[] { this.getId(), slot });
data.writeItemStack(this.getInventory().getStack(slot));
players.forEach(player -> ServerPlayNetworking.send(player, BackSlotServerPacket.VISIBILITY_UPDATE_PACKET, data));
players.forEach(player -> ServerPlayNetworking.send(player, new VisibilityPacket(this.getId(), slot, this.getInventory().getStack(slot))));

}

}
Loading

0 comments on commit 9a2ac88

Please sign in to comment.