This commit is contained in:
Infinityy committed 2024-07-12 03:19:04 +02:00
1 parent 459322b8aa
commit cf6ad01bfb
3 files changed
+28 -6

No files matched your search

-3
View File
@@ -26,13 +26,10 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modRuntimeOnly(modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modRuntimeOnly(modImplementation("carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_version}"))
include(implementation("net.kyori:adventure-text-minimessage:4.17.0-SNAPSHOT"))
include(implementation("net.kyori:adventure-text-serializer-gson:4.17.0-SNAPSHOT"))
include(modImplementation("io.github.blumbo:blf-scheduler:1.0.3-${project.minecraft_version}"))
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
include(modImplementation "eu.pb4:sgui:1.5.1+1.20.5")
}
Binary file not shown.
@@ -1,16 +1,20 @@
package com.nexia.teams.mixin;
import com.mojang.authlib.GameProfile;
import com.nexia.teams.NexiaTeams;
import com.nexia.teams.events.tournament.TournamentFight;
import com.nexia.teams.utilities.chat.ChatFormat;
import com.nexia.teams.utilities.time.ServerTime;
import eu.pb4.sgui.api.GuiHelpers;
import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
import net.minecraft.network.protocol.game.ServerboundTeleportToEntityPacket;
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
import net.minecraft.network.protocol.game.*;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.CombatTracker;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.projectile.LargeFireball;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
@@ -27,6 +31,8 @@ public abstract class ServerGamePacketListenerMixin {
@Shadow public abstract ServerPlayer getPlayer();
@Shadow protected abstract GameProfile playerProfile();
@Inject(method = "handleUseItem", at = @At("TAIL"))
public void pearlCooldownMessage(ServerboundUseItemPacket serverboundUseItemPacket, CallbackInfo ci) {
InteractionHand interactionHand = serverboundUseItemPacket.getHand();
@@ -57,4 +63,23 @@ public abstract class ServerGamePacketListenerMixin {
public GameType deathSystem(GameType gameType) {
return NexiaTeams.hardcoreEnabled ? GameType.SPECTATOR : this.getPlayer().gameMode.getGameModeForPlayer();
}
@Inject(method = "handleContainerClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/AbstractContainerMenu;suppressRemoteUpdates()V"), cancellable = true)
public void chestRefill(ServerboundContainerClickPacket serverboundContainerClickPacket, CallbackInfo ci) {
if (player.containerMenu instanceof ChestMenu chestMenu && TournamentFight.spawnArea.contains(player.position())) {
int slot = serverboundContainerClickPacket.getSlotNum();
if (slot >= 0 && slot < chestMenu.getContainer().getContainerSize()) {
player.connection.send(new ClientboundContainerSetSlotPacket(chestMenu.containerId, chestMenu.incrementStateId(), slot, chestMenu.getSlot(slot).getItem()));
}
GuiHelpers.sendSlotUpdate(this.player, -1, -1, chestMenu.getCarried(), chestMenu.getStateId());
GuiHelpers.sendPlayerScreenHandler(this.player);
ItemStack itemStack = chestMenu.getSlot(slot).getItem().copy();
player.addItem(itemStack);
ci.cancel();
}
}
}