Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to add instant structures to my mod but the code just won't work:

package com.kaptainwiz.mykindmod.blocks;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class BlockInstantStructure extends Block
{
Blocks block;

public BlockInstantStructure(Material material)
{
super(material);
}

public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);//Super

world.setBlockToAir(x, y, z);//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, block.cobblestone);//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y+1, z, block.planks, 2, 2); //Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x+1, y, z+1, block.planks, 2, 2); 
world.setBlock(x+2, y, z+2, block.planks, 2, 2); 
world.setBlock(x+3, y, z+3, block.planks, 2, 2); 
world.setBlock(x+4, y, z+4, block.planks, 2, 2);//This is for birch planks, if you want other planks, search 'Minecraft Block Metadata'in google or find it on the MinecraftWiki
}
}






Here's the registry:







public static Block blockInstantStructure;


blockInstantStructure = new BlockInstantStructure(Material.anvil).setCreativeTab(SampleTab).setBlockName("Instant").setBlockTextureName("sample:SampleInstant");

    	GameRegistry.registerBlock(blockInstantStructure, "instant");

 

This doesn't seem to work when I place the block down.. What now

wrong function its

 

@Override

public void onBlockPlacedBy(World world,int x,int y,int z,EntityLivingBase entity, ItemStack itemstack){

//code

}

 

Also you should do @Override before your functions, because if the function is incorrect, you get an error.

The proud(ish) developer of Ancients

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.