Search in sources :

Example 1 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project ImmersiveEngineering by BluSunrize.

the class BlockMetalDecoration1 method canConnectFenceTo.

//	@Override
//	public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
//	{
//		//		TileEntity tileEntity = world.getTileEntity(x, y, z);
//		IBlockState state = world.getBlockState(pos);
//		if(this.getMetaFromState(state)==BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta() || this.getMetaFromState(state)==BlockTypes_MetalDecoration1.ALUMINUM_FENCE.getMeta())
//			this.setBlockBounds(canConnectFenceTo(world,pos.add(-1,0,0))?0:.375f,0,canConnectFenceTo(world,pos.add(0,0,-1))?0:.375f, canConnectFenceTo(world,pos.add(1,0,0))?1:.625f,1,canConnectFenceTo(world,pos.add(0,0,1))?1:.625f);
//		//		else if(tileEntity instanceof TileEntityLantern)
//		//		{
//		//			int f = ((TileEntityLantern)tileEntity).facing ;
//		//			if(f<2)
//		//				this.setBlockBounds(.25f,f==1?0:.125f,.25f, .75f,f==1?.875f:1f,.75f);
//		//			else
//		//				this.setBlockBounds(f==5?0:.25f,0,f==3?0:.25f, f==4?1:.75f,.875f,f==2?1:.75f);
//		//		}
//		//		else if(tileEntity instanceof TileEntityConnectorStructural)
//		//		{
//		//			float length = .5f;
//		//			switch(((TileEntityConnectorStructural)tileEntity).facing )
//		//			{
//		//			case 0://UP
//		//				this.setBlockBounds(.25f,0,.25f,  .75f,length,.75f);
//		//				break;
//		//			case 1://DOWN
//		//				this.setBlockBounds(.25f,1-length,.25f,  .75f,1,.75f);
//		//				break;
//		//			case 2://SOUTH
//		//				this.setBlockBounds(.25f,.25f,0,  .75f,.75f,length);
//		//				break;
//		//			case 3://NORTH
//		//				this.setBlockBounds(.25f,.25f,1-length,  .75f,.75f,1);
//		//				break;
//		//			case 4://EAST
//		//				this.setBlockBounds(0,.25f,.25f,  length,.75f,.75f);
//		//				break;
//		//			case 5://WEST
//		//				this.setBlockBounds(1-length,.25f,.25f,  1,.75f,.75f);
//		//				break;
//		//			}
//		//		}
//		//		else if(tileEntity instanceof TileEntityWallmount)
//		//		{
//		//			TileEntityWallmount arm = (TileEntityWallmount)tileEntity;
//		//			int f = arm.facing;
//		//			if(arm.sideAttached>0)
//		//				this.setBlockBounds(f==4?0:f==5?.375f:.3125f,arm.inverted?.3125f:0,f==2?0:f==3?.375f:.3125f, f==5?1:f==4?.625f:.6875f,arm.inverted?1:.6875f,f==3?1:f==2?.625f:.6875f);
//		//			else
//		//				this.setBlockBounds(f==5?0:.3125f,arm.inverted?.375f:0,f==3?0:.3125f, f==4?1:.6875f,arm.inverted?1:.625f,f==2?1:.6875f);
//		//		}
//		else
//			this.setBlockBounds(0,0,0,1,1,1);
//	}
public boolean canConnectFenceTo(IBlockAccess world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    return block != Blocks.BARRIER && (!((!(block instanceof BlockFence || block.equals(this)) || state.getMaterial() != this.blockMaterial) && !(block instanceof BlockFenceGate)) || ((state.getMaterial().isOpaque() && state.isFullCube()) && state.getMaterial() != Material.GOURD));
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) IELadderBlock(blusunrize.immersiveengineering.common.blocks.BlockIEBase.IELadderBlock) Block(net.minecraft.block.Block) BlockFence(net.minecraft.block.BlockFence)

