Search in sources :

Example 16 with BlockPos

use of net.minecraft.util.math.BlockPos in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CustomNetHandlerPlayServer method processUpdateSign.

@Override
public void processUpdateSign(CPacketUpdateSign packetIn) {
    BlockPos packetPos = packetIn.getPosition();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
    if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
        lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
    }
    if (wrapper != null) {
        playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
        ticksSinceLastTry = 0;
    }
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    if (wrapper != null && wrapper.wrapping.coordTransform != null) {
        float playerYaw = playerEntity.rotationYaw;
        float playerPitch = playerEntity.rotationPitch;
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
        super.processUpdateSign(packetIn);
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
        playerEntity.rotationYaw = playerYaw;
        playerEntity.rotationPitch = playerPitch;
    } else {
        super.processUpdateSign(packetIn);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 17 with BlockPos

use of net.minecraft.util.math.BlockPos in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CustomNetHandlerPlayServer method processRightClickBlock.

@Override
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn) {
    BlockPos packetPos = packetIn.getPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
    if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
        lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
    }
    if (wrapper != null) {
        playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
        ticksSinceLastTry = 0;
    }
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    if (wrapper != null && wrapper.wrapping.coordTransform != null) {
        float playerYaw = playerEntity.rotationYaw;
        float playerPitch = playerEntity.rotationPitch;
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
        if (playerEntity.getHeldItem(packetIn.getHand()) != null && playerEntity.getHeldItem(packetIn.getHand()).getItem() instanceof ItemBucket) {
            playerEntity.interactionManager.setBlockReachDistance(lastGoodBlockReachDist);
        }
        try {
            super.processRightClickBlock(packetIn);
        } catch (Exception e) {
        }
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
        playerEntity.rotationYaw = playerYaw;
        playerEntity.rotationPitch = playerPitch;
    } else {
        super.processRightClickBlock(packetIn);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) ItemBucket(net.minecraft.item.ItemBucket)

Example 18 with BlockPos

use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.

the class PEUtils method transferPEToCollectors.

/**
	 * Attempts to transfer PE from a Manipulator to nearby Collectors
	 * @param world Current World
	 * @param pos Current BlockPos
	 * @param manipulator PE Manipulator
	 * @param boost Any range boost applied to the manipulator
	 */
public static void transferPEToCollectors(World world, BlockPos pos, IEnergyManipulator manipulator, int boost) {
    int xp = pos.getX();
    int yp = pos.getY();
    int zp = pos.getZ();
    List<TileEntity> collectors = Lists.newArrayList();
    for (int x = -1 * (3 + boost); x <= 3 + boost; x++) for (int y = 0; y <= getRangeAmplifiers(world, pos); y++) for (int z = -1 * (3 + boost); z <= 3 + boost; z++) if (x < -2 || x > 2 || z < -2 || z > 2)
        if (isCollector(world.getTileEntity(new BlockPos(xp + x, yp - y, zp + z))))
            collectors.add(world.getTileEntity(new BlockPos(xp + x, yp - y, zp + z)));
    for (TileEntity tile : collectors) if (checkForAdjacentCollectors(world, tile.getPos()))
        if (world.rand.nextInt(120 - (int) (20 * manipulator.getAmplifier(AmplifierType.DURATION))) == 0)
            if (((IEnergyContainer) tile).getContainedEnergy() < ((IEnergyContainer) tile).getMaxEnergy()) {
                if (!world.isRemote)
                    ((IEnergyContainer) tile).addEnergy(manipulator.getEnergyQuanta());
                for (double i = 0; i <= 0.7; i += 0.03) {
                    int xPos = xp < tile.getPos().getX() ? 1 : xp > tile.getPos().getX() ? -1 : 0;
                    int yPos = yp < tile.getPos().getY() ? 1 : yp > tile.getPos().getY() ? -1 : 0;
                    int zPos = zp < tile.getPos().getZ() ? 1 : zp > tile.getPos().getZ() ? -1 : 0;
                    double x = i * Math.cos(i) / 2 * xPos;
                    double y = i * Math.sin(i) / 2 * yPos;
                    double z = i * Math.sin(i) / 2 * zPos;
                    world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, xp + 0.5, yp + 0.5, zp + 0.5, x, y, z);
                }
            }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 19 with BlockPos

use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.

the class PEUtils method getRangeAmplifiers.

/**
	 * Checks for any range amplifying blocks below a specific BlockPos
	 * @param world Current World
	 * @param pos Current BlockPos
	 * @return A number between 0 and 2, representing the amount of range amplifiers below this BlockPos
	 */
public static int getRangeAmplifiers(World world, BlockPos pos) {
    Block block1 = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
    Block block2 = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 2, pos.getZ())).getBlock();
    int num = 0;
    if (block1 != null && block1 instanceof IEnergyAmplifier && ((IEnergyAmplifier) block1).getAmplifierType() == AmplifierType.RANGE)
        num = 1;
    if (block1 != null && block1 instanceof IEnergyAmplifier && ((IEnergyAmplifier) block1).getAmplifierType() == AmplifierType.RANGE && block2 != null && block2 instanceof IEnergyAmplifier && ((IEnergyAmplifier) block2).getAmplifierType() == AmplifierType.RANGE)
        num = 2;
    return num;
}
Also used : Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 20 with BlockPos

use of net.minecraft.util.math.BlockPos in project Witchworks by Um-Mitternacht.

the class BlockSaltBarrier method updateSurroundingSalt.

private IBlockState updateSurroundingSalt(World worldIn, IBlockState state) {
    final List<BlockPos> list = Lists.newArrayList(this.blocksNeedingUpdate);
    this.blocksNeedingUpdate.clear();
    for (BlockPos blockpos : list) {
        worldIn.notifyNeighborsOfStateChange(blockpos, this, true);
    }
    return state;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)4488 IBlockState (net.minecraft.block.state.IBlockState)1202 TileEntity (net.minecraft.tileentity.TileEntity)675 ItemStack (net.minecraft.item.ItemStack)577 World (net.minecraft.world.World)550 Block (net.minecraft.block.Block)545 EnumFacing (net.minecraft.util.EnumFacing)517 EntityPlayer (net.minecraft.entity.player.EntityPlayer)257 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)249 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)216 Vec3d (net.minecraft.util.math.Vec3d)216 ArrayList (java.util.ArrayList)211 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)182 Entity (net.minecraft.entity.Entity)176 NBTTagList (net.minecraft.nbt.NBTTagList)139 Random (java.util.Random)130 Biome (net.minecraft.world.biome.Biome)129 Nullable (javax.annotation.Nullable)126 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)126 RayTraceResult (net.minecraft.util.math.RayTraceResult)112