Java Code Examples for net.minecraft.util.EnumFacing#getFrontOffsetZ()

The following examples show how to use net.minecraft.util.EnumFacing#getFrontOffsetZ() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
Example 2
Source File: DispenserBehaviorFireball.java    From Artifacts with MIT License 6 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    EnumFacing enumfacing = BlockTrap.getFacing(par1IBlockSource.getBlockMetadata());
    IPosition iposition = BlockTrap.getIPositionFromBlockSource(par1IBlockSource);
    double d0 = iposition.getX() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F);
    double d1 = iposition.getY() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F);
    double d2 = iposition.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 0.3F);
    World world = par1IBlockSource.getWorld();
    Random random = world.rand;
    double d3 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetX();
    double d4 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetY();
    double d5 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetZ();
    world.spawnEntityInWorld(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example 3
Source File: DispenserBehaviorMobEgg.java    From Artifacts with MIT License 6 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata());
    double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX();
    double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F) + enumfacing.getFrontOffsetY();
    double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ();
    Entity entity = ItemMonsterPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2);

    if (entity instanceof EntityLiving && par2ItemStack.hasDisplayName())
    {
        ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName());
    }

    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example 4
Source File: BlockTrap.java    From Artifacts with MIT License 5 votes vote down vote up
public static IPosition getIPositionFromBlockSource(IBlockSource par0IBlockSource)
{
    EnumFacing enumfacing = getFacing(par0IBlockSource.getBlockMetadata());
    double d0 = par0IBlockSource.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
    double d1 = par0IBlockSource.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
    double d2 = par0IBlockSource.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
    return new PositionImpl(d0, d1, d2);
}
 
Example 5
Source File: RenderWaterPad.java    From AgriCraft with MIT License 5 votes vote down vote up
private static void renderSide(ITessellator tess, EnumFacing side, TextureAtlasSprite matIcon) {
    //data about side to render
    boolean xAxis = side.getAxis() == EnumFacing.Axis.X;
    int index = xAxis ? side.getFrontOffsetX() : side.getFrontOffsetZ();
    int min = index < 0 ? 0 : 15;
    int max = index < 0 ? 1 : 16;

    //render upper face
    tess.drawScaledFace(xAxis ? min : 0, xAxis ? 0 : min, xAxis ? max : 16, xAxis ? 16 : max, EnumFacing.UP, matIcon, 16);

    //render side
    tess.drawScaledFace(0, 8, 16, 16, side, matIcon, index > 0 ? 16 : 0);
    tess.drawScaledFace(0, 8, 16, 16, side.getOpposite(), matIcon, index > 0 ? 15 : 1);
}
 
Example 6
Source File: DispenserBehaviorFireworks.java    From Artifacts with MIT License 5 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata());
    double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX();
    double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F);
    double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ();
    EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(par1IBlockSource.getWorld(), d0, d1, d2, par2ItemStack);
    par1IBlockSource.getWorld().spawnEntityInWorld(entityfireworkrocket);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example 7
Source File: TileCuttingMachine.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void update() {
	super.update();

	if(isRunning() && world.getTotalWorldTime() % 10 == 0) {
		EnumFacing back = RotatableBlock.getFront(world.getBlockState(pos)).getOpposite();

		float xCoord = this.getPos().getX() + (0.5f*back.getFrontOffsetX()); 
		float zCoord = this.getPos().getZ() + (0.5f*back.getFrontOffsetZ());

		for(Object entity : world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(xCoord, this.getPos().getY() + 1, zCoord, xCoord + 1, this.getPos().getY() + 1.5f, zCoord + 1))) {
			((EntityLivingBase)entity).attackEntityFrom(DamageSource.CACTUS, 1f);
		}
	}
}
 
Example 8
Source File: ItemEngineeringTable.java    From Cyberware with MIT License 5 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	if (facing != EnumFacing.UP)
	{
		return EnumActionResult.FAIL;
	}
	else
	{
		IBlockState iblockstate = worldIn.getBlockState(pos);
		Block block = iblockstate.getBlock();

		if (!block.isReplaceable(worldIn, pos))
		{
			pos = pos.offset(facing);
		}

		if (playerIn.canPlayerEdit(pos, facing, stack) && this.block.canPlaceBlockAt(worldIn, pos))
		{
			EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);
			int i = enumfacing.getFrontOffsetX();
			int j = enumfacing.getFrontOffsetZ();
			placeDoor(worldIn, pos, enumfacing, this.block);
			SoundType soundtype = this.block.getSoundType();
			worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
			--stack.stackSize;
			return EnumActionResult.SUCCESS;
		}
		else
		{
			return EnumActionResult.FAIL;
		}
	}
}
 
