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

Ok, so I am trying to get a feel of structure generations and what can be done with it and im trying to generate a village for example when you right click with an item called Generator1. Any suggestions on how to go about doing that?

Mark a point as the center and the do setblock so many x y and z from it to make what you want.

The basic is simple :)

 

    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
                   par1World.setBlock(par2, par3, par4, BlockID);
     }

 

par2 is your X coordinate of your block

par3 is your Y coordinate of your block

par4 is your Z coordinate of your block

BlockId is the block you want to place at that coordinate :)

 

Here is some example code im using in my mod to build a small tent :)

 

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
    	par1World.spawnParticle("smoke", par2, par3, par4, 0.1F, 0.1F, 0.1F);
    	
    	par1World.setBlock(par2, par3, par4,61);
    	par1World.setBlock(par2, par3+1, par4,61);
    	par1World.setBlock(par2, par3+2, par4,35);
    	
    	par1World.setBlock(par2-1, par3, par4,58);
    	par1World.setBlock(par2-2, par3, par4,35);
    	par1World.setBlock(par2-1, par3+1, par4,35);

    	par1World.setBlock(par2+1, par3, par4,58);
    	par1World.setBlock(par2+2, par3, par4,35);
    	par1World.setBlock(par2+1, par3+1, par4,35);
    	
    	par1World.setBlock(par2-1, par3, par4-1,85);
    	par1World.setBlock(par2-2, par3, par4-1,35);
    	par1World.setBlock(par2-1, par3+1, par4-1,35);
    	par1World.setBlock(par2+1, par3, par4-1,85);
    	par1World.setBlock(par2+2, par3, par4-1,35);
    	par1World.setBlock(par2+1, par3+1, par4-1,35);
    	par1World.setBlock(par2, par3, par4-1,85);
    	par1World.setBlock(par2, par3+1, par4-1,85);
    	par1World.setBlock(par2, par3+2, par4-1,35);  	
    	
    	par1World.setBlock(par2-2, par3, par4+1,35);
    	par1World.setBlock(par2-1, par3+1, par4+1,35);
    	par1World.setBlock(par2+2, par3, par4+1,35);
    	par1World.setBlock(par2+1, par3+1, par4+1,35);
    	par1World.setBlock(par2, par3+2, par4+1,35); 
    	
    	return true;
    };

  • Author

Now i am running into a problem where it is returning both feet post, and eye pos.

 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
  {
	World world = par3World;
	EntityPlayer ply = par2EntityPlayer;
	double posX = ply.lastTickPosX;
	double posY = ply.lastTickPosY;
	double posZ = ply.lastTickPosZ;
	System.out.println("X: " + posX);
	System.out.println("Y: " + posY);
	System.out.println("Z: " + posZ);
	System.out.println("Int 1: " + par4);
	System.out.println("Int 2: " + par5);
	System.out.println("Int 3: " + par6);
	System.out.println("Int 4: " + par7);
	System.out.println("Float 1: " + par8);
	System.out.println("Float 2: " + par9);
	System.out.println("Float 3: " + par10);

	return true;
}

This is what it outputs:

2013-05-12 15:02:17 [iNFO] [sTDOUT] X: 1573.8539209767246
2013-05-12 15:02:17 [iNFO] [sTDOUT] Y: 8.485128304470969
2013-05-12 15:02:17 [iNFO] [sTDOUT] Z: 35.771595298500344
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 1: 1574
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 2: 3
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 3: 35
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 4: 1
2013-05-12 15:02:17 [iNFO] [sTDOUT] Float 1: 0.03881836
2013-05-12 15:02:17 [iNFO] [sTDOUT] Float 2: 1.0
2013-05-12 15:02:17 [iNFO] [sTDOUT] Float 3: 0.87386703
2013-05-12 15:02:17 [iNFO] [sTDOUT] X: 1573.8539209767246
2013-05-12 15:02:17 [iNFO] [sTDOUT] Y: 6.865128299702597
2013-05-12 15:02:17 [iNFO] [sTDOUT] Z: 35.771595298500344
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 1: 1574
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 2: 3
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 3: 35
2013-05-12 15:02:17 [iNFO] [sTDOUT] Int 4: 1
2013-05-12 15:02:17 [iNFO] [sTDOUT] Float 1: 0.03881836
2013-05-12 15:02:17 [iNFO] [sTDOUT] Float 2: 1.0
2013-05-12 15:02:17 [iNFO] [sTDOUT] Float 3: 0.87386703

You can find the block right clicked on with a Forge event. Heres some code:

@ForgeSubscribe
public void buildVillage(PlayerInteractEvent event)	
{
if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() == youritemid)
  {
    //event.x, event.y,event.z are the block coordinates for the block you right clicked on
    
  //your code for generating
  }
}

  • Author

Oh, thank you :D, i will for sure try that out :D

 

Wait, how would i get my item in the if statement? Its probably obvious but im drawing a blank. Because it is asking for an itemstack but my item is an item...

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.