Search in sources :

Example 1 with CustomHoneyBlock

use of com.teamresourceful.resourcefulbees.block.CustomHoneyBlock in project ResourcefulBees by Resourceful-Bees.

the class ColorHandler method onItemColors.

public static void onItemColors(ColorHandlerEvent.Item event) {
    ItemColors colors = event.getItemColors();
    BEE_REGISTRY.getBees().forEach(((s, beeData) -> {
        HoneycombData honeycombData = beeData.getHoneycombData();
        if (honeycombData.getHoneycombType().equals(HoneycombType.DEFAULT) && !honeycombData.getColor().isDefault()) {
            registerItems(colors, HoneycombItem::getColor, BeeInfoUtils.getItem(ResourcefulBees.MOD_ID + ":" + s + "_honeycomb"));
            registerItems(colors, HoneycombBlock::getItemColor, BeeInfoUtils.getItem(ResourcefulBees.MOD_ID + ":" + s + "_honeycomb_block"));
        }
        if (!beeData.getRenderData().getColorData().getSpawnEggPrimaryColor().isDefault() && !beeData.getRenderData().getColorData().getSpawnEggSecondaryColor().isDefault()) {
            registerItems(colors, BeeSpawnEggItem::getColor, BeeInfoUtils.getItem(ResourcefulBees.MOD_ID + ":" + s + "_bee_spawn_egg"));
        }
    }));
    HoneyRegistry.getRegistry().getHoneyBottles().forEach((h, honeyData) -> {
        registerItems(colors, CustomHoneyBottleItem::getColor, honeyData.getHoneyBottleRegistryObject().get());
        if (Config.HONEY_GENERATE_BLOCKS.get() && honeyData.doGenerateHoneyBlock()) {
            registerItems(colors, CustomHoneyBlock::getItemColor, honeyData.getHoneyBlockItemRegistryObject().get());
        }
        if (Config.HONEY_GENERATE_FLUIDS.get() && honeyData.doGenerateHoneyFluid()) {
            registerItems(colors, CustomHoneyBucketItem::getColor, honeyData.getHoneyBucketItemRegistryObject().get());
        }
    });
    registerItems(colors, BeeJar::getColor, ModItems.BEE_JAR.get());
}
Also used : BlockColor(net.minecraft.client.color.block.BlockColor) CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) Config(com.teamresourceful.resourcefulbees.config.Config) HoneycombType(com.teamresourceful.resourcefulbees.lib.enums.HoneycombType) BeeInfoUtils(com.teamresourceful.resourcefulbees.utils.BeeInfoUtils) ModItems(com.teamresourceful.resourcefulbees.registry.ModItems) HoneyRegistry(com.teamresourceful.resourcefulbees.registry.HoneyRegistry) HoneycombBlock(com.teamresourceful.resourcefulbees.block.HoneycombBlock) LOGGER(com.teamresourceful.resourcefulbees.ResourcefulBees.LOGGER) com.teamresourceful.resourcefulbees.item(com.teamresourceful.resourcefulbees.item) ItemColors(net.minecraft.client.color.item.ItemColors) BeeRegistry(com.teamresourceful.resourcefulbees.registry.BeeRegistry) ItemLike(net.minecraft.world.level.ItemLike) HoneycombData(com.teamresourceful.resourcefulbees.api.beedata.HoneycombData) BlockColors(net.minecraft.client.color.block.BlockColors) ResourcefulBees(com.teamresourceful.resourcefulbees.ResourcefulBees) Block(net.minecraft.world.level.block.Block) IBeeRegistry(com.teamresourceful.resourcefulbees.api.IBeeRegistry) ColorHandlerEvent(net.minecraftforge.client.event.ColorHandlerEvent) ItemColor(net.minecraft.client.color.item.ItemColor) HoneycombData(com.teamresourceful.resourcefulbees.api.beedata.HoneycombData) ItemColors(net.minecraft.client.color.item.ItemColors) CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock)

Example 2 with CustomHoneyBlock

use of com.teamresourceful.resourcefulbees.block.CustomHoneyBlock in project ResourcefulBees by Resourceful-Bees.

the class RegistryHandler method registerHoneyBottle.

