-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
150 additions
and
457 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...tem-api-v1/src/client/java/net/fabricmc/fabric/impl/client/item/ClientItemEventHooks.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,15 @@ | ||
package net.fabricmc.fabric.impl.client.item; | ||
|
||
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; | ||
|
||
@EventBusSubscriber | ||
public class ClientItemEventHooks { | ||
|
||
@SubscribeEvent | ||
public static void onItemTooltip(ItemTooltipEvent event) { | ||
ItemTooltipCallback.EVENT.invoker().getTooltip(event.getItemStack(), event.getContext(), event.getFlags(), event.getToolTip()); | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
...lient/java/net/fabricmc/fabric/mixin/item/client/ClientPlayerInteractionManagerMixin.java
This file was deleted.
Oops, something went wrong.
66 changes: 0 additions & 66 deletions
66
...m-api-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/HeldItemRendererMixin.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
...i-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/IItemExtensionClientMixin.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,35 @@ | ||
package net.fabricmc.fabric.mixin.item.client; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import net.fabricmc.fabric.api.item.v1.FabricItem; | ||
import net.fabricmc.fabric.impl.item.RecursivityHelper; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.neoforged.neoforge.common.extensions.IItemExtension; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(IItemExtension.class) | ||
public interface IItemExtensionClientMixin { | ||
|
||
@ModifyReturnValue(method = "shouldCauseReequipAnimation", at = @At("RETURN")) | ||
default boolean shouldCauseReequipAnimation(boolean result, ItemStack oldStack, ItemStack newStack, boolean slotChanged) { | ||
if (result) { | ||
Player player = Minecraft.getInstance().player; | ||
InteractionHand hand = oldStack == player.getMainHandItem() ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; | ||
return RecursivityHelper.nonRecursiveApiCall(() -> ((FabricItem) this).allowComponentsUpdateAnimation(player, hand, oldStack, newStack)); | ||
} | ||
return false; | ||
} | ||
|
||
@Inject(method = "shouldCauseBlockBreakReset", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;isDamageableItem()Z"), cancellable = true) | ||
default void shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack, CallbackInfoReturnable<Boolean> cir) { | ||
if (!ItemStack.isSameItemSameComponents(newStack, oldStack) && oldStack.getItem().allowContinuingBlockBreaking(Minecraft.getInstance().player, oldStack, newStack)) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} |
40 changes: 0 additions & 40 deletions
40
fabric-item-api-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/ItemStackMixin.java
This file was deleted.
Oops, something went wrong.
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
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
23 changes: 0 additions & 23 deletions
23
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/RecipeRemainderHandler.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/RecursivityHelper.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,21 @@ | ||
package net.fabricmc.fabric.impl.item; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public final class RecursivityHelper { | ||
public static final ThreadLocal<Boolean> FORGE_CALL = ThreadLocal.withInitial(() -> false); | ||
|
||
public static <T> T nonRecursiveApiCall(Supplier<T> supplier) { | ||
FORGE_CALL.set(true); | ||
T result = supplier.get(); | ||
FORGE_CALL.set(false); | ||
return result; | ||
} | ||
|
||
public static boolean allowForgeCall() { | ||
return !FORGE_CALL.get(); | ||
} | ||
|
||
private RecursivityHelper() { | ||
} | ||
} |
Oops, something went wrong.