Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipseisoffline committed Jan 19, 2025
1 parent d22e815 commit 4b7ef99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public record Consumable(@Positive float consumeSeconds, Animation animation) {
}

/**
* Not all animations work perfectly on bedrock. Bedrock behaviour is noted per animation.
* Not all animations work perfectly on bedrock. Bedrock behaviour is noted per animation. The {@code toot_horn} animation doesn't exist on bedrock, and is therefore not listed here.
*/
public enum Animation {
/**
Expand Down Expand Up @@ -71,7 +71,6 @@ public enum Animation {
* Does nothing in 1st person, but looks like spyglass in 3rd person.
*/
SPYGLASS,
TOOT_HORN,
/**
* Brush in 1st and 3rd person. Will look weird when not displayed handheld.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public class CustomItemRegistryPopulator {
Consumable.ItemUseAnimation.SPEAR, 6,
Consumable.ItemUseAnimation.CROSSBOW, 9,
Consumable.ItemUseAnimation.SPYGLASS, 10,
Consumable.ItemUseAnimation.TOOT_HORN, 11,
Consumable.ItemUseAnimation.BRUSH, 12
);

Expand Down Expand Up @@ -509,11 +508,14 @@ private static void computeChargeableProperties(NbtMapBuilder itemProperties, Nb
private static void computeConsumableProperties(Consumable consumable, @Nullable FoodProperties foodProperties, NbtMapBuilder itemProperties, NbtMapBuilder componentBuilder) {
// this is the duration of the use animation in ticks; note that in behavior packs this is set as a float in seconds, but over the network it is an int in ticks
itemProperties.putInt("use_duration", (int) (consumable.consumeSeconds() * 20));
itemProperties.putInt("use_animation", BEDROCK_ANIMATIONS.get(consumable.animation()));

componentBuilder.putCompound("minecraft:use_animation", NbtMap.builder()
.putString("value", consumable.animation().toString().toLowerCase())
.build());
Integer animationId = BEDROCK_ANIMATIONS.get(consumable.animation());
if (animationId != null) {
itemProperties.putInt("use_animation", animationId);
componentBuilder.putCompound("minecraft:use_animation", NbtMap.builder()
.putString("value", consumable.animation().toString().toLowerCase())
.build());
}

int nutrition = foodProperties == null ? 0 : foodProperties.getNutrition();
float saturationModifier = foodProperties == null ? 0.0F : foodProperties.getSaturationModifier();
Expand Down

0 comments on commit 4b7ef99

Please sign in to comment.