diff --git a/docs/document-en_us.md b/docs/document-en_us.md index 4f35de5e..ece9c067 100644 --- a/docs/document-en_us.md +++ b/docs/document-en_us.md @@ -1053,6 +1053,31 @@ Modify the maximum number of history messages stored in the chat hud - Where's My Chat History (`wmch`) +### clientEntityTargetingSelectAll + +Make the following client-side entity targeting stuffs being able to select all types of entities: + +1. F3 + I entity data querying + +2. Client-side command suggestion with target entity UUID + +3. Mouse middle-click item picking. Supports picking items, xp orbs and falling blocks + +Example use cases: + +1. Get a /summon command for an item entity (F3 + I) + +2. Enter /kill and tab-suggested a projectile entity (UUID suggestion) + +3. Pick the item stack from the item entity to your inventory (pick entity) + +Notes: In vanilla, client can only select collide-able and non-spectator entities + +- Category: MC Tweaks +- Type: hotkey togglable boolean (Generic) +- Default value: *no hotkey*, `false` + + ### connectionSimulatedDelay Client network delay simulator. Enabled when the value is greater than 0 diff --git a/docs/document-zh_cn.md b/docs/document-zh_cn.md index 9ed9ee77..d5d27f20 100644 --- a/docs/document-zh_cn.md +++ b/docs/document-zh_cn.md @@ -1049,6 +1049,31 @@ schematicBlockPlacement的严格模式 - Where's My Chat History (`wmch`) +### 客户端实体目标选择所有实体 (clientEntityTargetingSelectAll) + +令下述客户端实体选择的功能可以选中所有类型的实体: + +1. F3 + I 实体数据查询 + +2. 客户端指令补全中的实体UUID选项 + +3. 鼠标中键物品提取。支持提取物品实体、经验球实体和重力方块实体 + +用法举例: + +1. 获取一个物品实体对应的/summon指令 (F3 + I) + +2. 输入/kill然后tab补全面前的投掷物实体(UUID补全) + +3. 把一个物品实体用鼠标中间拎进物品栏 (实体物品提取) + +注:原版环境下,只能选中有碰撞箱且非旁观者的实体 + +- 分类: MC修改 +- 类型: 带热键布尔值 (通用) +- 默认值: *无快捷键*, `false` + + ### 网络连接延迟模拟 (connectionSimulatedDelay) 客户端网络延迟模拟器,于给定值大于0时启用 diff --git a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java index 5ae30bcf..5fa9d6f5 100644 --- a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java +++ b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java @@ -392,6 +392,9 @@ public class TweakerMoreConfigs ) public static final TweakerMoreConfigInteger CHAT_MESSAGE_LIMIT = newConfigInteger("chatMessageLimit", 100, 100, 10000); + @Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS) + public static final TweakerMoreConfigBooleanHotkeyed CLIENT_ENTITY_TARGETING_SUPPORT_ALL = newConfigBooleanHotkeyed("clientEntityTargetingSelectAll"); + @Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS) public static final TweakerMoreConfigInteger CONNECTION_SIMULATED_DELAY = newConfigInteger("connectionSimulatedDelay", 0, 0, 15_000); diff --git a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/EntityItemPickHelper.java b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/EntityItemPickHelper.java new file mode 100644 index 00000000..0a45275b --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/EntityItemPickHelper.java @@ -0,0 +1,51 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll; + +import net.minecraft.block.Block; +import net.minecraft.entity.*; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import org.jetbrains.annotations.Nullable; + +public class EntityItemPickHelper +{ + @Nullable + public static ItemStack pickItem(Entity entity) + { + if (entity instanceof ItemEntity) + { + return ((ItemEntity)entity).getStack().copy(); + } + else if (entity instanceof ExperienceOrbEntity) + { + return new ItemStack(Items.EXPERIENCE_BOTTLE); + } + else if (entity instanceof FallingBlockEntity) + { + Block block = ((FallingBlockEntity)entity).getBlockState().getBlock(); + ItemStack itemStack = new ItemStack(block); + return itemStack.isEmpty() ? null : itemStack; + } + + return null; + } +} diff --git a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClientWithExtendedTargetEntity.java b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClientWithExtendedTargetEntity.java new file mode 100644 index 00000000..ab54a9ab --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClientWithExtendedTargetEntity.java @@ -0,0 +1,32 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll; + +import net.minecraft.util.hit.EntityHitResult; +import org.jetbrains.annotations.Nullable; + +public interface MinecraftClientWithExtendedTargetEntity +{ + @Nullable + EntityHitResult getExtendedEntityHitResult$TKM(); + + void setExtendedEntityHitResult$TKM(@Nullable EntityHitResult entityHitResult); +} diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/ClientCommandSourceMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/ClientCommandSourceMixin.java new file mode 100644 index 00000000..8fda58a5 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/ClientCommandSourceMixin.java @@ -0,0 +1,59 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.clientEntityTargetingSelectAll; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; +import me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClientWithExtendedTargetEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientCommandSource; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.util.hit.HitResult; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ClientCommandSource.class) +public abstract class ClientCommandSourceMixin +{ + @Shadow @Final private MinecraftClient client; + + @ModifyExpressionValue( + method = "getEntitySuggestions", + at = @At( + value = "FIELD", + target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;" + ) + ) + private HitResult clientEntityTargetingSelectAll_hackUuidSuggestion(HitResult crosshairTarget) + { + if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + { + EntityHitResult entityHitResult = ((MinecraftClientWithExtendedTargetEntity)this.client).getExtendedEntityHitResult$TKM(); + if (entityHitResult != null) + { + crosshairTarget = entityHitResult; + } + } + return crosshairTarget; + } +} diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/GameRendererMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/GameRendererMixin.java new file mode 100644 index 00000000..dfb7fc7b --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/GameRendererMixin.java @@ -0,0 +1,66 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.clientEntityTargetingSelectAll; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; +import me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClientWithExtendedTargetEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.GameRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.function.Predicate; + +@Mixin(GameRenderer.class) +public abstract class GameRendererMixin +{ + @Shadow @Final private MinecraftClient client; + + @WrapOperation( + method = "updateTargetedEntity", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/ProjectileUtil;rayTrace(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Ljava/util/function/Predicate;D)Lnet/minecraft/util/hit/EntityHitResult;" + ) + ) + private @Nullable EntityHitResult clientEntityTargetingSelectAll_makeExtendedTarget(Entity entity, Vec3d vecStart, Vec3d vecEnd, Box box, Predicate predicate, double reach, Operation original) + { + MinecraftClientWithExtendedTargetEntity access = (MinecraftClientWithExtendedTargetEntity)this.client; + if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + { + access.setExtendedEntityHitResult$TKM(original.call(entity, vecStart, vecEnd, box, (Predicate)e -> true, reach)); + } + else + { + access.setExtendedEntityHitResult$TKM(null); + } + return original.call(entity, vecStart, vecEnd, box, predicate, reach); + } +} diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/KeyboardMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/KeyboardMixin.java new file mode 100644 index 00000000..f0f4c7b7 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/KeyboardMixin.java @@ -0,0 +1,59 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.clientEntityTargetingSelectAll; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; +import me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClientWithExtendedTargetEntity; +import net.minecraft.client.Keyboard; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.util.hit.HitResult; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(Keyboard.class) +public abstract class KeyboardMixin +{ + @Shadow @Final private MinecraftClient client; + + @ModifyExpressionValue( + method = "copyLookAt", + at = @At( + value = "FIELD", + target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;" + ) + ) + private HitResult clientEntityTargetingSelectAll_hackF3I(HitResult crosshairTarget) + { + if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + { + EntityHitResult entityHitResult = ((MinecraftClientWithExtendedTargetEntity)this.client).getExtendedEntityHitResult$TKM(); + if (entityHitResult != null) + { + crosshairTarget = entityHitResult; + } + } + return crosshairTarget; + } +} diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_extendedTargetMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_extendedTargetMixin.java new file mode 100644 index 00000000..7cd592c7 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_extendedTargetMixin.java @@ -0,0 +1,48 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.clientEntityTargetingSelectAll; + +import me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClientWithExtendedTargetEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.hit.EntityHitResult; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +@Mixin(MinecraftClient.class) +public abstract class MinecraftClient_extendedTargetMixin implements MinecraftClientWithExtendedTargetEntity +{ + @Unique + private EntityHitResult extendedEntityHitResult = null; + + @Nullable + @Override + public EntityHitResult getExtendedEntityHitResult$TKM() + { + return this.extendedEntityHitResult; + } + + @Override + public void setExtendedEntityHitResult$TKM(@Nullable EntityHitResult entityHitResult) + { + this.extendedEntityHitResult = entityHitResult; + } +} diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_pickEntityMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_pickEntityMixin.java new file mode 100644 index 00000000..610b39c5 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_pickEntityMixin.java @@ -0,0 +1,138 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TweakerMore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.clientEntityTargetingSelectAll; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; +import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; +import me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll.EntityItemPickHelper; +import me.fallenbreath.tweakermore.impl.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClientWithExtendedTargetEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.item.ItemStack; +import net.minecraft.item.SpawnEggItem; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.util.hit.HitResult; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(MinecraftClient.class) +public abstract class MinecraftClient_pickEntityMixin +{ + @ModifyExpressionValue( + method = "doItemPick", + at = @At( + value = "FIELD", + target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;" + ) + ) + private HitResult clientEntityTargetingSelectAll_hackPickItem_replaceHitResult(HitResult crosshairTarget) + { + if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + { + EntityHitResult entityHitResult = ((MinecraftClientWithExtendedTargetEntity)this).getExtendedEntityHitResult$TKM(); + if (entityHitResult != null) + { + crosshairTarget = entityHitResult; + } + } + return crosshairTarget; + } + + //#if MC >= 11700 + //$$ @ModifyExpressionValue( + //$$ method = "doItemPick", + //$$ at = @At( + //$$ value = "INVOKE", + //$$ target = "Lnet/minecraft/entity/Entity;getPickBlockStack()Lnet/minecraft/item/ItemStack;" + //$$ ) + //$$ ) + //$$ private @Nullable ItemStack clientEntityTargetingSelectAll_hackPickItem_overrideVanillaResult( + //$$ @Nullable ItemStack itemStack, + //$$ @Local Entity entity + //$$ ) + //$$ { + //$$ if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + //$$ { + //$$ if (itemStack == null) + //$$ { + //$$ itemStack = EntityItemPickHelper.pickItem(entity); + //$$ } + //$$ } + //$$ return itemStack; + //$$ } + //#else + @ModifyExpressionValue( + method = "doItemPick", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/item/SpawnEggItem;forEntity(Lnet/minecraft/entity/EntityType;)Lnet/minecraft/item/SpawnEggItem;" + ) + ) + private @Nullable SpawnEggItem clientEntityTargetingSelectAll_hackPickItem_overrideVanillaTempResult( + @Nullable SpawnEggItem item, + @Local Entity entity, + @Share("overrideItemStack") LocalRef overrideItemStack + ) + { + if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + { + if (item == null) + { + ItemStack newPickedItem = EntityItemPickHelper.pickItem(entity); + if (newPickedItem != null) + { + overrideItemStack.set(newPickedItem); + item = SpawnEggItem.forEntity(EntityType.BAT); + } + } + } + return item; + } + + @ModifyExpressionValue( + method = "doItemPick", + at = @At( + value = "NEW", + target = "(Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/item/ItemStack;" + ) + ) + private ItemStack clientEntityTargetingSelectAll_hackPickItem_applyOurResult( + ItemStack itemStack, + @Share("overrideItemStack") LocalRef overrideItemStack + ) + { + if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) + { + ItemStack newPickedItem = overrideItemStack.get(); + if (newPickedItem != null) // it shouldn't be null + { + itemStack = newPickedItem; + } + } + return itemStack; + } + //#endif +} diff --git a/src/main/resources/assets/tweakermore/lang/en_us.yml b/src/main/resources/assets/tweakermore/lang/en_us.yml index 2286a0b9..ee258642 100644 --- a/src/main/resources/assets/tweakermore/lang/en_us.yml +++ b/src/main/resources/assets/tweakermore/lang/en_us.yml @@ -385,6 +385,18 @@ tweakermore: chatMessageLimit: .: chatMessageLimit comment: Modify the maximum number of history messages stored in the chat hud + clientEntityTargetingSelectAll: + .: clientEntityTargetingSelectAll + comment: |- + Make the following client-side entity targeting stuffs being able to select all types of entities: + 1. F3 + I entity data querying + 2. Client-side command suggestion with target entity UUID + 3. Mouse middle-click item picking. Supports picking items, xp orbs and falling blocks + Example use cases: + 1. Get a /summon command for an item entity (F3 + I) + 2. Enter /kill and tab-suggested a projectile entity (UUID suggestion) + 3. Pick the item stack from the item entity to your inventory (pick entity) + Notes: In vanilla, client can only select collide-able and non-spectator entities connectionSimulatedDelay: .: connectionSimulatedDelay comment: |- diff --git a/src/main/resources/assets/tweakermore/lang/zh_cn.yml b/src/main/resources/assets/tweakermore/lang/zh_cn.yml index f367748e..71977000 100644 --- a/src/main/resources/assets/tweakermore/lang/zh_cn.yml +++ b/src/main/resources/assets/tweakermore/lang/zh_cn.yml @@ -385,6 +385,18 @@ tweakermore: chatMessageLimit: .: 聊天信息数量上限 comment: 修改聊天栏的历史信息储存数量上限 + clientEntityTargetingSelectAll: + .: 客户端实体目标选择所有实体 + comment: |- + 令下述客户端实体选择的功能可以选中所有类型的实体: + 1. F3 + I 实体数据查询 + 2. 客户端指令补全中的实体UUID选项 + 3. 鼠标中键物品提取。支持提取物品实体、经验球实体和重力方块实体 + 用法举例: + 1. 获取一个物品实体对应的/summon指令 (F3 + I) + 2. 输入/kill然后tab补全面前的投掷物实体(UUID补全) + 3. 把一个物品实体用鼠标中间拎进物品栏 (实体物品提取) + 注:原版环境下,只能选中有碰撞箱且非旁观者的实体 connectionSimulatedDelay: .: 网络连接延迟模拟 comment: |- diff --git a/src/main/resources/tweakermore.mixins.json b/src/main/resources/tweakermore.mixins.json index 68c36486..37e0b62b 100644 --- a/src/main/resources/tweakermore.mixins.json +++ b/src/main/resources/tweakermore.mixins.json @@ -68,6 +68,10 @@ "tweaks.mc_tweaks.bossBarMaxEntry.BossBarHudMixin", "tweaks.mc_tweaks.bossBarScale.BossBarHudMixin", "tweaks.mc_tweaks.chatMessageLimit.ChatHudMixin", + "tweaks.mc_tweaks.clientEntityTargetingSelectAll.GameRendererMixin", + "tweaks.mc_tweaks.clientEntityTargetingSelectAll.KeyboardMixin", + "tweaks.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClient_extendedTargetMixin", + "tweaks.mc_tweaks.clientEntityTargetingSelectAll.MinecraftClient_pickEntityMixin", "tweaks.mc_tweaks.connectionSimulatedDelay.ClientConnection_ChannelInitializerMixin", "tweaks.mc_tweaks.daytimeOverride.ClientWorldMixin", "tweaks.mc_tweaks.daytimeOverride.WorldMixin", @@ -196,6 +200,7 @@ "util.render.TextHandlerAccessor" ], "client": [ + "tweaks.mc_tweaks.clientEntityTargetingSelectAll.ClientCommandSourceMixin" ], "injectors": { "defaultRequire": 1