Example 9
Source File: ItemSurgeryChamber.java    From Cyberware with MIT License 5 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	if (facing != EnumFacing.UP)
	{
		return EnumActionResult.FAIL;
	}
	else
	{
		IBlockState iblockstate = worldIn.getBlockState(pos);
		Block block = iblockstate.getBlock();

		if (!block.isReplaceable(worldIn, pos))
		{
			pos = pos.offset(facing);
		}

		if (playerIn.canPlayerEdit(pos, facing, stack) && this.block.canPlaceBlockAt(worldIn, pos))
		{
			EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);
			int i = enumfacing.getFrontOffsetX();
			int j = enumfacing.getFrontOffsetZ();
			placeDoor(worldIn, pos, enumfacing, this.block);
			SoundType soundtype = this.block.getSoundType();
			worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
			--stack.stackSize;
			return EnumActionResult.SUCCESS;
		}
		else
		{
			return EnumActionResult.FAIL;
		}
	}
}
 
Example 10
Source File: ItemTraverseWoodDoor.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (facing != EnumFacing.UP) {
        return EnumActionResult.FAIL;
    } else {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (!block.isReplaceable(worldIn, pos)) {
            pos = pos.offset(facing);
        }

        ItemStack itemstack = player.getHeldItem(hand);

        if (player.canPlayerEdit(pos, facing, itemstack) && this.block.canPlaceBlockAt(worldIn, pos)) {
            EnumFacing enumfacing = EnumFacing.fromAngle((double) player.rotationYaw);
            int i = enumfacing.getFrontOffsetX();
            int j = enumfacing.getFrontOffsetZ();
            boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
            placeDoor(worldIn, pos, enumfacing, this.block, flag);
            SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, player);
            worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.shrink(1);
            return EnumActionResult.SUCCESS;
        } else {
            return EnumActionResult.FAIL;
        }
    }
}
 
Example 11
Source File: ShapeModelGenerator.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static CCModel[] generateRotatedVariants(CCModel originalModel) {
    CCModel[] result = new CCModel[6];
    double modelHeight = originalModel.verts[2].vec.y;
    double translate = 1.0 - modelHeight;
    for (int i = 0; i < 3; i++) {
        EnumFacing side = EnumFacing.VALUES[i * 2 + 1];
        Transformation rotation = Rotation.sideRotations[i * 2].at(Vector3.center);
        Transformation translation = new Translation(side.getFrontOffsetX() * translate, side.getFrontOffsetY() * translate, side.getFrontOffsetZ() * translate);
        CCModel negativeModel = originalModel.copy().apply(rotation);
        CCModel positiveModel = negativeModel.copy().apply(translation);
        result[i * 2] = negativeModel;
        result[i * 2 + 1] = positiveModel;
    }
    return result;
}
 