Example 2 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project NetherEx by LogicTechCorp.

the class PigtificateVillageCollection method getOutside.

private EnumFacing getOutside(BlockPos fenceGatePos) {
    IBlockState fenceGateState = world.getBlockState(fenceGatePos);
    IBlockState stairState = world.getBlockState(fenceGatePos.up(2));
    if (fenceGateState.getBlock() instanceof BlockFenceGate && stairState.getBlock() instanceof BlockStairs) {
        EnumFacing fenceGateFacing = fenceGateState.getValue(BlockFenceGate.FACING);
        EnumFacing stairFacing = stairState.getValue(BlockStairs.FACING);
        if (stairFacing == fenceGateFacing || stairFacing == fenceGateFacing.getOpposite()) {
            return stairFacing;
        }
        return null;
    } else {
        return null;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) EnumFacing(net.minecraft.util.EnumFacing) BlockStairs(net.minecraft.block.BlockStairs)

Example 3 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project ImmersiveEngineering by BluSunrize.

the class BlockWoodenDecoration method canConnectFenceTo.

//	@Override
//	public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
//	{
//		//		TileEntity tileEntity = world.getTileEntity(x, y, z);
//		IBlockState state = world.getBlockState(pos);
//		if(this.getMetaFromState(state)==BlockTypes_WoodenDecoration.FENCE.getMeta())
//			this.setBlockBounds(canConnectFenceTo(world,pos.add(-1,0,0))?0:.375f,0,canConnectFenceTo(world,pos.add(0,0,-1))?0:.375f, canConnectFenceTo(world,pos.add(1,0,0))?1:.625f,1,canConnectFenceTo(world,pos.add(0,0,1))?1:.625f);
//		//		else if(tileEntity instanceof TileEntityLantern)
//		//		{
//		//			int f = ((TileEntityLantern)tileEntity).facing ;
//		//			if(f<2)
//		//				this.setBlockBounds(.25f,f==1?0:.125f,.25f, .75f,f==1?.875f:1f,.75f);
//		//			else
//		//				this.setBlockBounds(f==5?0:.25f,0,f==3?0:.25f, f==4?1:.75f,.875f,f==2?1:.75f);
//		//		}
//		//		else if(tileEntity instanceof TileEntityConnectorStructural)
//		//		{
//		//			float length = .5f;
//		//			switch(((TileEntityConnectorStructural)tileEntity).facing )
//		//			{
//		//			case 0://UP
//		//				this.setBlockBounds(.25f,0,.25f,  .75f,length,.75f);
//		//				break;
//		//			case 1://DOWN
//		//				this.setBlockBounds(.25f,1-length,.25f,  .75f,1,.75f);
//		//				break;
//		//			case 2://SOUTH
//		//				this.setBlockBounds(.25f,.25f,0,  .75f,.75f,length);
//		//				break;
//		//			case 3://NORTH
//		//				this.setBlockBounds(.25f,.25f,1-length,  .75f,.75f,1);
//		//				break;
//		//			case 4://EAST
//		//				this.setBlockBounds(0,.25f,.25f,  length,.75f,.75f);
//		//				break;
//		//			case 5://WEST
//		//				this.setBlockBounds(1-length,.25f,.25f,  1,.75f,.75f);
//		//				break;
//		//			}
//		//		}
//		//		else if(tileEntity instanceof TileEntityWallmount)
//		//		{
//		//			TileEntityWallmount arm = (TileEntityWallmount)tileEntity;
//		//			int f = arm.facing;
//		//			if(arm.sideAttached>0)
//		//				this.setBlockBounds(f==4?0:f==5?.375f:.3125f,arm.inverted?.3125f:0,f==2?0:f==3?.375f:.3125f, f==5?1:f==4?.625f:.6875f,arm.inverted?1:.6875f,f==3?1:f==2?.625f:.6875f);
//		//			else
//		//				this.setBlockBounds(f==5?0:.3125f,arm.inverted?.375f:0,f==3?0:.3125f, f==4?1:.6875f,arm.inverted?1:.625f,f==2?1:.6875f);
//		//		}
//		else
//			this.setBlockBounds(0,0,0,1,1,1);
//	}
public boolean canConnectFenceTo(IBlockAccess world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    return block != Blocks.BARRIER && (!((!(block instanceof BlockFence || block.equals(this)) || state.getMaterial() != this.blockMaterial) && !(block instanceof BlockFenceGate)) || ((state.getMaterial().isOpaque() && state.isFullCube()) && state.getMaterial() != Material.GOURD));
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) IELadderBlock(blusunrize.immersiveengineering.common.blocks.BlockIEBase.IELadderBlock) Block(net.minecraft.block.Block) BlockFence(net.minecraft.block.BlockFence)

Example 4 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project MorePlanets by SteveKunG.

the class BlockWallMP method canConnectTo.

private boolean canConnectTo(IBlockAccess world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    return block == Blocks.BARRIER ? false : block != this && !(block instanceof BlockWallMP) && !(block instanceof BlockFenceGate) ? state.getMaterial().isOpaque() && state.isFullCube() ? state.getMaterial() != Material.GOURD : false : true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) Block(net.minecraft.block.Block)

Example 5 with BlockFenceGate

use of net.minecraft.block.BlockFenceGate in project Wizardry by TeamWizardry.

the class PotionPhase method entityMove.

@SubscribeEvent
public void entityMove(EntityMoveEvent event) {
    if (!(event.entity instanceof EntityLivingBase))
        return;
    EntityLivingBase base = (EntityLivingBase) event.entity;
    if (!base.isPotionActive(ModPotions.PHASE))
        return;
    event.override = true;
    // event.entity.noClip = true;
    event.entity.fallDistance = 0;
    event.entity.isAirBorne = true;
    Entity entity = event.entity;
    double x = event.x;
    double y = event.y;
    double z = event.z;
    MoverType type = event.type;
    entity.world.profiler.startSection("move");
    double d10 = entity.posX;
    double d11 = entity.posY;
    double d1 = entity.posZ;
    double d2 = x;
    double d3 = y;
    double d4 = z;
    if ((type == MoverType.SELF || type == MoverType.PLAYER) && entity.onGround && entity.isSneaking() && entity instanceof EntityPlayer) {
        for (; x != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), 0.0D)).isEmpty(); d2 = x) {
            if (x >= 0.05D || x < -0.05D) {
                if (x > 0.0D) {
                    x -= 0.05D;
                } else {
                    x += 0.05D;
                }
            }
        }
        for (; z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(0.0D, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
            if (z >= 0.05D || z < -0.05D) {
                if (z > 0.0D) {
                    z -= 0.05D;
                } else {
                    z += 0.05D;
                }
            }
        }
        for (; x != 0.0D && z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
            if (x >= 0.05D || x < -0.05D) {
                if (x > 0.0D) {
                    x -= 0.05D;
                } else {
                    x += 0.05D;
                }
            }
            d2 = x;
            if (z >= 0.05D || z < -0.05D) {
                if (z > 0.0D) {
                    z -= 0.05D;
                } else {
                    z += 0.05D;
                }
            }
        }
    }
    List<AxisAlignedBB> list1 = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, y, z));
    AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox();
    if (y != 0.0D) {
        int k = 0;
        for (int l = list1.size(); k < l; ++k) {
            double offsetY = list1.get(k).calculateYOffset(entity.getEntityBoundingBox(), y);
            if (offsetY <= 0)
                y = offsetY;
        }
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
    }
    if (x != 0.0D)
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(x, 0.0D, 0.0D));
    if (z != 0.0D)
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, 0.0D, z));
    boolean flag = entity.onGround || d3 != y && d3 < 0.0D;
    if (entity.stepHeight > 0.0F && flag && (d2 != x || d4 != z)) {
        double d14 = x;
        double d6 = y;
        double d7 = z;
        AxisAlignedBB axisalignedbb1 = entity.getEntityBoundingBox();
        entity.setEntityBoundingBox(axisalignedbb);
        y = (double) entity.stepHeight;
        List<AxisAlignedBB> list = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(d2, y, d4));
        AxisAlignedBB axisalignedbb2 = entity.getEntityBoundingBox();
        AxisAlignedBB axisalignedbb3 = axisalignedbb2.offset(d2, 0.0D, d4);
        double d8 = y;
        int j1 = 0;
        for (int k1 = list.size(); j1 < k1; ++j1) {
            double offsetY = list1.get(j1).calculateYOffset(axisalignedbb3, y);
            if (offsetY <= 0)
                d8 = offsetY;
        }
        axisalignedbb2 = axisalignedbb2.offset(0.0D, d8, 0.0D);
        axisalignedbb2 = axisalignedbb2.offset(d2, 0.0D, 0.0D);
        axisalignedbb2 = axisalignedbb2.offset(0.0D, 0.0D, d4);
        AxisAlignedBB axisalignedbb4 = entity.getEntityBoundingBox();
        double d20 = y;
        int l2 = 0;
        for (int i3 = list.size(); l2 < i3; ++l2) {
            double offsetY = list1.get(i3).calculateYOffset(axisalignedbb4, y);
            if (offsetY <= 0)
                d20 = offsetY;
        }
        axisalignedbb4 = axisalignedbb4.offset(0.0D, d20, 0.0D);
        axisalignedbb4 = axisalignedbb4.offset(d2, 0.0D, 0.0D);
        axisalignedbb4 = axisalignedbb4.offset(0.0D, 0.0D, d4);
        double d23 = d2 * d2 + d4 * d4;
        double d9 = d2 * d2 + d4 * d4;
        if (d23 > d9) {
            x = d2;
            z = d4;
            y = -d8;
            entity.setEntityBoundingBox(axisalignedbb2);
        } else {
            x = d2;
            z = d4;
            y = -d20;
            entity.setEntityBoundingBox(axisalignedbb4);
        }
        int j4 = 0;
        for (int k4 = list.size(); j4 < k4; ++j4) {
            double offsetY = list1.get(j4).calculateYOffset(entity.getEntityBoundingBox(), y);
            if (offsetY <= 0)
                y = offsetY;
        }
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
        if (d14 * d14 + d7 * d7 >= x * x + z * z) {
            x = d14;
            y = d6;
            z = d7;
            entity.setEntityBoundingBox(axisalignedbb1);
        }
    }
    entity.world.profiler.endSection();
    entity.world.profiler.startSection("rest");
    entity.resetPositionToBB();
    entity.collidedHorizontally = d2 != x || d4 != z;
    entity.collidedVertically = d3 != y;
    entity.onGround = entity.collidedVertically && d3 < 0.0D;
    entity.collided = entity.collidedHorizontally || entity.collidedVertically;
    int j6 = MathHelper.floor(entity.posX);
    int i1 = MathHelper.floor(entity.posY - 0.20000000298023224D);
    int k6 = MathHelper.floor(entity.posZ);
    BlockPos blockpos = new BlockPos(j6, i1, k6);
    IBlockState iblockstate = entity.world.getBlockState(blockpos);
    if (iblockstate.getMaterial() == Material.AIR) {
        BlockPos blockpos1 = blockpos.down();
        IBlockState iblockstate1 = entity.world.getBlockState(blockpos1);
        Block block1 = iblockstate1.getBlock();
        if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate) {
            iblockstate = iblockstate1;
            blockpos = blockpos1;
        }
    }
    Block block = iblockstate.getBlock();
    if (d3 != y) {
        block.onLanded(entity.world, entity);
    }
    if ((!entity.onGround || !entity.isSneaking() || !(entity instanceof EntityPlayer)) && !entity.isRiding()) {
        double d15 = entity.posX - d10;
        double d16 = entity.posY - d11;
        double d17 = entity.posZ - d1;
        if (block != Blocks.LADDER) {
            d16 = 0.0D;
        }
        if (block != null && entity.onGround) {
            block.onEntityWalk(entity.world, blockpos, entity);
        }
        entity.distanceWalkedModified = (float) ((double) entity.distanceWalkedModified + (double) MathHelper.sqrt(d15 * d15 + d17 * d17) * 0.6D);
        entity.distanceWalkedOnStepModified = (float) ((double) entity.distanceWalkedOnStepModified + (double) MathHelper.sqrt(d15 * d15 + d16 * d16 + d17 * d17) * 0.6D);
    }
    try {
        AxisAlignedBB bb = entity.getEntityBoundingBox();
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(bb.minX + 0.001D, bb.minY + 0.001D, bb.minZ + 0.001D);
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos1 = BlockPos.PooledMutableBlockPos.retain(bb.maxX - 0.001D, bb.maxY - 0.001D, bb.maxZ - 0.001D);
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos2 = BlockPos.PooledMutableBlockPos.retain();
        if (entity.world.isAreaLoaded(blockpos$pooledmutableblockpos, blockpos$pooledmutableblockpos1)) {
            for (int i = blockpos$pooledmutableblockpos.getX(); i <= blockpos$pooledmutableblockpos1.getX(); ++i) {
                for (int j = blockpos$pooledmutableblockpos.getY(); j <= blockpos$pooledmutableblockpos1.getY(); ++j) {
                    for (int k = blockpos$pooledmutableblockpos.getZ(); k <= blockpos$pooledmutableblockpos1.getZ(); ++k) {
                        blockpos$pooledmutableblockpos2.setPos(i, j, k);
                        IBlockState state = entity.world.getBlockState(blockpos$pooledmutableblockpos2);
                        try {
                            state.getBlock().onEntityCollidedWithBlock(entity.world, blockpos$pooledmutableblockpos2, state, entity);
                        } catch (Throwable throwable) {
                            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
                            CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
                            CrashReportCategory.addBlockInfo(crashreportcategory, blockpos$pooledmutableblockpos2, state);
                            throw new ReportedException(crashreport);
                        }
                    }
                }
            }
        }
        blockpos$pooledmutableblockpos.release();
        blockpos$pooledmutableblockpos1.release();
        blockpos$pooledmutableblockpos2.release();
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
        entity.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
    entity.world.profiler.endSection();
// event.entity.noClip = false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) MoverType(net.minecraft.entity.MoverType) BlockWall(net.minecraft.block.BlockWall) CrashReport(net.minecraft.crash.CrashReport) BlockFenceGate(net.minecraft.block.BlockFenceGate) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockFence(net.minecraft.block.BlockFence) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockFenceGate (net.minecraft.block.BlockFenceGate)20 Block (net.minecraft.block.Block)18 IBlockState (net.minecraft.block.state.IBlockState)16 BlockFence (net.minecraft.block.BlockFence)7 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 BlockWall (net.minecraft.block.BlockWall)3 Entity (net.minecraft.entity.Entity)3 EnumFacing (net.minecraft.util.EnumFacing)3 BlockPos (net.minecraft.util.math.BlockPos)3 IELadderBlock (blusunrize.immersiveengineering.common.blocks.BlockIEBase.IELadderBlock)2 BlockDoor (net.minecraft.block.BlockDoor)2 BlockTrapDoor (net.minecraft.block.BlockTrapDoor)2 BlockFaceShape (net.minecraft.block.state.BlockFaceShape)2 CrashReport (net.minecraft.crash.CrashReport)2 CrashReportCategory (net.minecraft.crash.CrashReportCategory)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 MoverType (net.minecraft.entity.MoverType)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 ReportedException (net.minecraft.util.ReportedException)2