diff --git a/src/main/java/tobinio/realarrowtip/RealArrowTip.java b/src/main/java/tobinio/realarrowtip/RealArrowTip.java index eb24146..a42a6e2 100644 --- a/src/main/java/tobinio/realarrowtip/RealArrowTip.java +++ b/src/main/java/tobinio/realarrowtip/RealArrowTip.java @@ -1,10 +1,14 @@ package tobinio.realarrowtip; import net.fabricmc.api.ModInitializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RealArrowTip implements ModInitializer { public static String modID = "real_arrow_tip"; + public static final Logger LOGGER = LoggerFactory.getLogger("Real Arrow Tip"); + /** * Runs the mod initializer. */ diff --git a/src/main/java/tobinio/realarrowtip/mixin/ItemColorsMixin.java b/src/main/java/tobinio/realarrowtip/mixin/ItemColorsMixin.java new file mode 100644 index 0000000..b92bb05 --- /dev/null +++ b/src/main/java/tobinio/realarrowtip/mixin/ItemColorsMixin.java @@ -0,0 +1,44 @@ +package tobinio.realarrowtip.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.color.block.BlockColors; +import net.minecraft.client.color.item.ItemColors; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.item.BowItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.TippedArrowItem; +import net.minecraft.potion.PotionUtil; +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; +import tobinio.realarrowtip.RealArrowTip; + +/** + * Created: 03/10/2023 + * @author Tobias Frischmann + */ + +@Mixin (ItemColors.class) +public abstract class ItemColorsMixin { + @Inject (method = "create", at = @At (value = "RETURN")) + private static void create(BlockColors blockColors, CallbackInfoReturnable cir, + @Local ItemColors itemColors) { + + itemColors.register((stack, tintIndex) -> { + ClientPlayerEntity player = MinecraftClient.getInstance().player; + + if (player == null || tintIndex != 1) + return -1; + + ItemStack projectileType = player.getProjectileType(stack); + + if (!(projectileType.getItem() instanceof TippedArrowItem)) + return -1; + + return PotionUtil.getColor(projectileType); + }, Items.BOW); + } +} diff --git a/src/main/resources/assets/minecraft/models/item/bow.json b/src/main/resources/assets/minecraft/models/item/bow.json new file mode 100644 index 0000000..c212875 --- /dev/null +++ b/src/main/resources/assets/minecraft/models/item/bow.json @@ -0,0 +1,50 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "item/bow" + }, + "display": { + "thirdperson_righthand": { + "rotation": [ -80, 260, -40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] + }, + "thirdperson_lefthand": { + "rotation": [ -80, -280, 40 ], + "translation": [ -1, -2, 2.5 ], + "scale": [ 0.9, 0.9, 0.9 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -90, 25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 90, -25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + } + }, + "overrides": [ + { + "predicate": { + "pulling": 1 + }, + "model": "item/bow_pulling_0" + }, + { + "predicate": { + "pulling": 1, + "pull": 0.65 + }, + "model": "item/bow_pulling_1" + }, + { + "predicate": { + "pulling": 1, + "pull": 0.9 + }, + "model": "item/bow_pulling_2" + } + ] +} diff --git a/src/main/resources/assets/minecraft/models/item/bow_pulling_0.json b/src/main/resources/assets/minecraft/models/item/bow_pulling_0.json new file mode 100644 index 0000000..dd53e14 --- /dev/null +++ b/src/main/resources/assets/minecraft/models/item/bow_pulling_0.json @@ -0,0 +1,7 @@ +{ + "parent": "item/bow", + "textures": { + "layer0": "real_arrow_tip:item/bow_pulling_0", + "layer1": "real_arrow_tip:item/bow_pulling_0_head" + } +} diff --git a/src/main/resources/assets/minecraft/models/item/bow_pulling_1.json b/src/main/resources/assets/minecraft/models/item/bow_pulling_1.json new file mode 100644 index 0000000..f6932ff --- /dev/null +++ b/src/main/resources/assets/minecraft/models/item/bow_pulling_1.json @@ -0,0 +1,7 @@ +{ + "parent": "item/bow", + "textures": { + "layer0": "real_arrow_tip:item/bow_pulling_1", + "layer1": "real_arrow_tip:item/bow_pulling_1_head" + } +} diff --git a/src/main/resources/assets/minecraft/models/item/bow_pulling_2.json b/src/main/resources/assets/minecraft/models/item/bow_pulling_2.json new file mode 100644 index 0000000..b1fb0d4 --- /dev/null +++ b/src/main/resources/assets/minecraft/models/item/bow_pulling_2.json @@ -0,0 +1,7 @@ +{ + "parent": "item/bow", + "textures": { + "layer0": "real_arrow_tip:item/bow_pulling_2", + "layer1": "real_arrow_tip:item/bow_pulling_2_head" + } +} diff --git a/src/main/resources/assets/real_arrow_tip/textures/item/bow_pulling_0.png b/src/main/resources/assets/real_arrow_tip/textures/item/bow_pulling_0.png new file mode 100644 index 0000000000000000000000000000000000000000..7c3c372bbcf500bba2551771fd976e804172b570 GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4rT@h1`S>QU&3=EtF9+AZi419+{nDKc2iWCM0hB!|b#}JL+*d9-z0|q>Y_NaXQ zUms%-Y4vo{#H0k44ofy`glX=O&z`&C3 z=}F~q_@nW6E&14G&b#u*Mr umif+>$h)({ahu}e1d*PmMs^+^hM;?#bC%5ia*lz4fx*+&&t;ucLK6U~wkUl7 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/real_arrow_tip/textures/item/bow_pulling_1.png b/src/main/resources/assets/real_arrow_tip/textures/item/bow_pulling_1.png new file mode 100644 index 0000000000000000000000000000000000000000..f1af98c40a1d505dc6cdcf210a1036b1fd6c7344 GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4rT@h1`S>QU`3w BRI>m8 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/real_arrow_tip/textures/item/bow_pulling_1_head.png b/src/main/resources/assets/real_arrow_tip/textures/item/bow_pulling_1_head.png new file mode 100644 index 0000000000000000000000000000000000000000..1acff8856a216e633a45796c8a41d35be064794d GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s77>k44ofy`glX=O&z`&C3 z=QUk44ofy`glX=O&z`&C3 z=}F~q_@St90vy@10^7iKjL tUbfk0xk)<;AG4io>uCx!;F6GFP!;8z^KV1OR|W