From d2ed8f7a94563ae19c8c168876a43c3e1b2162cb Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Fri, 22 Nov 2024 20:54:04 -0800 Subject: [PATCH 1/4] Remove Modrinth (temporary) from release workflow --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aabb0c8..69e77b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,8 @@ jobs: CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }} with: - arguments: curseforge modrinth --console=verbose + arguments: curseforge --console=verbose +# arguments: curseforge modrinth --console=verbose - name: Commit hash file and reset changelog run: | git config --global user.email "ci@sweetrpg.com" From 5193febc5a6f1798a7612477d47a8be350a02be5 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Fri, 22 Nov 2024 20:54:12 -0800 Subject: [PATCH 2/4] Update handler --- .../common/network/packet/QueueCommandPacket.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/QueueCommandPacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/QueueCommandPacket.java index 377678c..6c8cb25 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/QueueCommandPacket.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/QueueCommandPacket.java @@ -5,7 +5,6 @@ import com.sweetrpg.crafttracker.common.network.IPacket; import com.sweetrpg.crafttracker.common.network.packet.data.QueueCommandData; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.network.NetworkEvent.Context; @@ -31,11 +30,7 @@ public final void handle(QueueCommandData data, Supplier ctx) { ctx.get().enqueueWork(() -> { LogicalSide side = ctx.get().getDirection().getReceptionSide(); if(side.isClient()) { - - } - else if(side.isServer()) { -// var player = ctx.get().getSender(); -// CraftingQueueManager.get(player, player.level).addProduct(player.level, data.itemId, data.quantity); + CraftingQueueManager.INSTANCE.computeAll(); } }); From 7429fbdce9e34b870313d0bbb6b2652161d2ce27 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Fri, 22 Nov 2024 20:54:24 -0800 Subject: [PATCH 3/4] Cleanup --- .../network/packet/AddToQueuePacket.java | 49 ------ .../network/packet/ToggleCraftListPacket.java | 47 ------ .../packet/ToggleShoppingListPacket.java | 47 ------ .../packet/UpdateCraftQueuePacket.java | 55 ------- .../packet/UpdateShoppingListPacket.java | 42 ------ .../network/packet/data/AddToQueueData.java | 14 -- .../packet/data/ToggleCraftListData.java | 7 - .../packet/data/ToggleShoppingListData.java | 8 - .../packet/data/UpdateCraftQueueData.java | 22 --- .../packet/data/UpdateShoppingListData.java | 9 -- .../common/storage/CraftingQueueData.java | 77 ---------- .../common/storage/ShoppingListData.java | 7 - .../crafttracker/common/util/EntityUtil.java | 142 ------------------ .../common/util/InventoryUtil.java | 2 - 14 files changed, 528 deletions(-) delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/AddToQueuePacket.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleCraftListPacket.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleShoppingListPacket.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateCraftQueuePacket.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateShoppingListPacket.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AddToQueueData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleCraftListData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleShoppingListData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateCraftQueueData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateShoppingListData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/storage/CraftingQueueData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/storage/ShoppingListData.java delete mode 100644 src/main/java/com/sweetrpg/crafttracker/common/util/EntityUtil.java diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/AddToQueuePacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/AddToQueuePacket.java deleted file mode 100644 index 429f412..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/AddToQueuePacket.java +++ /dev/null @@ -1,49 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet; -// -//import com.sweetrpg.crafttracker.CraftTracker; -//import com.sweetrpg.crafttracker.common.addon.jei.CTPlugin; -//import com.sweetrpg.crafttracker.common.manager.CraftingQueueManager; -//import com.sweetrpg.crafttracker.common.network.IPacket; -//import com.sweetrpg.crafttracker.common.network.packet.data.AddToQueueData; -//import net.minecraft.network.FriendlyByteBuf; -//import net.minecraft.resources.ResourceLocation; -//import net.minecraft.world.item.ItemStack; -//import net.minecraftforge.fml.LogicalSide; -//import net.minecraftforge.network.NetworkEvent.Context; -// -//import java.util.function.Supplier; -// -//public class AddToQueuePacket implements IPacket { -// -// @Override -// public void encode(AddToQueueData data, FriendlyByteBuf buf) { -// buf.writeResourceLocation(data.itemId); -// buf.writeInt(data.quantity); -// } -// -// @Override -// public AddToQueueData decode(FriendlyByteBuf buf) { -// ResourceLocation itemId = buf.readResourceLocation(); -// int quantity = buf.readInt(); -// return new AddToQueueData(itemId, quantity); -// } -// -// @Override -// public final void handle(AddToQueueData data, Supplier ctx) { -// CraftTracker.LOGGER.debug("AddToQueuePacket#handle: {}", data); -// -// ctx.get().enqueueWork(() -> { -// LogicalSide side = ctx.get().getDirection().getReceptionSide(); -// if(side.isClient()) { -// -// } -// else if(side.isServer()) { -// var player = ctx.get().getSender(); -// CraftingQueueManager.get(player, player.level).addProduct(player.level, data.itemId, data.quantity); -// } -// }); -// -// ctx.get().setPacketHandled(true); -// } -// -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleCraftListPacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleCraftListPacket.java deleted file mode 100644 index fe3aff2..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleCraftListPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet; -// -//import com.sweetrpg.crafttracker.common.network.IPacket; -//import com.sweetrpg.crafttracker.common.network.packet.data.ToggleCraftListData; -//import net.minecraft.network.FriendlyByteBuf; -//import net.minecraftforge.api.distmarker.Dist; -//import net.minecraftforge.fml.DistExecutor; -//import net.minecraftforge.network.NetworkEvent; -//import net.minecraftforge.network.NetworkEvent.Context; -// -//import java.util.function.Supplier; -// -//public class ToggleCraftListPacket implements IPacket { -// -// @Override -// public void encode(ToggleCraftListData data, FriendlyByteBuf buf) { -// -//// buf.writeBoolean(data.display); -// } -// -// @Override -// public ToggleCraftListData decode(FriendlyByteBuf buf) { -//// boolean display = buf.readBoolean(); -// return new ToggleCraftListData(); -// } -// -// @Override -// public final void handle(ToggleCraftListData data, Supplier ctx) { -// ctx.get().enqueueWork(() -> { -//// Entity target = ctx.get().getSender().level.getEntity(data.entityId); -//// -//// if (!(target instanceof CatEntity)) { -//// return; -//// } -//// -//// this.handleCat((CatEntity) target, data, ctx); -// DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> handleClientPacket(data, ctx)); -// }); -// -// ctx.get().setPacketHandled(true); -// } -// -// static void handleClientPacket(ToggleCraftListData data, Supplier ctx) { -// -// } -// -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleShoppingListPacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleShoppingListPacket.java deleted file mode 100644 index 550e0a8..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/ToggleShoppingListPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet; -// -//import com.sweetrpg.crafttracker.common.network.IPacket; -//import com.sweetrpg.crafttracker.common.network.packet.data.ToggleCraftListData; -//import com.sweetrpg.crafttracker.common.network.packet.data.ToggleShoppingListData; -//import net.minecraft.network.FriendlyByteBuf; -//import net.minecraftforge.api.distmarker.Dist; -//import net.minecraftforge.fml.DistExecutor; -//import net.minecraftforge.network.NetworkEvent; -//import net.minecraftforge.network.NetworkEvent.Context; -// -//import java.util.function.Supplier; -// -//public class ToggleShoppingListPacket implements IPacket { -// -// @Override -// public void encode(ToggleShoppingListData data, FriendlyByteBuf buf) { -// -//// buf.writeBoolean(data.display); -// } -// -// @Override -// public ToggleShoppingListData decode(FriendlyByteBuf buf) { -//// boolean display = buf.readBoolean(); -// return new ToggleShoppingListData(); -// } -// -// @Override -// public final void handle(ToggleShoppingListData data, Supplier ctx) { -// ctx.get().enqueueWork(() -> { -//// Entity target = ctx.get().getSender().level.getEntity(data.entityId); -//// -//// if (!(target instanceof CatEntity)) { -//// return; -//// } -//// -//// this.handleCat((CatEntity) target, data, ctx); -// DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> handleClientPacket(data, ctx)); -// }); -// -// ctx.get().setPacketHandled(true); -// } -// -// static void handleClientPacket(ToggleShoppingListData data, Supplier ctx) { -// -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateCraftQueuePacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateCraftQueuePacket.java deleted file mode 100644 index ad4116f..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateCraftQueuePacket.java +++ /dev/null @@ -1,55 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet; -// -//import com.sweetrpg.crafttracker.CraftTracker; -//import com.sweetrpg.crafttracker.common.Screens; -//import com.sweetrpg.crafttracker.common.manager.CraftingQueueManager; -//import com.sweetrpg.crafttracker.common.network.IPacket; -//import com.sweetrpg.crafttracker.common.network.packet.data.UpdateCraftQueueData; -//import net.minecraft.network.FriendlyByteBuf; -//import net.minecraft.server.level.ServerPlayer; -//import net.minecraftforge.fml.LogicalSide; -//import net.minecraftforge.network.NetworkEvent; -// -//import java.util.List; -//import java.util.function.Supplier; -// -//public class UpdateCraftQueuePacket implements IPacket { -// -// @Override -// public UpdateCraftQueueData decode(FriendlyByteBuf buf) { -// List items = buf.readList((lb) -> { -// var itemId = lb.readResourceLocation(); -// var quantity = lb.readInt(); -// var categories = lb.readList(FriendlyByteBuf::readResourceLocation); -// -// return new CraftingQueueManager.ProductItem(itemId, quantity, categories); -// }); -// -// return new UpdateCraftQueueData(items); -// } -// -// @Override -// public void encode(UpdateCraftQueueData data, FriendlyByteBuf buf) { -// buf.writeCollection(data.getEndProducts(), -// (pb, item) -> { -// pb.writeResourceLocation(item.getItemId()); -// pb.writeInt(item.getQuantity()); -// pb.writeCollection(item.getCategories(), -// (cb, category) -> pb.writeResourceLocation(category)); -// }); -// } -// -// @Override -// public void handle(UpdateCraftQueueData data, Supplier ctx) { -// CraftTracker.LOGGER.debug("UpdateCraftQueuePacket#handle: {}, ctx: {}", data, ctx); -// -// ctx.get().enqueueWork(() -> { -// if(ctx.get().getDirection().getReceptionSide() == LogicalSide.SERVER) { -// ServerPlayer player = ctx.get().getSender(); -// Screens.updateCraftQueue(player); -// } -// }); -// -// ctx.get().setPacketHandled(true); -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateShoppingListPacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateShoppingListPacket.java deleted file mode 100644 index ed4fde0..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/UpdateShoppingListPacket.java +++ /dev/null @@ -1,42 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet; -// -//import com.sweetrpg.crafttracker.common.network.IPacket; -//import com.sweetrpg.crafttracker.common.network.packet.data.UpdateCraftQueueData; -//import com.sweetrpg.crafttracker.common.network.packet.data.UpdateShoppingListData; -//import net.minecraft.network.FriendlyByteBuf; -//import net.minecraft.server.level.ServerPlayer; -//import net.minecraftforge.fml.LogicalSide; -//import net.minecraftforge.network.NetworkEvent; -// -//import java.util.function.Supplier; -// -//public class UpdateShoppingListPacket implements IPacket { -// -// @Override -// public UpdateShoppingListData decode(FriendlyByteBuf buf) { -// return new UpdateShoppingListData(); -// } -// -// -// @Override -// public void encode(UpdateShoppingListData data, FriendlyByteBuf buf) { -// -// } -// -// @Override -// public void handle(UpdateShoppingListData data, Supplier ctx) { -// ctx.get().enqueueWork(() -> { -// if (ctx.get().getDirection().getReceptionSide() == LogicalSide.SERVER) { -// ServerPlayer player = ctx.get().getSender(); -//// List cats = player.level.getEntitiesOfClass(CatEntity.class, player.getBoundingBox().inflate(12D, 12D, 12D), -//// (cat) -> cat.canInteract(player) && PackCatTalent.hasInventory(cat) -//// ); -//// if (!cats.isEmpty()) { -//// Screens.openCatInventoriesScreen(player, cats); -//// } -// } -// }); -// -// ctx.get().setPacketHandled(true); -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AddToQueueData.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AddToQueueData.java deleted file mode 100644 index 840d7e5..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AddToQueueData.java +++ /dev/null @@ -1,14 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet.data; -// -//import net.minecraft.resources.ResourceLocation; -// -//public class AddToQueueData { -// -// public ResourceLocation itemId; -// public int quantity; -// -// public AddToQueueData(ResourceLocation itemId, int quantity) { -// this.itemId = itemId; -// this.quantity = quantity; -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleCraftListData.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleCraftListData.java deleted file mode 100644 index d167074..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleCraftListData.java +++ /dev/null @@ -1,7 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet.data; -// -//public class ToggleCraftListData { -// -// public ToggleCraftListData() { -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleShoppingListData.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleShoppingListData.java deleted file mode 100644 index 10957b2..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/ToggleShoppingListData.java +++ /dev/null @@ -1,8 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet.data; -// -//public class ToggleShoppingListData { -// -// public ToggleShoppingListData() { -// -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateCraftQueueData.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateCraftQueueData.java deleted file mode 100644 index 3d4fa8d..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateCraftQueueData.java +++ /dev/null @@ -1,22 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet.data; -// -//import com.sweetrpg.crafttracker.common.manager.CraftingQueueManager; -//import net.minecraft.resources.ResourceLocation; -//import org.antlr.v4.misc.OrderedHashMap; -// -//import java.util.ArrayList; -//import java.util.List; -//import java.util.Map; -// -//public class UpdateCraftQueueData { -// -// private List endProducts = new ArrayList<>(); -// -// public UpdateCraftQueueData(List endProducts) { -// this.endProducts = endProducts; -// } -// -// public List getEndProducts() { -// return endProducts; -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateShoppingListData.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateShoppingListData.java deleted file mode 100644 index 476bc99..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/UpdateShoppingListData.java +++ /dev/null @@ -1,9 +0,0 @@ -//package com.sweetrpg.crafttracker.common.network.packet.data; -// -//public class UpdateShoppingListData { -// -// public UpdateShoppingListData() { -// super(); -// } -// -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/storage/CraftingQueueData.java b/src/main/java/com/sweetrpg/crafttracker/common/storage/CraftingQueueData.java deleted file mode 100644 index 1a94f76..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/storage/CraftingQueueData.java +++ /dev/null @@ -1,77 +0,0 @@ -//package com.sweetrpg.crafttracker.common.storage; -// -//import com.sweetrpg.crafttracker.CraftTracker; -//import com.sweetrpg.crafttracker.common.util.NBTUtil; -//import net.minecraft.nbt.CompoundTag; -//import net.minecraft.resources.ResourceLocation; -// -///** -// * This class represents an entry in the crafting queue's end products list. -// */ -//public class CraftingQueueData { -// -// private final CraftingQueueStorage storage; -// private ResourceLocation itemId; -// private int quantity; -// -// protected CraftingQueueData(CraftingQueueStorage storage) { -// this.storage = storage; -// } -// -// protected CraftingQueueData(CraftingQueueStorage storage, ResourceLocation itemId, int quantity) { -// this.storage = storage; -// this.itemId = itemId; -// this.quantity = quantity; -// } -// -//// public void addItem(ResourceLocation itemId, int quantity) { -//// CraftTracker.LOGGER.debug("CraftingQueueData#addItem: {}, quantity {}", itemId, quantity); -//// -//// this.endProducts.compute(itemId, (k, v) -> (v == null ? 0 : v) + quantity); -//// -//// this.storage.setDirty(); -//// } -//// -//// public void removeItem(ResourceLocation itemId, int quantity) { -//// CraftTracker.LOGGER.debug("CraftingQueueData#removeItem: {}, quantity {}", itemId, quantity); -//// -//// this.endProducts.computeIfPresent(itemId, (k, v) -> { -//// if(v - quantity < 1) { -//// return null; -//// } -//// -//// return v - quantity; -//// }); -//// -//// this.storage.setDirty(); -//// } -// -// public void read(CompoundTag compound) { -// CraftTracker.LOGGER.debug("CraftingQueueData#read"); -// -// this.itemId = NBTUtil.getResourceLocation(compound, Keys.ITEM_ID); -// this.quantity = compound.getInt(Keys.QUANTITY); -// } -// -// public CompoundTag write(CompoundTag compound) { -// CraftTracker.LOGGER.debug("CraftingQueueData#write"); -// -// NBTUtil.putResourceLocation(compound, Keys.ITEM_ID, this.itemId); -// compound.putInt(Keys.QUANTITY, this.quantity); -// -// return compound; -// } -// -// public ResourceLocation getItemId() { -// return itemId; -// } -// -// public int getQuantity() { -// return quantity; -// } -// -// static class Keys { -// static String ITEM_ID = "item_id"; -// static String QUANTITY = "quantity"; -// } -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/storage/ShoppingListData.java b/src/main/java/com/sweetrpg/crafttracker/common/storage/ShoppingListData.java deleted file mode 100644 index 64b795e..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/storage/ShoppingListData.java +++ /dev/null @@ -1,7 +0,0 @@ -//package com.sweetrpg.crafttracker.common.storage; -// -//import java.util.UUID; -// -//public class ShoppingListData { -// -//} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/EntityUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/EntityUtil.java deleted file mode 100644 index c393594..0000000 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/EntityUtil.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.sweetrpg.crafttracker.common.util; - -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.attributes.AttributeInstance; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.ai.navigation.PathNavigation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.LeavesBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.pathfinder.BlockPathTypes; -import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; -import net.minecraft.world.phys.Vec3; - -import javax.annotation.Nullable; -import java.util.Comparator; -import java.util.Iterator; -import java.util.function.Predicate; - -public class EntityUtil { - - public static double getFollowRange(LivingEntity entityIn) { - AttributeInstance rangeAttribute = entityIn.getAttribute(Attributes.FOLLOW_RANGE); - return rangeAttribute == null ? 16.0D : rangeAttribute.getValue(); - } - - public static boolean tryToTeleportNearEntity(LivingEntity entityIn, PathNavigation navigator, LivingEntity target, int radius) { - return tryToTeleportNearEntity(entityIn, navigator, target.blockPosition(), radius); - } - - public static boolean tryToTeleportNearEntity(LivingEntity entityIn, PathNavigation navigator, BlockPos targetPos, int radius) { - for (int i = 0; i < 10; ++i) { - int j = getRandomNumber(entityIn, -radius, radius); - int k = getRandomNumber(entityIn, -1, 1); - int l = getRandomNumber(entityIn, -radius, radius); - boolean flag = tryToTeleportToLocation(entityIn, navigator, targetPos, targetPos.getX() + j, targetPos.getY() + k, targetPos.getZ() + l); - if (flag) { - return true; - } - } - - return false; - } - - public static boolean tryToTeleportToLocation(LivingEntity entityIn, PathNavigation navigator, BlockPos targetPos, int x, int y, int z) { - if (Math.abs(x - targetPos.getX()) < 2.0D && Math.abs(z - targetPos.getZ()) < 2.0D) { - return false; - } else if (!isTeleportFriendlyBlock(entityIn, new BlockPos(x, y, z), false)) { - return false; - } else { - entityIn.moveTo(x + 0.5F, y, z + 0.5F, entityIn.getYRot(), entityIn.getXRot()); - navigator.stop(); - return true; - } - } - - private static boolean isTeleportFriendlyBlock(LivingEntity entityIn, BlockPos pos, boolean teleportToLeaves) { - BlockPathTypes pathnodetype = WalkNodeEvaluator.getBlockPathTypeStatic(entityIn.level, pos.mutable()); - if (pathnodetype != BlockPathTypes.WALKABLE) { - return false; - } else { - BlockState blockstate = entityIn.level.getBlockState(pos.below()); - if (!teleportToLeaves && blockstate.getBlock() instanceof LeavesBlock) { - return false; - } else { - BlockPos blockpos = pos.subtract(entityIn.blockPosition()); - return entityIn.level.noCollision(entityIn, entityIn.getBoundingBox().move(blockpos)); - } - } - } - - public static int getRandomNumber(LivingEntity entityIn, int minIn, int maxIn) { - return entityIn.getRandom().nextInt(maxIn - minIn + 1) + minIn; - } - - public static boolean isHolding(@Nullable Entity entity, Item item, Predicate nbtPredicate) { - return isHolding(entity, stack -> stack.getItem() == item && stack.hasTag() && nbtPredicate.test(stack.getTag())); - } - - public static boolean isHolding(@Nullable Entity entity, Item item) { - return isHolding(entity, stack -> stack.getItem() == item); - } - - public static boolean isHolding(@Nullable Entity entity, Predicate matcher) { - if (entity == null) { - return false; - } - - Iterator heldItems = entity.getHandSlots().iterator(); - while (heldItems.hasNext()) { - ItemStack stack = heldItems.next(); - if (matcher.test(stack)) { - return true; - } - } - - return false; - } - - public static T getClosestTo(Entity center, Iterable entities) { - return getClosestTo(center.position(), entities); - } - - public static T getClosestTo(Vec3 posVec, Iterable entities) { - double smallestDist = Double.MAX_VALUE; - T closest = null; - - for (T entity : entities) { - double distance = posVec.distanceToSqr(entity.position()); - if (distance < smallestDist) { - closest = entity; - smallestDist = distance; - } - } - - return closest; - } - - public static class Sorter implements Comparator { - - private final Vec3 vec3d; - - public Sorter(Entity entityIn) { - this.vec3d = entityIn.position(); - } - - public Sorter(Vec3 vec3d) { - this.vec3d = vec3d; - } - - @Override - public int compare(Entity entity1, Entity entity2) { - double d0 = this.vec3d.distanceToSqr(entity1.position()); - double d1 = this.vec3d.distanceToSqr(entity2.position()); - - return Double.compare(d0, d1); - } - } -} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/InventoryUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/InventoryUtil.java index 4aa5ea1..8aaa0f6 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/InventoryUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/InventoryUtil.java @@ -11,8 +11,6 @@ public class InventoryUtil { - - public static Pair findStack(IItemHandler source, Predicate searchCriteria) { for (int i = 0; i < source.getSlots(); i++) { From 6fe4aa3b500634094cfe01c0d727023599e11032 Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Sat, 23 Nov 2024 04:55:32 +0000 Subject: [PATCH 4/4] Update 1.18 VERSION file --- .release-info/1.18/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/VERSION b/.release-info/1.18/VERSION index b056f41..2678ff8 100644 --- a/.release-info/1.18/VERSION +++ b/.release-info/1.18/VERSION @@ -1 +1 @@ -0.0.24 +0.0.25