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
  On 5/5/2014 at 1:44 AM, jeremy450 said:

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
  On 5/5/2014 at 7:58 AM, jeremy450 said:

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

    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
    • Crashes the server when trying to start. Error code -1. Log  
  • Topics

×
×
  • Create New...

Important Information

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