// TODO does this need to use the codec? - epic
private static void registerHoneyBottle(String name, JsonObject honeyData) {
    HoneyBottleData honeyBottleData = HoneyBottleData.CODEC.parse(JsonOps.INSTANCE, honeyData).getOrThrow(false, s -> ResourcefulBees.LOGGER.error("Could not create Custom Honey Data for {} honey", name));
    final RegistryObject<Item> customHoneyBottle = ModItems.ITEMS.register(name + "_honey_bottle", () -> new CustomHoneyBottleItem(honeyBottleData.getProperties(), honeyBottleData));
    honeyBottleData.setHoneyBottleRegistryObject(customHoneyBottle);
    honeyBottleData.setName(name);
    if (Config.HONEY_GENERATE_BLOCKS.get() && honeyBottleData.doGenerateHoneyBlock()) {
        final RegistryObject<Block> customHoneyBlock = ModBlocks.BLOCKS.register(name + "_honey_block", () -> new CustomHoneyBlock(honeyBottleData));
        final RegistryObject<Item> customHoneyBlockItem = ModItems.ITEMS.register(name + "_honey_block", () -> new BlockItem(customHoneyBlock.get(), new Item.Properties().tab(ItemGroupResourcefulBees.RESOURCEFUL_BEES)));
        honeyBottleData.setHoneyBlockRegistryObject(customHoneyBlock);
        honeyBottleData.setHoneyBlockItemRegistryObject(customHoneyBlockItem);
    }
    if (Config.HONEY_GENERATE_FLUIDS.get() && honeyBottleData.doGenerateHoneyFluid()) {
        stillFluids.put(name, ModFluids.FLUIDS.register(name + "_honey", () -> new CustomHoneyFluid.Source(makeProperties(name, honeyBottleData), honeyBottleData)));
        flowingFluids.put(name, ModFluids.FLUIDS.register(name + "_honey_flowing", () -> new CustomHoneyFluid.Flowing(makeProperties(name, honeyBottleData), honeyBottleData)));
        honeyBuckets.put(name, ModItems.ITEMS.register(name + "_honey_fluid_bucket", () -> new CustomHoneyBucketItem(stillFluids.get(name), new Item.Properties().tab(ItemGroupResourcefulBees.RESOURCEFUL_BEES).craftRemainder(Items.BUCKET).stacksTo(1), honeyBottleData)));
        fluidBlocks.put(name, ModBlocks.BLOCKS.register(name + "_honey", () -> new CustomHoneyFluidBlock(stillFluids.get(name), BlockBehaviour.Properties.of(Material.WATER).noCollission().strength(100.0F).noDrops(), honeyBottleData)));
        honeyBottleData.setHoneyStillFluidRegistryObject(stillFluids.get(name));
        honeyBottleData.setHoneyFlowingFluidRegistryObject(flowingFluids.get(name));
        honeyBottleData.setHoneyBucketItemRegistryObject(honeyBuckets.get(name));
        honeyBottleData.setHoneyFluidBlockRegistryObject(fluidBlocks.get(name));
    }
    HoneyRegistry.getRegistry().registerHoney(name, honeyBottleData);
}
Also used : CustomHoneyBucketItem(com.teamresourceful.resourcefulbees.item.CustomHoneyBucketItem) HoneyBottleData(com.teamresourceful.resourcefulbees.api.honeydata.HoneyBottleData) CustomHoneyFluidBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyFluidBlock) BlockItem(net.minecraft.world.item.BlockItem) Item(net.minecraft.world.item.Item) CustomHoneyBottleItem(com.teamresourceful.resourcefulbees.item.CustomHoneyBottleItem) BlockItem(net.minecraft.world.item.BlockItem) CustomHoneyBucketItem(com.teamresourceful.resourcefulbees.item.CustomHoneyBucketItem) BeeSpawnEggItem(com.teamresourceful.resourcefulbees.item.BeeSpawnEggItem) HoneycombItem(com.teamresourceful.resourcefulbees.item.HoneycombItem) CustomHoneyBottleItem(com.teamresourceful.resourcefulbees.item.CustomHoneyBottleItem) CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) LiquidBlock(net.minecraft.world.level.block.LiquidBlock) CustomHoneyFluidBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyFluidBlock) CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) HoneycombBlock(com.teamresourceful.resourcefulbees.block.HoneycombBlock) DispenserBlock(net.minecraft.world.level.block.DispenserBlock) Block(net.minecraft.world.level.block.Block)

Example 3 with CustomHoneyBlock

use of com.teamresourceful.resourcefulbees.block.CustomHoneyBlock in project ResourcefulBees by Resourceful-Bees.

