Skip to content
Open
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
@@ -0,0 +1,84 @@
package com.aechtrob.prehistoricnature.block.trees.walchia;

import com.aechtrob.prehistoricnature.PrehistoricNatureMod;
import com.aechtrob.prehistoricnature.block.BlockHandler;
import com.aechtrob.prehistoricnature.block.BlockRegistration;
import com.aechtrob.prehistoricnature.block.trees.WoodTypeHelper;
import com.aechtrob.prehistoricnature.creativetabs.CreativeTabHelper;
import com.aechtrob.prehistoricnature.datagen.loottable.BlockLootSubProvider;
import com.aechtrob.prehistoricnature.world.tree.walchia.WalchiaTreeGrower;
import com.ibm.icu.impl.Pair;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraftforge.registries.RegistryObject;

import java.util.List;

public class BlocksTreeWalchia {
public static class WalchiaBlockTags {
public static TagKey<Block> WALCHIA_LOGS = BlockTags.create(new ResourceLocation(PrehistoricNatureMod.MOD_ID, "walchia_logs"));
}
public static class WalchiaItemTags {
public static TagKey<Item> WALCHIA_LOGS = ItemTags.create(new ResourceLocation(PrehistoricNatureMod.MOD_ID, "walchia_logs"));
}
public static String treeName = "walchia";
public static int treeId = 1;
public static final WoodType WALCHIA = WoodTypeHelper.putWoodType(WoodType.create(treeName));

public static final RegistryObject<Block> WALCHIA_STRIPPED_LOG = BlockRegistration.strippedLogBlock(
List.of(WalchiaBlockTags.WALCHIA_LOGS,BlockTags.MINEABLE_WITH_AXE,BlockTags.LOGS,BlockTags.LOGS_THAT_BURN,BlockTags.OVERWORLD_NATURAL_LOGS),
List.of(WalchiaItemTags.WALCHIA_LOGS, ItemTags.LOGS,ItemTags.LOGS_THAT_BURN),treeName,treeId);
public static final RegistryObject<Block> WALCHIA_LOG = BlockRegistration.logBlock(WALCHIA_STRIPPED_LOG,
List.of(WalchiaBlockTags.WALCHIA_LOGS,BlockTags.MINEABLE_WITH_AXE,BlockTags.LOGS,BlockTags.LOGS_THAT_BURN,BlockTags.OVERWORLD_NATURAL_LOGS),
List.of(WalchiaItemTags.WALCHIA_LOGS, ItemTags.LOGS,ItemTags.LOGS_THAT_BURN),treeName,treeId);
public static final RegistryObject<Block> WALCHIA_STRIPPED_WOOD = BlockRegistration.strippedWoodBlock(WALCHIA_STRIPPED_LOG,
List.of(WalchiaBlockTags.WALCHIA_LOGS, BlockTags.MINEABLE_WITH_AXE,BlockTags.LOGS,BlockTags.LOGS_THAT_BURN,BlockTags.OVERWORLD_NATURAL_LOGS),
List.of(WalchiaItemTags.WALCHIA_LOGS, ItemTags.LOGS,ItemTags.LOGS_THAT_BURN), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_WOOD = BlockRegistration.woodBlock(WALCHIA_LOG,WALCHIA_STRIPPED_WOOD, List.of(WalchiaBlockTags.WALCHIA_LOGS, BlockTags.MINEABLE_WITH_AXE,BlockTags.LOGS,BlockTags.LOGS_THAT_BURN,BlockTags.OVERWORLD_NATURAL_LOGS),
List.of(WalchiaItemTags.WALCHIA_LOGS, ItemTags.LOGS,ItemTags.LOGS_THAT_BURN), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_SAPLING = BlockRegistration.saplingBlock(new WalchiaTreeGrower(),List.of(BlockTags.SAPLINGS),
List.of(ItemTags.SAPLINGS), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_LEAVES = BlockRegistration.leafBlock(WALCHIA_SAPLING,
List.of(BlockTags.MINEABLE_WITH_HOE, BlockTags.LEAVES),List.of(ItemTags.LEAVES), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_PLANKS = BlockRegistration.plankBlock(WalchiaItemTags.WALCHIA_LOGS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.PLANKS),
List.of(ItemTags.PLANKS),treeName,treeId);
public static final RegistryObject<Block> WALCHIA_SLAB = BlockRegistration.slabBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_SLABS),
List.of(ItemTags.WOODEN_SLABS),treeName,treeId);
public static final RegistryObject<Block> WALCHIA_STAIRS = BlockRegistration.stairsBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_STAIRS),
List.of(ItemTags.WOODEN_STAIRS),treeName,treeId);
public static final RegistryObject<Block> WALCHIA_FENCE = BlockRegistration.fenceBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_FENCES),
List.of(ItemTags.WOODEN_FENCES),treeName,treeId);
public static final RegistryObject<Block> WALCHIA_FENCE_GATE = BlockRegistration.fenceGateBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.FENCE_GATES),
List.of(ItemTags.FENCE_GATES), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_DOOR = BlockRegistration.doorBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_DOORS),
List.of(ItemTags.WOODEN_DOORS), treeName, treeId);
//Needs manual json file.
public static final RegistryObject<Block> WALCHIA_TRAPDOOR = BlockRegistration.trapdoorBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_TRAPDOORS),
List.of(ItemTags.WOODEN_TRAPDOORS), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_PRESSURE_PLATE = BlockRegistration.pressurePlateBlock(WALCHIA_PLANKS,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_PRESSURE_PLATES),
List.of(ItemTags.WOODEN_PRESSURE_PLATES), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_BUTTON = BlockRegistration.buttonBlock(WALCHIA_PLANKS ,List.of(BlockTags.MINEABLE_WITH_AXE,BlockTags.WOODEN_BUTTONS),
List.of(ItemTags.WOODEN_BUTTONS), treeName, treeId);
public static final RegistryObject<Block> WALCHIA_WALL_SIGN = BlockRegistration.wallSignBlock(WALCHIA,List.of(BlockTags.WALL_SIGNS),treeName);
public static final RegistryObject<Block> WALCHIA_SIGN = BlockRegistration.standingSignBlock(WALCHIA_WALL_SIGN,WALCHIA,List.of(BlockTags.STANDING_SIGNS),treeName);

