9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-26 18:39:17 +00:00

fix swinghand on 1.18

This commit is contained in:
XiaoMoMi
2024-03-13 07:04:54 +08:00
parent 2900fe9584
commit a8b902d519
4 changed files with 11 additions and 3 deletions

View File

@@ -17,6 +17,8 @@
package net.momirealms.customcrops.mechanic.action;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
@@ -49,6 +51,7 @@ import net.momirealms.customcrops.api.util.LogUtils;
import net.momirealms.customcrops.compatibility.VaultHook;
import net.momirealms.customcrops.manager.AdventureManagerImpl;
import net.momirealms.customcrops.manager.HologramManager;
import net.momirealms.customcrops.manager.PacketManager;
import net.momirealms.customcrops.mechanic.item.impl.VariationCrop;
import net.momirealms.customcrops.mechanic.misc.TempFakeItem;
import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
@@ -427,7 +430,10 @@ public class ActionManagerImpl implements ActionManager {
return state -> {
if (Math.random() > chance) return;
if (state.getPlayer() == null) return;
state.getPlayer().swingHand(arg ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND);
PacketContainer animationPacket = new PacketContainer(PacketType.Play.Server.ANIMATION);
animationPacket.getIntegers().write(0, state.getPlayer().getEntityId());
animationPacket.getIntegers().write(1, arg ? 0 : 3);
PacketManager.getInstance().send(state.getPlayer(), animationPacket);
};
});
}

View File

@@ -89,6 +89,7 @@ public class ItemsAdderProvider implements CustomProvider {
@Override
public ItemStack getItemStack(String id) {
if (id == null) return new ItemStack(Material.AIR);
CustomStack customStack = CustomStack.getInstance(id);
if (customStack == null) {
return null;

View File

@@ -41,7 +41,7 @@ public class OraxenProvider implements CustomProvider {
if (block.getType() == Material.AIR) {
return false;
}
if (OraxenBlocks.remove(location, null, false)) {
if (!OraxenBlocks.remove(location, null, false)) {
block.setType(Material.AIR);
}
return true;
@@ -88,6 +88,7 @@ public class OraxenProvider implements CustomProvider {
@Override
public ItemStack getItemStack(String id) {
if (id == null) return new ItemStack(Material.AIR);
ItemBuilder builder = OraxenItems.getItemById(id);
if (builder == null) {
return null;