Jump to content

How do I generate blocks onthe surface (Like flowers)


Kander16
 Share

Recommended Posts

Hi,

 

My question is that I wanted to create a plant (StrawberryBush) that grows on top of grass, how do I do this?

I think its the easiest way with the events, but I don't know how to do this.

 

Thanks.

 

 

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

//Appears to be x coordinate (offset by +-  I'd assume from the middle of the chunk
            int i1 = p_76484_3_ + p_76484_2_.nextInt( - p_76484_2_.nextInt(;
//y +- 4 (probably from top block at center of chunk
            int j1 = p_76484_4_ + p_76484_2_.nextInt(4) - p_76484_2_.nextInt(4);
//z coordinate of the chunk +- 8 (once again, probably from center)
            int k1 = p_76484_5_ + p_76484_2_.nextInt( - p_76484_2_.nextInt(;

//If the the block at given location is air and the block below it is grass (And as a final check, can we really put it there) spawn the block!
            if (p_76484_1_.isAirBlock(i1, j1, k1) && p_76484_1_.getBlock(i1, j1 - 1, k1) == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(p_76484_1_, i1, j1, k1))
            {

 

I have no idea what

p_76484_2_.nextInt(4),

inside the set block is.

Link to comment
Share on other sites

I have no idea what p_76484_2_.nextInt(4), inside the set block is.

 

Setting a random metadata facing, perhaps. :|

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Hi,

 

Do i need to register it too before this actually works?

 

I think of

world.setBlock(i1, j1, k1, Chef.bushStrawberryBush, random.nextInt(75), 10);

that the

random.nextInt(75), 10)

the chance to spawn is.

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

Use an event, an event is something that happens in minecraft like a chuk load or terain gen, that is how they spawn caves and caverns and mineshaft, well you get the idea. there is a tutorial on them in the forge or a really good one @ http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and (soory if it isnt a hyper link) but that contains things like terrain gen. So TRY IT OUT .But yes that needs to be in some sort of forge-registered class and a tickhandler probobly that watches Chunk.Load but would be very complicated, i would highly suggest that you use events though. They greatly reduce lag be being called upon only when needed. This is irrelevant but FYI, strawberries aren't grown on bushes

Link to comment
Share on other sites

Decoratebiome event, right?

 

If you ask me, I think this is where it generates the pumpkins and things like that.

 

    @HasResult
    public static class Decorate extends DecorateBiomeEvent
    {
        /** Use CUSTOM to filter custom event types
        */
        public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM }
       
        public final EventType type;
       
        public Decorate(World world, Random rand, int worldX, int worldZ, EventType type)
        {
            super(world, rand, worldX, worldZ);
            this.type = type;
        }
    }
}[/Code]

 

but how do I let him generate my own strawberrybush?

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

I've never worked with this event before, sorry. I dont like random stuff that much. But that i do not know but i do know that you can but some registery is involved hence;

 public static enum EventType

  {
      BIG_SHROOM,  CACTUS,  CLAY,  DEAD_BUSH,  LILYPAD,  FLOWERS,  GRASS,  LAKE,  PUMPKIN,  REED,  SAND,  SAND_PASS2,  SHROOM,  TREE,  CUSTOM // < that;
      
      private EventType() {}
    }

Link to comment
Share on other sites

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • try this: if first three conditions { if not clientside drop pebble else play sound } i can't fire up the ide now but something like this should work.
    • I am trying to play a vanilla Minecraft sound when I am spawning an item into the world. I think I am close but the sound does not play when the item spawns into the world.   @SubscribeEvent public static void onRightClickBlock(RightClickBlock event) { Player player = event.getEntity(); Level level = event.getLevel(); InteractionHand hand = event.getHand(); BlockState blockState = event.getLevel().getBlockState(event.getPos()); Block block = blockState.getBlock(); if (player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND && block == Blocks.MOSS_BLOCK && !level.isClientSide){ player.drop(ItemInit.STONE_PEBBLE.get().getDefaultInstance(), false); level.playSound(player, event.getPos(), SoundEvents.MOSS_PLACE, SoundSource.BLOCKS, 1f, 1f); }   I am still new to modding and coding so this may be a little ugly haha. Trying to learn!
    • I have a custom recipe that uses JSON to work properly. And everything works right except I cant seem to figure out how to find the stack count for each ingredient of my recipe.   Recipe class: public class AlloyKilnRecipe implements Recipe<SimpleContainer> { private final ResourceLocation id; private final ItemStack output; private final NonNullList<Ingredient> ingredients; public AlloyKilnRecipe(ResourceLocation id, ItemStack output, NonNullList<Ingredient> ingredients) { this.id = id; this.output = output; this.ingredients = ingredients; } @Override public boolean matches(SimpleContainer pContainer, Level pLevel) { if (pLevel.isClientSide()) return false; return (ingredients.get(0).test(pContainer.getItem(0)) && ingredients.get(1).test(pContainer.getItem(1))) || (ingredients.get(0).test(pContainer.getItem(1)) && ingredients.get(1).test(pContainer.getItem(0))); } public int getIngAmnt(int index) { ItemStack[] stacks = ingredients.get(index).getItems(); for (ItemStack stack : stacks) { return stack.getCount(); } return 0; } @Override public NonNullList<Ingredient> getIngredients() { return ingredients; } @Override public ItemStack assemble(SimpleContainer pContainer) { return output; } @Override public boolean canCraftInDimensions(int pWidth, int pHeight) { return true; } @Override public ItemStack getResultItem() { return output.copy(); } @Override public ResourceLocation getId() { return id; } @Override public RecipeSerializer<?> getSerializer() { return Serializer.INSTANCE; } @Override public RecipeType<?> getType() { return Type.INSTANCE; } public static class Type implements RecipeType<AlloyKilnRecipe> { private Type() {} public static final Type INSTANCE = new Type(); public static final String ID = "alloy_kiln_recipe"; } public static class Serializer implements RecipeSerializer<AlloyKilnRecipe> { public static final Serializer INSTANCE = new Serializer(); public static final ResourceLocation ID = new ResourceLocation(FF.MOD_ID, "alloy_kiln_recipe"); @Override public AlloyKilnRecipe fromJson(ResourceLocation pRecipeId, JsonObject pSerializedRecipe) { ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(pSerializedRecipe, "output")); JsonArray ingredients = GsonHelper.getAsJsonArray(pSerializedRecipe, "ingredients"); NonNullList<Ingredient> inputs = NonNullList.withSize(2, Ingredient.EMPTY); for (int i = 0; i < ingredients.size(); i++) { inputs.set(i, Ingredient.fromJson(ingredients.get(i))); } return new AlloyKilnRecipe(pRecipeId, output, inputs); } @Override public @Nullable AlloyKilnRecipe fromNetwork(ResourceLocation pRecipeId, FriendlyByteBuf pBuffer) { NonNullList<Ingredient> inputs = NonNullList.withSize(pBuffer.readInt(), Ingredient.EMPTY); for (int i = 0; i < inputs.size(); i++) { inputs.set(i, Ingredient.fromNetwork(pBuffer)); } ItemStack output = pBuffer.readItem(); return new AlloyKilnRecipe(pRecipeId, output, inputs); } @Override public void toNetwork(FriendlyByteBuf pBuffer, AlloyKilnRecipe pRecipe) { pBuffer.writeInt(pRecipe.getIngredients().size()); for (Ingredient ing : pRecipe.getIngredients()) { ing.toNetwork(pBuffer); } pBuffer.writeItemStack(pRecipe.getResultItem(), false); } } } And here is my recipe.json { "type": "forgedfactory:alloy_kiln_recipe", "ingredients": [ { "item": "minecraft:iron_ingot", "count": 3 }, { "item": "minecraft:gold_ingot" } ], "output": { "item": "minecraft:diamond", "count": 3 } } Could someone tell me what I would have to do? The getIngAmount method just returns 1 even though I have a count defined for the iron ingots.
    • forge installer version 43.1.7 for 1.19.2 won't download the jar file, only the json 
    • Stop bumping your post. This sounds like a issue with your install. Try deleting your .minecraft folder and re-installing the launcher. Beyond that it's not something we control. As we don't control the launcher.
  • Topics

×
×
  • Create New...

Important Information

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