Search in sources :

Example 1 with AbstractFurnaceBlockEntity

use of net.minecraft.block.entity.AbstractFurnaceBlockEntity 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);
}
Also used : AbstractFurnaceBlockEntity(net.minecraft.block.entity.AbstractFurnaceBlockEntity) AbstractFurnaceAccessor(net.sistr.littlemaidrebirth.util.AbstractFurnaceAccessor) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Example 2 with AbstractFurnaceBlockEntity

use of net.minecraft.block.entity.AbstractFurnaceBlockEntity in project Polymorph by TheIllusiveC4.

the class PolymorphMod method onInitialize.

@Override
public void onInitialize() {
    PolymorphNetwork.setup();
    PolymorphCommands.setup();
    CommonEventsListener.setup();
    PolymorphIntegrations.init();
    PolymorphIntegrations.setup();
    PolymorphCommon commonApi = PolymorphApi.common();
    commonApi.registerBlockEntity2RecipeData(AbstractFurnaceBlockEntity.class, blockEntity -> new FurnaceRecipeData((AbstractFurnaceBlockEntity) blockEntity));
    commonApi.registerScreenHandler2BlockEntity(container -> {
        for (Slot inventorySlot : container.slots) {
            Inventory inventory = inventorySlot.inventory;
            if (inventory instanceof BlockEntity) {
                return (BlockEntity) inventory;
            }
        }
        return null;
    });
}
Also used : AbstractFurnaceBlockEntity(net.minecraft.block.entity.AbstractFurnaceBlockEntity) FurnaceRecipeData(top.theillusivec4.polymorph.common.component.FurnaceRecipeData) Slot(net.minecraft.screen.slot.Slot) PolymorphCommon(top.theillusivec4.polymorph.api.common.base.PolymorphCommon) Inventory(net.minecraft.inventory.Inventory) BlockEntity(net.minecraft.block.entity.BlockEntity) AbstractFurnaceBlockEntity(net.minecraft.block.entity.AbstractFurnaceBlockEntity)

Aggregations

AbstractFurnaceBlockEntity (net.minecraft.block.entity.AbstractFurnaceBlockEntity)2 Inventory (net.minecraft.inventory.Inventory)2 BlockEntity (net.minecraft.block.entity.BlockEntity)1 SimpleInventory (net.minecraft.inventory.SimpleInventory)1 Slot (net.minecraft.screen.slot.Slot)1 AbstractFurnaceAccessor (net.sistr.littlemaidrebirth.util.AbstractFurnaceAccessor)1 PolymorphCommon (top.theillusivec4.polymorph.api.common.base.PolymorphCommon)1 FurnaceRecipeData (top.theillusivec4.polymorph.common.component.FurnaceRecipeData)1