Skip to content

Commit

Permalink
feat: Flower set
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jun 20, 2024
1 parent 43039f4 commit 7d4535c
Show file tree
Hide file tree
Showing 21 changed files with 207 additions and 50 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aether_version=1.20.4-1.4.1-neoforge
nitrogen_version=1.20.4-1.1.4-neoforge
cumulus_version=1.20.4-1.0.1-neoforge
curios_version=7.3.4
zenith_version=1.0.74
zenith_version=1.0.77
aeroblender_version=5271794
terrablender_version=1.20.4-3.3.0.12
terrablender_version_minimum=1.20.4-3.3.0.0
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/zepalesque/redux/Redux.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.zepalesque.redux.world.biome.tint.ReduxBiomeTints;
import net.zepalesque.redux.world.feature.gen.ReduxFeatures;
import net.zepalesque.redux.world.tree.foliage.ReduxFoliagePlacers;
import net.zepalesque.zenith.api.blockset.AbstractFlowerSet;
import net.zepalesque.zenith.api.blockset.AbstractStoneSet;
import net.zepalesque.zenith.api.blockset.AbstractWoodSet;
import org.slf4j.Logger;
Expand All @@ -44,8 +45,8 @@ public class Redux {
public static final Logger LOGGER = LogUtils.getLogger();

public static final Collection<AbstractWoodSet> WOOD_SETS = new ArrayList<>();

public static final Collection<AbstractStoneSet> STONE_SETS = new ArrayList<>();
public static final Collection<AbstractFlowerSet> FLOWER_SETS = new ArrayList<>();

public Redux(IEventBus bus, Dist dist) {
bus.addListener(ReduxData::dataSetup);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.zepalesque.redux.blockset.flower;

import com.aetherteam.aether.block.AetherBlocks;
import com.aetherteam.aether.item.AetherCreativeTabs;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.block.natural.bush.CustomBoundsFlowerBlock;
import net.zepalesque.redux.blockset.flower.type.AetherFlowerSet;
import net.zepalesque.redux.blockset.flower.type.BaseFlowerSet;
import net.zepalesque.redux.blockset.stone.ReduxStoneSets;
import net.zepalesque.zenith.api.blockset.AbstractFlowerSet;
import net.zepalesque.zenith.api.blockset.AbstractStoneSet;
import net.zepalesque.zenith.block.util.CommonPlantBounds;

public class ReduxFlowerSets {

public static final BaseFlowerSet<CustomBoundsFlowerBlock> AURUM = register(new AetherFlowerSet<>("aurum", "natural/",
() -> new CustomBoundsFlowerBlock(CommonPlantBounds.FLOWER,
() -> MobEffects.LUCK, 60, Properties.ofFullCopy(Blocks.DANDELION)), 1, /*TODO*/ 0xFFED96))
.creativeTab(AetherCreativeTabs.AETHER_NATURAL_BLOCKS, AetherBlocks.WHITE_FLOWER)
.craftsIntoShapeless(1, () -> Items.YELLOW_DYE, 1, RecipeCategory.MISC);

public static <T extends AbstractFlowerSet> T register(T set) {
Redux.FLOWER_SETS.add(set);
return set;
}

public static void init() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.zepalesque.redux.blockset.flower.type;

import net.minecraft.world.level.block.Block;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.data.prov.ReduxBlockStateProvider;
import net.zepalesque.redux.data.prov.ReduxItemModelProvider;
import net.zepalesque.zenith.util.lambda.Consumers;
import org.apache.logging.log4j.util.TriConsumer;

import java.util.function.Supplier;

public class AetherFlowerSet<B extends Block> extends TintedFlowerSet<B> {
public AetherFlowerSet(String id, String textureFolder, Supplier<B> constructor, int tintdex, int itemTint) {
super(id, textureFolder, constructor, tintdex, itemTint);
}

@Override
public void blockData(ReduxBlockStateProvider data) {
data.crossTintedOverlay(this.flower().get(), this.textureFolder);
Consumers.C3<Block, Block, String> pot = this.usePottedPrefix ? data::tintedPotOverlayAlt : data::tintedPotOverlay;
pot.accept(this.pot().get(), this.flower().get(), this.textureFolder);
}

@Override
public void itemData(ReduxItemModelProvider data) {
data.itemBlockFlatTintOverlay(this.flower().get(), this.textureFolder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.tags.TagKey;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour.OffsetType;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.block.natural.bush.CustomBoundsFlowerBlock;
import net.zepalesque.redux.blockset.util.MutableLoreGeneration;
import net.zepalesque.redux.data.prov.ReduxDataMapProvider;
import net.zepalesque.redux.data.prov.ReduxLanguageProvider;
Expand All @@ -47,12 +42,13 @@
import java.util.function.Supplier;
import java.util.function.UnaryOperator;

public abstract class BaseFlowerSet extends AbstractFlowerSet implements MutableLoreGeneration<BaseFlowerSet> {
@SuppressWarnings("unchecked")
public abstract class BaseFlowerSet<B extends Block> extends AbstractFlowerSet implements MutableLoreGeneration<BaseFlowerSet<B>> {

public final String id, textureFolder;
protected String lore;
protected final VoxelShape shape;
private float compost = 0.65F;
protected float compost = 0.65F;
protected boolean usePottedPrefix = false;

protected final Map<CraftingMatrix, Pair<Supplier<? extends ItemLike>, RecipeCategory>> crafted = new HashMap<>();
protected final Map<Integer, Triple<Supplier<? extends ItemLike>, Integer, RecipeCategory>> shapeless = new HashMap<>();
Expand All @@ -64,33 +60,28 @@ public abstract class BaseFlowerSet extends AbstractFlowerSet implements Mutable
@Nullable
protected Pair<Integer, Integer> flammability = Pair.of(60, 100);

protected final DeferredBlock<CustomBoundsFlowerBlock> flower;
protected final DeferredBlock<B> flower;
protected final DeferredBlock<FlowerPotBlock> pot;
private UnaryOperator<Properties> properties;
private UnaryOperator<Properties> potProperties;
protected UnaryOperator<Properties> potProperties;

public BaseFlowerSet(String id, String textureFolder, VoxelShape shape, Supplier<MobEffect> effect, int duration, OffsetType offset, SoundType sound) {
public BaseFlowerSet(String id, String textureFolder, Supplier<B> constructor) {
this.id = id;
DeferredRegister.Blocks blocks = ReduxBlocks.BLOCKS;
DeferredRegister.Items items = ReduxItems.ITEMS;
this.textureFolder = textureFolder;
this.shape = shape;
this.flower = flower(blocks, items, id, effect, duration, offset, sound);
this.flower = flower(blocks, items, id, constructor);
this.pot = pot(blocks, id);
}

@Override
protected DeferredBlock<CustomBoundsFlowerBlock> flower(DeferredRegister.Blocks registry, DeferredRegister.Items items, String id, Supplier<MobEffect> effect, int duration, OffsetType offset, SoundType sound) {
var flower = registry.register(id, () -> new CustomBoundsFlowerBlock(this.shape, effect, duration, this.properties.apply(Properties.ofFullCopy(Blocks.DANDELION)
.sound(sound)
.offsetType(offset)
)));
protected <T extends Block> DeferredBlock<T> flower(DeferredRegister.Blocks registry, DeferredRegister.Items items, String id, Supplier<T> constructor) {
var flower = registry.register(id, constructor);
items.register(flower.getId().getPath(), () -> new BlockItem(flower.get(), new Item.Properties()));
return flower;
}

@Override
public DeferredBlock<CustomBoundsFlowerBlock> flower() {
public DeferredBlock<B> flower() {
return this.flower;
}

Expand All @@ -105,63 +96,56 @@ public DeferredBlock<FlowerPotBlock> pot() {
}

@Override
public AbstractFlowerSet craftsInto(Supplier<? extends ItemLike> block, CraftingMatrix shape, RecipeCategory category) {
public BaseFlowerSet<B> craftsInto(Supplier<? extends ItemLike> block, CraftingMatrix shape, RecipeCategory category) {
this.crafted.put(shape, Pair.of(block, category));
return this;
}

@Override
public AbstractFlowerSet craftsIntoShapeless(int ingredientCount, Supplier<? extends ItemLike> result, int resultCount, RecipeCategory category) {
public BaseFlowerSet<B> craftsIntoShapeless(int ingredientCount, Supplier<? extends ItemLike> result, int resultCount, RecipeCategory category) {
this.shapeless.put(ingredientCount, Triple.of(result, resultCount, category));
return this;
}

@Override
public AbstractFlowerSet withFlowerTag(TagKey<Block> tag) {
public BaseFlowerSet<B> withFlowerTag(TagKey<Block> tag) {
this.tags.add(tag);
return this;
}

@Override
public AbstractFlowerSet withPotTag(TagKey<Block> tag) {
public BaseFlowerSet<B> withPotTag(TagKey<Block> tag) {
this.potTags.add(tag);
return this;
}

@Override
public AbstractFlowerSet withItemTag(TagKey<Item> tag) {
public BaseFlowerSet<B> withItemTag(TagKey<Item> tag) {
this.itemTags.add(tag);
return this;
}

@Override
public AbstractFlowerSet creativeTab(Supplier<CreativeModeTab> tab, Supplier<? extends ItemLike> placeAfter) {
public BaseFlowerSet<B> creativeTab(Supplier<CreativeModeTab> tab, Supplier<? extends ItemLike> placeAfter) {
this.creativeTabOrdering.put(tab, placeAfter);
return this;
}

@Override
public AbstractFlowerSet compost(float amount) {
public BaseFlowerSet<B> compost(float amount) {
this.compost = amount;
return this;
}

@Override
public AbstractFlowerSet withProperties(UnaryOperator<Properties> prop) {
UnaryOperator<Properties> old = this.properties;
this.properties = original -> prop.apply(old.apply(original));
return this;
}

@Override
public AbstractFlowerSet withPotProperties(UnaryOperator<Properties> prop) {
public BaseFlowerSet<B> withPotProperties(UnaryOperator<Properties> prop) {
UnaryOperator<Properties> old = this.potProperties;
this.potProperties = original -> prop.apply(old.apply(original));
return this;
}

@Override
public AbstractFlowerSet flammable(int encouragement, int flammability) {
public BaseFlowerSet<B> flammable(int encouragement, int flammability) {
this.flammability = Pair.of(encouragement, flammability);
return this;
}
Expand Down Expand Up @@ -228,11 +212,17 @@ public void lootData(ReduxBlockLootProvider data) {
}

@Override
public BaseFlowerSet withLore(String lore) {
public BaseFlowerSet<B> withLore(String lore) {
this.lore = lore;
return this;
}

@Override
public BaseFlowerSet<B> withPottedPrefix() {
this.usePottedPrefix = true;
return this;
}

// Ignore the prev value, implementation is different here
@Override
public Supplier<? extends ItemLike> addToCreativeTab(BuildCreativeModeTabContentsEvent event, Supplier<? extends ItemLike> prev) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.zepalesque.redux.blockset.flower.type;

import net.minecraft.world.level.block.Block;
import net.zepalesque.redux.blockset.util.TintableSet;

import java.util.function.Supplier;

public abstract class TintedFlowerSet<B extends Block> extends BaseFlowerSet<B> implements TintableSet {
private final int tintdex, itemTint;

public TintedFlowerSet(String id, String textureFolder, Supplier<B> constructor, int tintdex, int itemTint) {
super(id, textureFolder, constructor);
this.tintdex = tintdex;
this.itemTint = itemTint;
}

@Override
public int getTintIndex() {
return this.tintdex;
}

@Override
public int getDefaultItemTint() {
return this.itemTint;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.aetherteam.aether.AetherTags;
import com.aetherteam.aether.block.AetherBlocks;
import com.aetherteam.aether.item.AetherCreativeTabs;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.MapColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MapColor;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import net.neoforged.neoforge.common.data.DataMapProvider;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.blockset.flower.type.BaseFlowerSet;
import net.zepalesque.redux.blockset.util.MutableLoreGeneration;
import net.zepalesque.redux.blockset.util.ReduxGeneration;
import net.zepalesque.redux.data.prov.ReduxBlockStateProvider;
import net.zepalesque.redux.data.prov.ReduxDataMapProvider;
import net.zepalesque.redux.data.prov.ReduxItemModelProvider;
Expand All @@ -42,11 +41,9 @@
import net.zepalesque.zenith.mixin.mixins.common.accessor.FireAccessor;
import net.zepalesque.zenith.util.DatagenUtil;
import net.zepalesque.zenith.util.TabUtil;
import org.apache.commons.lang3.tuple.Triple;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.zepalesque.redux.blockset.util;

public interface MutableLoreGeneration<T extends MutableLoreGeneration<?>> extends ReduxGeneration {
import net.zepalesque.redux.blockset.flower.type.BaseFlowerSet;

public interface MutableLoreGeneration<T extends MutableLoreGeneration<T>> extends ReduxGeneration {
T withLore(String lore);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package net.zepalesque.redux.blockset.util;

public interface TintableSet {

int getTintIndex();

int getDefaultItemTint();
}
Loading

0 comments on commit 7d4535c

Please sign in to comment.