Skip to content

Commit

Permalink
convert tree features
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Aug 11, 2024
1 parent 2cb5058 commit cd8cd5a
Show file tree
Hide file tree
Showing 50 changed files with 1,611 additions and 456 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static WoodBlockSet registerWoodBlockSetMotherAurel() {
sapling,
add("potted_" + id + "_sapling", new FlowerPotBlock(sapling, flowerPotSettings)),
id + "_log", id + "_wood", "stripped_" + id + "_log", "stripped_" + id + "_wood",
add(id + "_leaves", new ParadiseLostLeavesBlock(leavesSettings, true), flammableLeaves, cutoutMippedRenderLayer),
add(id + "_leaves", new ParadiseLostLeavesBlock(leavesSettings), flammableLeaves, cutoutMippedRenderLayer),
id + "_planks", id + "_stairs", id + "_slab",
id + "_fence", id + "_fence_gate",
id + "_door", id + "_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,19 @@ protected static Settings wisteriaSapling() {
return copy(Blocks.OAK_SAPLING);
}

public static final WisteriaLeavesBlock ROSE_WISTERIA_LEAVES = add("rose_wisteria_leaves", new WisteriaLeavesBlock(wisteriaLeaf().mapColor(MapColor.PINK), false), flammableLeaves, cutoutMippedRenderLayer);
public static final WisteriaLeavesBlock ROSE_WISTERIA_LEAVES = add("rose_wisteria_leaves", new WisteriaLeavesBlock(wisteriaLeaf().mapColor(MapColor.PINK)), flammableLeaves, cutoutMippedRenderLayer);
public static final LeafPileBlock ROSE_WISTERIA_LEAF_PILE = add("rose_wisteria_leaf_pile", new LeafPileBlock(leafPile().mapColor(MapColor.PINK)), flammableLeaves, cutoutMippedRenderLayer);
public static final SaplingBlock ROSE_WISTERIA_SAPLING = add("rose_wisteria_sapling", new ParadiseLostSaplingBlock(new RoseWisteriaSaplingGenerator(), wisteriaSapling().mapColor(MapColor.PINK)), cutoutRenderLayer);
public static final FlowerPotBlock POTTED_ROSE_WISTERIA_SAPLING = add("potted_rose_wisteria_sapling", new FlowerPotBlock(ROSE_WISTERIA_SAPLING, flowerPot()), cutoutRenderLayer);
public static final ParadiseLostHangerBlock ROSE_WISTERIA_HANGER = add("rose_wisteria_hanger", new ParadiseLostHangerBlock(wisteriaHanger().mapColor(MapColor.PINK)), flammableLeaves, cutoutRenderLayer);

public static final WisteriaLeavesBlock FROST_WISTERIA_LEAVES = add("frost_wisteria_leaves", new WisteriaLeavesBlock(wisteriaLeaf().mapColor(MapColor.LIGHT_BLUE), false), flammableLeaves, cutoutMippedRenderLayer);
public static final WisteriaLeavesBlock FROST_WISTERIA_LEAVES = add("frost_wisteria_leaves", new WisteriaLeavesBlock(wisteriaLeaf().mapColor(MapColor.LIGHT_BLUE)), flammableLeaves, cutoutMippedRenderLayer);
public static final LeafPileBlock FROST_WISTERIA_LEAF_PILE = add("frost_wisteria_leaf_pile", new LeafPileBlock(leafPile().mapColor(MapColor.LIGHT_BLUE)), flammableLeaves, cutoutMippedRenderLayer);
public static final SaplingBlock FROST_WISTERIA_SAPLING = add("frost_wisteria_sapling", new ParadiseLostSaplingBlock(new FrostWisteriaSaplingGenerator(), wisteriaSapling().mapColor(MapColor.LIGHT_BLUE)), cutoutRenderLayer);
public static final FlowerPotBlock POTTED_FROST_WISTERIA_SAPLING = add("potted_frost_wisteria_sapling", new FlowerPotBlock(FROST_WISTERIA_SAPLING, flowerPot()), cutoutRenderLayer);
public static final ParadiseLostHangerBlock FROST_WISTERIA_HANGER = add("frost_wisteria_hanger", new ParadiseLostHangerBlock(wisteriaHanger().mapColor(MapColor.LIGHT_BLUE)), flammableLeaves, cutoutRenderLayer);

