use of cech12.extendedmushrooms.item.MushroomType in project ExtendedMushrooms by cech12.
the class EatMushroomGoal method tick.
/**
* Keep ticking a continuous task that has already been started
*/
@Override
public void tick() {
this.eatingTimer = Math.max(0, this.eatingTimer - 1);
if (this.eatingTimer == 4) {
BlockPos blockPos = getBlockPos();
if (this.isEntityOnMushroom()) {
MushroomType mushroomType = MushroomType.byItemOrNull(this.entityWorld.getBlockState(this.eaterEntity.blockPosition()).getBlock().asItem());
if (this.entityWorld.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
this.entityWorld.destroyBlock(blockPos, false);
}
this.eaterEntity.ate();
if (Config.SHEEP_ABSORB_MUSHROOM_TYPE_ENABLED.get()) {
if (this.eaterEntity instanceof SheepEntity && mushroomType != null) {
if (this.eaterEntity instanceof MushroomSheepEntity) {
MushroomSheepEntity mushroomSheep = (MushroomSheepEntity) this.eaterEntity;
mushroomSheep.setMushroomType(mushroomType);
mushroomSheep.activateMushroomEffect(mushroomType);
} else {
MushroomSheepEntity.replaceSheep((SheepEntity) this.eaterEntity, mushroomType);
}
}
}
}
}
}
use of cech12.extendedmushrooms.item.MushroomType in project ExtendedMushrooms by cech12.
the class MushroomSheepEntity method mobInteract.
@Override
@Nonnull
public ActionResultType mobInteract(PlayerEntity player, @Nonnull Hand hand) {
Item item = player.getItemInHand(hand).getItem();
ActionResultType superResult = super.mobInteract(player, hand);
if (superResult.consumesAction() && Config.SHEEP_ABSORB_MUSHROOM_TYPE_ENABLED.get() && item.is(Tags.Items.MUSHROOMS)) {
// change mushroom type
MushroomType type = MushroomType.byItemOrNull(item);
if (type != null && type != this.getMushroomType()) {
this.setMushroomType(type);
this.activateMushroomEffect(type);
return ActionResultType.SUCCESS;
}
}
return superResult;
}
Aggregations