Jump to content

Talp1

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by Talp1

  1. If somebody would ever need this, after a bit of testing I got a pretty good result, here's what I ended up with. Feature: public class FlorealVineFeature extends Feature<NoFeatureConfig> { public FlorealVineFeature(Codec<NoFeatureConfig> p_i232002_1_) { super(p_i232002_1_); } public boolean func_230362_a_(ISeedReader worldIn, StructureManager strucManager, ChunkGenerator chucnkGen, Random rand, BlockPos pos, NoFeatureConfig config) { BlockPos.Mutable blockPos = new BlockPos.Mutable().setPos(pos.getX(), pos.getY(), pos.getZ()); BlockState currentBlockState = worldIn.getBlockState(blockPos); for (Direction direction : Direction.Plane.HORIZONTAL) { if (blockPos.getY()>63 && currentBlockState==Blocks.AIR.getDefaultState()){ checkSorroundingBlocks(blockPos, worldIn, rand, direction); } } return true; } private boolean checkValidSpot(Direction dir, BlockPos pos, ISeedReader worldIn,BlockPos originalPos){ if(worldIn.getBlockState(pos).getBlock() instanceof LeavesBlock){ return RegistryHandler.floreal_vines.get().isValidPosition(RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE),worldIn,originalPos); } return false; } private void checkSorroundingBlocks(BlockPos blockPos, ISeedReader worldIn, Random rand, Direction dir){ if (checkValidSpot(dir, blockPos.east(),worldIn,blockPos)){ worldIn.setBlockState(blockPos, RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); for (int i=0; i<=rand.nextInt(3);i++) { if (worldIn.getBlockState(blockPos.add(0, -(i), 0)) == Blocks.AIR.getDefaultState()) { worldIn.setBlockState(blockPos.add(0, -(i), 0), RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); } } } if (checkValidSpot(dir, blockPos.west(),worldIn,blockPos)){ worldIn.setBlockState(blockPos, RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); for (int i=0; i<=rand.nextInt(3);i++) { if (worldIn.getBlockState(blockPos.add(0, -(i), 0)) == Blocks.AIR.getDefaultState()) { worldIn.setBlockState(blockPos.add(0, -(i), 0), RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); } } } if (checkValidSpot(dir, blockPos.north(),worldIn,blockPos)){ worldIn.setBlockState(blockPos, RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); for (int i=0; i<=rand.nextInt(3);i++) { if (worldIn.getBlockState(blockPos.add(0, -(i), 0)) == Blocks.AIR.getDefaultState()) { worldIn.setBlockState(blockPos.add(0, -(i), 0), RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); } } } if (checkValidSpot(dir, blockPos.south(),worldIn,blockPos)){ worldIn.setBlockState(blockPos, RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); for (int i=0; i<=rand.nextInt(3);i++) { if (worldIn.getBlockState(blockPos.add(0, -(i), 0)) == Blocks.AIR.getDefaultState()) { worldIn.setBlockState(blockPos.add(0, -(i), 0), RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(dir), Boolean.TRUE), 2); } } } } } Gen: @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class VinesGen { @SubscribeEvent public static void generateVines(FMLLoadCompleteEvent event){ for (Biome biome : ForgeRegistries.BIOMES){ if (biome.getCategory()== Biome.Category.SWAMP||biome== Biomes.FLOWER_FOREST||biome.getCategory()== Biome.Category.JUNGLE){ biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, RegistryHandler.floreal_vine_feature.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.COUNT_HEIGHTMAP.configure(new FrequencyConfig(600)))); } } } }
  2. You may also find useful the 2nd and 3rd episode of McJty's tut series. If you never tried, of course you won't be able to do it. Just research before asking for help! Devi avere pazienza
  3. Just look at how vanilla does that. (It's good practice to make some research before opening topics, so maybe also try to look up about Tags, I think you'll need it. I dont think that just copying minecraft:planks in your json will get your recipe works with your wood type.) That's how Vanilla handle chest crafting (you may found it useful later): { "type": "minecraft:crafting_shaped", "pattern": [ "###", "# #", "###" ], "key": { "#": { "tag": "minecraft:planks" } }, "result": { "item": "minecraft:chest" } }
  4. No! .setRequiresTool() does not take any parameter, just add it.
  5. Try to add .setRequiresTool()
  6. I found @ChampionAsh5357 and @tcode2k16 guides pretty helpful, here's the links: https://championash5357.github.io/ChampionAsh5357/tutorial/minecraft/ https://thebookofmodding.ml/ Also keep in mind that some of the code for 1.14/1.15 works in 1.16 as well. If you prefer some YT tutorials, I suggest the ones form McJty, here's the playlist and his wiki: https://www.youtube.com/playlist?list=PLmaTwVFUUXiDRjPTbDmBgJZN4MeQ5uYby https://wiki.mcjty.eu/modding/index.php?title=YouTube-Tutorials#Introduction
  7. If I'm not wrong, you actually need to override the method onBlockActivated as well. Just keep it identical as vanilla and replace the Sweetberry Item in spawnAsEntity with your blue berry. I did this in my own Blueberry bush and it's working just fine!
  8. I'm not an expert and I dont have a really good knowledge about crash reports and minecraft/forge code, but judging by those lines, it seems that VoxelMap is generating a NullPointerException (I assume, looking at the error, during some rendering process for the Waypoint labels, or something similar). Try to remove VoxelMap or maybe the dark theme mod that you installed. Keep in mind that I might be wrong. Hope to be of help anyways.
  9. So... since I need my gen to do the exact same as the vanilla vine's one, I pretty much created a new identical feature changing the vanilla vine block with mine: public class FlorealVineFeature extends Feature<NoFeatureConfig> { private static final Direction[] DIRECTIONS = Direction.values(); public FlorealVineFeature(Codec<NoFeatureConfig> p_i232002_1_) { super(p_i232002_1_); } public boolean func_230362_a_(ISeedReader p_230362_1_, StructureManager p_230362_2_, ChunkGenerator p_230362_3_, Random p_230362_4_, BlockPos p_230362_5_, NoFeatureConfig p_230362_6_) { BlockPos.Mutable blockpos$mutable = p_230362_5_.toMutable(); for(int i = p_230362_5_.getY(); i < 256; ++i) { blockpos$mutable.setPos(p_230362_5_); blockpos$mutable.move(p_230362_4_.nextInt(4) - p_230362_4_.nextInt(4), 0, p_230362_4_.nextInt(4) - p_230362_4_.nextInt(4)); blockpos$mutable.setY(i); if (p_230362_1_.isAirBlock(blockpos$mutable)) { for(Direction direction : DIRECTIONS) { if (direction != Direction.DOWN && VineBlock.canAttachTo(p_230362_1_, blockpos$mutable, direction)) { p_230362_1_.setBlockState(blockpos$mutable, RegistryHandler.floreal_vines.get().getDefaultState().with(VineBlock.getPropertyFor(direction), Boolean.TRUE), 2); break; } } } } return true; } } I then registered my feature like this: (Obviously I registered my FEATURES register as well, in an init() method) public static final RegistryObject<Feature<NoFeatureConfig>> floreal_vine_feature = FEATURES.register("floreal_vine_feature", ()->new FlorealVineFeature(NoFeatureConfig.field_236558_a_)); and finally, I used this code for the generation itself: @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class VinesGen { @SubscribeEvent public static void generateVines(FMLLoadCompleteEvent event){ for (Biome biome : ForgeRegistries.BIOMES){ if (biome.getCategory()== Biome.Category.SWAMP||biome== Biomes.FLOWER_FOREST||biome.getCategory()== Biome.Category.JUNGLE){ biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, RegistryHandler.floreal_vine_feature.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.COUNT_HEIGHT_64.configure(new FrequencyConfig(25)))); } } } } I tried to stick as vanilla style as much as possible, but yet no luck: my vines are not generating in the world, no errors or warns in the console tho, the registrations seems to happen just fine. What am I missing? I apologize if I made a stupid error... but i cant really find out where I messed up
  10. First of all, thanks for answeing! Yup, I think I'm gonna try to create somethig that check that if a block is a leaf/log then it places my custom vine on it. It's gonna be a challenge but I'll eventually figure it out, I hope. I'll relpy on this topic in case I need help with that. Thank you for the hint!
  11. Hi everyone! I'm pretty new to modding and I'm trying to figure out how to generate custom vines in certains biomes. So far i have created the vine block and the item to place that block, but i can't figure out how to make this block generate in the world. Thats what i have started with: @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class VinesGen { @SubscribeEvent public static void generateVines(FMLLoadCompleteEvent event){ for (Biome biome : ForgeRegistries.BIOMES){ if (biome.getCategory()== Biome.Category.SWAMP||biome== Biomes.FLOWER_FOREST) } } } I noticed that there's a feature for vines, but it takes in NoFeatureConfig, causing my block to not be "selected" for the generation. Here's the code i'm talking about: biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.VINES.withConfiguration(new NoFeatureConfig())); So, how could i make my vines to generate? Have I to create a custom gen?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.