public static final RegistryObject<Block> WALCHIA_LADDER = BlockRegistration.ladderBlock(
WALCHIA_PLANKS, List.of(BlockTags.MINEABLE_WITH_AXE, BlockTags.CLIMBABLE),List.of(),treeName,treeId);


// public static final RegistryObject<Block> WALCHIA_BENCH = BlockHandler.registerBlock("walchia_bench",
// () -> new PNBenchBlock(BlockBehaviour.Properties.copy(Blocks.OAK_BUTTON)
// , 30, true, SoundEvents.WOODEN_BUTTON_CLICK_OFF, SoundEvents.WOODEN_BUTTON_CLICK_ON));

//Other tree-specific stuff:

public static void register() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.aechtrob.prehistoricnature.block.trees.walchia;

import com.aechtrob.prehistoricnature.entity.block.blocks.PNSignBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.RegistryObject;

import static com.aechtrob.prehistoricnature.entity.block.PNBlockEntities.BLOCK_ENTITY_REGISTER;

public class EntitiesTreeWalchia {

public static void register(){

}
public static final RegistryObject<BlockEntityType<PNSignBlockEntity>> WALCHIA_SIGN_BLOCK_ENTITIES =
BLOCK_ENTITY_REGISTER.register("walchia_sign_block_entity", ()->
BlockEntityType.Builder.of(PNSignBlockEntity::new, BlocksTreeWalchia.WALCHIA_WALL_SIGN.get(),
BlocksTreeWalchia.WALCHIA_SIGN.get()).build(null));


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.aechtrob.prehistoricnature.block.trees.walchia;

import com.aechtrob.prehistoricnature.block.BlockRegistration;
import com.aechtrob.prehistoricnature.entity.entities.PNBoat;
import com.aechtrob.prehistoricnature.item.ItemHandler;
import com.aechtrob.prehistoricnature.item.items.PNBoatItem;
import com.ibm.icu.impl.Pair;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.RegistryObject;

import java.util.List;

import static com.aechtrob.prehistoricnature.creativetabs.CreativeTabHelper.transportTabBoatTier;

public class ItemsTreeWalchia {
public static void register(){}
public static final RegistryObject<Item> WALCHIA_SIGN_ITEM = BlockRegistration.signItem(BlocksTreeWalchia.WALCHIA_PLANKS, BlocksTreeWalchia.WALCHIA_WALL_SIGN, BlocksTreeWalchia.WALCHIA_SIGN,
List.of(ItemTags.SIGNS), BlocksTreeWalchia.treeName, BlocksTreeWalchia.treeId);


public static final RegistryObject<Item> WALCHIA_BOAT_ITEM = ItemHandler.addItem("walchia_boat",
() -> new PNBoatItem(false, PNBoat.Type.WALCHIA, new Item.Properties().stacksTo(1)),
(provider, item) -> {provider.basicItem(item);},
List.of(Pair.of("prehistoricnature_transport_tab",Pair.of(transportTabBoatTier, BlocksTreeWalchia.treeId))),
"Walchia Boat");

public static final RegistryObject<Item> WALCHIA_CHEST_BOAT_ITEM = ItemHandler.addItem("walchia_chest_boat",
() -> new PNBoatItem(true, PNBoat.Type.WALCHIA, new Item.Properties().stacksTo(1)),
(provider, item) -> {provider.basicItem(item);},
List.of(Pair.of("prehistoricnature_transport_tab",Pair.of(transportTabBoatTier, BlocksTreeWalchia.treeId))),
"Walchia Chest Boat");


//regular item creation applies



}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.aechtrob.prehistoricnature.entity.entities;

import com.aechtrob.prehistoricnature.block.trees.lepidodendron.*;
import com.aechtrob.prehistoricnature.block.trees.walchia.BlocksTreeWalchia;
import com.aechtrob.prehistoricnature.block.trees.walchia.ItemsTreeWalchia;
import net.minecraft.nbt.*;
import net.minecraft.network.protocol.*;
import net.minecraft.network.protocol.game.*;
Expand Down Expand Up @@ -35,9 +37,11 @@ public PNBoat.Type getPNBoatType() {
public Item getDropItem() {
return switch (this.getPNBoatType()) {
case LEPIDODENDRON -> ItemsTreeLepidodendron.LEPIDODENDRON_BOAT_ITEM.get();
case WALCHIA -> ItemsTreeWalchia.WALCHIA_BOAT_ITEM.get();
};
}


public void setPNBoatType(PNBoat.Type boatType) {
this.getEntityData().set(BOAT_TYPE, boatType.ordinal());
}
Expand Down Expand Up @@ -67,7 +71,12 @@ public Packet<ClientGamePacketListener> getAddEntityPacket() {
//TODO add every woodtype thats added to the mod here
public enum Type {

LEPIDODENDRON(BlocksTreeLepidodendron.LEPIDODENDRON_PLANKS.get(),BlocksTreeLepidodendron.treeName);

WALCHIA(BlocksTreeWalchia.WALCHIA_PLANKS.get(), BlocksTreeWalchia.treeName),
LEPIDODENDRON(BlocksTreeLepidodendron.LEPIDODENDRON_PLANKS.get(), BlocksTreeLepidodendron.treeName);




private final String name;
private final Block block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public class ModConfiguredFeatures {
public static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES =
DeferredRegister.create(Registries.CONFIGURED_FEATURE, PrehistoricNatureMod.MOD_ID);

//TODO add configured features for all trees in mod
public static final ResourceKey<ConfiguredFeature<?, ?>> LEPIDODENDRON_TREE = createKey("lepidodendron_tree");
public static final ResourceKey<ConfiguredFeature<?, ?>> WALCHIA_TREE = createKey("walchia_tree");

public static ResourceKey<ConfiguredFeature<?, ?>> createKey(String name) {
return ResourceKey.create(CONFIGURED_FEATURES.getRegistryKey(), new ResourceLocation(PrehistoricNatureMod.MOD_ID, name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.aechtrob.prehistoricnature.PrehistoricNatureMod;
import com.aechtrob.prehistoricnature.world.tree.lepidodendron.LepidodendronFoliagePlacer;
import com.aechtrob.prehistoricnature.world.tree.walchia.WalchiaFoliagePlacer;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType;
import net.minecraftforge.registries.DeferredRegister;
Expand All @@ -11,6 +12,10 @@ public class PNFoliagePlacerType {
public static final DeferredRegister<FoliagePlacerType<?>> FOLIAGE_PLACER_TYPES = DeferredRegister.create(Registries.FOLIAGE_PLACER_TYPE, PrehistoricNatureMod.MOD_ID);

public static RegistryObject<FoliagePlacerType<LepidodendronFoliagePlacer>> LEPIDODENDRON_FOLIAGE_PLACER = FOLIAGE_PLACER_TYPES.register("lepidodendron_foliage_placer", () -> new FoliagePlacerType<>(LepidodendronFoliagePlacer.CODEC));

public static RegistryObject<FoliagePlacerType<WalchiaFoliagePlacer>> WALCHIA_FOLIAGE_PLACER = FOLIAGE_PLACER_TYPES.register("walchia_foliage_placer", () -> new FoliagePlacerType<>(WalchiaFoliagePlacer.CODEC));


//public static RegistryObject<FoliagePlacerType<FancyCherryBlossomFoliagePlacer>> FANCY_CHERRY_TREE_Foliage_PLACER = Foliage_PLACER_TYPES.register("fancy_cherry_blossom_tree_Foliage_placer", () -> new FoliagePlacerType<>(FancyCherryBlossomFoliagePlacer.CODEC));
//public static RegistryObject<FoliagePlacerType<GrandCherryBlossomFoliagePlacer>> GRAND_CHERRY_TREE_Foliage_PLACER = Foliage_PLACER_TYPES.register("grand_cherry_blossom_tree_Foliage_placer", () -> new FoliagePlacerType<>(GrandCherryBlossomFoliagePlacer.CODEC));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.aechtrob.prehistoricnature.PrehistoricNatureMod;
import com.aechtrob.prehistoricnature.world.tree.lepidodendron.LepidodendronTrunkPlacer;
import com.aechtrob.prehistoricnature.world.tree.walchia.WalchiaTrunkPlacer;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType;
import net.minecraftforge.registries.DeferredRegister;
Expand All @@ -11,6 +12,9 @@ public class PNTrunkPlacerType {
public static final DeferredRegister<TrunkPlacerType<?>> TRUNK_PLACER_TYPES = DeferredRegister.create(Registries.TRUNK_PLACER_TYPE, PrehistoricNatureMod.MOD_ID);

public static RegistryObject<TrunkPlacerType<LepidodendronTrunkPlacer>> LEPIDODENDRON_TRUNK_PLACER = TRUNK_PLACER_TYPES.register("lepidodendron_trunk_placer", () -> new TrunkPlacerType<>(LepidodendronTrunkPlacer.CODEC));

public static RegistryObject<TrunkPlacerType<WalchiaTrunkPlacer>> WALCHIA_TRUNK_PLACER = TRUNK_PLACER_TYPES.register("walchia_trunk_placer", () -> new TrunkPlacerType<>(WalchiaTrunkPlacer.CODEC));

//public static RegistryObject<TrunkPlacerType<LepidodendronTrunkPlacer>> LEPIDODENDRON_TRUNK_PLACER = TRUNK_PLACER_TYPES.register("lepidodendron_trunk_placer", () -> new TrunkPlacerType<>(LepidodendronTrunkPlacer.CODEC));

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.aechtrob.prehistoricnature.world.tree.walchia;

import com.aechtrob.prehistoricnature.block.blocks.PNDecayableDirectional;
import com.aechtrob.prehistoricnature.block.trees.walchia.BlocksTreeWalchia;
import com.aechtrob.prehistoricnature.world.tree.PNFoliagePlacerType;
import com.aechtrob.prehistoricnature.world.tree.PNTreeFeature;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.util.valueproviders.IntProvider;
import net.minecraft.world.level.LevelSimulatedReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
import net.minecraft.world.level.levelgen.feature.foliageplacers.BlobFoliagePlacer;
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType;

import java.util.function.BiConsumer;

public class WalchiaFoliagePlacer extends BlobFoliagePlacer {
public WalchiaFoliagePlacer(IntProvider p_161356_, IntProvider p_161357_, int p_161358_) {
super(p_161356_, p_161357_, p_161358_);
}
public static final Codec<WalchiaFoliagePlacer> CODEC = RecordCodecBuilder.create((instance) -> {
return blobParts(instance).apply(instance, WalchiaFoliagePlacer::new);
});

@Override
protected FoliagePlacerType<?> type() {
return PNFoliagePlacerType.WALCHIA_FOLIAGE_PLACER.get();
}

BlockState leafState = BlocksTreeWalchia.WALCHIA_LEAVES.get().defaultBlockState();
//BlockState strobilusState = BlocksTreeWalchia.WALCHIA_STROBILUS.get().defaultBlockState().setValue(PNDecayableDirectional.PERSISTENT, false);

@Override
protected void createFoliage(LevelSimulatedReader levelSimulatedReader, BiConsumer<BlockPos, BlockState> biConsumer, RandomSource random, TreeConfiguration treeConfiguration, int ii, FoliageAttachment foliageAttachment, int p_161366_, int p_161367_, int p_161368_) {
//This sets a single block of foliage only, and is detailed in the Trunk generator for where exactly it all has to go.
//For trees with no flowers, strobili or variant leaf blocks, do not use this, use PNFoliagePlacer instead.
BlockPos pos = foliageAttachment.pos();
BlockState state = treeConfiguration.foliageProvider.getState(random, pos);
switch (foliageAttachment.radiusOffset()) { //Co-opting the radius field as a block enumerator for varied blocks
case 0: default:
state = leafState;
break;
}

if (PNTreeFeature.canLeavesReplaceBlock(levelSimulatedReader, pos)) {
biConsumer.accept(pos, state);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.aechtrob.prehistoricnature.world.tree.walchia;

import com.aechtrob.prehistoricnature.world.ModConfiguredFeatures;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.grower.AbstractTreeGrower;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import org.jetbrains.annotations.Nullable;

public class WalchiaTreeGrower extends AbstractTreeGrower {
@Nullable
@Override
protected ResourceKey<ConfiguredFeature<?, ?>> getConfiguredFeature(RandomSource pRandom, boolean pLargeHive) {
return ModConfiguredFeatures.WALCHIA_TREE;
}

}
Loading