generated from Fallen-Breath/fabric-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mc_tweak
clientEntityTargetingSelectAll
resolved #56
- Loading branch information
1 parent
6aee682
commit b105915
Showing
13 changed files
with
535 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...reath/tweakermore/impl/mc_tweaks/clientEntityTargetingSelectAll/EntityItemPickHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...mpl/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClientWithExtendedTargetEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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); | ||
} |
59 changes: 59 additions & 0 deletions
59
...more/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/ClientCommandSourceMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/GameRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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<Entity> predicate, double reach, Operation<EntityHitResult> original) | ||
{ | ||
MinecraftClientWithExtendedTargetEntity access = (MinecraftClientWithExtendedTargetEntity)this.client; | ||
if (TweakerMoreConfigs.CLIENT_ENTITY_TARGETING_SUPPORT_ALL.getBooleanValue()) | ||
{ | ||
access.setExtendedEntityHitResult$TKM(original.call(entity, vecStart, vecEnd, box, (Predicate<Entity>)e -> true, reach)); | ||
} | ||
else | ||
{ | ||
access.setExtendedEntityHitResult$TKM(null); | ||
} | ||
return original.call(entity, vecStart, vecEnd, box, predicate, reach); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ath/tweakermore/mixins/tweaks/mc_tweaks/clientEntityTargetingSelectAll/KeyboardMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
.../tweaks/mc_tweaks/clientEntityTargetingSelectAll/MinecraftClient_extendedTargetMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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; | ||
} | ||
} |
Oops, something went wrong.