2016-02-17 09:21:22 -05:00
|
|
|
package WayofTime.bloodmagic.block;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2018-03-07 19:43:00 -08:00
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
2018-02-15 18:49:01 -08:00
|
|
|
import WayofTime.bloodmagic.soul.IDemonWillGem;
|
|
|
|
import WayofTime.bloodmagic.soul.IDiscreteDemonWill;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.tile.TileDemonCrucible;
|
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
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;
|
2017-01-01 21:43:34 -08:00
|
|
|
import net.minecraft.block.Block;
|
2016-02-17 09:21:22 -05:00
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
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;
|
2016-02-17 16:31:11 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2017-08-15 21:24:59 -07:00
|
|
|
import net.minecraft.item.ItemBlock;
|
2016-02-17 16:31:11 -05:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-02-17 09:21:22 -05:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-03-18 13:16:38 -04:00
|
|
|
import net.minecraft.util.EnumBlockRenderType;
|
2016-02-17 16:31:11 -05:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-18 13:16:38 -04:00
|
|
|
import net.minecraft.util.EnumHand;
|
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-17 09:21:22 -05:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2017-01-01 21:43:34 -08:00
|
|
|
import javax.annotation.Nullable;
|
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 java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
2017-01-01 21:43:34 -08:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBlock {
|
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, 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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public BlockDemonCrucible() {
|
2016-04-24 10:06:28 -07:00
|
|
|
super(Material.ROCK);
|
2016-02-17 09:21:22 -05:00
|
|
|
|
2017-08-14 20:53:42 -07:00
|
|
|
setUnlocalizedName(BloodMagic.MODID + ".demonCrucible");
|
|
|
|
setCreativeTab(BloodMagic.TAB_BM);
|
2016-02-17 09:21:22 -05:00
|
|
|
setHardness(2.0F);
|
|
|
|
setResistance(5.0F);
|
|
|
|
setHarvestLevel("pickaxe", 0);
|
|
|
|
|
|
|
|
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-02-17 09:21:22 -05:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
2016-02-17 09:21:22 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public boolean isOpaqueCube(IBlockState state) {
|
2016-02-17 09:21:22 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public boolean causesSuffocation(IBlockState state) {
|
2016-02-17 09:21:22 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public EnumBlockRenderType getRenderType(IBlockState state) {
|
2016-03-18 13:16:38 -04:00
|
|
|
return EnumBlockRenderType.MODEL;
|
2016-02-17 09:21:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
2017-01-01 21:43:34 -08:00
|
|
|
ItemStack heldItem = player.getHeldItem(hand);
|
2016-02-17 16:31:11 -05:00
|
|
|
TileDemonCrucible crucible = (TileDemonCrucible) world.getTileEntity(pos);
|
|
|
|
|
|
|
|
if (crucible == null || player.isSneaking())
|
|
|
|
return false;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (!heldItem.isEmpty()) {
|
|
|
|
if (!(heldItem.getItem() instanceof IDiscreteDemonWill) && !(heldItem.getItem() instanceof IDemonWillGem)) {
|
2017-03-05 10:38:23 -08:00
|
|
|
return true;
|
|
|
|
}
|
2016-02-17 16:31:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Utils.insertItemToTile(crucible, player);
|
|
|
|
|
2016-03-18 13:16:38 -04:00
|
|
|
world.notifyBlockUpdate(pos, state, state, 3);
|
2016-02-17 16:31:11 -05:00
|
|
|
return true;
|
2016-02-17 09:21:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
|
2016-02-17 16:31:11 -05:00
|
|
|
TileDemonCrucible tile = (TileDemonCrucible) world.getTileEntity(blockPos);
|
|
|
|
if (tile != null)
|
|
|
|
tile.dropItems();
|
2016-02-17 09:21:22 -05:00
|
|
|
|
|
|
|
super.breakBlock(world, blockPos, blockState);
|
|
|
|
}
|
2016-03-16 15:37:55 -07:00
|
|
|
|
2017-01-01 21:43:34 -08:00
|
|
|
@Override
|
|
|
|
public boolean hasTileEntity(IBlockState state) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
|
|
|
return new TileDemonCrucible();
|
|
|
|
}
|
|
|
|
|
2017-08-15 21:24:59 -07:00
|
|
|
@Override
|
|
|
|
public ItemBlock getItem() {
|
|
|
|
return new ItemBlock(this);
|
|
|
|
}
|
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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2016-02-17 09:21:22 -05:00
|
|
|
}
|