2016-02-23 13:40:08 -05:00
|
|
|
package WayofTime.bloodmagic.block;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
|
|
|
import WayofTime.bloodmagic.tile.TileDemonPylon;
|
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
2019-02-01 02:15:11 +01:00
|
|
|
import com.google.common.collect.Lists;
|
2019-09-22 12:55:43 -07:00
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.block.ContainerBlock;
|
2016-02-23 13:40:08 -05:00
|
|
|
import net.minecraft.block.material.Material;
|
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
2019-02-01 02:15:11 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
2019-09-22 12:55:43 -07:00
|
|
|
import net.minecraft.item.BlockItem;
|
2016-02-23 13:40:08 -05:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2019-09-22 12:55:43 -07:00
|
|
|
import net.minecraft.block.BlockRenderType;
|
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
2019-02-01 02:15:11 +01:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
2016-03-18 13:16:38 -04:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
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
2019-02-01 02:15:11 +01:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
2016-03-18 13:16:38 -04:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2016-02-23 13:40:08 -05:00
|
|
|
import net.minecraft.world.World;
|
2016-03-16 15:37:55 -07:00
|
|
|
|
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
2019-02-01 02:15:11 +01:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
2019-09-22 12:55:43 -07:00
|
|
|
public class BlockDemonPylon extends ContainerBlock implements IBMBlock, IVariantProvider {
|
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
2019-02-01 02:15:11 +01:00
|
|
|
protected static final AxisAlignedBB BODY = new AxisAlignedBB(2 / 16F, 7 / 16F, 2 / 16F, 14 / 16F, 20 / 16F, 14 / 16F);
|
|
|
|
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
|
|
|
|
};
|
|
|
|
private static final AxisAlignedBB[] ARMS = {};
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public BlockDemonPylon() {
|
2016-04-24 10:06:28 -07:00
|
|
|
super(Material.ROCK);
|
2016-02-23 13:40:08 -05:00
|
|
|
|
2019-01-31 19:10:37 -08:00
|
|
|
setTranslationKey(BloodMagic.MODID + ".demonPylon");
|
2017-08-14 20:53:42 -07:00
|
|
|
setCreativeTab(BloodMagic.TAB_BM);
|
2016-02-23 13:40:08 -05:00
|
|
|
setHardness(2.0F);
|
|
|
|
setResistance(5.0F);
|
|
|
|
setHarvestLevel("pickaxe", 0);
|
|
|
|
|
|
|
|
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
|
|
|
}
|
|
|
|
|
2019-09-22 12:55:43 -07:00
|
|
|
private static List<AxisAlignedBB> getCollisionBoxList(BlockState state) {
|
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
2019-02-01 02:15:11 +01:00
|
|
|
ArrayList<AxisAlignedBB> collBox = new ArrayList<>(Arrays.asList(ARMS));
|
|
|
|
collBox.add(BODY);
|
|
|
|
collBox.addAll(Arrays.asList(FEET));
|
|
|
|
return collBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
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
2019-02-01 02:15:11 +01:00
|
|
|
return BODY;
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:40:08 -05:00
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
2016-02-23 13:40:08 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-22 09:31:47 -04:00
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public boolean isOpaqueCube(BlockState state) {
|
2016-03-22 09:31:47 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:40:08 -05:00
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public boolean isFullCube(BlockState state) {
|
2016-02-23 13:40:08 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public boolean causesSuffocation(BlockState state) {
|
2016-02-23 13:40:08 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public BlockRenderType getRenderType(BlockState state) {
|
|
|
|
return BlockRenderType.MODEL;
|
2016-02-23 13:40:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public TileEntity createNewTileEntity(World world, int meta) {
|
2016-02-23 13:40:08 -05:00
|
|
|
return new TileDemonPylon();
|
|
|
|
}
|
2018-04-07 13:08:28 -07:00
|
|
|
|
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public BlockItem getItem() {
|
|
|
|
return new BlockItem(this);
|
2018-04-07 13:08:28 -07:00
|
|
|
}
|
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
2019-02-01 02:15:11 +01:00
|
|
|
|
|
|
|
@Override
|
2019-09-22 12:55:43 -07:00
|
|
|
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
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
2019-02-01 02:15:11 +01:00
|
|
|
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
|
2019-09-22 12:55:43 -07:00
|
|
|
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean bool) {
|
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
2019-02-01 02:15:11 +01:00
|
|
|
state = this.getActualState(state, worldIn, pos);
|
|
|
|
|
|
|
|
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) {
|
|
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
|
|
|
|
}
|
|
|
|
}
|
2016-02-23 13:40:08 -05:00
|
|
|
}
|