Posted June 25, 201510 yr I created a block that is made up of up to 8 little blocks, so you can build a slab, a stair, or anything else possible with this configuration. Now, my problem is, the bounding box of the block has to be exactly the shape of the texture. How can I make a bounding box that's not a cuboid? My first Mod: http://www.curse.com/mc-mods/minecraft/231302-adamantium-mod-better-than-diamonds#
June 25, 201510 yr Author Yeah I have the collisionBoxes, the wireframe is the issue. I googled around quite a bit now, but as I'm delving deeper into forge, there are less and less examples to learn from.. I really can't figure out how exactly to draw a wireframe My first Mod: http://www.curse.com/mc-mods/minecraft/231302-adamantium-mod-better-than-diamonds#
June 26, 201510 yr Author @SubscribeEvent public void drawSelectionBox(DrawBlockHighlightEvent e) { World world = e.player.worldObj; EntityPlayer player = e.player; float partialTicks = e.partialTicks; if(world.getTileEntity(e.target.getBlockPos()) instanceof TileEntityTinyDirt) { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F); GL11.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); BlockPos blockpos = e.target.getBlockPos(); Block block = world.getBlockState(blockpos).getBlock(); if (block.getMaterial() != Material.air && world.getWorldBorder().contains(blockpos)) { double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks; double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks; double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks; AxisAlignedBB box = new AxisAlignedBB(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) //.expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D) //.offset(-d0, -d1, -d2); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.startDrawing(3); //worldrenderer.addVertex(box.minX, box.minY, box.minZ); //worldrenderer.addVertex(box.minX+0.5, box.minY, box.minZ); //worldrenderer.addVertex(box.minX, box.minY, box.minZ); //worldrenderer.addVertex(box.minX, box.minY, box.minZ); tessellator.draw(); } GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } } I can't seem to change the bounding box of my block. I'm not sure what the 3 parameters for addVertex do, the info I find online is inconsistent. And shouldn't the box be "not there" with this code? Since the AxisAlignedBB I start with is empty. My first Mod: http://www.curse.com/mc-mods/minecraft/231302-adamantium-mod-better-than-diamonds#
June 26, 201510 yr Author I completely forgot about that sorry Now the default box is gone, but I still have no idea how to "addVertex"es correctly. I played around with the values, but no box appears. My first Mod: http://www.curse.com/mc-mods/minecraft/231302-adamantium-mod-better-than-diamonds#
June 26, 201510 yr Author Oh yeah, just found it out, I thought I had to run drawSelectionBox myself. Well, now it slowly starts to work as intended. Small problem: The correct boxes are only drawn as long as I look at the last part of the texture that's loaded, when I look at another "part" of my block, I look through. I know why, but I don't know how to fix it. The problem is that I'm using setBlockBounds often, for setting the collision box for every tiny block, and also for setting the wireframe now. I tried without using setBlockBounds, but then I don't get any collisions anymore... I have this inside the Block class: @Override public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { return new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); } @Override public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { TileEntityTinyDirt tileEntity = (TileEntityTinyDirt) worldIn.getTileEntity(pos); boolean bot_nw = tileEntity.isBot_nw(); boolean bot_ne = tileEntity.isBot_ne(); boolean bot_se = tileEntity.isBot_se(); boolean bot_sw = tileEntity.isBot_sw(); boolean top_nw = tileEntity.isTop_nw(); boolean top_ne = tileEntity.isTop_ne(); boolean top_se = tileEntity.isTop_se(); boolean top_sw = tileEntity.isTop_sw(); if(bot_nw) { AxisAlignedBB box = new AxisAlignedBB(0.0, 0.0, 0.0, 0.5, 0.5, 0.5); addCollisionBox(box, list, mask); } if(bot_ne) { AxisAlignedBB box = new AxisAlignedBB(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F); addCollisionBox(box, list, mask); } if(bot_se) { AxisAlignedBB box = new AxisAlignedBB(0.5F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F); addCollisionBox(box, list, mask); } if(bot_sw) { AxisAlignedBB box = new AxisAlignedBB(0.0F, 0.0F, 0.5F, 0.5F, 0.5F, 1.0F); addCollisionBox(box, list, mask); } if(top_nw) { AxisAlignedBB box = new AxisAlignedBB(0.0F, 0.5F, 0.0F, 0.5F, 1.0F, 0.5F); addCollisionBox(box, list, mask); } if(top_ne) { AxisAlignedBB box = new AxisAlignedBB(0.5F, 0.5F, 0.0F, 1.0F, 1.0F, 0.5F); addCollisionBox(box, list, mask); } if(top_se) { AxisAlignedBB box = new AxisAlignedBB(0.5F, 0.5F, 0.5F, 1.0F, 1.0F, 1.0F); addCollisionBox(box, list, mask); } if(top_sw) { AxisAlignedBB box = new AxisAlignedBB(0.0F, 0.5F, 0.5F, 0.5F, 1.0F, 1.0F); addCollisionBox(box, list, mask); } } public void addCollisionBox(AxisAlignedBB box, List list, AxisAlignedBB mask) { if (box != null && mask.intersectsWith(box)) { list.add(box); } } And this as the Event: @SubscribeEvent public void drawSelectionBox(DrawBlockHighlightEvent e) { ///* if(e.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { BlockPos blockpos = e.target.getBlockPos(); World world = e.player.worldObj; TileEntity tileEntity = world.getTileEntity(blockpos); if(tileEntity instanceof TileEntityTinyDirt) { TileEntityTinyDirt tileEntityTinyDirt = (TileEntityTinyDirt) tileEntity; TinyDirt block = (TinyDirt) world.getBlockState(blockpos).getBlock(); if(tileEntityTinyDirt.isBot_nw()) { block.setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 0.5F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isBot_ne()) { block.setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isBot_se()) { block.setBlockBounds(0.5F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isBot_sw()) { block.setBlockBounds(0.0F, 0.0F, 0.5F, 0.5F, 0.5F, 1.0F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isTop_nw()) { block.setBlockBounds(0.0F, 0.5F, 0.0F, 0.5F, 1.0F, 0.5F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isTop_ne()) { block.setBlockBounds(0.5F, 0.5F, 0.0F, 1.0F, 1.0F, 0.5F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isTop_se()) { block.setBlockBounds(0.5F, 0.5F, 0.5F, 1.0F, 1.0F, 1.0F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } if(tileEntityTinyDirt.isTop_sw()) { block.setBlockBounds(0.0F, 0.5F, 0.5F, 0.5F, 1.0F, 1.0F); e.context.drawSelectionBox(e.player, e.target, 0, e.partialTicks); } e.setCanceled(true); } //*/ } } My first Mod: http://www.curse.com/mc-mods/minecraft/231302-adamantium-mod-better-than-diamonds#
June 27, 201510 yr Author Hm yeah, now the wireframe shows correctly; however, it is completely useless now. I thought the wireframe determined where exactly you could click, but that's the bounding box. Now this bounding box is always a full cube, so I can't place several blocks "inside it" anymore. Or, well I can, if I modify the "pos = pos.offset(side);" condition, but I'll often get the wrong hitY value. So there is no way of actually setting to real blockBounds to a complex shape? My first Mod: http://www.curse.com/mc-mods/minecraft/231302-adamantium-mod-better-than-diamonds#
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.