Jump to content

Recommended Posts

Posted

Hi there

 

I have a block that is 4.0F high

 

the problem is i cant click/mouse over on it past 1 block from the ground

 

how can i it so i can mouse over it and click it for its full height.

 

Please do be warned i'm not good with coding yet and wont understand if you say use this or that.

 

this is my current code for it

 

thank you

 

package glowsblocksandlights;

import java.util.Random;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.particle.EntityFlameFX;
import net.minecraft.client.particle.EntityNoteFX;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class outsidelightgassteel extends BlockContainer {

public outsidelightgassteel(int id, Material Material) {
	super(id, Material);
	setHardness(0.5F);
	setStepSound(Block.soundGlassFootstep);
	setLightOpacity(255);
	setLightValue(1.0F);
	setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 4.0F, 0.7F);
	setTickRandomly(true);
					// setBlockBounds(0.0f, 0.0f, 0.0f, 0.6875f, 0.9000f,0.6875f);
}

@Override
public TileEntity createNewTileEntity(World world) {
	// TODO Auto-generated method stub
	return new TileEntityoutsidelightgassteel();
}

@Override
public void updateTick(World par1World, int par2, int par3, int par4,
		Random par5Random) {
	super.updateTick(par1World, par2, par3, par4, par5Random);
	//par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate());

	if (par1World.getBlockMetadata(par2, par3, par4) == 0) {
		par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate());
		this.onBlockAdded(par1World, par2, par3, par4);
	}
}

/**
 * Called whenever the block is added into the world. Args: world, x, y, z
 */
@Override
public void onBlockAdded(World par1World, int par2, int par3, int par4) {
	super.onBlockAdded(par1World, par2, par3, par4);

}



@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister IconRegister) {
	blockIcon = IconRegister.registerIcon(Basicinfo.ID.toLowerCase()
			+ ":outsidelightgassteel");
}

@Override
public boolean isOpaqueCube() {
	return false;
}

@Override
public int getRenderType() {
	return -1;
}

@Override
public boolean renderAsNormalBlock() {
	return false;
}




public int tickRate() {
	   return 1;
	}

@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
	Minecraft.getMinecraft().effectRenderer.addEffect(new EntitycusflamesFX(par1World, par2 + 0.5F, par3 + 3.25F, par4 + 0.5F, 0.0D, 0.0D, 0.0D));
    }



}

Posted

anyone

 

What you want is setBlockBounds.

SetBlickBounds(0,0,0,1F,1F,1F) is a full cube.

SetBlockBoubds(0,0,0,1F,0.5F,1F) is a half.cube and so on...

Don't forget the thankyou button ;)

Here could be your advertisement!

Posted

Hi Jacky2611

 

if you looked at my code you would see i already have that in my code

 

setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 4.0F, 0.7F);

 

regards

Jeremy

Posted

Hi Jacky2611

 

if you looked at my code you would see i already have that in my code

 

setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 4.0F, 0.7F);

 

regards

Jeremy

 

How big is your model in pixel? 1 block =16px

Here could be your advertisement!

Posted

it is 64px

 

at the moment my hitbox/mousebox is only at 1 block high. if i want o break it i have to go to the bottom of the block to break it. want to be able to break it anyway on the block

Posted

You cannot have a block with a hitbox larger than 1 block -- you will need to use tile entities and a multiblock structure to accomplish what you are trying to do.  This is due to the way minecraft looks up the hitbox -- it has no way of knowing that when you are looking at a given X,Y,Z that you really want to pull up and use the hitbox from the block located at X,Y-1,Z.

  • 1 month later...
Posted

Actually I think you can override a block collision block to custom size, but it is done dynamically when the collision bounding boxes are set, it is not a fixed field for the block.  You do this by @Overriding the addCollisionBoxesToList method and

 

@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
    // change the parameters below to what you want
    super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}

 

You can do interesting things with this, like changing the bounding box depending on entity type (this could create mod-resistant force field).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.