the class AbstractHoneyTankContainer method processFluid.

public void processFluid() {
    if (canProcessFluid()) {
        ItemStack stack = getTileStackHandler().getStackInSlot(BOTTLE_INPUT_EMPTY);
        ItemStack output = getTileStackHandler().getStackInSlot(BOTTLE_OUTPUT_EMPTY);
        BlockItem blockItem = null;
        if (stack.getItem() instanceof BlockItem) {
            blockItem = (BlockItem) stack.getItem();
        }
        if (blockItem != null && blockItem.getBlock() instanceof CustomHoneyBlock) {
            stack.shrink(1);
            HoneyBottleData data = ((CustomHoneyBlock) blockItem.getBlock()).getData();
            getFluidTank().fill(new FluidStack(data.getHoneyStillFluidRegistryObject().get(), 1000), IFluidHandler.FluidAction.EXECUTE);
        } else if (stack.getItem() instanceof BucketItem) {
            BucketItem bucket = (BucketItem) stack.getItem();
            getFluidTank().fill(new FluidStack(bucket.getFluid(), 1000), IFluidHandler.FluidAction.EXECUTE);
            stack.shrink(1);
            if (output.isEmpty()) {
                getTileStackHandler().setStackInSlot(BOTTLE_OUTPUT_EMPTY, new ItemStack(Items.BUCKET));
            } else {
                output.grow(1);
            }
        } else {
            FluidStack fluidStack = new FluidStack(BeeInfoUtils.getHoneyFluidFromBottle(stack), HONEY_FILL_AMOUNT);
            if (!fluidStack.isEmpty())
                getFluidTank().fill(fluidStack, IFluidHandler.FluidAction.EXECUTE);
            stack.shrink(1);
            if (output.isEmpty()) {
                getTileStackHandler().setStackInSlot(BOTTLE_OUTPUT_EMPTY, new ItemStack(Items.GLASS_BOTTLE));
            } else {
                output.grow(1);
            }
        }
        this.dirty = true;
    }
}
Also used : CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) HoneyBottleData(com.teamresourceful.resourcefulbees.api.honeydata.HoneyBottleData) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 4 with CustomHoneyBlock

use of com.teamresourceful.resourcefulbees.block.CustomHoneyBlock in project ResourcefulBees by Resourceful-Bees.

the class AbstractHoneyTankContainer method canProcessFluid.

public boolean canProcessFluid() {
    boolean spaceLeft;
    ItemStack stack = getTileStackHandler().getStackInSlot(BOTTLE_INPUT_EMPTY);
    if (!canStartFluidProcess())
        return false;
    Fluid fluid;
    BlockItem blockItem = null;
    if (stack.getItem() instanceof BlockItem) {
        blockItem = (BlockItem) stack.getItem();
    }
    if (blockItem != null && blockItem.getBlock() instanceof CustomHoneyBlock) {
        HoneyBottleData item = ((CustomHoneyBlock) blockItem.getBlock()).getData();
        spaceLeft = (getFluidTank().getFluidAmount() + 1000) <= getFluidTank().getCapacity();
        fluid = item.getHoneyStillFluidRegistryObject().get();
    } else if (stack.getItem() instanceof BucketItem) {
        BucketItem item = (BucketItem) stack.getItem();
        spaceLeft = (getFluidTank().getFluidAmount() + 1000) <= getFluidTank().getCapacity();
        fluid = item.getFluid();
    } else {
        spaceLeft = (getFluidTank().getFluidAmount() + HONEY_FILL_AMOUNT) <= getFluidTank().getCapacity();
        fluid = BeeInfoUtils.getHoneyFluidFromBottle(stack);
    }
    return spaceLeft && (getFluidTank().getFluid().getFluid() == fluid || getFluidTank().isEmpty());
}
Also used : CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) HoneyBottleData(com.teamresourceful.resourcefulbees.api.honeydata.HoneyBottleData) Fluid(net.minecraft.world.level.material.Fluid)

Example 5 with CustomHoneyBlock

use of com.teamresourceful.resourcefulbees.block.CustomHoneyBlock in project ResourcefulBees by Resourceful-Bees.

the class ColorHandler method onBlockColors.

