Jump to content

Recommended Posts

Posted

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

Posted

you are always overwriting the block bounds and then you are adding an object that has never been modified.

But the model looks awesome(mine always look like I used random setting...)

Here could be your advertisement!

Posted

Use something like this:

	bounds.setBounds(par1, par3, par5, par7, par9, par11)
	this.addCollisionBoxesToList(world, x, y, z, bounds, list, entity);
                ...

Here could be your advertisement!

Posted

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);
}

}

 

Posted

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);
}

 

Posted

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?)
}

  • 5 years later...
Posted

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.

Posted

@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!

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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