-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tool model now supports propigating item overrides, allowing us to add pulling properties Added properties for pulling for bows in a convenient location
- Loading branch information
1 parent
755ea9b
commit 2978e7c
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/slimeknights/tconstruct/library/client/model/TinkerItemProperties.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 @@ | ||
package slimeknights.tconstruct.library.client.model; | ||
|
||
import net.minecraft.client.renderer.item.ItemProperties; | ||
import net.minecraft.client.renderer.item.ItemPropertyFunction; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
import slimeknights.tconstruct.library.tools.nbt.ToolStack; | ||
import slimeknights.tconstruct.library.tools.stat.ToolStats; | ||
|
||
/** Properties for tinker tools */ | ||
public class TinkerItemProperties { | ||
/** ID for the pull property */ | ||
private static final ResourceLocation PULL_ID = new ResourceLocation("pull"); | ||
/** Property for bow pull amount */ | ||
private static final ItemPropertyFunction PULL = (stack, level, holder, seed) -> { | ||
if (holder == null) { | ||
return 0.0F; | ||
} | ||
return holder.getUseItem() != stack ? 0.0F : (float)(stack.getUseDuration() - holder.getUseItemRemainingTicks()) * ToolStack.from(stack).getStats().get(ToolStats.DRAW_SPEED) / 20.0F; | ||
}; | ||
|
||
/** ID for the pulling property */ | ||
private static final ResourceLocation PULLING_ID = new ResourceLocation("pulling"); | ||
/** Boolean indicating the bow is pulling */ | ||
private static final ItemPropertyFunction PULLING = (stack, level, holder, seed) -> holder != null && holder.isUsingItem() && holder.getUseItem() == stack ? 1.0F : 0.0F; | ||
|
||
/** Registers properties for a bow */ | ||
public static void registerBowProperties(Item item) { | ||
ItemProperties.register(item, PULL_ID, PULL); | ||
ItemProperties.register(item, PULLING_ID, PULLING); | ||
} | ||
} |
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