Jump to content

Recommended Posts

Posted

Okay, so I want to make it so that when you place a block and then activate it, it places some dummy blocks around it in 1 3x3 square having the original block the center, and also having a model render over it so that it has a texture. Any help on this?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

Not sure why you locked your old post to be honest, you pretty much had it :P

 

As mentioned before, you'll need this tutorial: http://minalien.com/tutorial-multi-block-structures-in-minecraft/

 

Then, make one of the blocks (the one you place) a rendered Tile Entity. Without the above tutorial, you'd have the 3x3 block visible, but can walk through it.

 

Make a block, call it "Gag Block" or something, and make it so it's solid, but can't be seen. Those are the other blocks that will be placed when you place the model block. Does that make sense?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Not sure why you locked your old post to be honest, you pretty much had it :P

 

As mentioned before, you'll need this tutorial: http://minalien.com/tutorial-multi-block-structures-in-minecraft/

 

Then, make one of the blocks (the one you place) a rendered Tile Entity. Without the above tutorial, you'd have the 3x3 block visible, but can walk through it.

 

Make a block, call it "Gag Block" or something, and make it so it's solid, but can't be seen. Those are the other blocks that will be placed when you place the model block. Does that make sense?

 

Yeah sorta, So I need to make a base block, that has a render tilenetity that renders the model, and the gag blocks?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

I'm not sure about rending a model over the whole thing, but to have it add blocks on activation, you want something like this in your block's class:

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+1, par4, Registration.celestialBlock.blockID, 0, 2);
        return true;
}

This creates a single block directly above the activated block.

Posted

I'm not sure about rending a model over the whole thing, but to have it add blocks on activation, you want something like this in your block's class:

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+1, par4, Registration.celestialBlock.blockID, 0, 2);
        return true;
}

This creates a single block directly above the activated block.

If a model is bigger than 1x1x1 it will just render outside the block, without any sort of collision to it.

So, he'd use his existing model with the code you put there. That code has to place invisible blocks, so the model will still show and have collision too. Only issue he'll have then is the mode will de-render when the original block is out of the screen - I have no idea how to fix that.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

hmmm, thanks for the tip on placing the blocks, now, for the model de-rendering, Ill look it up, think i saw it somewhere before.

I might just make some more blocks, about 6, and have them have the textures of the model on them, the model isn't to special, just a box the size of the 3x3 square, with a texture. It would be take up some ids, but it would still work.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

If your model is based of the centre block, adding this to your blocks class should do the trick.

 

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
    return AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}

Posted

If your model is based of the centre block, adding this to your blocks class should do the trick.

 

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
    return AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}

 

Thanks, now how about rendering the model?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

thanks for helping me expand my collison box, and I was wondering if you know how to load a tile entity, when the block is right clicked?

Replying here instead just in case someone else runs across this needing the same answers.

 

 

To your block class add (your block will need to extend BlockContainer or implement ITileEntityProvider before its available)

@Override
public TileEntity createNewTileEntity(World world)
{
    return new TileEntityLargeBlock(); //Rename to your tile entity 
}

 

 

This will create the tile entity as soon as the block is in the world, but you didn't want it to render until your right clicked so in your tile entity add

public boolean shouldRender = false;

 

Back to your block class

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int face, float posX, float posY, float posZ)
{
  TileEntity tile = world.getBlockTileEntity(x, y, z);  // Once again rename to your tile entity.
  if (!(tile instanceof TileEntityLargeBlock)) {
    return false; // If for some reason your block does not have the correct tileentity you don't want it to create the false blocks, as nothing will hide them.
  }

  // run any pre-generation code you have here.  eg. making sure there is space for the false blocks.

  ((TileEntityLargeBlock)tile).shouldRender = true;

  // create your false blocks here as they are now hidden
  return true;
}

 

 

The last thing to do is in your renderer, simply check if shouldRender is true before rendering, if not leave without rendering anything.

 

 

 

You can change the other code I gave you too,

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
    TileEntity tile = world.getBlockTileEntity(x, y, z);  // Once again rename to your tile entity.
    if (tile instanceof TileEntityLargeBlock  && ((TileEntityLargeBlock)tile).shouldRender) {
        return AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
    }
    return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}

 

Posted

thanks for helping me expand my collison box, and I was wondering if you know how to load a tile entity, when the block is right clicked?

Replying here instead just in case someone else runs across this needing the same answers.

 

 

To your block class add (your block will need to extend BlockContainer or implement ITileEntityProvider before its available)

@Override
public TileEntity createNewTileEntity(World world)
{
    return new TileEntityLargeBlock(); //Rename to your tile entity 
}

 

 

This will create the tile entity as soon as the block is in the world, but you didn't want it to render until your right clicked so in your tile entity add

public boolean shouldRender = false;

 

Back to your block class

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int face, float posX, float posY, float posZ)
{
  TileEntity tile = world.getBlockTileEntity(x, y, z);  // Once again rename to your tile entity.
  if (!(tile instanceof TileEntityLargeBlock)) {
    return false; // If for some reason your block does not have the correct tileentity you don't want it to create the false blocks, as nothing will hide them.
  }

  // run any pre-generation code you have here.  eg. making sure there is space for the false blocks.

  ((TileEntityLargeBlock)tile).shouldRender = true;

  // create your false blocks here as they are now hidden
  return true;
}

 

 

The last thing to do is in your renderer, simply check if shouldRender is true before rendering, if not leave without rendering anything.

 

 

 

You can change the other code I gave you too,

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
    TileEntity tile = world.getBlockTileEntity(x, y, z);  // Once again rename to your tile entity.
    if (tile instanceof TileEntityLargeBlock  && ((TileEntityLargeBlock)tile).shouldRender) {
        return AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
    }
    return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}

 

oh my god thank you thank you thank you!

 

I'll edit this post if telling you if it worked!

 

EDIT: Well now when i right click it does nothing.

Heres my code:

BlockTowerFloorBase:

package codelyoko;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockTowerFloorBase extends Block
{

public BlockTowerFloorBase(int id, Material par1Material)
{

	super(id, par1Material);
	this.setCreativeTab(Lyoko.tabLyoko);

}

@Override
public TileEntity createTileEntity(World world, int metadata)
{
	return new TileEntityTowerFloor();
}

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
	TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);  // Once again rename to your tile entity.
	if (!(tile instanceof TileEntityTowerFloor)) {
		return false; // If for some reason your block does not have the correct tileentity you don't want it to create the false blocks, as nothing will hide them.
	}
	par1World.setBlock(par2+1, par3, par4, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2+1, par3, par4+1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2+1, par3, par4-1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2, par3, par4+1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2, par3, par4-1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2-1, par3, par4+1, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2-1, par3, par4, Lyoko.TowerFloorGagBlock.blockID, 0, 2);
	par1World.setBlock(par2-1, par3, par4-1, Lyoko.TowerFloorGagBlock.blockID, 0, 2); 
	ModLoader.openGUI(par5EntityPlayer, new GUITowerFloorCreated());
	return true;
}




@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
	return AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}

//This will tell minecraft not to render any side of our cube.
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
	return false;
}

//And this tell it that you can see through this block, and neighbor blocks should be rendered.
public boolean isOpaqueCube()
{
	return false;
}

}

 

EDIT: Opps, forgot to implement ITileEntityProvider. Hehe :)

Now it just loads when i place the block, not even waiting for me to right click it!

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

you missed a line in your onBlockActivated

((TileEntityTowerFloor)tile).shouldRender = true;

 

 

As for rendering right away, did you set shouldRender in your tile entity to false?

What about checking shouldRender in your rendering code?

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.