Example 12
Source File: DispenserBehaviorSword.java    From Artifacts with MIT License 4 votes vote down vote up
/**
   * Dispense the specified stack, play the dispense sound and spawn particles.
   */
  public ItemStack dispenseStack(IBlockSource blockSource, ItemStack itemStack)
  {
      EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(blockSource.getBlockMetadata());
      double d0, d1, d2, d3, d4, d5;
      d0 = (int)blockSource.getX() - 1;
      d1 = (int)blockSource.getY() - 1;
      d2 = (int)blockSource.getZ() - 1;
      d3 = (int)blockSource.getX() + 1;
      d4 = (int)blockSource.getY() + 1;
      d5 = (int)blockSource.getZ() + 1;
      //System.out.println((int)par1IBlockSource.getX() + "," + (int)par1IBlockSource.getZ());
      d0 += 0.5 * d0/Math.abs(d0);
      d1 += 0.5 * d1/Math.abs(d1);
      d2 += 0.5 * d2/Math.abs(d2);
      d3 += 0.5 * d3/Math.abs(d3);
      d4 += 0.5 * d4/Math.abs(d4);
      d5 += 0.5 * d5/Math.abs(d5);
      
      d0 += enumfacing.getFrontOffsetX();
      d3 += enumfacing.getFrontOffsetX();
      d2 += enumfacing.getFrontOffsetZ();
      d5 += enumfacing.getFrontOffsetZ();
      
      if(enumfacing.getFrontOffsetX() != 0) {
      	d2 += 0.5;
      	d5 -= 0.5;
      }
      if(enumfacing.getFrontOffsetZ() != 0) {
      	d0 += 0.5;
      	d3 -= 0.5;
      }
      
      //Play sound.
      blockSource.getWorld().playAuxSFX(1002, blockSource.getXInt(), blockSource.getYInt(), blockSource.getZInt(), 0);
      
      AxisAlignedBB par2AxisAlignedBB = AxisAlignedBB.getBoundingBox(d0, d1, d2, d3, d4, d5);
      //System.out.println(par2AxisAlignedBB);
      List<EntityLivingBase> ents = blockSource.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, par2AxisAlignedBB);
      if(ents.size() > 0) {
      	for(int l=ents.size() - 1; l >= 0; l--) {
      		EntityLivingBase ent = ents.get(l);
      		ent.attackEntityFrom(DamageSourceSword.instance, damage);
      		itemStack.damageItem(1, ent);
      	}
      }
      TileEntity te = blockSource.getBlockTileEntity();
      if(te != null && te instanceof TileEntityTrap) {
      	TileEntityTrap tet = (TileEntityTrap) te;
	/*int a = par2ItemStack.getItem().itemID;
	int b = 0;
	switch(a) {
		case 11:
			b = 1;
			break;
		case 12:
			b = 2;
			break;
		case 16:
			b = 3;
			break;
		case 20:
			b = 4;
			break;
		case 27:
			b = 5;
			break;
	}*/
	tet.startSwordRender(blockSource.getWorld(), blockSource.getXInt()+enumfacing.getFrontOffsetX(), blockSource.getYInt()+enumfacing.getFrontOffsetY(), blockSource.getZInt()+enumfacing.getFrontOffsetZ(), blockSource.getBlockMetadata(), itemStack);
}
      else {
      	System.out.println("Tile Entity was null!");
      }
      
      /*EntitySword entsw = new EntitySword(par1IBlockSource.getWorld(), par1IBlockSource.getX(), par1IBlockSource.getY(), par1IBlockSource.getZ());
      par1IBlockSource.getWorld().spawnEntityInWorld((Entity)entsw);*/
      return itemStack;
  }
 
Example 13
Source File: BlockPos.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public BlockPos offset(EnumFacing facing, int n) {
	return new BlockPos(getX() + facing.getFrontOffsetX() * n, getY() + facing.getFrontOffsetY() * n, getZ() + facing.getFrontOffsetZ() * n);
}
 
Example 14
Source File: BehaviorDefaultDispenseItem.java    From Artifacts with MIT License 4 votes vote down vote up
private int func_82488_a(EnumFacing par1EnumFacing)
{
    return par1EnumFacing.getFrontOffsetX() + 1 + (par1EnumFacing.getFrontOffsetZ() + 1) * 3;
}
 
Example 15
Source File: TileRocketBuilder.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
/**
 * Does not make sure the structure is complete, only gets max bounds!
 * @param world the world
 * @param x coord to evaluate from
 * @param y coord to evaluate from
 * @param z coord to evaluate from
 * @return AxisAlignedBB bounds of structure if valid  otherwise null
 */
