Jump to content

Recommended Posts

Posted

I got my block class for the plant extending FlowerBlock

package com.lethalmap.stardewmod.common.blocks;


import com.lethalmap.stardewmod.Constants;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.potion.Effects;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;


public class Worms extends FlowerBlock {
    protected static final VoxelShape SHAPE = Block.makeCuboidShape(5.0D, 0.0D, 5.0D, 11.0D, 5.0D, 11.0D);

    public Worms() {
        super(Effects.WEAKNESS,9,Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT));
        setRegistryName(Constants.MODID,Constants.WORMS);
    }


    /**
     * Get the OffsetType for this Block. Determines if the model is rendered slightly offset.
     */
    public Block.OffsetType getOffsetType() {
        return Block.OffsetType.XZ;
    }

    @Override
    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
        Vec3d vec3d = state.getOffset(worldIn, pos);
        return this.SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z);
    }
}

And got a class to generate things over the world, but I dont know how to generate this flower

package com.lethalmap.stardewmod.common.world;


import com.lethalmap.stardewmod.common.blocks.BlockList;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.feature.*;
import net.minecraftforge.registries.ForgeRegistries;


public class WormGeneration {
    public void WormGeneration(){
        for(Biome biome : ForgeRegistries.BIOMES)
        {
                biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, new DecoratedFeature(Feature.DECORATED_FLOWER, new SimpleBlockStateProvider(BlockList.worms));

        }
    }
}

I don´t know what to do to generate this, Im quite noob modding :(

Posted
1 hour ago, Ugdhar said:

Check out vanilla code, it's super helpful :)

net.minecraft.world.biome.DefaultBiomeFeatures is where it's at :)

Im looking at it, but I don´t know what to do with that

Posted
3 minutes ago, BurstSword said:

Im looking at it, but I don´t know what to do with that

Well, you should have a basic-intermediate grasp of Java before starting modding, so you should be able to follow the code paths and see how features are set up.

Think of what already happens in Minecraft that is similar to what you want to do, and look at the code for it. So find where, say, the flowers are setup in the plains biome or something like that.

Posted (edited)

Ok, I think I see what you need to do, you need to put that in your FMLCommonSetupEvent , I believe using DeferredWorkQueue, because the biome stuff isn't threadsafe.

 

If you search these forums for DeferredWorkQueue, I believe there's an example of how it's used. And the FMLCommonSetupEvent I believe is demonstrated in the examplemod that comes with the MDK.

Edited by Ugdhar

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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