Bounding boxes / Collision boxes rework (#1464)

* Bounding boxes, first part:

- BlockDemonCrystal ATTACHED "UP" (facing upwards) (AABB_UP) finished all ages
- BlockDemonCrystal Age 0 finished for all ATTACHED values
 TODO: Remaining ATTACHED/AGE values, making it look a bit more tidy.

- BlockIncenseAltar: changed bounding box to the closest full pixel

- BlockDemonPylon: Made bounding box a bit higher

TODO: remaining blocks that are visually higher or smaller than a full block, how should values be displayed: "x / 16F" or "0.X"

* Bounding boxes, second part:

- up to EAST, age 1
 TODO: Remaining ATTACHED/AGE values.

TODO: remaining blocks that are visually higher or smaller than a full block, how should values be displayed: "x / 16F" or "0.X"

* Finished EAST, started WEST

* finished WEST

* Changed Bounding and Collision boxes for:

BlockAlchemyTable - lowered by 2 pixels (fits with base model without "accessoires" on the table)
BlockAltar - lowered by 4 pixels (fits with base model)
BlockDemonCrucible - seperated into ARMS, BODY and LEGS, each with their own collision boxes. Uses BODY as Bounding box
BlockDemonPylon - seperated into BODY and LEGS, uses BODY as Bounding box.

* Alchemy Table BB
This commit is contained in:
Tobias Gremeyer 2019-02-01 02:15:11 +01:00 committed by Nick Ignoffo
parent 4bf8e94d26
commit 95464ca509
6 changed files with 325 additions and 28 deletions

View file

@ -6,9 +6,11 @@ import WayofTime.bloodmagic.soul.IDemonWillGem;
import WayofTime.bloodmagic.soul.IDiscreteDemonWill;
import WayofTime.bloodmagic.tile.TileDemonCrucible;
import WayofTime.bloodmagic.util.Utils;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@ -16,13 +18,34 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBlock {
protected static final AxisAlignedBB BODY = new AxisAlignedBB(2 / 16F, 7 / 16F, 2 / 16F, 14 / 16F, 15 / 16F, 14 / 16F);
private static final AxisAlignedBB[] ARMS = {
new AxisAlignedBB(5 / 16F, 13 / 16F, 0 / 16F, 11 / 16F, 25 / 16F, 2 / 16F), // N
new AxisAlignedBB(14 / 16F, 13 / 16F, 5 / 16F, 16 / 16F, 25 / 16F, 11 / 16F), // E
new AxisAlignedBB(5 / 16F, 13 / 16F, 14 / 16F, 11 / 16F, 25 / 16F, 16 / 16F), // S
new AxisAlignedBB(0 / 16F, 13 / 16F, 5 / 16F, 2 / 16F, 25 / 16F, 11 / 16F) // W
};
private static final AxisAlignedBB[] FEET = {
new AxisAlignedBB(10 / 16F, 0F, 2 / 16F, 14 / 16F, 7 / 16F, 6 / 16F), // NE
new AxisAlignedBB(10 / 16F, 0F, 10 / 16F, 14 / 16F, 7 / 16F, 14 / 16F), // SE
new AxisAlignedBB(2 / 16F, 0F, 10 / 16F, 6 / 16F, 7 / 16F, 14 / 16F), // SW
new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 6 / 16F, 7 / 16F, 6 / 16F) // NW
};
public BlockDemonCrucible() {
super(Material.ROCK);
@ -35,6 +58,18 @@ public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBl
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
}
private static List<AxisAlignedBB> getCollisionBoxList(IBlockState state) {
ArrayList<AxisAlignedBB> collBox = new ArrayList<>(Arrays.asList(ARMS));
collBox.add(BODY);
collBox.addAll(Arrays.asList(FEET));
return collBox;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BODY;
}
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
return false;
@ -99,4 +134,39 @@ public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBl
public ItemBlock getItem() {
return new ItemBlock(this);
}
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
List<RayTraceResult> list = Lists.newArrayList();
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) {
list.add(this.rayTrace(pos, start, end, axisalignedbb));
}
RayTraceResult rayTrace = null;
double d1 = 0.0D;
for (RayTraceResult raytraceresult : list) {
if (raytraceresult != null) {
double d0 = raytraceresult.hitVec.squareDistanceTo(end);
if (d0 > d1) {
rayTrace = raytraceresult;
d1 = d0;
}
}
}
return rayTrace;
}
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean bool) {
state = this.getActualState(state, worldIn, pos);
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) {
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
}
}
}