public AxisAlignedBB getRocketPadBounds(World world, BlockPos pos) {
	EnumFacing direction = RotatableBlock.getFront(world.getBlockState(pos)).getOpposite();
	int xMin, zMin, xMax, zMax;
	int yCurrent = pos.getY() -1;
	int xCurrent = pos.getX() + direction.getFrontOffsetX();
	int zCurrent = pos.getZ() + direction.getFrontOffsetZ();
	xMax = xMin = xCurrent;
	zMax = zMin = zCurrent;
	int xSize, zSize;

	BlockPos currPos = new BlockPos(xCurrent, yCurrent, zCurrent);
	
	if(world.isRemote)
		return null;

	//Get min and maximum Z/X bounds
	if(direction.getFrontOffsetX() != 0) {
		xSize = ZUtils.getContinuousBlockLength(world, direction, currPos, MAX_SIZE, viableBlocks);
		zMin = ZUtils.getContinuousBlockLength(world, EnumFacing.NORTH, currPos, MAX_SIZE, viableBlocks);
		zMax = ZUtils.getContinuousBlockLength(world, EnumFacing.SOUTH, currPos.add(0,0,1), MAX_SIZE - zMin, viableBlocks);
		zSize = zMin + zMax;
		
		zMin = zCurrent - zMin + 1;
		zMax = zCurrent + zMax;

		if(direction.getFrontOffsetX() > 0) {
			xMax = xCurrent + xSize-1;
		}

		if(direction.getFrontOffsetX() < 0) {
			xMin = xCurrent - xSize+1;
		}
	}
	else {
		zSize = ZUtils.getContinuousBlockLength(world, direction, currPos, MAX_SIZE, viableBlocks);
		xMin = ZUtils.getContinuousBlockLength(world, EnumFacing.WEST, currPos, MAX_SIZE, viableBlocks);
		xMax = ZUtils.getContinuousBlockLength(world, EnumFacing.EAST, currPos.add(1,0,0), MAX_SIZE - xMin, viableBlocks);
		xSize = xMin + xMax;

		xMin = xCurrent - xMin + 1;
		xMax = xCurrent + xMax;

		if(direction.getFrontOffsetZ() > 0) {
			zMax = zCurrent + zSize-1;
		}

		if(direction.getFrontOffsetZ() < 0) {
			zMin = zCurrent - zSize+1;
		}
	}


	int maxTowerSize = 0;
	//Check perimeter for structureBlocks and get the size
	for(int i = xMin; i <= xMax; i++) {
		if(world.getBlockState(new BlockPos(i, yCurrent, zMin-1)).getBlock() == AdvancedRocketryBlocks.blockStructureTower) {
			maxTowerSize = Math.max(maxTowerSize, ZUtils.getContinuousBlockLength(world, EnumFacing.UP, new BlockPos(i, yCurrent, zMin-1), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower));
		}

		if(world.getBlockState(new BlockPos(i, yCurrent, zMax+1)).getBlock() == AdvancedRocketryBlocks.blockStructureTower) {
			maxTowerSize = Math.max(maxTowerSize, ZUtils.getContinuousBlockLength(world, EnumFacing.UP, new BlockPos(i, yCurrent, zMax+1), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower));
		}
	}

	for(int i = zMin; i <= zMax; i++) {
		if(world.getBlockState(new BlockPos(xMin-1, yCurrent, i)).getBlock() == AdvancedRocketryBlocks.blockStructureTower) {
			maxTowerSize = Math.max(maxTowerSize, ZUtils.getContinuousBlockLength(world, EnumFacing.UP, new BlockPos(xMin-1, yCurrent, i), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower));
		}

		if(world.getBlockState(new BlockPos(xMax+1, yCurrent, i)).getBlock() == AdvancedRocketryBlocks.blockStructureTower) {
			maxTowerSize = Math.max(maxTowerSize, ZUtils.getContinuousBlockLength(world, EnumFacing.UP, new BlockPos(xMax+1, yCurrent, i), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower));
		}
	}

	//if tower does not meet criteria then reutrn null
	if(maxTowerSize < MIN_SIZE_Y || xSize < MIN_SIZE || zSize < MIN_SIZE) {
		return null;
	}

	return new AxisAlignedBB(new BlockPos(xMin, yCurrent+1, zMin), new BlockPos(xMax, yCurrent + maxTowerSize - 1, zMax));
}
 
Example 16
Source File: TileStationDeployedAssembler.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
/**
 * Does not make sure the structure is complete, only gets max bounds!
 * @param world the world
 * @param x coord to evaluate from
 * @param y coord to evaluate from
 * @param z coord to evaluate from
 * @return AxisAlignedBB bounds of structure if valid  otherwise null
 */
