Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.bcm.cmatd.datagen;
- import com.mojang.serialization.Codec;
- import com.mojang.serialization.codecs.RecordCodecBuilder;
- import net.minecraft.core.registries.BuiltInRegistries;
- import net.minecraft.world.level.block.Block;
- import net.minecraft.world.level.block.Blocks;
- import net.neoforged.neoforge.registries.datamaps.builtin.Compostable;
- public record HeatProducers(int heatProduced, boolean turnsIntoAnotherBlock, Block blockToTurnInto, float blockReplacementChance) {
- public static final Codec<HeatProducers> BLOCK_REPLACEMENT_CHANCE = Codec.floatRange(0f, 1f)
- .xmap(HeatProducers::new, HeatProducers::blockReplacementChance);
- public static final Codec<HeatProducers> TURNS_INTO_BLOCK = Codec.BOOL
- .xmap(HeatProducers::new, HeatProducers::turnsIntoAnotherBlock);
- public static final Codec<HeatProducers> HEAT_PRODUCED = Codec.intRange(1,Integer.MAX_VALUE)
- .xmap(HeatProducers::new,HeatProducers::heatProduced);
- public static final Codec<HeatProducers> BLOCK_TO_TURN_INTO = BuiltInRegistries.BLOCK.byNameCodec()
- .xmap(HeatProducers::new, HeatProducers::blockToTurnInto);
- public static final Codec<Compostable> CODEC = Codec.withAlternative(
- RecordCodecBuilder.create(in -> in.group(
- Codec.intRange(1,Integer.MAX_VALUE).fieldOf("heat_produced")
- .forGetter(HeatProducers::heatProduced).apply(in,HeatProducers::new),
- Codec.BOOL.fieldOf("turns_into_another_block")
- .forGetter(HeatProducers::turnsIntoAnotherBlock).apply(in,HeatProducers::new),
- Codec.floatRange(0f, 1f).fieldOf("block_replacement_chance")
- .forGetter(HeatProducers::blockReplacementChance).apply(in,HeatProducers::new),
- BuiltInRegistries.BLOCK.byNameCodec().fieldOf("next_oxidation_stage")
- .forGetter(HeatProducers::blockToTurnInto).apply(in, HeatProducers::new),
- HEAT_PRODUCED,TURNS_INTO_BLOCK,BLOCK_TO_TURN_INTO,BLOCK_REPLACEMENT_CHANCE)));
- public HeatProducers(){
- this(0,false, Blocks.AIR,0.0f);
- }
- public HeatProducers(int heatProduced){
- this(heatProduced,false,Blocks.AIR,0.0f);
- }
- public HeatProducers(boolean turnsIntoAnotherBlock){
- this(0,turnsIntoAnotherBlock,Blocks.AIR,0.0f);
- }
- public HeatProducers(Block blockToTurnInto){
- this(0,true,blockToTurnInto,0.0f);
- }
- public HeatProducers(float blockReplacementChance){
- this(0,false,Blocks.AIR,blockReplacementChance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement