diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java index 8d9c9b8f..6e6fe841 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.block; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.item.block.ItemBlockAlchemyTable; import WayofTime.bloodmagic.tile.TileAlchemyTable; +import WayofTime.bloodmagic.util.Constants; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; @@ -17,6 +17,7 @@ import net.minecraft.util.BlockRenderLayer; 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.world.IBlockAccess; import net.minecraft.world.World; @@ -26,6 +27,7 @@ import javax.annotation.Nullable; public class BlockAlchemyTable extends Block implements IBMBlock { public static final PropertyBool INVISIBLE = PropertyBool.create("invisible"); public static final PropertyEnum DIRECTION = PropertyEnum.create("direction", EnumFacing.class); + private static final AxisAlignedBB BODY = new AxisAlignedBB(0, 0, 0, 16 / 16F, 13 / 16F, 16 / 16F); public BlockAlchemyTable() { super(Material.ROCK); @@ -40,6 +42,10 @@ public class BlockAlchemyTable extends Block implements IBMBlock { // setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F); } + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return BODY; + } + @Override public boolean isOpaqueCube(IBlockState state) { return false; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java index 3f979f47..136f7801 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java @@ -1,7 +1,10 @@ package WayofTime.bloodmagic.block; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.altar.*; +import WayofTime.bloodmagic.altar.AltarUtil; +import WayofTime.bloodmagic.altar.ComponentType; +import WayofTime.bloodmagic.altar.IAltarManipulator; +import WayofTime.bloodmagic.altar.IBloodAltar; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.SoulNetwork; @@ -23,6 +26,7 @@ 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.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; @@ -35,6 +39,8 @@ import java.util.ArrayList; import java.util.List; public class BlockAltar extends Block implements IVariantProvider, IDocumentedBlock, IBMBlock { + private static final AxisAlignedBB BODY = new AxisAlignedBB(0, 0, 0, 16 / 16F, 12 / 16F, 16 / 16F); + public BlockAltar() { super(Material.ROCK); @@ -45,6 +51,10 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl setHarvestLevel("pickaxe", 1); } + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return BODY; + } + @Override public boolean hasComparatorInputOverride(IBlockState state) { return true; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java index 5627ce9d..b4d5c1d2 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java @@ -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 getCollisionBoxList(IBlockState state) { + ArrayList 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 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 collidingBoxes, @Nullable Entity entityIn, boolean bool) { + state = this.getActualState(state, worldIn, pos); + + for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb); + } + } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java index 61b7073c..78a54ba5 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java @@ -7,6 +7,7 @@ import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal; import WayofTime.bloodmagic.soul.EnumDemonWillType; import WayofTime.bloodmagic.soul.PlayerDemonWillHandler; import WayofTime.bloodmagic.tile.TileDemonCrystal; +import com.google.common.collect.Lists; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -15,6 +16,7 @@ import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -23,17 +25,81 @@ import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; +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.Nonnull; import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.EnumMap; +import java.util.List; public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvider { + public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6); public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumDemonWillType.class); public static final PropertyEnum ATTACHED = PropertyEnum.create("attached", EnumFacing.class); + private static final EnumMap bounds = new EnumMap<>(EnumFacing.class); + + // Bounding / Collision boxes + private static final AxisAlignedBB[] UP = { + new AxisAlignedBB(6 / 16F, 0, 5 / 16F, 10 / 16F, 13 / 16F, 9 / 16F), + new AxisAlignedBB(7 / 16F, 0, 0, 13 / 16F, 6 / 16F, 5 / 16F), + new AxisAlignedBB(9 / 16F, 0, 9 / 16F, 13 / 16F, 5 / 16F, 14 / 16F), + new AxisAlignedBB(2 / 16F, 0, 1 / 16F, 7 / 16F, 6 / 16F, 7 / 16F), + new AxisAlignedBB(5 / 16F, 0, 9 / 16F, 9 / 16F, 7 / 16F, 15 / 16F), + new AxisAlignedBB(0, 0, 7 / 16F, 6 / 16F, 6 / 16F, 10 / 16F), + new AxisAlignedBB(10 / 16F, 0, 6 / 16F, 15 / 16F, 6 / 16F, 9 / 16F) + }; + private static final AxisAlignedBB[] DOWN = { + new AxisAlignedBB(6 / 16F, 3 / 16F, 7 / 16F, 10 / 16F, 16 / 16F, 11 / 16F), + new AxisAlignedBB(7 / 16F, 10 / 16F, 11 / 16F, 13 / 16F, 16 / 16F, 16 / 16F), + new AxisAlignedBB(9 / 16F, 11 / 16F, 2 / 16F, 13 / 16F, 16 / 16F, 7 / 16F), + new AxisAlignedBB(2 / 16F, 9 / 16F, 11 / 16F, 7 / 16F, 16 / 16F, 15 / 16F), + new AxisAlignedBB(5 / 16F, 9 / 16F, 1 / 16F, 9 / 16F, 16 / 16F, 7 / 16F), + new AxisAlignedBB(0, 10 / 16F, 6 / 16F, 6 / 16F, 16 / 16F, 9 / 16F), + new AxisAlignedBB(10 / 16F, 11 / 16F, 7 / 16F, 15 / 16F, 16 / 16F, 10 / 16F) + }; + private static final AxisAlignedBB[] NORTH = { + new AxisAlignedBB(6 / 16F, 5 / 16F, 3 / 16F, 10 / 16F, 9 / 16F, 16 / 16F), + new AxisAlignedBB(9 / 16F, 0, 6 / 16F, 13 / 16F, 5 / 16F, 16 / 16F), + new AxisAlignedBB(8 / 16F, 9 / 16F, 11 / 16F, 13 / 16F, 14 / 16F, 16 / 16F), + new AxisAlignedBB(2 / 16F, 1 / 16F, 9 / 16F, 7 / 16F, 7 / 16F, 16 / 16F), + new AxisAlignedBB(5 / 16F, 9 / 16F, 9 / 16F, 9 / 16F, 15 / 16F, 16 / 16F), + new AxisAlignedBB(0, 7 / 16F, 10 / 16F, 6 / 16F, 10 / 16F, 16 / 16F), + new AxisAlignedBB(10 / 16F, 7 / 16F, 10 / 16F, 15 / 16F, 9 / 16F, 15 / 16F), + }; + private static final AxisAlignedBB[] SOUTH = { + new AxisAlignedBB(6 / 16F, 7 / 16F, 0 / 16F, 10 / 16F, 11 / 16F, 13 / 16F), + new AxisAlignedBB(7 / 16F, 11 / 16F, 0, 13 / 16F, 16 / 16F, 6 / 16F), + new AxisAlignedBB(8 / 16F, 2 / 16F, 9 / 16F, 13 / 16F, 7 / 16F, 14 / 16F), + new AxisAlignedBB(2 / 16F, 9 / 16F, 1 / 16F, 7 / 16F, 14 / 16F, 7 / 16F), + new AxisAlignedBB(5 / 16F, 1 / 16F, 9 / 16F, 9 / 16F, 7 / 16F, 9 / 16F), + new AxisAlignedBB(0, 6 / 16F, 1 / 16F, 6 / 16F, 9 / 16F, 7 / 16F), + new AxisAlignedBB(10 / 16F, 8 / 16F, 1 / 16F, 15 / 16F, 10 / 16F, 6 / 16F) + }; + private static final AxisAlignedBB[] EAST = { + new AxisAlignedBB(0, 6 / 16F, 5 / 16F, 13 / 16F, 10 / 16F, 9 / 16F), + new AxisAlignedBB(0, 3 / 16F, 0, 6 / 16F, 9 / 16F, 5 / 16F), + new AxisAlignedBB(0 / 16F, 3 / 16F, 9 / 16F, 5 / 16F, 8 / 16F, 14 / 16F), + new AxisAlignedBB(1 / 16F, 9 / 16F, 1 / 16F, 7 / 16F, 13 / 16F, 7 / 16F), + new AxisAlignedBB(1 / 16F, 0, 9 / 16F, 7 / 16F, 11 / 16F, 15 / 16F), + new AxisAlignedBB(0, 10 / 16F, 7 / 16F, 6 / 16F, 16 / 16F, 10 / 16F), + new AxisAlignedBB(0, 1 / 16F, 6 / 16F, 5 / 16F, 6 / 16F, 9 / 16F) + }; + private static final AxisAlignedBB[] WEST = { + new AxisAlignedBB(3 / 16F, 6 / 16F, 5 / 16F, 16 / 16F, 10 / 16F, 9 / 16F), + new AxisAlignedBB(9 / 16F, 7 / 16F, 0, 16 / 16F, 12 / 16F, 5 / 16F), + new AxisAlignedBB(11 / 16F, 4 / 16F, 9 / 16F, 16 / 16F, 13 / 16F, 14 / 16F), + new AxisAlignedBB(9 / 16F, 3 / 16F, 1 / 16F, 16 / 16F, 8 / 16F, 7 / 16F), + new AxisAlignedBB(9 / 16F, 6 / 16F, 9 / 16F, 16 / 16F, 8 / 16F, 15 / 16F), + new AxisAlignedBB(10 / 16F, 1 / 16F, 7 / 16F, 16 / 16F, 6 / 16F, 10 / 16F), + new AxisAlignedBB(10 / 16F, 6 / 16F, 6 / 16F, 15 / 16F, 15 / 16F, 9 / 16F) + }; public BlockDemonCrystal() { super(Material.ROCK); @@ -46,6 +112,72 @@ public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvid setHarvestLevel("pickaxe", 2); } + public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) { + ItemStack stack = ItemStack.EMPTY; + switch (type) { + case CORROSIVE: + stack = EnumDemonWillType.CORROSIVE.getStack(); + break; + case DEFAULT: + stack = EnumDemonWillType.DEFAULT.getStack(); + break; + case DESTRUCTIVE: + stack = EnumDemonWillType.DESTRUCTIVE.getStack(); + break; + case STEADFAST: + stack = EnumDemonWillType.STEADFAST.getStack(); + break; + case VENGEFUL: + stack = EnumDemonWillType.VENGEFUL.getStack(); + break; + } + + stack.setCount(crystalNumber); + return stack; + } + + // collects a sublist from 0 to age for the collision boxes + private static List getCollisionBoxList(IBlockState state) { + int age = state.getValue(BlockDemonCrystal.AGE) + 1; + switch (state.getValue(BlockDemonCrystal.ATTACHED)) { + case DOWN: + return Arrays.asList(DOWN).subList(0, age); + case NORTH: + return Arrays.asList(NORTH).subList(0, age); + case SOUTH: + return Arrays.asList(SOUTH).subList(0, age); + case WEST: + return Arrays.asList(WEST).subList(0, age); + case EAST: + return Arrays.asList(EAST).subList(0, age); + case UP: + default: + return Arrays.asList(UP).subList(0, age); + } + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + TileEntity tile = source.getTileEntity(pos); + if (tile != null) + state = getActualState(state, tile.getWorld(), pos); + switch (state.getValue(ATTACHED)) { + case DOWN: + return DOWN[0]; + case NORTH: + return NORTH[0]; + case SOUTH: + return SOUTH[0]; + case EAST: + return EAST[0]; + case WEST: + return WEST[0]; + case UP: + default: + return UP[0]; + } + } + @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { @@ -62,7 +194,7 @@ public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvid if (!crystal.getWorld().isRemote && isCreative && holdsCrystal) { if (crystal.crystalCount < 7) { crystal.internalCounter = 0; - if(crystal.progressToNextCrystal > 0) + if (crystal.progressToNextCrystal > 0) crystal.progressToNextCrystal--; crystal.crystalCount++; crystal.markDirty(); @@ -167,6 +299,7 @@ public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvid @Override public int getMetaFromState(IBlockState state) { + return state.getValue(TYPE).ordinal(); } @@ -186,30 +319,6 @@ public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvid return new TileDemonCrystal(); } - public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) { - ItemStack stack = ItemStack.EMPTY; - switch (type) { - case CORROSIVE: - stack = EnumDemonWillType.CORROSIVE.getStack(); - break; - case DEFAULT: - stack = EnumDemonWillType.DEFAULT.getStack(); - break; - case DESTRUCTIVE: - stack = EnumDemonWillType.DESTRUCTIVE.getStack(); - break; - case STEADFAST: - stack = EnumDemonWillType.STEADFAST.getStack(); - break; - case VENGEFUL: - stack = EnumDemonWillType.VENGEFUL.getStack(); - break; - } - - stack.setCount(crystalNumber); - return stack; - } - @Override public ItemBlock getItem() { return new ItemBlockDemonCrystal(this); @@ -220,4 +329,40 @@ public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvid for (EnumDemonWillType willType : EnumDemonWillType.values()) variants.put(willType.ordinal(), "age=3,attached=up,type=" + willType.getName()); } + + @Override + public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) { + List 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 collidingBoxes, @Nullable Entity entityIn, boolean bool) { + state = this.getActualState(state, worldIn, pos); + + for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb); + } + } + } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java index 60fdafea..38a64240 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java @@ -3,17 +3,36 @@ package WayofTime.bloodmagic.block; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.tile.TileDemonPylon; +import com.google.common.collect.Lists; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; import net.minecraft.item.ItemBlock; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; +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 BlockDemonPylon extends BlockContainer implements IBMBlock, IVariantProvider { + 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 = {}; + public BlockDemonPylon() { super(Material.ROCK); @@ -26,6 +45,18 @@ public class BlockDemonPylon extends BlockContainer implements IBMBlock, IVarian // setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F); } + private static List getCollisionBoxList(IBlockState state) { + ArrayList 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; @@ -60,4 +91,39 @@ public class BlockDemonPylon extends BlockContainer implements IBMBlock, IVarian public ItemBlock getItem() { return new ItemBlock(this); } + + @Override + public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) { + List 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 collidingBoxes, @Nullable Entity entityIn, boolean bool) { + state = this.getActualState(state, worldIn, pos); + + for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb); + } + } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java index e77d0982..12d9d77e 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; import javax.annotation.Nullable; public class BlockIncenseAltar extends Block implements IVariantProvider, IBMBlock { - protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F); + protected static final AxisAlignedBB AABB = new AxisAlignedBB(5 / 16F, 0F, 5 / 16F, 12 / 16F, 1F, 11 / 16F); public BlockIncenseAltar() { super(Material.ROCK);