@Override
public AxisAlignedBB getRocketPadBounds(World world, BlockPos pos2) {
	EnumFacing direction = RotatableBlock.getFront(world.getBlockState(pos2)).getOpposite();
	int xMin, zMin, xMax, zMax, yMax, yMin;
	int yCurrent = pos2.getY();
	int xCurrent = pos2.getX();
	int zCurrent = pos2.getZ();
	xMax = xMin = xCurrent;
	zMax = zMin = zCurrent;
	int xSize, zSize;

	yMax = ZUtils.getContinuousBlockLength(world, EnumFacing.UP, getPos().add(0,1,0), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower);

	//Get min and maximum Z/X bounds
	if(direction.getFrontOffsetX() != 0) {
		xSize = ZUtils.getContinuousBlockLength(world, direction, pos2.add(0, yMax, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower);
		zMin = ZUtils.getContinuousBlockLength(world, EnumFacing.NORTH, pos2.add(0, 0, -1), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower) + 1;
		zMax = ZUtils.getContinuousBlockLength(world, EnumFacing.SOUTH, pos2.add(0, 0, 1), MAX_SIZE - zMin, AdvancedRocketryBlocks.blockStructureTower);
		zSize = zMin + zMax;

		zMin = zCurrent - zMin +1;
		zMax = zCurrent + zMax;

		if(direction.getFrontOffsetX() > 0) {
			xMax = xCurrent + xSize - 1;
			xMin++;
		}

		if(direction.getFrontOffsetX() < 0) {
			xMin = xCurrent - xSize+1;
			xMax--;
		}
	}
	else {
		zSize = ZUtils.getContinuousBlockLength(world, direction, pos2.add(0, yMax, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower);
		xMin = ZUtils.getContinuousBlockLength(world, EnumFacing.WEST, pos2.add(-1, 0, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower) + 1;
		xMax = ZUtils.getContinuousBlockLength(world, EnumFacing.EAST, pos2.add(1, 0, 0), MAX_SIZE - xMin, AdvancedRocketryBlocks.blockStructureTower);
		xSize = xMin + xMax;

		xMin = xCurrent - xMin +1;
		xMax = xCurrent + xMax;


		if(direction.getFrontOffsetZ() > 0) {
			zMax = zCurrent + zSize - 1;
			zMin++;
		}

		if(direction.getFrontOffsetZ() < 0) {
			zMin = zCurrent - zSize+1;
			zMax --;
		}
	}

	//if tower does not meet criteria then reutrn null
	if(yMax < MIN_SIZE_Y || xSize < MIN_SIZE || zSize < MIN_SIZE) {
		return null;
	}

	return new AxisAlignedBB(xMin, yCurrent, zMin, xMax, yCurrent + yMax - 1, zMax);
}
 
Example 17
Source File: BlockTeleportRail.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
private void teleport(EntityMinecart cart, MCPos destination){
    if(cart instanceof EntityMinecartContainer) {
        ((EntityMinecartContainer)cart).dropContentsWhenDead = false;
    }

    int dimensionIn = destination.getDimID();
    BlockPos destPos = destination.getPos();
    if(!ForgeHooks.onTravelToDimension(cart, destination.getDimID())) return;

    MinecraftServer minecraftserver = cart.getServer();
    int i = cart.dimension;
    WorldServer worldserver = minecraftserver.getWorld(i);
    WorldServer worldserver1 = minecraftserver.getWorld(dimensionIn);
    cart.dimension = dimensionIn;

    /*if (i == 1 && dimensionIn == 1)
    {
        worldserver1 = minecraftserver.getWorld(0);
        this.dimension = 0;
    }*/

    cart.world.removeEntity(cart);
    cart.isDead = false;
    BlockPos blockpos = destination.getPos();

    /* double moveFactor = worldserver.provider.getMovementFactor() / worldserver1.provider.getMovementFactor();
    double d0 = MathHelper.clamp(this.posX * moveFactor, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D);
    double d1 = MathHelper.clamp(this.posZ * moveFactor, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D);
    double d2 = 8.0D;*/

    cart.moveToBlockPosAndAngles(destPos, 90.0F, 0.0F);
    /*Teleporter teleporter = worldserver1.getDefaultTeleporter();
    teleporter.placeInExistingPortal(this, f);
    blockpos = new BlockPos(this);*/

    worldserver.updateEntityWithOptionalForce(cart, false);
    Entity entity = EntityList.newEntity(cart.getClass(), worldserver1);

    if(entity != null) {
        copyDataFromOld(entity, cart);

        entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch);

        IBlockState state = destination.getLoadedBlockState();
        if(state.getBlock() == ModBlocks.TELEPORT_RAIL) { //If the destination is a teleport track, use its rail direction to push the cart the right direction
            EnumFacing teleportDir = getTeleportDirection(state);
            double speed = 0.2;
            entity.motionX = teleportDir.getFrontOffsetX() * speed;
            entity.motionY = teleportDir.getFrontOffsetY() * speed;
            entity.motionZ = teleportDir.getFrontOffsetZ() * speed;
        } else {
            entity.motionX = entity.motionY = entity.motionZ = 0;
        }

        boolean flag = entity.forceSpawn;
        entity.forceSpawn = true;
        worldserver1.spawnEntity(entity);
        entity.forceSpawn = flag;
        worldserver1.updateEntityWithOptionalForce(entity, false);
    }

    cart.isDead = true;
    worldserver.resetUpdateEntityTick();
    worldserver1.resetUpdateEntityTick();
}
 
Example 18
Source File: TileSpaceElevator.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public double getLandingLocationX() {
	EnumFacing facing = RotatableBlock.getFront(world.getBlockState(getPos()));
	return getPos().getX() + facing.getFrontOffsetX()*-3 - facing.getFrontOffsetZ() + 0.5;
}
 
Example 19
Source File: TileSpaceElevator.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public double getLandingLocationZ() {
	EnumFacing facing = RotatableBlock.getFront(world.getBlockState(getPos()));
	return getPos().getZ() + facing.getFrontOffsetX()*1 + facing.getFrontOffsetZ()*-3 + 0.5;
}
 
Example 20
Source File: RenderTank.java    From AgriCraft with MIT License 4 votes vote down vote up
private void renderSide(ITessellator tessellator, EnumFacing dir, byte connection, TextureAtlasSprite icon) {
    if (connection < 0 || connection > 1) {
        return;
    }
    //data about side to render
    boolean xAxis = dir.getAxis() == EnumFacing.Axis.X;
    int index = xAxis ? dir.getFrontOffsetX() : dir.getFrontOffsetZ();
    int min = index < 0 ? 0 : 14;
    int max = index < 0 ? 2 : 16;

    //render upper face
    tessellator.drawScaledFace(xAxis ? min : 0, xAxis ? 0 : min, xAxis ? max : 16, xAxis ? 16 : max, EnumFacing.UP, icon, 16);

    //render side
    if (connection == 0) {
        tessellator.drawScaledFace(0, 0, 16, 16, dir, icon, index > 0 ? 16 : 0);
        tessellator.drawScaledFace(0, 0, 16, 16, dir.getOpposite(), icon, index > 0 ? 14 : 2);
    } else {
        //vertical faces

        //lower part, under the channel
        tessellator.drawScaledFace(0, 0, 16, 5, dir, icon, index > 0 ? 16 : 0);
        tessellator.drawScaledFace(0, 0, 16, 5, dir.getOpposite(), icon, index > 0 ? 14 : 2);
        //left center part, same height as the channel
        tessellator.drawScaledFace(0, 5, 5, 12, dir, icon, index > 0 ? 16 : 0);
        tessellator.drawScaledFace(0, 5, 5, 12, dir.getOpposite(), icon, index > 0 ? 14 : 2);
        //right center part, same height as the channel
        tessellator.drawScaledFace(11, 5, 16, 12, dir, icon, index > 0 ? 16 : 0);
        tessellator.drawScaledFace(11, 5, 16, 12, dir.getOpposite(), icon, index > 0 ? 14 : 2);
        //upper part, above the channel
        tessellator.drawScaledFace(0, 12, 16, 16, dir, icon, index > 0 ? 16 : 0);
        tessellator.drawScaledFace(0, 12, 16, 16, dir.getOpposite(), icon, index > 0 ? 14 : 2);

        //inside of the gap
        tessellator.drawScaledFace(xAxis ? min : 5, xAxis ? 5 : min, xAxis ? max : 11, xAxis ? 11 : max, EnumFacing.UP, icon, 5);
        tessellator.drawScaledFace(xAxis ? min : 5, xAxis ? 5 : min, xAxis ? max : 11, xAxis ? 11 : max, EnumFacing.DOWN, icon, 12);

        EnumFacing left = xAxis ? EnumFacing.NORTH : EnumFacing.WEST;
        EnumFacing right = left.getOpposite();

        tessellator.drawScaledFace(min, 5, max, 12, left, icon, 11);
        tessellator.drawScaledFace(min, 5, max, 12, right, icon, 5);
    }
}