Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apple slice tag #8

Open
wants to merge 2 commits into
base: 1.16.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import com.cgessinger.creaturesandbeasts.CreaturesAndBeasts;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;

import javax.annotation.Nullable;
import java.util.Arrays;
Expand All @@ -62,6 +65,8 @@ public class LizardEntity
extends AnimalEntity
implements IAnimatable, IModNetable, IAnimationHolder<LizardEntity>
{
private final ResourceLocation APPLE_SLICE = new ResourceLocation(CreaturesAndBeasts.MOD_ID, "apple_slice");

private final AnimationFactory factory = new AnimationFactory( this );

private static final DataParameter<Boolean> PARTYING =
Expand Down Expand Up @@ -218,7 +223,9 @@ public ActionResultType func_230254_b_( PlayerEntity player, Hand hand ) // on r
{
ActionResultType result = super.func_230254_b_( player, hand );
ItemStack item = player.getHeldItem( hand );
if ( item.getItem() instanceof AppleSliceItem && this.isSad() )
ITag<Item> apple_slice = ItemTags.getCollection().get(APPLE_SLICE);
boolean has_slices = apple_slice == null ? item.getItem() instanceof AppleSliceItem : apple_slice.contains(item.getItem());
if( has_slices && this.isSad() )
{
this.setSad( false );
item.shrink( player.abilities.isCreativeMode ? 0 : 1 );
Expand Down Expand Up @@ -346,7 +353,8 @@ public boolean shouldLookAround()
@Override
public boolean isBreedingItem( ItemStack stack )
{
return stack.getItem() instanceof AppleSliceItem;
ITag<Item> apple_slice = ItemTags.getCollection().get(APPLE_SLICE);
return apple_slice == null ? stack.getItem() instanceof AppleSliceItem : apple_slice.contains(stack.getItem());
}

public void spawnParticles( IParticleData data )
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/data/cnb/tags/items/apple_slice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"cnb:apple_slice"
]
}