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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please read the FAQ and post logs as described there.
    • Upon starting the server I get; [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     Framework (framework) has failed to load correctly §7java.lang.NoClassDefFoundError: net/minecraft/client/gui/components/toasts/Toast ] I suspect there is a (possibly a few) client-only mods installed on my server. Any help would be appreciated! (Yes I know there are a lot of mods...) Here is the crash log:   https://paste.ee/p/pRz5mhMl#s=0
    • That's basically what the failure does, my apologies for failing to specify.  It just tries again on the next tick until it detects the entities for that chunk are loaded, and then tries to load the entity.  From there it gets into different failure states depending on what goes wrong, but in short, if the entity fails to load once the entity list becomes available, the request is cleared and must be resubmitted by the end user.  There should be few cases where that actually happens. Yes, that is my understanding of forceloading.  That's why on a successful summon, it removes the forceload.  Otherwise it does just leave the chunks loaded long term. Thank you for your help, any knowledge is useful!  I don't often mess with forceloading and my prior experience is 1.16 so I'm also a bit out of my depth haha.
    • I will have to do more research about 1.18 chunk loading. You were unclear about how your code manages with the entity load failure. If you simply used a loop, I suggest submitting a tick task to the next tick which does the same thing, checking if the entities are loaded and if so teleporting the right one else submitting another tick task etc. Also I think forceloading permanently force loads the chunk, and it only starts to unload when you make a subsequent call to mark the chunk as not forceloaded. I may be completely wrong, I dont know much about 1.18, most of my experience is 1.20. Good luck I hope you figure it out after all this time 😅
    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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