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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
    • Ah, it appears I spoke too soon, I still need a little help here. I now have the forceloading working reliably.  However, I've realized it's not always the first tick that loads the entity.  I've seen it take anywhere from 2-20ish to actually go through, in which time my debugging has revealed that the chunk is loaded, but during which time calling  serverLevelIn.getEntity(uuidIn) returns a null result.  I suspect this has to do with queuing and how entities are loaded into the game.  While not optimal, it's acceptable, and I don't think there's a whole ton I can do to avoid it. However, my concern is that occasionally teleporting an entity in this manner causes a lag spike.  It's not every time and gives the appearance of being correlated with when other chunks are loading in.  It's also not typically a long spike, but can last a second or two, which is less than ideal.  The gist of how I'm summoning is here (although I've omitted some parts that weren't relevant.  The lag occurs before the actual summon so I'm pretty confident it's the loading, and not the actual summon call). ChunkPos chunkPos = new ChunkPos(entityPosIn); if (serverLevelIn.areEntitiesLoaded(chunkPos.toLong())) { boolean isSummoned = // The method I'm using for actual summoning is called here. Apart from a few checks, the bulk of it is shown later on. if (isSummoned) { // Code that runs here just notifies the player of the summon, clears it from the queue, and removes the forceload } } else { // I continue forcing the chunk until the summon succeeds, to make sure it isn't inadvertently cleared ForgeChunkManager.forceChunk(serverLevelIn, MODID, summonPosIn, chunkPos.x, chunkPos.z, true, true); } The summon code itself uses serverLevelIn.getEntity(uuidIn) to retrieve the entity, and moves it as such.  It is then moved thusly: if (entity.isAlive()) { entity.moveTo(posIn.getX(), posIn.getY(), posIn.getZ()); serverLevelIn.playSound(null, entity, SoundEvents.ENDERMAN_TELEPORT, SoundSource.NEUTRAL, 1.0F, 1.0F); return true; } I originally was calling .getEntity() more frequently and didn't have the check for whether or not entities were loaded in place to prevent unnecessary code calls, but even with those safety measures in place, the lag still persists.  Could this just be an issue with 1.18's lack of optimization in certain areas?  Is there anything I can do to mitigate it?  Is there a performance boosting mod I could recommend alongside my own to reduce the chunk loading lag? At the end of the day, it does work, and I'm putting measures in place to prevent players from abusing the system to cause lag (i.e. each player can only have one queued summon at a time-- trying to summon another replaces the first call).  It's also not an unacceptable level of lag, IMO, given the infrequency of such calls, and the fact that I'm providing the option to toggle off the feature if server admins don't want it used.  However, no amount of lag is ideal, so if possible I'd love to find a more elegant solution-- or at least a mod recommendation to help improve it. Thanks!
    • When i start my forge server its on but when i try to join its come a error Internal Exception: java.lang.OutOfMemoryError: Requested array size exceeds VM limit Server infos: Linux Minecraft version 1.20.1 -Xmx11G -Xms8G
    • Also add the latest.log from your logs-folder
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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