public static final WisteriaLeavesBlock LAVENDER_WISTERIA_LEAVES = add("lavender_wisteria_leaves", new WisteriaLeavesBlock(wisteriaLeaf().mapColor(MapColor.MAGENTA), false), flammableLeaves, cutoutMippedRenderLayer);
public static final WisteriaLeavesBlock LAVENDER_WISTERIA_LEAVES = add("lavender_wisteria_leaves", new WisteriaLeavesBlock(wisteriaLeaf().mapColor(MapColor.MAGENTA)), flammableLeaves, cutoutMippedRenderLayer);
public static final LeafPileBlock LAVENDER_WISTERIA_LEAF_PILE = add("lavender_wisteria_leaf_pile", new LeafPileBlock(leafPile().mapColor(MapColor.MAGENTA)), flammableLeaves, cutoutMippedRenderLayer);
public static final SaplingBlock LAVENDER_WISTERIA_SAPLING = add("lavender_wisteria_sapling", new ParadiseLostSaplingBlock(new LavenderWisteriaSaplingGenerator(), wisteriaSapling().mapColor(MapColor.MAGENTA)), cutoutRenderLayer);
public static final FlowerPotBlock POTTED_LAVENDER_WISTERIA_SAPLING = add("potted_lavender_wisteria_sapling", new FlowerPotBlock(LAVENDER_WISTERIA_SAPLING, flowerPot()), cutoutRenderLayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

public class ParadiseLostLeavesBlock extends LeavesBlock implements Fertilizable {

protected final boolean collidable;
protected int speed = 0;

public ParadiseLostLeavesBlock(Settings settings, boolean collidable) {
public ParadiseLostLeavesBlock(Settings settings) {
super(settings);
this.collidable = collidable;
}

public static BlockState getHanger(BlockState state) {
Expand All @@ -37,15 +35,6 @@ public static BlockState getHanger(BlockState state) {
return Blocks.AIR.getDefaultState();
}

@SuppressWarnings("deprecation")
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (!collidable && entity instanceof LivingEntity) {
entity.fallDistance = 0;
entity.slowMovement(state, new Vec3d(0.99D, 0.9D, 0.99D));
}
}

@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
if (state.isOf(ParadiseLostBlocks.MOTHER_AUREL_WOODSTUFF.leaves()) && random.nextInt(75) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

public class WisteriaLeavesBlock extends ParadiseLostLeavesBlock {

public WisteriaLeavesBlock(Settings settings, boolean collidable) {
super(settings, collidable);
public WisteriaLeavesBlock(Settings settings) {
super(settings);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.registry.RegistryCodecs;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntryList;
import net.minecraft.util.math.intprovider.IntProvider;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;

import java.util.List;

public record LongFeatureConfig(IntProvider size, BlockStateProvider body, BlockStateProvider top, BlockStateProvider shell, float topChance, float shellChance, List<BlockState> validFloor) implements FeatureConfig {
public record LongFeatureConfig(IntProvider size, BlockStateProvider body, BlockStateProvider top, BlockStateProvider shell, float topChance, float shellChance, RegistryEntryList<Block> validFloor) implements FeatureConfig {
public static final Codec<LongFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
IntProvider.VALUE_CODEC.fieldOf("size").forGetter(LongFeatureConfig::size),
BlockStateProvider.TYPE_CODEC.fieldOf("body").forGetter(LongFeatureConfig::body),
BlockStateProvider.TYPE_CODEC.fieldOf("top").forGetter(LongFeatureConfig::top),
BlockStateProvider.TYPE_CODEC.fieldOf("shell").forGetter(LongFeatureConfig::shell),
Codec.FLOAT.fieldOf("topChance").forGetter(LongFeatureConfig::topChance),
Codec.FLOAT.fieldOf("shellChance").forGetter(LongFeatureConfig::shellChance),
Codec.list(BlockState.CODEC).fieldOf("floor").forGetter(LongFeatureConfig::validFloor)
Codec.FLOAT.fieldOf("top_chance").forGetter(LongFeatureConfig::topChance),
Codec.FLOAT.fieldOf("shell_chance").forGetter(LongFeatureConfig::shellChance),
RegistryCodecs.entryList(RegistryKeys.BLOCK).fieldOf("floor").forGetter(LongFeatureConfig::validFloor)
).apply(instance, LongFeatureConfig::new));
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import net.id.paradiselost.world.feature.placed_features.ParadiseLostPlacedFeatures;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.placementmodifier.PlacementModifier;
import net.minecraft.world.gen.root.MangroveRootPlacer;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;

import java.util.List;
Expand All @@ -17,14 +21,19 @@
*/
@SuppressWarnings("unused")
public class ParadiseLostConfiguredFeatures {
protected static <FC extends FeatureConfig, F extends Feature<FC>> RegistryEntry<ConfiguredFeature<FC, ?>> register(String id, F feature, FC featureConfig) {
return register(BuiltinRegistries.CONFIGURED_FEATURE, id, new ConfiguredFeature<>(feature, featureConfig));
}

private static <V extends T, T> RegistryEntry<V> register(Registry<T> registry, String id, V value) {
return (RegistryEntry<V>) BuiltinRegistries.<T>add(registry, locate(id), value);
public static RegistryKey<ConfiguredFeature<?, ?>> of(String id) {
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, locate(id));
}

// protected static <FC extends FeatureConfig, F extends Feature<FC>> RegistryEntry<ConfiguredFeature<FC, ?>> register(String id, F feature, FC featureConfig) {
// return register(BuiltinRegistries.CONFIGURED_FEATURE, id, new ConfiguredFeature<>(feature, featureConfig));
// }
//
// private static <V extends T, T> RegistryEntry<V> register(Registry<T> registry, String id, V value) {
// return (RegistryEntry<V>) BuiltinRegistries.<T>add(registry, locate(id), value);
// }

public static void init() {
ParadiseLostTreeConfiguredFeatures.init();
ParadiseLostVegetationConfiguredFeatures.init();
Expand Down Expand Up @@ -63,8 +72,6 @@ static RegistryEntry<PlacedFeature> singleBlock(BlockStateProvider provider, Pla
static RegistryEntry<PlacedFeature> singleBlock(Block block, PlacementModifier... modifiers) {
return singleBlock(BlockStateProvider.of(block), modifiers);
}
// TODO This is incorrect, also convert this to tag
static final List<BlockState> GENERIC_FLOOR_WHITELIST = List.of(HIGHLANDS_GRASS.getDefaultState(), COARSE_DIRT.getDefaultState(), FLOESTONE.getDefaultState(), COBBLED_FLOESTONE.getDefaultState());

protected static <C extends FeatureConfig, F extends Feature<C>> F register(String name, F feature) {
return Registry.register(Registry.FEATURE, locate(name), feature);
Expand Down
Loading

0 comments on commit cd8cd5a

Please sign in to comment.