Jump to content

[1.7.10] Custom Collision Box


Arkazex

Recommended Posts

Hello,

I am trying to make a model that has a custom collision model, with three walls, and an open side, so that the player can walk into it, but not out of the sides.  (See the picture for clarification)

 

Picture for Clarification:

 

ByQ3ogF.png

 

 

I looked at the code for Hoppers (Since I know you can fall into it a little bit) and I copied it into my block class, changing the values to match my model, but the block is still completely impassable.  Does anybody know what I did wrong, or have any idea what I could do to make it work?

 

Here is the code of my block class:

 

 

package com.arkazex.forge.arkmod.block;

import java.util.List;

import com.arkazex.forge.arkmod.tileentity.ElevatorCarEntity;

import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class ElevatorCarBlock extends TileEntityBlock{

public ElevatorCarBlock() {
	super(Material.iron);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

@Override
public TileEntity createNewTileEntity(World world, int meta) {
	return new ElevatorCarEntity();
}

@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB bounds, List list, Entity entity) {
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0625F, 1.0F, 1.0F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1 + 0.0625F, 1.0F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

}

 

 

Thanks in advance,

- Nicholas

Link to comment
Share on other sites

So I did what you said, and now the block is entirely passable (ie. players and entites pass through it like signs/buttons)

 

Updated code:

 

package com.arkazex.forge.arkmod.block;

import java.util.List;

import com.arkazex.forge.arkmod.tileentity.ElevatorCarEntity;

import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class ElevatorCarBlock extends TileEntityBlock{

public ElevatorCarBlock() {
	super(Material.iron);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

@Override
public TileEntity createNewTileEntity(World world, int meta) {
	return new ElevatorCarEntity();
}

@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB bounds, List list, Entity entity) {
	bounds.setBounds(0.0F, 0.0F, 0.0F, 0.0625F, 1.0F, 1.0F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1 + 0.0625F, 1.0F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

}

 

Link to comment
Share on other sites

I tried that, but it still doesn't work.  Am I missing something really obvious, or is this just more complicated than I thought?

 

Code:

 

@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB bounds, List list, Entity entity) {

	bounds = bounds.setBounds(0.0F, 0.0F, 0.0F, 0.0625F, 1.0F, 1.0F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds = bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds = bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds = bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1 + 0.0625F, 1.0F);
	super.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
	bounds = bounds.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

 

Link to comment
Share on other sites

As far as I understand this function you get an (empty) List passed in from Forge and should add your hitboxes to it. Also remember that in minecraft Y-axis is up. So the code you are looking for looks something like this (I guess, not tested):

 

@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB blockBounds, List<> list, Entity collidingEntity) {
// you should use blockBounds as a "mask". Only the intersection of all BoundingBoxes and blockBounds should be added
// (this basically means that you should offset your bounding box by the block's position)
// The list is the list you should add your bounding boxes to by calling list.add(AxisAlignedBoundBox); 
// Also by sure that you add different bounding box objects for every bounding box. The bounds are NOT copied when you add
// it to the list so changes to the added box will be reflected in the list. Just instantiate a new AxisAlignedBoundingBox for
// every box you add.
// You may use collidingEntity to let different entities board (only players?)
}

Link to comment
Share on other sites

  • 5 years later...

How about this:

@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB bounds, List list, Entity entity)
{
    AxisAlignedBB bounds1 = new AxisAlignedBB.setBounds(0.0F, 0.0F, 0.0F, 0.0625F, 1.0F, 1.0F);
    AxisAlignedBB bounds2 = new AxisAlignedBB.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
    AxisAlignedBB bounds3 = new AxisAlignedBB.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
    AxisAlignedBB bounds4 = new AxisAlignedBB.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1 + 0.0625F, 1.0F);
    AxisAlignedBB bounds5 = new AxisAlignedBB.setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    list = new List<AxisAlignedBB>(bounds1, bounds2, bounds3, bounds4, bounds5);
    super.addCollisionBoxesToList(world, x, y, z, null, list, entity);
}

I think, this creates your parts, puts them to a list and passes them to the super-method.

Link to comment
Share on other sites

@Drachenbauer, first the topic was asking on how to make this in the 1.7.10 (A lot of methods have changed from 1.7.10 and 1.15.2), then 1.7.10 is no longer supported. If the modder really has needed help then he has bumping, i think he found a solution, but forgot to say it. Pls only reply on modern Topics.

New in Modding? == Still learning!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • where opportunities abound and promises of financial prosperity beckon from every corner of the internet, the line between opportunity and deception becomes increasingly blurred. As a 38-year-old single mom, I embarked on a journey into the world of cryptocurrency investing, hoping to secure a brighter future for myself and my family. Little did I know, this journey would lead me down a treacherous path fraught with deception and heartbreak. My foray into cryptocurrency investing began with the promise of lucrative returns from a platform claiming to operate within Europe and South Asia. Blinded by optimism and the allure of financial gain, I entrusted my hard-earned savings to this fraudulent company, believing wholeheartedly in its legitimacy. However, my hopes were dashed when I began encountering difficulties with withdrawals and found myself entangled in a web of exorbitant fees and dubious practices. In a desperate bid to salvage what remained of my investment, I turned to a recovery company recommended to me by the very platform that had deceived me. Yet, even in my darkest hour, the deceit persisted, as I soon discovered that the company tasked with recovering my funds was complicit in the deception. Faced with the crushing realization that I had been betrayed once again, I felt a sense of hopelessness engulf me. It was in this moment of despair that I stumbled upon Lee Ultimate Hacker – a shining beacon of hope amidst the darkness of deception. Through a stroke of luck, I came across a blog post singing the praises of this remarkable team, and I knew I had found my savior. With nothing left to lose and everything to gain, I reached out to them, hoping against hope for a chance at redemption. From the outset, Lee Ultimate Hacker proved to be a guiding light in my journey toward financial recovery. Their professionalism, expertise, and unwavering commitment to client satisfaction set them apart from the myriad of recovery services in the digital sphere. With empathy and understanding, they listened to my story and embarked on a mission to reclaim what was rightfully mine. Through their diligent efforts and meticulous attention to detail, Lee Ultimate Hacker succeeded where others had failed, restoring a sense of hope and security in the wake of betrayal. Their dedication to justice and unwavering determination to deliver results ensured that I emerged from the ordeal stronger and more resilient than ever before. Throughout the recovery process, their team remained accessible, transparent, and supportive, offering guidance and reassurance every step of the way. To anyone grappling with devastating financial fraud, I offer a lifeline of hope – trust in Lee Ultimate Hacker to guide you through the storm with expertise and compassion. In a world rife with deception and uncertainty, they stand as a beacon of reliability and trustworthiness, ready to lead you toward financial restitution and a brighter future. If you find yourself in a similar predicament, do not hesitate to reach out to Lee Ultimate Hacker.AT LEEULTIMATEHACKER@ AOL. COM   Support @ leeultimatehacker . com.  telegram:LEEULTIMATE   wh@tsapp +1  (715) 314  -  9248  https://leeultimatehacker.com
    • Sorry, this is the report https://paste.ee/p/OeDj1
    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ
    • This is the crash report [User dumped their crash report directly in their thread, triggering the anti-spam]  
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

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