Jump to content

Recommended Posts

Posted

I have created some new items and i have set their bounds different then normal. For example if i made one 10 blocks long

i would be able to walk through 9 of the blocks. The texture still shows though on the 10 long block. i have tryed setting

public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)

    {

        float var5 = 1F;

        return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)((float)par2 + var5), (double)par3, (double)((float)par4 + var5), (double)((float)(par2 + 1) - var5), (double)(par3 + 1), (double)((float)(par4 + 1) - var5));

    }

 

but im still able to walk through them

 

Posted

At risk of putting my foot in my mouth, there are two problems with your method.  Firstly, you're using getSelectedBoundingBoxFromPool.  This method, as the name *and javadoc* imply, only affects what happens when a player puts their cursor over the block (and is client-side only, to boot).  Take a look at BlockFence, that block is technically 1.5 blocks tall and has an example of what you're trying to do.

 

In addition, I'm worried by your use of 'var5's and 'par2's and other anonymous variables -- it makes code terribly difficult to read. MCP-decompiled code looks like that only because of how the vanilla minecraft code has to be deobfuscated and decombiled.  Variable names *that represent what the variable does* are much, much better -- take a look at the methods near the end of Block.java, specifically the bit after the "FORGE START" comment for an example of what I'm talking about.

Posted

public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)

    {

return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(2,2,2,3,3,3);

    }

is what fence uses and it doesnt change the fact i can walk through my block no matter what i put as the min and max

 

Posted

public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)

    {

return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(2,2,2,3,3,3);

    }

is what fence uses and it doesnt change the fact i can walk through my block no matter what i put as the min and max

 

 

Firstly:  You can rename parameters in overridden methods.

 

getCollisionBoundingBoxFromPool(World world, int x, int y, int z) is *far* easier on the eyes than (World par1, int par2. . .).

 

Secondly, take another look at the fence's code -- you've changed the collision box so that, instead of starting at the relevant block's x, y, and z coordinates, it starts at the (2,2,2) coordinate -- four levels deep in bedrock, not too far from the initial spawn in the x and z directions, no matter where the relevant block actually *is*.  And I apologize that my knowledge of the minecraft engine is somewhat limited, but you might have problems with your block if it extends across chunks.  In general, if a something needs to have a collision box larger than 1 block multiple blocks are used instead -- the top and bottom of a door are technically separate blocks, as is the arm of a piston.  The fence (and fence gate) is vanilla minecraft's only block that has a collision box extending beyond it's 1x1x1 m cube.

  • 8 months later...
Posted

I also am trying to get a block to be walk through. I looked at the vanilla blocks that are walk through, namely BlockTallGrass and it's super class, BlockPlant.  Both have this:

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
        return null;
    }

When I use this on my block, I can force my player into the block by having it in a hole, but when there is an open area to the side of the block the block pushes me into the open space. Anyone know how to fix this?

Posted

I looked at the vanilla blocks that are walk through, namely BlockTallGrass and it's super class, BlockPlant.  Both have this:

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
        return null;
    }

 

 

In addition to this, in the blocks constructor, add a call to

//this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

This allowed me to walk through a block. Let me know if this doesn't work and I can look into it more.

allout58

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

    • I can't understand the logs, so I'm hoping someone could tell me what's causing the issues. https://pastebin.com/d1XPxCes
    • Hello I'm currently making an Item that thrusts you to viewing direction, and I referenced riptide code of trident for my item. @Override public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { if(!pLevel.isClientSide() && pUsedHand == InteractionHand.MAIN_HAND && pPlayer.isOnGround()){ Impale(pPlayer, pUsedHand); pPlayer.getCooldowns().addCooldown(this, 40); } return super.use(pLevel, pPlayer, pUsedHand); } public void Impale(Player pPlayer, InteractionHand pUsedHand) { float playerYRot = pPlayer.getYRot(); float xForce = -Mth.sin(playerYRot * ((float)Math.PI / 180F)) * Mth.cos((float)Math.PI / 180F); float yForce = 100.6F; float zForce = Mth.cos(playerYRot * ((float)Math.PI / 180F)) * Mth.cos((float)Math.PI / 180F); float stabilizedForce = Mth.sqrt(xForce * xForce + zForce * zForce); xForce /= stabilizedForce; zForce /= stabilizedForce; pPlayer.push((double)xForce, (double)yForce, (double)zForce); pPlayer.sendSystemMessage(Component.literal(playerYRot + " " + xForce + " " + yForce + " " + zForce + " " + stabilizedForce + "shoo")); } I sure edited a lot from source code but this isn't working somehow? the sendSystemMessage works correctly. It prints value of variables and string, but the force isn't applying to player. how can I make this to work? Thanks.
    • i tried putting a modpack together and cant get this working no matter what i have tried log: https://pastebin.com/uqz1aKiY
    • We have an event for an Entity being struck by lighting, but doesn't look like we have one for Blocks. And unfortunately, looking at it, the LightingBolt entity doesn't have any context on why it was registered, so you wouldn't be able to get the source context. What are you trying to accomplish with this event?
    • Hey guys, I'm trying to use the simple planes mod https://www.curseforge.com/minecraft/mc-mods/simple-planes with a nuclear bombs mod https://www.curseforge.com/minecraft/mc-mods/nuclear-bombs . The simple planes mod has a cargo plane that can drop tnt, and i want it to work with the nuclear bombs. I added this JSON file from chatGPT to the payloads folder in simple planes (because the nukes couldn't even get stored in the plane in the first place), but this only allows the nuke to drop but doesn't explode: https://mclo.gs/3uEQIX2 . This nuke mod requires a redstone signal and then manual activation, which makes this tougher i imagine. If someone could write me a code for the payload folder for simpleplanes, something that even tampers with the nuke mod, or any general suggestions that would be great!  Many Thanks
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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