use of net.sistr.littlemaidrebirth.util.AbstractFurnaceAccessor in project LittleMaidReBirth-Fabric by SistrScarlet.
the class CookingMode method tick.
@Override
public void tick() {
AbstractFurnaceBlockEntity furnace = getFurnace(furnacePos).orElse(getFurnace(findFurnacePos().orElse(null)).orElse(null));
if (furnace == null) {
furnacePos = null;
return;
}
this.mob.getLookControl().lookAt(furnacePos.getX() + 0.5, furnacePos.getY() + 0.5, furnacePos.getZ() + 0.5);
if (!this.mob.getBlockPos().isWithinDistance(furnacePos, 2)) {
if (this.mob.isSneaking()) {
this.mob.setSneaking(false);
}
if (--this.timeToRecalcPath <= 0) {
this.timeToRecalcPath = 10;
this.mob.getNavigation().startMovingTo(furnacePos.getX() + 0.5D, furnacePos.getY() + 0.5D, furnacePos.getZ() + 0.5D, 1);
}
return;
}
this.mob.getNavigation().stop();
if (!this.mob.isSneaking()) {
this.mob.setSneaking(true);
}
Inventory inventory = this.mob.getInventory();
RecipeType<? extends AbstractCookingRecipe> recipeType = ((AbstractFurnaceAccessor) furnace).getRecipeType_LM();
getCookable(recipeType).ifPresent(cookableIndex -> tryInsertCookable(furnace, inventory, cookableIndex));
getFuel().ifPresent(fuelIndex -> tryInsertFuel(furnace, inventory, fuelIndex));
tryExtractItem(furnace, inventory);
}
use of net.sistr.littlemaidrebirth.util.AbstractFurnaceAccessor in project LittleMaidReBirth-Fabric by SistrScarlet.
the class CookingMode method canUseFurnace.
public boolean canUseFurnace(AbstractFurnaceBlockEntity tile) {
if (tile == null) {
return false;
}
for (int slot : tile.getAvailableSlots(Direction.UP)) {
ItemStack stack = tile.getStack(slot);
if (!stack.isEmpty())
continue;
RecipeType<? extends AbstractCookingRecipe> recipeType = ((AbstractFurnaceAccessor) tile).getRecipeType_LM();
if (getAllCoockable(recipeType).anyMatch(cookable -> tile.canInsert(slot, cookable, Direction.UP))) {
return true;
}
}
return false;
}
Aggregations