public static void onBlockColors(ColorHandlerEvent.Block event) {
    BlockColors colors = event.getBlockColors();
    BEE_REGISTRY.getBees().forEach(((s, beeData) -> {
        HoneycombData honeycombData = beeData.getHoneycombData();
        if (honeycombData.getHoneycombType().equals(HoneycombType.DEFAULT) && (!honeycombData.getColor().isDefault())) {
            registerBlocks(colors, HoneycombBlock::getBlockColor, BeeInfoUtils.getBlock(ResourcefulBees.MOD_ID + ":" + s + "_honeycomb_block"));
        }
    }));
    HoneyRegistry.getRegistry().getHoneyBottles().forEach((h, honeyData) -> {
        if (Config.HONEY_GENERATE_BLOCKS.get() && honeyData.doGenerateHoneyBlock()) {
            registerBlocks(colors, CustomHoneyBlock::getBlockColor, honeyData.getHoneyBlockRegistryObject().get());
        }
    });
}
Also used : BlockColor(net.minecraft.client.color.block.BlockColor) CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) Config(com.teamresourceful.resourcefulbees.config.Config) HoneycombType(com.teamresourceful.resourcefulbees.lib.enums.HoneycombType) BeeInfoUtils(com.teamresourceful.resourcefulbees.utils.BeeInfoUtils) ModItems(com.teamresourceful.resourcefulbees.registry.ModItems) HoneyRegistry(com.teamresourceful.resourcefulbees.registry.HoneyRegistry) HoneycombBlock(com.teamresourceful.resourcefulbees.block.HoneycombBlock) LOGGER(com.teamresourceful.resourcefulbees.ResourcefulBees.LOGGER) com.teamresourceful.resourcefulbees.item(com.teamresourceful.resourcefulbees.item) ItemColors(net.minecraft.client.color.item.ItemColors) BeeRegistry(com.teamresourceful.resourcefulbees.registry.BeeRegistry) ItemLike(net.minecraft.world.level.ItemLike) HoneycombData(com.teamresourceful.resourcefulbees.api.beedata.HoneycombData) BlockColors(net.minecraft.client.color.block.BlockColors) ResourcefulBees(com.teamresourceful.resourcefulbees.ResourcefulBees) Block(net.minecraft.world.level.block.Block) IBeeRegistry(com.teamresourceful.resourcefulbees.api.IBeeRegistry) ColorHandlerEvent(net.minecraftforge.client.event.ColorHandlerEvent) ItemColor(net.minecraft.client.color.item.ItemColor) HoneycombData(com.teamresourceful.resourcefulbees.api.beedata.HoneycombData) CustomHoneyBlock(com.teamresourceful.resourcefulbees.block.CustomHoneyBlock) BlockColors(net.minecraft.client.color.block.BlockColors)

Aggregations

CustomHoneyBlock (com.teamresourceful.resourcefulbees.block.CustomHoneyBlock)5 HoneyBottleData (com.teamresourceful.resourcefulbees.api.honeydata.HoneyBottleData)3 HoneycombBlock (com.teamresourceful.resourcefulbees.block.HoneycombBlock)3 Block (net.minecraft.world.level.block.Block)3 ResourcefulBees (com.teamresourceful.resourcefulbees.ResourcefulBees)2 LOGGER (com.teamresourceful.resourcefulbees.ResourcefulBees.LOGGER)2 IBeeRegistry (com.teamresourceful.resourcefulbees.api.IBeeRegistry)2 HoneycombData (com.teamresourceful.resourcefulbees.api.beedata.HoneycombData)2 Config (com.teamresourceful.resourcefulbees.config.Config)2 com.teamresourceful.resourcefulbees.item (com.teamresourceful.resourcefulbees.item)2 HoneycombType (com.teamresourceful.resourcefulbees.lib.enums.HoneycombType)2 BeeRegistry (com.teamresourceful.resourcefulbees.registry.BeeRegistry)2 HoneyRegistry (com.teamresourceful.resourcefulbees.registry.HoneyRegistry)2 ModItems (com.teamresourceful.resourcefulbees.registry.ModItems)2 BeeInfoUtils (com.teamresourceful.resourcefulbees.utils.BeeInfoUtils)2 BlockColor (net.minecraft.client.color.block.BlockColor)2 BlockColors (net.minecraft.client.color.block.BlockColors)2 ItemColor (net.minecraft.client.color.item.ItemColor)2 ItemColors (net.minecraft.client.color.item.ItemColors)2 ItemLike (net.minecraft.world.level.ItemLike)2