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

Add composting support #4501

Merged
Merged
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 @@ -30,6 +30,7 @@
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.MinecartComparatorLogicRegistry;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FlattenableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.registry.TillableBlockRegistry;
Expand Down Expand Up @@ -125,6 +126,7 @@ public void onInitialize() {
registryInit();

PaintableData.init();
CompostingData.init(CompostingChanceRegistry.INSTANCE::add);
DefaultCorporeaMatchers.init();

PatchouliAPI.get().registerMultiblock(BuiltInRegistries.BLOCK.getKey(BotaniaBlocks.alfPortal), AlfheimPortalBlockEntity.MULTIBLOCK.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.world.item.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -147,6 +148,7 @@ public void commonSetup(FMLCommonSetupEvent evt) {
evt.enqueueWork(BotaniaBlocks::addDispenserBehaviours);
BotaniaBlocks.addAxeStripping();
PaintableData.init();
CompostingData.init((itemLike, chance) -> ComposterBlock.COMPOSTABLES.putIfAbsent(itemLike.asItem(), (float) chance));
DefaultCorporeaMatchers.init();

PatchouliAPI.get().registerMultiblock(BuiltInRegistries.BLOCK.getKey(BotaniaBlocks.alfPortal), AlfheimPortalBlockEntity.MULTIBLOCK.get());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package vazkii.botania.common.handler;

import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.ItemLike;

import vazkii.botania.common.block.BotaniaBlocks;
import vazkii.botania.common.item.BotaniaItems;

import java.util.function.BiConsumer;

public class CompostingData {
public static void init(BiConsumer<ItemLike, Float> registrationMethod) {
// common vanilla composting chances:
final float chanceLowest = 0.3f;
final float chanceLow = 0.5f;
final float chanceMid = 0.65f;
final float chanceHigh = 0.85f;
// unused here: final float chanceHighest = 1.0f;

// see https://github.com/VazkiiMods/Botania/issues/4263#issuecomment-1529130978
for (final var dyeColor : DyeColor.values()) {
registrationMethod.accept(BotaniaItems.getPetal(dyeColor), chanceLowest);
registrationMethod.accept(BotaniaBlocks.getPetalBlock(dyeColor), chanceLow);
registrationMethod.accept(BotaniaBlocks.getFlower(dyeColor), chanceMid);
registrationMethod.accept(BotaniaBlocks.getDoubleFlower(dyeColor), chanceMid);
registrationMethod.accept(BotaniaBlocks.getMushroom(dyeColor), chanceMid);
}

registrationMethod.accept(BotaniaBlocks.cellBlock, chanceHigh);
}
}
Loading